Skip to content

Commit

Permalink
Revert "ревью"
Browse files Browse the repository at this point in the history
This reverts commit 5b84e2a, reversing
changes made to f053392.
  • Loading branch information
Darkiich committed Aug 9, 2024
1 parent a3c7e27 commit caa7939
Show file tree
Hide file tree
Showing 65 changed files with 2,256 additions and 49 deletions.
14 changes: 14 additions & 0 deletions Content.Server/ADT/SizeAttribute/SizeAttributeComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Shared.Cloning;

namespace Content.Server.ADT.SizeAttribute
{
[RegisterComponent]
public sealed partial class SizeAttributeComponent : Component, ITransferredByCloning
{
[DataField("short")]
public bool Short = false;

[DataField("tall")]
public bool Tall = false;
}
}
94 changes: 94 additions & 0 deletions Content.Server/ADT/SizeAttribute/SizeAttributeSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System.Numerics;
using Robust.Server.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Systems;
using Content.Shared.Item.PseudoItem;

namespace Content.Server.ADT.SizeAttribute
{
public sealed class SizeAttributeSystem : EntitySystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly FixtureSystem _fixtures = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SizeAttributeComponent, ComponentInit>(OnComponentInit);
}

private void OnComponentInit(EntityUid uid, SizeAttributeComponent component, ComponentInit args)
{
if (!TryComp<SizeAttributeWhitelistComponent>(uid, out var whitelist))
return;

if (whitelist.Tall && component.Tall)
{
Scale(uid, component, whitelist.TallScale, whitelist.TallDensity, whitelist.TallCosmeticOnly);
PseudoItem(uid, component, whitelist.TallPseudoItem);
}
else if (whitelist.Short && component.Short)
{
Scale(uid, component, whitelist.ShortScale, whitelist.ShortDensity, whitelist.ShortCosmeticOnly);
PseudoItem(uid, component, whitelist.ShortPseudoItem);
}
}

private void PseudoItem(EntityUid uid, SizeAttributeComponent component, bool active)
{
if (active)
{
if (TryComp<PseudoItemComponent>(uid, out var pseudoI))
return;

_entityManager.AddComponent<PseudoItemComponent>(uid);
}
else
{
if (!TryComp<PseudoItemComponent>(uid, out var pseudoI))
return;

_entityManager.RemoveComponent<PseudoItemComponent>(uid);
}
}

private void Scale(EntityUid uid, SizeAttributeComponent component, float scale, float density, bool cosmeticOnly)
{
if (scale <= 0f && density <= 0f)
return;

_entityManager.EnsureComponent<ScaleVisualsComponent>(uid);

var appearanceComponent = _entityManager.EnsureComponent<AppearanceComponent>(uid);
if (!_appearance.TryGetData<Vector2>(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent))
oldScale = Vector2.One;

_appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent);

if (!cosmeticOnly && _entityManager.TryGetComponent(uid, out FixturesComponent? manager))
{
foreach (var (id, fixture) in manager.Fixtures)
{
if (!fixture.Hard || fixture.Density <= 1f)
continue; // This will skip the flammable fixture and any other fixture that is not supposed to contribute to mass

switch (fixture.Shape)
{
case PhysShapeCircle circle:
_physics.SetPositionRadius(uid, id, fixture, circle, circle.Position * scale, circle.Radius * scale, manager);
break;
default:
throw new NotImplementedException();
}

_physics.SetDensity(uid, id, fixture, density);
}
}
}
}

[ByRefEvent]
public readonly record struct ScaleEntityEvent(EntityUid Uid) { }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Robust.Shared.Physics.Collision.Shapes;

namespace Content.Server.SizeAttribute
namespace Content.Server.ADT.SizeAttribute
{
[RegisterComponent]
public sealed partial class SizeAttributeWhitelistComponent : Component
Expand Down
83 changes: 83 additions & 0 deletions Content.Server/Abilities/WoundLicking/WoundLickingComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System.Threading;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.Felinid
{
[RegisterComponent]
[Access(typeof(WoundLickingSystem))]
public sealed partial class WoundLickingComponent : Component
{
[DataField("woundLickingAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? WoundLickingAction = "ActionWoundLicking";

[DataField("woundLickingActionEntity")]
public EntityUid? WoundLickingActionEntity;

/// <summary>
/// How frequent wound-licking will cause diseases. Scales with amount of reduced bleeding
/// </summary>
[DataField("diseaseChance")]
[ViewVariables(VVAccess.ReadWrite)]
public float DiseaseChance { get; set; } = 0.25f;

/// <summary>
/// Max possible bleeding reduce. Human max bleeding is 20f, many weapons deals near 15f bleeding
/// </summary>
[DataField("maxHeal")]
[ViewVariables(VVAccess.ReadWrite)]
public float MaxHeal { get; set; } = 15f;

/// <summary>
/// How long it requires to lick wounds
/// </summary>
[DataField("delay")]
[ViewVariables(VVAccess.ReadWrite)]
public float Delay { get; set; } = 3f;

/// <summary>
/// If true, then wound-licking can be applied only on yourself
/// </summary>
[DataField("canApplyOnSelf")]
[ViewVariables(VVAccess.ReadWrite)]
public bool CanApplyOnSelf { get; set; } = true;

/// <summary>
/// If true, then wound-licking can be applied only on other entities
/// </summary>
[DataField("canApplyOnOther")]
[ViewVariables(VVAccess.ReadWrite)]
public bool CanApplyOnOther { get; set; } = false;



/// <summary>
/// Which diseases can be caused because of wound-licking
/// </summary>
[DataField("possibleDiseases")]
public List<String> PossibleDiseases { get; set; } = new()
{
"Plague",
"BirdFlew",
"SpaceFlu",
"SpaceCold",
"VentCough"
};

/// <summary>
/// If Target's bloodstream don't use one of these reagents, then ability can't be performed on it.
/// </summary>
[DataField("reagentWhitelist")]
public List<String> ReagentWhitelist { get; set; } = new()
{
"Blood",
"Slime"
};

/// <summary>
/// Token for interrupting a do-after action. If not null, implies component is
/// currently "in use".
/// </summary>
public CancellationTokenSource? CancelToken;
}
}
Loading

0 comments on commit caa7939

Please sign in to comment.