From aeebe282d4556ffa3513aa8a730b27a9acb3f64d Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:35:28 +1200 Subject: [PATCH] Prevent brains from walking (#15709) Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> --- Content.Server/Body/Systems/BrainSystem.cs | 13 ++++++++++++- .../Body/Systems/SharedBodySystem.Parts.cs | 6 +++--- .../Components/MovementBodyPartComponent.cs | 14 ++++++++++++++ Resources/Prototypes/Body/Organs/diona.yml | 4 ---- Resources/Prototypes/Body/Organs/human.yml | 4 ---- Resources/Prototypes/Body/Parts/animal.yml | 2 +- Resources/Prototypes/Body/Parts/diona.yml | 17 ++++++----------- Resources/Prototypes/Body/Parts/human.yml | 9 ++------- Resources/Prototypes/Body/Parts/reptilian.yml | 17 ++++++----------- Resources/Prototypes/Body/Parts/skeleton.yml | 7 ++----- Resources/Prototypes/Body/Parts/slime.yml | 9 ++------- Resources/Prototypes/Body/Parts/vox.yml | 9 ++------- 12 files changed, 50 insertions(+), 61 deletions(-) create mode 100644 Content.Shared/Movement/Components/MovementBodyPartComponent.cs diff --git a/Content.Server/Body/Systems/BrainSystem.cs b/Content.Server/Body/Systems/BrainSystem.cs index 52b743eebc..97a76a64d1 100644 --- a/Content.Server/Body/Systems/BrainSystem.cs +++ b/Content.Server/Body/Systems/BrainSystem.cs @@ -4,12 +4,16 @@ using Content.Server.Mind.Components; using Content.Shared.Body.Components; using Content.Shared.Body.Events; using Content.Shared.Body.Organ; +using Content.Shared.Body.Part; using Content.Shared.Movement.Components; +using Content.Shared.Movement.Systems; namespace Content.Server.Body.Systems { public sealed class BrainSystem : EntitySystem { + [Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!; + public override void Initialize() { base.Initialize(); @@ -42,7 +46,14 @@ namespace Content.Server.Body.Systems Comp(newEntity).MustBeDead = true; // TODO: This is an awful solution. - EnsureComp(newEntity); + // Our greatest minds still can't figure out how to allow brains/heads to ghost without giving them the + // ability to move first. I hate this with a passion. + if (!HasComp(newEntity)) + { + AddComp(newEntity); + var move = EnsureComp(newEntity); + _movementSpeed.ChangeBaseSpeed(newEntity, 0, 0 , 0, move); + } oldMind.Mind?.TransferTo(newEntity); } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs index 1b446dff92..eab2dae602 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs @@ -311,11 +311,11 @@ public partial class SharedBodySystem var acceleration = 0f; foreach (var leg in allLegs) { - if (!TryComp(leg, out var legModifier)) + if (!TryComp(leg, out var legModifier)) continue; - walkSpeed += legModifier.BaseWalkSpeed; - sprintSpeed += legModifier.BaseSprintSpeed; + walkSpeed += legModifier.WalkSpeed; + sprintSpeed += legModifier.SprintSpeed; acceleration += legModifier.Acceleration; } diff --git a/Content.Shared/Movement/Components/MovementBodyPartComponent.cs b/Content.Shared/Movement/Components/MovementBodyPartComponent.cs new file mode 100644 index 0000000000..6f40987c1a --- /dev/null +++ b/Content.Shared/Movement/Components/MovementBodyPartComponent.cs @@ -0,0 +1,14 @@ +namespace Content.Shared.Movement.Components; + +[RegisterComponent, NetworkedComponent] +public sealed class MovementBodyPartComponent : Component +{ + [DataField("walkSpeed")] + public readonly float WalkSpeed = MovementSpeedModifierComponent.DefaultBaseWalkSpeed; + + [DataField("sprintSpeed")] + public readonly float SprintSpeed = MovementSpeedModifierComponent.DefaultBaseSprintSpeed; + + [DataField("acceleration")] + public float Acceleration = MovementSpeedModifierComponent.DefaultAcceleration; +} diff --git a/Resources/Prototypes/Body/Organs/diona.yml b/Resources/Prototypes/Body/Organs/diona.yml index c5d5c0cb36..b59b1458f8 100644 --- a/Resources/Prototypes/Body/Organs/diona.yml +++ b/Resources/Prototypes/Body/Organs/diona.yml @@ -40,10 +40,6 @@ Lung: maxVol: 100 canReact: False - - type: MovementSpeedModifier - baseWalkSpeed: 0 - baseSprintSpeed: 0 - - type: GhostOnMove - type: Brain - type: Lung #lungs in they head. why they there tho? - type: Metabolizer diff --git a/Resources/Prototypes/Body/Organs/human.yml b/Resources/Prototypes/Body/Organs/human.yml index e92c426a1c..b9d0242f72 100644 --- a/Resources/Prototypes/Body/Organs/human.yml +++ b/Resources/Prototypes/Body/Organs/human.yml @@ -29,10 +29,6 @@ - type: Input context: "ghost" - type: InputMover - - type: MovementSpeedModifier - baseWalkSpeed: 0 - baseSprintSpeed: 0 - - type: GhostOnMove - type: Brain - type: entity diff --git a/Resources/Prototypes/Body/Parts/animal.yml b/Resources/Prototypes/Body/Parts/animal.yml index dab65fe25d..3d90f24e1a 100644 --- a/Resources/Prototypes/Body/Parts/animal.yml +++ b/Resources/Prototypes/Body/Parts/animal.yml @@ -40,7 +40,7 @@ components: - type: BodyPart partType: Leg - - type: MovementSpeedModifier + - type: MovementBodyPart - type: entity id: FeetAnimal diff --git a/Resources/Prototypes/Body/Parts/diona.yml b/Resources/Prototypes/Body/Parts/diona.yml index fb11c0772a..527d56eee5 100644 --- a/Resources/Prototypes/Body/Parts/diona.yml +++ b/Resources/Prototypes/Body/Parts/diona.yml @@ -48,11 +48,6 @@ vital: true - type: Input context: "ghost" - - type: MovementSpeedModifier - baseWalkSpeed: 0 - baseSprintSpeed: 0 - - type: InputMover - - type: GhostOnMove - type: Tag tags: - Head @@ -121,9 +116,9 @@ - type: BodyPart partType: Leg symmetry: Left - - type: MovementSpeedModifier - baseWalkSpeed : 1.5 - baseSprintSpeed : 3.5 + - type: MovementBodyPart + walkSpeed : 1.5 + sprintSpeed : 3.5 - type: entity id: RightLegDiona @@ -137,9 +132,9 @@ - type: BodyPart partType: Leg symmetry: Right - - type: MovementSpeedModifier - baseWalkSpeed : 1.5 - baseSprintSpeed : 3.5 + - type: MovementBodyPart + walkSpeed : 1.5 + sprintSpeed : 3.5 - type: entity id: LeftFootDiona diff --git a/Resources/Prototypes/Body/Parts/human.yml b/Resources/Prototypes/Body/Parts/human.yml index 175d4c1837..316958dba6 100644 --- a/Resources/Prototypes/Body/Parts/human.yml +++ b/Resources/Prototypes/Body/Parts/human.yml @@ -51,11 +51,6 @@ vital: true - type: Input context: "ghost" - - type: MovementSpeedModifier - baseWalkSpeed: 0 - baseSprintSpeed: 0 - - type: InputMover - - type: GhostOnMove - type: Tag tags: - Head @@ -139,7 +134,7 @@ - type: BodyPart partType: Leg symmetry: Left - - type: MovementSpeedModifier + - type: MovementBodyPart - type: entity id: RightLegHuman @@ -156,7 +151,7 @@ - type: BodyPart partType: Leg symmetry: Right - - type: MovementSpeedModifier + - type: MovementBodyPart - type: entity id: LeftFootHuman diff --git a/Resources/Prototypes/Body/Parts/reptilian.yml b/Resources/Prototypes/Body/Parts/reptilian.yml index 3a54af0f61..0c17913034 100644 --- a/Resources/Prototypes/Body/Parts/reptilian.yml +++ b/Resources/Prototypes/Body/Parts/reptilian.yml @@ -49,11 +49,6 @@ vital: true - type: Input context: "ghost" - - type: MovementSpeedModifier - baseWalkSpeed: 0 - baseSprintSpeed: 0 - - type: InputMover - - type: GhostOnMove - type: Tag tags: - Head @@ -137,9 +132,9 @@ - type: BodyPart partType: Leg symmetry: Left - - type: MovementSpeedModifier - baseWalkSpeed : 2.7 - baseSprintSpeed : 4.5 + - type: MovementBodyPart + walkSpeed : 2.7 + sprintSpeed : 4.5 - type: entity id: RightLegReptilian @@ -156,9 +151,9 @@ - type: BodyPart partType: Leg symmetry: Right - - type: MovementSpeedModifier - baseWalkSpeed : 2.7 - baseSprintSpeed : 4.5 + - type: MovementBodyPart + walkSpeed : 2.7 + sprintSpeed : 4.5 - type: entity id: LeftFootReptilian diff --git a/Resources/Prototypes/Body/Parts/skeleton.yml b/Resources/Prototypes/Body/Parts/skeleton.yml index fe4aefa1c4..2d5d76a039 100644 --- a/Resources/Prototypes/Body/Parts/skeleton.yml +++ b/Resources/Prototypes/Body/Parts/skeleton.yml @@ -50,9 +50,6 @@ partType: Head - type: Input context: "human" - - type: MovementSpeedModifier - baseWalkSpeed: 0 - baseSprintSpeed: 0 - type: Speech - type: SkeletonAccent - type: Actions @@ -154,7 +151,7 @@ - type: BodyPart partType: Leg symmetry: Left - - type: MovementSpeedModifier + - type: MovementBodyPart - type: entity id: RightLegSkeleton @@ -171,7 +168,7 @@ - type: BodyPart partType: Leg symmetry: Right - - type: MovementSpeedModifier + - type: MovementBodyPart - type: entity id: LeftFootSkeleton diff --git a/Resources/Prototypes/Body/Parts/slime.yml b/Resources/Prototypes/Body/Parts/slime.yml index f2168e9481..8f58f0b7eb 100644 --- a/Resources/Prototypes/Body/Parts/slime.yml +++ b/Resources/Prototypes/Body/Parts/slime.yml @@ -50,11 +50,6 @@ vital: true - type: Input context: "ghost" - - type: MovementSpeedModifier - baseWalkSpeed: 0 - baseSprintSpeed: 0 - - type: InputMover - - type: GhostOnMove - type: Tag tags: - Head @@ -138,7 +133,7 @@ - type: BodyPart partType: Leg symmetry: Left - - type: MovementSpeedModifier + - type: MovementBodyPart - type: entity id: RightLegSlime @@ -155,7 +150,7 @@ - type: BodyPart partType: Leg symmetry: Right - - type: MovementSpeedModifier + - type: MovementBodyPart - type: entity id: LeftFootSlime diff --git a/Resources/Prototypes/Body/Parts/vox.yml b/Resources/Prototypes/Body/Parts/vox.yml index b38acb6a88..c87cbaa67e 100644 --- a/Resources/Prototypes/Body/Parts/vox.yml +++ b/Resources/Prototypes/Body/Parts/vox.yml @@ -51,11 +51,6 @@ vital: true - type: Input context: "ghost" - - type: MovementSpeedModifier - baseWalkSpeed: 0 - baseSprintSpeed: 0 - - type: InputMover - - type: GhostOnMove - type: Tag tags: - Head @@ -139,7 +134,7 @@ - type: BodyPart partType: Leg symmetry: Left - - type: MovementSpeedModifier + - type: MovementBodyPart - type: entity id: RightLegVox @@ -156,7 +151,7 @@ - type: BodyPart partType: Leg symmetry: Right - - type: MovementSpeedModifier + - type: MovementBodyPart - type: entity id: LeftFootVox