Prevent brains from walking (#15709)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2023-04-29 18:35:28 +12:00
committed by GitHub
parent 56f618e9ff
commit aeebe282d4
12 changed files with 50 additions and 61 deletions

View File

@@ -4,12 +4,16 @@ using Content.Server.Mind.Components;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
using Content.Shared.Body.Events; using Content.Shared.Body.Events;
using Content.Shared.Body.Organ; using Content.Shared.Body.Organ;
using Content.Shared.Body.Part;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
namespace Content.Server.Body.Systems namespace Content.Server.Body.Systems
{ {
public sealed class BrainSystem : EntitySystem public sealed class BrainSystem : EntitySystem
{ {
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -42,7 +46,14 @@ namespace Content.Server.Body.Systems
Comp<GhostOnMoveComponent>(newEntity).MustBeDead = true; Comp<GhostOnMoveComponent>(newEntity).MustBeDead = true;
// TODO: This is an awful solution. // TODO: This is an awful solution.
EnsureComp<InputMoverComponent>(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<InputMoverComponent>(newEntity))
{
AddComp<InputMoverComponent>(newEntity);
var move = EnsureComp<MovementSpeedModifierComponent>(newEntity);
_movementSpeed.ChangeBaseSpeed(newEntity, 0, 0 , 0, move);
}
oldMind.Mind?.TransferTo(newEntity); oldMind.Mind?.TransferTo(newEntity);
} }

View File

@@ -311,11 +311,11 @@ public partial class SharedBodySystem
var acceleration = 0f; var acceleration = 0f;
foreach (var leg in allLegs) foreach (var leg in allLegs)
{ {
if (!TryComp<MovementSpeedModifierComponent>(leg, out var legModifier)) if (!TryComp<MovementBodyPartComponent>(leg, out var legModifier))
continue; continue;
walkSpeed += legModifier.BaseWalkSpeed; walkSpeed += legModifier.WalkSpeed;
sprintSpeed += legModifier.BaseSprintSpeed; sprintSpeed += legModifier.SprintSpeed;
acceleration += legModifier.Acceleration; acceleration += legModifier.Acceleration;
} }

View File

@@ -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;
}

View File

@@ -40,10 +40,6 @@
Lung: Lung:
maxVol: 100 maxVol: 100
canReact: False canReact: False
- type: MovementSpeedModifier
baseWalkSpeed: 0
baseSprintSpeed: 0
- type: GhostOnMove
- type: Brain - type: Brain
- type: Lung #lungs in they head. why they there tho? - type: Lung #lungs in they head. why they there tho?
- type: Metabolizer - type: Metabolizer

View File

@@ -29,10 +29,6 @@
- type: Input - type: Input
context: "ghost" context: "ghost"
- type: InputMover - type: InputMover
- type: MovementSpeedModifier
baseWalkSpeed: 0
baseSprintSpeed: 0
- type: GhostOnMove
- type: Brain - type: Brain
- type: entity - type: entity

View File

@@ -40,7 +40,7 @@
components: components:
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
- type: MovementSpeedModifier - type: MovementBodyPart
- type: entity - type: entity
id: FeetAnimal id: FeetAnimal

View File

@@ -48,11 +48,6 @@
vital: true vital: true
- type: Input - type: Input
context: "ghost" context: "ghost"
- type: MovementSpeedModifier
baseWalkSpeed: 0
baseSprintSpeed: 0
- type: InputMover
- type: GhostOnMove
- type: Tag - type: Tag
tags: tags:
- Head - Head
@@ -121,9 +116,9 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Left symmetry: Left
- type: MovementSpeedModifier - type: MovementBodyPart
baseWalkSpeed : 1.5 walkSpeed : 1.5
baseSprintSpeed : 3.5 sprintSpeed : 3.5
- type: entity - type: entity
id: RightLegDiona id: RightLegDiona
@@ -137,9 +132,9 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Right symmetry: Right
- type: MovementSpeedModifier - type: MovementBodyPart
baseWalkSpeed : 1.5 walkSpeed : 1.5
baseSprintSpeed : 3.5 sprintSpeed : 3.5
- type: entity - type: entity
id: LeftFootDiona id: LeftFootDiona

View File

@@ -51,11 +51,6 @@
vital: true vital: true
- type: Input - type: Input
context: "ghost" context: "ghost"
- type: MovementSpeedModifier
baseWalkSpeed: 0
baseSprintSpeed: 0
- type: InputMover
- type: GhostOnMove
- type: Tag - type: Tag
tags: tags:
- Head - Head
@@ -139,7 +134,7 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Left symmetry: Left
- type: MovementSpeedModifier - type: MovementBodyPart
- type: entity - type: entity
id: RightLegHuman id: RightLegHuman
@@ -156,7 +151,7 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Right symmetry: Right
- type: MovementSpeedModifier - type: MovementBodyPart
- type: entity - type: entity
id: LeftFootHuman id: LeftFootHuman

View File

@@ -49,11 +49,6 @@
vital: true vital: true
- type: Input - type: Input
context: "ghost" context: "ghost"
- type: MovementSpeedModifier
baseWalkSpeed: 0
baseSprintSpeed: 0
- type: InputMover
- type: GhostOnMove
- type: Tag - type: Tag
tags: tags:
- Head - Head
@@ -137,9 +132,9 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Left symmetry: Left
- type: MovementSpeedModifier - type: MovementBodyPart
baseWalkSpeed : 2.7 walkSpeed : 2.7
baseSprintSpeed : 4.5 sprintSpeed : 4.5
- type: entity - type: entity
id: RightLegReptilian id: RightLegReptilian
@@ -156,9 +151,9 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Right symmetry: Right
- type: MovementSpeedModifier - type: MovementBodyPart
baseWalkSpeed : 2.7 walkSpeed : 2.7
baseSprintSpeed : 4.5 sprintSpeed : 4.5
- type: entity - type: entity
id: LeftFootReptilian id: LeftFootReptilian

View File

@@ -50,9 +50,6 @@
partType: Head partType: Head
- type: Input - type: Input
context: "human" context: "human"
- type: MovementSpeedModifier
baseWalkSpeed: 0
baseSprintSpeed: 0
- type: Speech - type: Speech
- type: SkeletonAccent - type: SkeletonAccent
- type: Actions - type: Actions
@@ -154,7 +151,7 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Left symmetry: Left
- type: MovementSpeedModifier - type: MovementBodyPart
- type: entity - type: entity
id: RightLegSkeleton id: RightLegSkeleton
@@ -171,7 +168,7 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Right symmetry: Right
- type: MovementSpeedModifier - type: MovementBodyPart
- type: entity - type: entity
id: LeftFootSkeleton id: LeftFootSkeleton

View File

@@ -50,11 +50,6 @@
vital: true vital: true
- type: Input - type: Input
context: "ghost" context: "ghost"
- type: MovementSpeedModifier
baseWalkSpeed: 0
baseSprintSpeed: 0
- type: InputMover
- type: GhostOnMove
- type: Tag - type: Tag
tags: tags:
- Head - Head
@@ -138,7 +133,7 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Left symmetry: Left
- type: MovementSpeedModifier - type: MovementBodyPart
- type: entity - type: entity
id: RightLegSlime id: RightLegSlime
@@ -155,7 +150,7 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Right symmetry: Right
- type: MovementSpeedModifier - type: MovementBodyPart
- type: entity - type: entity
id: LeftFootSlime id: LeftFootSlime

View File

@@ -51,11 +51,6 @@
vital: true vital: true
- type: Input - type: Input
context: "ghost" context: "ghost"
- type: MovementSpeedModifier
baseWalkSpeed: 0
baseSprintSpeed: 0
- type: InputMover
- type: GhostOnMove
- type: Tag - type: Tag
tags: tags:
- Head - Head
@@ -139,7 +134,7 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Left symmetry: Left
- type: MovementSpeedModifier - type: MovementBodyPart
- type: entity - type: entity
id: RightLegVox id: RightLegVox
@@ -156,7 +151,7 @@
- type: BodyPart - type: BodyPart
partType: Leg partType: Leg
symmetry: Right symmetry: Right
- type: MovementSpeedModifier - type: MovementBodyPart
- type: entity - type: entity
id: LeftFootVox id: LeftFootVox