-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
2,256 additions
and
49 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
Content.Server/ADT/SizeAttribute/SizeAttributeComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { } | ||
} |
2 changes: 1 addition & 1 deletion
2
Content.Server/ADT/SizeAttribute/SizeAttributeWhitelistComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
Content.Server/Abilities/WoundLicking/WoundLickingComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.