From 69969bbdc6f6df799533da50f0a7517a6fa14aa7 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Wed, 16 Jun 2021 16:44:38 +0200 Subject: [PATCH] Remove IBody, IBodyPart, IMechanism and IMechanismBehavior (#4187) * Remove IBody, IBodyPart, IMechanism and IMechanismBehavior interfaces * Summary cleanup --- .../Body/Components/BodyComponent.cs | 2 +- .../Body/Components/BodyPartComponent.cs | 1 - .../Body/Components/MechanismComponent.cs | 5 +- Content.Client/Body/UI/BodyScannerDisplay.cs | 8 +- .../HumanoidAppearanceComponent.cs | 6 +- .../Commands/HideMechanismsCommand.cs | 2 +- .../Commands/ShowMechanismsCommand.cs | 2 +- .../Tests/Body/LegTest.cs | 2 +- .../Tests/Body/LungTest.cs | 4 +- .../Tests/Body/MechanismBehaviorEventsTest.cs | 14 +- .../Tests/Buckle/BuckleTest.cs | 2 +- .../Components/ActionBlocking/HandCuffTest.cs | 2 +- .../States/Mobs/NearbyBodiesState.cs | 2 +- Content.Server/Body/Behavior/BrainBehavior.cs | 12 +- Content.Server/Body/Behavior/LungBehavior.cs | 2 +- .../Body/Behavior/MechanismBehavior.cs | 46 ++-- .../Body/Behavior/MechanismExtensions.cs | 74 ----- Content.Server/Body/BodyComponent.cs | 11 +- .../Body/BodyManagerHealthChangeParams.cs | 2 + .../Body/Commands/AddHandCommand.cs | 6 +- .../Body/Commands/AttachBodyPartCommand.cs | 8 +- .../Body/Commands/DestroyMechanismCommand.cs | 2 +- .../Body/Commands/RemoveHandCommand.cs | 2 +- .../Body/Mechanism/MechanismComponent.cs | 9 +- Content.Server/Body/Part/BodyPartComponent.cs | 21 +- .../Body/Scanner/BodyScannerComponent.cs | 4 +- .../Surgery/BiologicalSurgeryDataComponent.cs | 20 +- .../Components/SurgeryToolComponent.cs | 16 +- .../Components/HumanoidAppearanceComponent.cs | 4 +- .../Chemistry/Components/PillComponent.cs | 2 +- .../Climbing/Components/ClimbableComponent.cs | 2 +- .../Thresholds/Behaviors/GibBehavior.cs | 2 +- .../Mailing/DisposalMailingUnitComponent.cs | 2 +- .../Components/DisposalHolderComponent.cs | 2 +- .../Kitchen/Components/MicrowaveComponent.cs | 2 +- .../Metabolism/MetabolismComponent.cs | 2 +- .../BodyBagEntityStorageComponent.cs | 2 +- .../MorgueEntityStorageComponent.cs | 4 +- .../Nutrition/Components/DrinkComponent.cs | 2 +- .../Nutrition/Components/FoodComponent.cs | 2 +- .../Recycling/Components/RecyclerComponent.cs | 6 +- .../Components/EntityStorageComponent.cs | 2 +- Content.Server/Toilet/ToiletComponent.cs | 2 +- .../Body/Behavior/IMechanismBehavior.cs | 142 ---------- .../Body/Behavior/SharedMechanismBehavior.cs | 119 ++++++++ Content.Shared/Body/Components/IBody.cs | 256 ------------------ .../Body/Components/SharedBodyComponent.cs | 144 ++++++---- Content.Shared/Body/Mechanism/IMechanism.cs | 178 ------------ .../Body/Mechanism/MechanismSystem.cs | 2 +- .../Mechanism/SharedMechanismComponent.cs | 43 +-- .../Body/Part/BodyPartCompatibility.cs | 2 +- .../Body/Part/BodyPartExtensions.cs | 81 ------ Content.Shared/Body/Part/BodyPartSymmetry.cs | 2 +- Content.Shared/Body/Part/BodyPartType.cs | 2 +- Content.Shared/Body/Part/IBodyPart.cs | 131 --------- Content.Shared/Body/Part/IBodyPartAdded.cs | 6 +- Content.Shared/Body/Part/IBodyPartRemoved.cs | 6 +- .../Property/BodyPartPropertyComponent.cs | 4 +- .../Body/Part/Property/ExtensionComponent.cs | 2 +- .../Body/Part/Property/GraspComponent.cs | 2 +- .../Body/Part/Property/IBodyPartProperty.cs | 2 +- .../Body/Part/Property/LegComponent.cs | 2 +- .../Body/Part/SharedBodyPartComponent.cs | 146 +++++++--- .../Body/Preset/BodyPresetPrototype.cs | 2 +- Content.Shared/Body/Slot/BodyPartSlot.cs | 12 +- Content.Shared/Body/Surgery/ISurgeon.cs | 8 +- .../Body/Surgery/SurgeryDataComponent.cs | 22 +- .../Body/Template/BodyTemplatePrototype.cs | 2 +- .../HumanoidVisualLayersExtension.cs | 2 +- Content.Shared/Damage/DamageChangeParams.cs | 1 + .../Components/SharedDisposalUnitComponent.cs | 2 +- .../SharedMedicalScannerComponent.cs | 2 +- 72 files changed, 508 insertions(+), 1142 deletions(-) delete mode 100644 Content.Server/Body/Behavior/MechanismExtensions.cs delete mode 100644 Content.Shared/Body/Behavior/IMechanismBehavior.cs create mode 100644 Content.Shared/Body/Behavior/SharedMechanismBehavior.cs delete mode 100644 Content.Shared/Body/Components/IBody.cs delete mode 100644 Content.Shared/Body/Mechanism/IMechanism.cs delete mode 100644 Content.Shared/Body/Part/BodyPartExtensions.cs delete mode 100644 Content.Shared/Body/Part/IBodyPart.cs diff --git a/Content.Client/Body/Components/BodyComponent.cs b/Content.Client/Body/Components/BodyComponent.cs index 5ddaac9e0a..c49b850969 100644 --- a/Content.Client/Body/Components/BodyComponent.cs +++ b/Content.Client/Body/Components/BodyComponent.cs @@ -5,7 +5,7 @@ using Robust.Shared.GameObjects; namespace Content.Client.Body.Components { [RegisterComponent] - [ComponentReference(typeof(IBody))] + [ComponentReference(typeof(SharedBodyComponent))] public class BodyComponent : SharedBodyComponent, IDraggable { bool IDraggable.CanStartDrag(StartDragDropEvent args) diff --git a/Content.Client/Body/Components/BodyPartComponent.cs b/Content.Client/Body/Components/BodyPartComponent.cs index 2b797c64ed..aad192f355 100644 --- a/Content.Client/Body/Components/BodyPartComponent.cs +++ b/Content.Client/Body/Components/BodyPartComponent.cs @@ -5,7 +5,6 @@ namespace Content.Client.Body.Components { [RegisterComponent] [ComponentReference(typeof(SharedBodyPartComponent))] - [ComponentReference(typeof(IBodyPart))] public class BodyPartComponent : SharedBodyPartComponent { } diff --git a/Content.Client/Body/Components/MechanismComponent.cs b/Content.Client/Body/Components/MechanismComponent.cs index f5d1b50404..d7a1880ec9 100644 --- a/Content.Client/Body/Components/MechanismComponent.cs +++ b/Content.Client/Body/Components/MechanismComponent.cs @@ -5,6 +5,7 @@ namespace Content.Client.Body.Components { [RegisterComponent] [ComponentReference(typeof(SharedMechanismComponent))] - [ComponentReference(typeof(IMechanism))] - public class MechanismComponent : SharedMechanismComponent { } + public class MechanismComponent : SharedMechanismComponent + { + } } diff --git a/Content.Client/Body/UI/BodyScannerDisplay.cs b/Content.Client/Body/UI/BodyScannerDisplay.cs index 947014f3b4..13afdfa6d6 100644 --- a/Content.Client/Body/UI/BodyScannerDisplay.cs +++ b/Content.Client/Body/UI/BodyScannerDisplay.cs @@ -15,9 +15,9 @@ namespace Content.Client.Body.UI public sealed class BodyScannerDisplay : SS14Window { private IEntity? _currentEntity; - private IBodyPart? _currentBodyPart; + private SharedBodyPartComponent? _currentBodyPart; - private IBody? CurrentBody => _currentEntity?.GetComponentOrNull(); + private SharedBodyComponent? CurrentBody => _currentEntity?.GetComponentOrNull(); public BodyScannerDisplay(BodyScannerBoundUserInterface owner) { @@ -137,7 +137,7 @@ namespace Content.Client.Body.UI } } - private void UpdateBodyPartBox(IBodyPart part, string slotName) + private void UpdateBodyPartBox(SharedBodyPartComponent part, string slotName) { BodyPartLabel.Text = $"{Loc.GetString(slotName)}: {Loc.GetString(part.Owner.Name)}"; @@ -161,7 +161,7 @@ namespace Content.Client.Body.UI UpdateMechanismBox(_currentBodyPart?.Mechanisms.ElementAt(args.ItemIndex)); } - private void UpdateMechanismBox(IMechanism? mechanism) + private void UpdateMechanismBox(SharedMechanismComponent? mechanism) { // TODO BODY Improve UI if (mechanism == null) diff --git a/Content.Client/CharacterAppearance/HumanoidAppearanceComponent.cs b/Content.Client/CharacterAppearance/HumanoidAppearanceComponent.cs index 8245cb344d..d4c0c3ce4e 100644 --- a/Content.Client/CharacterAppearance/HumanoidAppearanceComponent.cs +++ b/Content.Client/CharacterAppearance/HumanoidAppearanceComponent.cs @@ -52,7 +52,7 @@ namespace Content.Client.CharacterAppearance return; } - if (Owner.TryGetComponent(out IBody? body)) + if (Owner.TryGetComponent(out SharedBodyComponent? body)) { foreach (var (part, _) in body.Parts) { @@ -115,7 +115,7 @@ namespace Content.Client.CharacterAppearance return; } - if (!args.Part.Owner.TryGetComponent(out SpriteComponent? partSprite)) + if (!args.Part.Owner.HasComponent()) { return; } @@ -138,7 +138,7 @@ namespace Content.Client.CharacterAppearance return; } - if (!args.Part.Owner.TryGetComponent(out SpriteComponent? partSprite)) + if (!args.Part.Owner.HasComponent()) { return; } diff --git a/Content.Client/Commands/HideMechanismsCommand.cs b/Content.Client/Commands/HideMechanismsCommand.cs index 523f1ac4e7..84d18854ee 100644 --- a/Content.Client/Commands/HideMechanismsCommand.cs +++ b/Content.Client/Commands/HideMechanismsCommand.cs @@ -17,7 +17,7 @@ namespace Content.Client.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { var componentManager = IoCManager.Resolve(); - var mechanisms = componentManager.EntityQuery(true); + var mechanisms = componentManager.EntityQuery(true); foreach (var mechanism in mechanisms) { diff --git a/Content.Client/Commands/ShowMechanismsCommand.cs b/Content.Client/Commands/ShowMechanismsCommand.cs index fc28270e9a..19a4aacf00 100644 --- a/Content.Client/Commands/ShowMechanismsCommand.cs +++ b/Content.Client/Commands/ShowMechanismsCommand.cs @@ -19,7 +19,7 @@ namespace Content.Client.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { var componentManager = IoCManager.Resolve(); - var mechanisms = componentManager.EntityQuery(true); + var mechanisms = componentManager.EntityQuery(true); foreach (var mechanism in mechanisms) { diff --git a/Content.IntegrationTests/Tests/Body/LegTest.cs b/Content.IntegrationTests/Tests/Body/LegTest.cs index adde417e4d..e85fed07bb 100644 --- a/Content.IntegrationTests/Tests/Body/LegTest.cs +++ b/Content.IntegrationTests/Tests/Body/LegTest.cs @@ -46,7 +46,7 @@ namespace Content.IntegrationTests.Tests.Body var entityManager = IoCManager.Resolve(); var human = entityManager.SpawnEntity("HumanBodyAndAppearanceDummy", new MapCoordinates(Vector2.Zero, mapId)); - Assert.That(human.TryGetComponent(out IBody body)); + Assert.That(human.TryGetComponent(out SharedBodyComponent body)); Assert.That(human.TryGetComponent(out appearance)); Assert.That(!appearance.TryGetData(RotationVisuals.RotationState, out RotationState _)); diff --git a/Content.IntegrationTests/Tests/Body/LungTest.cs b/Content.IntegrationTests/Tests/Body/LungTest.cs index 9d3314d31c..376a6965aa 100644 --- a/Content.IntegrationTests/Tests/Body/LungTest.cs +++ b/Content.IntegrationTests/Tests/Body/LungTest.cs @@ -63,7 +63,7 @@ namespace Content.IntegrationTests.Tests.Body var human = entityManager.SpawnEntity("HumanBodyAndBloodstreamDummy", new MapCoordinates(Vector2.Zero, mapId)); - Assert.That(human.TryGetComponent(out IBody body)); + Assert.That(human.TryGetComponent(out SharedBodyComponent body)); Assert.That(body.TryGetMechanismBehaviors(out List lungs)); Assert.That(lungs.Count, Is.EqualTo(1)); Assert.That(human.TryGetComponent(out BloodstreamComponent bloodstream)); @@ -167,7 +167,7 @@ namespace Content.IntegrationTests.Tests.Body var coordinates = new EntityCoordinates(grid.GridEntityId, center); human = entityManager.SpawnEntity("HumanBodyAndBloodstreamDummy", coordinates); - Assert.True(human.TryGetComponent(out IBody body)); + Assert.True(human.TryGetComponent(out SharedBodyComponent body)); Assert.True(body.HasMechanismBehavior()); Assert.True(human.TryGetComponent(out metabolism)); Assert.False(metabolism.Suffocating); diff --git a/Content.IntegrationTests/Tests/Body/MechanismBehaviorEventsTest.cs b/Content.IntegrationTests/Tests/Body/MechanismBehaviorEventsTest.cs index 6e716faf51..8536e940f2 100644 --- a/Content.IntegrationTests/Tests/Body/MechanismBehaviorEventsTest.cs +++ b/Content.IntegrationTests/Tests/Body/MechanismBehaviorEventsTest.cs @@ -59,42 +59,42 @@ namespace Content.IntegrationTests.Tests.Body ResetRemoved(); } - protected override void OnAddedToBody(IBody body) + protected override void OnAddedToBody(SharedBodyComponent body) { base.OnAddedToBody(body); WasAddedToBody = true; } - protected override void OnAddedToPart(IBodyPart part) + protected override void OnAddedToPart(SharedBodyPartComponent part) { base.OnAddedToPart(part); WasAddedToPart = true; } - protected override void OnAddedToPartInBody(IBody body, IBodyPart part) + protected override void OnAddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part) { base.OnAddedToPartInBody(body, part); WasAddedToPartInBody = true; } - protected override void OnRemovedFromBody(IBody old) + protected override void OnRemovedFromBody(SharedBodyComponent old) { base.OnRemovedFromBody(old); WasRemovedFromBody = true; } - protected override void OnRemovedFromPart(IBodyPart old) + protected override void OnRemovedFromPart(SharedBodyPartComponent old) { base.OnRemovedFromPart(old); WasRemovedFromPart = true; } - protected override void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart) + protected override void OnRemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart) { base.OnRemovedFromPartInBody(oldBody, oldPart); @@ -128,7 +128,7 @@ namespace Content.IntegrationTests.Tests.Body var entityManager = IoCManager.Resolve(); var human = entityManager.SpawnEntity("HumanBodyDummy", new MapCoordinates(Vector2.Zero, mapId)); - Assert.That(human.TryGetComponent(out IBody? body)); + Assert.That(human.TryGetComponent(out SharedBodyComponent? body)); Assert.NotNull(body); var centerPart = body!.CenterPart; diff --git a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs index b7c4eaa64c..6029e2572a 100644 --- a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs +++ b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs @@ -213,7 +213,7 @@ namespace Content.IntegrationTests.Tests.Buckle IEntity human = null; BuckleComponent buckle = null; HandsComponent hands = null; - IBody body = null; + SharedBodyComponent body = null; await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs index 7220318bed..5109c330f3 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs @@ -69,7 +69,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking // Test for components existing Assert.True(human.TryGetComponent(out cuffed!), $"Human has no {nameof(CuffableComponent)}"); Assert.True(human.TryGetComponent(out hands!), $"Human has no {nameof(HandsComponent)}"); - Assert.True(human.TryGetComponent(out IBody _), $"Human has no {nameof(IBody)}"); + Assert.True(human.TryGetComponent(out SharedBodyComponent _), $"Human has no {nameof(SharedBodyComponent)}"); Assert.True(cuffs.TryGetComponent(out HandcuffComponent _), $"Handcuff has no {nameof(HandcuffComponent)}"); Assert.True(secondCuffs.TryGetComponent(out HandcuffComponent _), $"Second handcuffs has no {nameof(HandcuffComponent)}"); diff --git a/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs b/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs index 1dbbce8e79..1c20b224fa 100644 --- a/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs +++ b/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs @@ -21,7 +21,7 @@ namespace Content.Server.AI.WorldState.States.Mobs return result; } - foreach (var entity in Visibility.GetEntitiesInRange(Owner.Transform.Coordinates, typeof(IBody), controller.VisionRadius)) + foreach (var entity in Visibility.GetEntitiesInRange(Owner.Transform.Coordinates, typeof(SharedBodyComponent), controller.VisionRadius)) { if (entity == Owner) continue; result.Add(entity); diff --git a/Content.Server/Body/Behavior/BrainBehavior.cs b/Content.Server/Body/Behavior/BrainBehavior.cs index aaf7317032..a939c70fdc 100644 --- a/Content.Server/Body/Behavior/BrainBehavior.cs +++ b/Content.Server/Body/Behavior/BrainBehavior.cs @@ -11,42 +11,42 @@ namespace Content.Server.Body.Behavior { public class BrainBehavior : MechanismBehavior { - protected override void OnAddedToBody(IBody body) + protected override void OnAddedToBody(SharedBodyComponent body) { base.OnAddedToBody(body); HandleMind(body.Owner, Owner); } - protected override void OnAddedToPart(IBodyPart part) + protected override void OnAddedToPart(SharedBodyPartComponent part) { base.OnAddedToPart(part); HandleMind(part.Owner, Owner); } - protected override void OnAddedToPartInBody(IBody body, IBodyPart part) + protected override void OnAddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part) { base.OnAddedToPartInBody(body, part); HandleMind(body.Owner, Owner); } - protected override void OnRemovedFromBody(IBody old) + protected override void OnRemovedFromBody(SharedBodyComponent old) { base.OnRemovedFromBody(old); HandleMind(Part!.Owner, old.Owner); } - protected override void OnRemovedFromPart(IBodyPart old) + protected override void OnRemovedFromPart(SharedBodyPartComponent old) { base.OnRemovedFromPart(old); HandleMind(Owner, old.Owner); } - protected override void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart) + protected override void OnRemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart) { base.OnRemovedFromPartInBody(oldBody, oldPart); diff --git a/Content.Server/Body/Behavior/LungBehavior.cs b/Content.Server/Body/Behavior/LungBehavior.cs index c2ab4e5023..c4121eba7d 100644 --- a/Content.Server/Body/Behavior/LungBehavior.cs +++ b/Content.Server/Body/Behavior/LungBehavior.cs @@ -48,7 +48,7 @@ namespace Content.Server.Body.Behavior IoCManager.InjectDependencies(this); } - protected override void OnAddedToBody(IBody body) + protected override void OnAddedToBody(SharedBodyComponent body) { base.OnAddedToBody(body); Inhale(CycleDelay); diff --git a/Content.Server/Body/Behavior/MechanismBehavior.cs b/Content.Server/Body/Behavior/MechanismBehavior.cs index 6ad38b2b21..4446b991ec 100644 --- a/Content.Server/Body/Behavior/MechanismBehavior.cs +++ b/Content.Server/Body/Behavior/MechanismBehavior.cs @@ -8,22 +8,24 @@ using Robust.Shared.Utility; namespace Content.Server.Body.Behavior { - public abstract class MechanismBehavior : IMechanismBehavior + public abstract class MechanismBehavior : SharedMechanismBehavior { - public IBody? Body => Part?.Body; + private SharedMechanismComponent _parent = default!; - public IBodyPart? Part => Parent.Part; + public override SharedBodyComponent? Body => Part?.Body; - public IMechanism Parent { get; private set; } = default!; + public override SharedBodyPartComponent? Part => Parent.Part; - public IEntity Owner => Parent.Owner; + public override SharedMechanismComponent Parent => _parent; - public virtual void Initialize(IMechanism parent) + public override IEntity Owner => Parent.Owner; + + public override void Initialize(SharedMechanismComponent parent) { - Parent = parent; + _parent = parent; } - public virtual void Startup() + public override void Startup() { if (Part == null) { @@ -40,7 +42,9 @@ namespace Content.Server.Body.Behavior } } - public void AddedToBody(IBody body) + public override void Update(float frameTime) { } + + public override void AddedToBody(SharedBodyComponent body) { DebugTools.AssertNotNull(Body); DebugTools.AssertNotNull(body); @@ -48,7 +52,7 @@ namespace Content.Server.Body.Behavior OnAddedToBody(body); } - public void AddedToPart(IBodyPart part) + public override void AddedToPart(SharedBodyPartComponent part) { DebugTools.AssertNotNull(Part); DebugTools.AssertNotNull(part); @@ -56,7 +60,7 @@ namespace Content.Server.Body.Behavior OnAddedToPart(part); } - public void AddedToPartInBody(IBody body, IBodyPart part) + public override void AddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part) { DebugTools.AssertNotNull(Body); DebugTools.AssertNotNull(body); @@ -66,7 +70,7 @@ namespace Content.Server.Body.Behavior OnAddedToPartInBody(body, part); } - public void RemovedFromBody(IBody old) + public override void RemovedFromBody(SharedBodyComponent old) { DebugTools.AssertNull(Body); DebugTools.AssertNotNull(old); @@ -74,7 +78,7 @@ namespace Content.Server.Body.Behavior OnRemovedFromBody(old); } - public void RemovedFromPart(IBodyPart old) + public override void RemovedFromPart(SharedBodyPartComponent old) { DebugTools.AssertNull(Part); DebugTools.AssertNotNull(old); @@ -82,7 +86,7 @@ namespace Content.Server.Body.Behavior OnRemovedFromPart(old); } - public void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart) + public override void RemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart) { DebugTools.AssertNull(Body); DebugTools.AssertNull(Part); @@ -92,18 +96,16 @@ namespace Content.Server.Body.Behavior OnRemovedFromPartInBody(oldBody, oldPart); } - protected virtual void OnAddedToBody(IBody body) { } + protected virtual void OnAddedToBody(SharedBodyComponent body) { } - protected virtual void OnAddedToPart(IBodyPart part) { } + protected virtual void OnAddedToPart(SharedBodyPartComponent part) { } - protected virtual void OnAddedToPartInBody(IBody body, IBodyPart part) { } + protected virtual void OnAddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part) { } - protected virtual void OnRemovedFromBody(IBody old) { } + protected virtual void OnRemovedFromBody(SharedBodyComponent old) { } - protected virtual void OnRemovedFromPart(IBodyPart old) { } + protected virtual void OnRemovedFromPart(SharedBodyPartComponent old) { } - protected virtual void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart) { } - - public virtual void Update(float frameTime) { } + protected virtual void OnRemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart) { } } } diff --git a/Content.Server/Body/Behavior/MechanismExtensions.cs b/Content.Server/Body/Behavior/MechanismExtensions.cs deleted file mode 100644 index a62139c524..0000000000 --- a/Content.Server/Body/Behavior/MechanismExtensions.cs +++ /dev/null @@ -1,74 +0,0 @@ -#nullable enable -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using Content.Shared.Body.Behavior; -using Content.Shared.Body.Components; -using Content.Shared.Body.Part; - -namespace Content.Server.Body.Behavior -{ - public static class MechanismExtensions - { - public static bool HasMechanismBehavior(this IBody body) where T : IMechanismBehavior - { - return body.Parts.Any(p => p.Key.HasMechanismBehavior()); - } - - public static bool HasMechanismBehavior(this IBodyPart part) where T : IMechanismBehavior - { - return part.Mechanisms.Any(m => m.HasBehavior()); - } - - public static IEnumerable GetMechanismBehaviors(this IBody body) - { - foreach (var (part, _) in body.Parts) - foreach (var mechanism in part.Mechanisms) - foreach (var behavior in mechanism.Behaviors.Values) - { - yield return behavior; - } - } - - public static bool TryGetMechanismBehaviors(this IBody body, - [NotNullWhen(true)] out List? behaviors) - { - behaviors = body.GetMechanismBehaviors().ToList(); - - if (behaviors.Count == 0) - { - behaviors = null; - return false; - } - - return true; - } - - public static IEnumerable GetMechanismBehaviors(this IBody body) where T : class, IMechanismBehavior - { - foreach (var (part, _) in body.Parts) - foreach (var mechanism in part.Mechanisms) - foreach (var behavior in mechanism.Behaviors.Values) - { - if (behavior is T tBehavior) - { - yield return tBehavior; - } - } - } - - public static bool TryGetMechanismBehaviors(this IBody entity, [NotNullWhen(true)] out List? behaviors) - where T : class, IMechanismBehavior - { - behaviors = entity.GetMechanismBehaviors().ToList(); - - if (behaviors.Count == 0) - { - behaviors = null; - return false; - } - - return true; - } - } -} diff --git a/Content.Server/Body/BodyComponent.cs b/Content.Server/Body/BodyComponent.cs index 84f52d902a..abb72e835d 100644 --- a/Content.Server/Body/BodyComponent.cs +++ b/Content.Server/Body/BodyComponent.cs @@ -21,27 +21,26 @@ namespace Content.Server.Body { [RegisterComponent] [ComponentReference(typeof(SharedBodyComponent))] - [ComponentReference(typeof(IBody))] [ComponentReference(typeof(IGhostOnMove))] public class BodyComponent : SharedBodyComponent, IRelayMoveInput, IGhostOnMove { private Container _partContainer = default!; [Dependency] private readonly IGameTicker _gameTicker = default!; - protected override bool CanAddPart(string slotId, IBodyPart part) + protected override bool CanAddPart(string slotId, SharedBodyPartComponent part) { return base.CanAddPart(slotId, part) && _partContainer.CanInsert(part.Owner); } - protected override void OnAddPart(BodyPartSlot slot, IBodyPart part) + protected override void OnAddPart(BodyPartSlot slot, SharedBodyPartComponent part) { base.OnAddPart(slot, part); _partContainer.Insert(part.Owner); } - protected override void OnRemovePart(BodyPartSlot slot, IBodyPart part) + protected override void OnRemovePart(BodyPartSlot slot, SharedBodyPartComponent part) { base.OnRemovePart(slot, part); @@ -64,9 +63,9 @@ namespace Content.Server.Body // a crash within the character preview menu in the lobby var entity = Owner.EntityManager.SpawnEntity(preset.PartIDs[slot.Id], Owner.Transform.MapPosition); - if (!entity.TryGetComponent(out IBodyPart? part)) + if (!entity.TryGetComponent(out SharedBodyPartComponent? part)) { - Logger.Error($"Entity {slot.Id} does not have a {nameof(IBodyPart)} component."); + Logger.Error($"Entity {slot.Id} does not have a {nameof(SharedBodyPartComponent)} component."); continue; } diff --git a/Content.Server/Body/BodyManagerHealthChangeParams.cs b/Content.Server/Body/BodyManagerHealthChangeParams.cs index 19a41c72b9..7d50827125 100644 --- a/Content.Server/Body/BodyManagerHealthChangeParams.cs +++ b/Content.Server/Body/BodyManagerHealthChangeParams.cs @@ -3,11 +3,13 @@ using Content.Shared.Damage; namespace Content.Server.Body { + // TODO BODY: Remove and pretend it never existed public interface IBodyHealthChangeParams { BodyPartType Part { get; } } + // TODO BODY: Remove and pretend it never existed public class BodyDamageChangeParams : DamageChangeParams, IBodyHealthChangeParams { public BodyDamageChangeParams(BodyPartType part) diff --git a/Content.Server/Body/Commands/AddHandCommand.cs b/Content.Server/Body/Commands/AddHandCommand.cs index 089afcb72c..bcba8d8f6f 100644 --- a/Content.Server/Body/Commands/AddHandCommand.cs +++ b/Content.Server/Body/Commands/AddHandCommand.cs @@ -122,7 +122,7 @@ namespace Content.Server.Body.Commands } } - if (!entity.TryGetComponent(out IBody? body)) + if (!entity.TryGetComponent(out SharedBodyComponent? body)) { var random = IoCManager.Resolve(); var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; @@ -131,9 +131,9 @@ namespace Content.Server.Body.Commands return; } - if (!hand.TryGetComponent(out IBodyPart? part)) + if (!hand.TryGetComponent(out SharedBodyPartComponent? part)) { - shell.WriteLine($"Hand entity {hand} does not have a {nameof(IBodyPart)} component."); + shell.WriteLine($"Hand entity {hand} does not have a {nameof(SharedBodyPartComponent)} component."); return; } diff --git a/Content.Server/Body/Commands/AttachBodyPartCommand.cs b/Content.Server/Body/Commands/AttachBodyPartCommand.cs index a8aaa198e5..337ff4cd83 100644 --- a/Content.Server/Body/Commands/AttachBodyPartCommand.cs +++ b/Content.Server/Body/Commands/AttachBodyPartCommand.cs @@ -76,9 +76,9 @@ namespace Content.Server.Body.Commands return; } - if (!entity.TryGetComponent(out IBody? body)) + if (!entity.TryGetComponent(out SharedBodyComponent? body)) { - shell.WriteLine($"Entity {entity.Name} with uid {entity.Uid} does not have a {nameof(IBody)} component."); + shell.WriteLine($"Entity {entity.Name} with uid {entity.Uid} does not have a {nameof(SharedBodyComponent)} component."); return; } @@ -88,9 +88,9 @@ namespace Content.Server.Body.Commands return; } - if (!partEntity.TryGetComponent(out IBodyPart? part)) + if (!partEntity.TryGetComponent(out SharedBodyPartComponent? part)) { - shell.WriteLine($"Entity {partEntity.Name} with uid {args[0]} does not have a {nameof(IBodyPart)} component."); + shell.WriteLine($"Entity {partEntity.Name} with uid {args[0]} does not have a {nameof(SharedBodyPartComponent)} component."); return; } diff --git a/Content.Server/Body/Commands/DestroyMechanismCommand.cs b/Content.Server/Body/Commands/DestroyMechanismCommand.cs index 3ec683b8c9..4b13951a86 100644 --- a/Content.Server/Body/Commands/DestroyMechanismCommand.cs +++ b/Content.Server/Body/Commands/DestroyMechanismCommand.cs @@ -37,7 +37,7 @@ namespace Content.Server.Body.Commands return; } - if (!player.AttachedEntity.TryGetComponent(out IBody? body)) + if (!player.AttachedEntity.TryGetComponent(out SharedBodyComponent? body)) { var random = IoCManager.Resolve(); var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; diff --git a/Content.Server/Body/Commands/RemoveHandCommand.cs b/Content.Server/Body/Commands/RemoveHandCommand.cs index b2d7f26a5e..9668889628 100644 --- a/Content.Server/Body/Commands/RemoveHandCommand.cs +++ b/Content.Server/Body/Commands/RemoveHandCommand.cs @@ -33,7 +33,7 @@ namespace Content.Server.Body.Commands return; } - if (!player.AttachedEntity.TryGetComponent(out IBody? body)) + if (!player.AttachedEntity.TryGetComponent(out SharedBodyComponent? body)) { var random = IoCManager.Resolve(); var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; diff --git a/Content.Server/Body/Mechanism/MechanismComponent.cs b/Content.Server/Body/Mechanism/MechanismComponent.cs index 82fdc15326..fd1ae0e308 100644 --- a/Content.Server/Body/Mechanism/MechanismComponent.cs +++ b/Content.Server/Body/Mechanism/MechanismComponent.cs @@ -20,7 +20,6 @@ namespace Content.Server.Body.Mechanism { [RegisterComponent] [ComponentReference(typeof(SharedMechanismComponent))] - [ComponentReference(typeof(IMechanism))] public class MechanismComponent : SharedMechanismComponent, IAfterInteract { [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key); @@ -47,11 +46,11 @@ namespace Content.Server.Body.Mechanism PerformerCache = null; BodyCache = null; - if (eventArgs.Target.TryGetComponent(out IBody? body)) + if (eventArgs.Target.TryGetComponent(out SharedBodyComponent? body)) { SendBodyPartListToUser(eventArgs, body); } - else if (eventArgs.Target.TryGetComponent(out var part)) + else if (eventArgs.Target.TryGetComponent(out var part)) { DebugTools.AssertNotNull(part); @@ -64,7 +63,7 @@ namespace Content.Server.Body.Mechanism return true; } - private void SendBodyPartListToUser(AfterInteractEventArgs eventArgs, IBody body) + private void SendBodyPartListToUser(AfterInteractEventArgs eventArgs, SharedBodyComponent body) { // Create dictionary to send to client (text to be shown : data sent back if selected) var toSend = new Dictionary(); @@ -120,7 +119,7 @@ namespace Content.Server.Body.Mechanism return; } - var target = (IBodyPart) targetObject; + var target = (SharedBodyPartComponent) targetObject; var message = target.TryAddMechanism(this) ? Loc.GetString("You jam {0:theName} inside {1:them}.", Owner, PerformerCache) : Loc.GetString("You can't fit it in!"); diff --git a/Content.Server/Body/Part/BodyPartComponent.cs b/Content.Server/Body/Part/BodyPartComponent.cs index 1397012a5d..5978238fbd 100644 --- a/Content.Server/Body/Part/BodyPartComponent.cs +++ b/Content.Server/Body/Part/BodyPartComponent.cs @@ -25,31 +25,30 @@ namespace Content.Server.Body.Part { [RegisterComponent] [ComponentReference(typeof(SharedBodyPartComponent))] - [ComponentReference(typeof(IBodyPart))] public class BodyPartComponent : SharedBodyPartComponent, IAfterInteract { private readonly Dictionary _optionsCache = new(); - private IBody? _owningBodyCache; + private SharedBodyComponent? _owningBodyCache; private int _idHash; private IEntity? _surgeonCache; private Container _mechanismContainer = default!; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key); - public override bool CanAddMechanism(IMechanism mechanism) + public override bool CanAddMechanism(SharedMechanismComponent mechanism) { return base.CanAddMechanism(mechanism) && _mechanismContainer.CanInsert(mechanism.Owner); } - protected override void OnAddMechanism(IMechanism mechanism) + protected override void OnAddMechanism(SharedMechanismComponent mechanism) { base.OnAddMechanism(mechanism); _mechanismContainer.Insert(mechanism.Owner); } - protected override void OnRemoveMechanism(IMechanism mechanism) + protected override void OnRemoveMechanism(SharedMechanismComponent mechanism) { base.OnRemoveMechanism(mechanism); @@ -70,9 +69,9 @@ namespace Content.Server.Body.Part { var entity = Owner.EntityManager.SpawnEntity(mechanismId, Owner.Transform.MapPosition); - if (!entity.TryGetComponent(out IMechanism? mechanism)) + if (!entity.TryGetComponent(out SharedMechanismComponent? mechanism)) { - Logger.Error($"Entity {mechanismId} does not have a {nameof(IMechanism)} component."); + Logger.Error($"Entity {mechanismId} does not have a {nameof(SharedMechanismComponent)} component."); continue; } @@ -108,7 +107,7 @@ namespace Content.Server.Body.Part _surgeonCache = null; _owningBodyCache = null; - if (eventArgs.Target.TryGetComponent(out IBody? body)) + if (eventArgs.Target.TryGetComponent(out SharedBodyComponent? body)) { SendSlots(eventArgs, body); } @@ -116,7 +115,7 @@ namespace Content.Server.Body.Part return true; } - private void SendSlots(AfterInteractEventArgs eventArgs, IBody body) + private void SendSlots(AfterInteractEventArgs eventArgs, SharedBodyComponent body) { // Create dictionary to send to client (text to be shown : data sent back if selected) var toSend = new Dictionary(); @@ -246,7 +245,7 @@ namespace Content.Server.Body.Part return; } - if (!user.TryGetComponent(out IBody? body)) + if (!user.TryGetComponent(out SharedBodyComponent? body)) { return; } @@ -262,7 +261,7 @@ namespace Content.Server.Body.Part protected override void Activate(IEntity user, BodyPartComponent component) { - if (!user.TryGetComponent(out IBody? body)) + if (!user.TryGetComponent(out SharedBodyComponent? body)) { return; } diff --git a/Content.Server/Body/Scanner/BodyScannerComponent.cs b/Content.Server/Body/Scanner/BodyScannerComponent.cs index b54b815e03..c932ea4e3a 100644 --- a/Content.Server/Body/Scanner/BodyScannerComponent.cs +++ b/Content.Server/Body/Scanner/BodyScannerComponent.cs @@ -30,7 +30,7 @@ namespace Content.Server.Body.Scanner return; } - if (session.AttachedEntity.TryGetComponent(out IBody? body)) + if (session.AttachedEntity.TryGetComponent(out SharedBodyComponent? body)) { var state = InterfaceState(body); UserInterface?.SetState(state); @@ -56,7 +56,7 @@ namespace Content.Server.Body.Scanner /// /// Copy BodyTemplate and BodyPart data into a common data class that the client can read. /// - private BodyScannerUIState InterfaceState(IBody body) + private BodyScannerUIState InterfaceState(SharedBodyComponent body) { return new(body.Owner.Uid); } diff --git a/Content.Server/Body/Surgery/BiologicalSurgeryDataComponent.cs b/Content.Server/Body/Surgery/BiologicalSurgeryDataComponent.cs index edb8de8282..21ece952f1 100644 --- a/Content.Server/Body/Surgery/BiologicalSurgeryDataComponent.cs +++ b/Content.Server/Body/Surgery/BiologicalSurgeryDataComponent.cs @@ -25,7 +25,7 @@ namespace Content.Server.Body.Surgery { public override string Name => "BiologicalSurgeryData"; - private readonly HashSet _disconnectedOrgans = new(); + private readonly HashSet _disconnectedOrgans = new(); private bool SkinOpened { get; set; } @@ -33,11 +33,11 @@ namespace Content.Server.Body.Surgery private bool VesselsClamped { get; set; } - public IBodyPart? Parent => Owner.GetComponentOrNull(); + public SharedBodyPartComponent? Parent => Owner.GetComponentOrNull(); public BodyPartType? ParentType => Parent?.PartType; - private void AddDisconnectedOrgan(IMechanism mechanism) + private void AddDisconnectedOrgan(SharedMechanismComponent mechanism) { if (_disconnectedOrgans.Add(mechanism)) { @@ -45,7 +45,7 @@ namespace Content.Server.Body.Surgery } } - private void RemoveDisconnectedOrgan(IMechanism mechanism) + private void RemoveDisconnectedOrgan(SharedMechanismComponent mechanism) { if (_disconnectedOrgans.Remove(mechanism)) { @@ -117,7 +117,7 @@ namespace Content.Server.Body.Surgery return toReturn.ToString(); } - public bool CanAddMechanism(IMechanism mechanism) + public bool CanAddMechanism(SharedMechanismComponent mechanism) { return Parent != null && SkinOpened && @@ -125,7 +125,7 @@ namespace Content.Server.Body.Surgery SkinRetracted; } - public bool CanAttachBodyPart(IBodyPart part) + public bool CanAttachBodyPart(SharedBodyPartComponent part) { return Parent != null; // TODO BODY if a part is disconnected, you should have to do some surgery to allow another body part to be attached. @@ -276,7 +276,7 @@ namespace Content.Server.Body.Surgery if (Parent == null) return; if (Parent.Mechanisms.Count <= 0) return; - var toSend = new List(); + var toSend = new List(); foreach (var mechanism in Parent.Mechanisms) { if (!_disconnectedOrgans.Contains(mechanism)) @@ -291,7 +291,7 @@ namespace Content.Server.Body.Surgery } } - private async void LoosenOrganSurgeryCallback(IMechanism? target, IBodyPartContainer container, ISurgeon surgeon, + private async void LoosenOrganSurgeryCallback(SharedMechanismComponent? target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer) { if (Parent == null || target == null || !Parent.Mechanisms.Contains(target)) @@ -332,7 +332,7 @@ namespace Content.Server.Body.Surgery } } - private async void RemoveOrganSurgeryCallback(IMechanism? target, IBodyPartContainer container, ISurgeon surgeon, + private async void RemoveOrganSurgeryCallback(SharedMechanismComponent? target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer) { if (Parent == null || target == null || !Parent.Mechanisms.Contains(target)) @@ -359,7 +359,7 @@ namespace Content.Server.Body.Surgery private async void RemoveBodyPartSurgery(IBodyPartContainer container, ISurgeon surgeon, IEntity performer) { if (Parent == null) return; - if (container is not IBody body) return; + if (container is not SharedBodyComponent body) return; performer.PopupMessage(Loc.GetString("Sawing off the limb!")); diff --git a/Content.Server/Body/Surgery/Components/SurgeryToolComponent.cs b/Content.Server/Body/Surgery/Components/SurgeryToolComponent.cs index ff1939b081..2839e13dc3 100644 --- a/Content.Server/Body/Surgery/Components/SurgeryToolComponent.cs +++ b/Content.Server/Body/Surgery/Components/SurgeryToolComponent.cs @@ -47,7 +47,7 @@ namespace Content.Server.Body.Surgery.Components [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key); - public IBody? BodyCache { get; private set; } + public SharedBodyComponent? BodyCache { get; private set; } public IEntity? PerformerCache { get; private set; } @@ -66,7 +66,7 @@ namespace Content.Server.Body.Surgery.Components CloseAllSurgeryUIs(); // Attempt surgery on a body by sending a list of operable parts for the client to choose from - if (eventArgs.Target.TryGetComponent(out IBody? body)) + if (eventArgs.Target.TryGetComponent(out SharedBodyComponent? body)) { // Create dictionary to send to client (text to be shown : data sent back if selected) var toSend = new Dictionary(); @@ -93,7 +93,7 @@ namespace Content.Server.Body.Surgery.Components NotUsefulPopup(); } } - else if (eventArgs.Target.TryGetComponent(out var part)) + else if (eventArgs.Target.TryGetComponent(out var part)) { // Attempt surgery on a DroppedBodyPart - there's only one possible target so no need for selection UI PerformerCache = eventArgs.User; @@ -113,7 +113,7 @@ namespace Content.Server.Body.Surgery.Components } // Log error if the surgery fails somehow. - Logger.Debug($"Error when trying to perform surgery on ${nameof(IBodyPart)} {eventArgs.User.Name}"); + Logger.Debug($"Error when trying to perform surgery on ${nameof(SharedBodyPartComponent)} {eventArgs.User.Name}"); throw new InvalidOperationException(); } @@ -122,7 +122,7 @@ namespace Content.Server.Body.Surgery.Components public float BaseOperationTime { get => _baseOperateTime; set => _baseOperateTime = value; } - public void RequestMechanism(IEnumerable options, ISurgeon.MechanismRequestCallback callback) + public void RequestMechanism(IEnumerable options, ISurgeon.MechanismRequestCallback callback) { var toSend = new Dictionary(); foreach (var mechanism in options) @@ -211,7 +211,7 @@ namespace Content.Server.Body.Surgery.Components /// /// Called after the client chooses from a list of possible - /// that can be operated on. + /// that can be operated on. /// private void HandleReceiveBodyPart(int key) { @@ -230,7 +230,7 @@ namespace Content.Server.Body.Surgery.Components return; } - var target = (IBodyPart) targetObject!; + var target = (SharedBodyPartComponent) targetObject!; // TODO BODY Reconsider if (!target.AttemptSurgery(_surgeryType, BodyCache, this, PerformerCache)) @@ -241,7 +241,7 @@ namespace Content.Server.Body.Surgery.Components /// /// Called after the client chooses from a list of possible - /// to choose from. + /// to choose from. /// private void HandleReceiveMechanism(int key) { diff --git a/Content.Server/CharacterAppearance/Components/HumanoidAppearanceComponent.cs b/Content.Server/CharacterAppearance/Components/HumanoidAppearanceComponent.cs index 243d636fc5..f0fa65c45e 100644 --- a/Content.Server/CharacterAppearance/Components/HumanoidAppearanceComponent.cs +++ b/Content.Server/CharacterAppearance/Components/HumanoidAppearanceComponent.cs @@ -16,7 +16,7 @@ namespace Content.Server.CharacterAppearance.Components { base.Appearance = value; - if (Owner.TryGetComponent(out IBody? body)) + if (Owner.TryGetComponent(out SharedBodyComponent? body)) { foreach (var (part, _) in body.Parts) { @@ -35,7 +35,7 @@ namespace Content.Server.CharacterAppearance.Components { base.Startup(); - if (Appearance != null! && Owner.TryGetComponent(out IBody? body)) + if (Appearance != null! && Owner.TryGetComponent(out SharedBodyComponent? body)) { foreach (var (part, _) in body.Parts) { diff --git a/Content.Server/Chemistry/Components/PillComponent.cs b/Content.Server/Chemistry/Components/PillComponent.cs index ff3fd642f9..d03c951edc 100644 --- a/Content.Server/Chemistry/Components/PillComponent.cs +++ b/Content.Server/Chemistry/Components/PillComponent.cs @@ -70,7 +70,7 @@ namespace Content.Server.Chemistry.Components var trueTarget = target ?? user; - if (!trueTarget.TryGetComponent(out IBody? body) || + if (!trueTarget.TryGetComponent(out SharedBodyComponent? body) || !body.TryGetMechanismBehaviors(out var stomachs)) { return false; diff --git a/Content.Server/Climbing/Components/ClimbableComponent.cs b/Content.Server/Climbing/Components/ClimbableComponent.cs index 562a6b40bc..1d5cfae5fe 100644 --- a/Content.Server/Climbing/Components/ClimbableComponent.cs +++ b/Content.Server/Climbing/Components/ClimbableComponent.cs @@ -75,7 +75,7 @@ namespace Content.Server.Climbing.Components } if (!user.HasComponent() || - !user.TryGetComponent(out IBody? body)) + !user.TryGetComponent(out SharedBodyComponent? body)) { reason = Loc.GetString("comp-climbable-cant-climb"); return false; diff --git a/Content.Server/Destructible/Thresholds/Behaviors/GibBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/GibBehavior.cs index 70a838d430..8994cf839e 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/GibBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/GibBehavior.cs @@ -13,7 +13,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors public void Execute(IEntity owner, DestructibleSystem system) { - if (owner.TryGetComponent(out IBody? body)) + if (owner.TryGetComponent(out SharedBodyComponent? body)) { body.Gib(_recursive); } diff --git a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs index 8ff3e7cabd..9a0fc21502 100644 --- a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs +++ b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs @@ -161,7 +161,7 @@ namespace Content.Server.Disposal.Mailing } if (!entity.HasComponent() && - !entity.HasComponent()) + !entity.HasComponent()) { return false; } diff --git a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs index 86feb33126..c9a8ac4225 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs @@ -79,7 +79,7 @@ namespace Content.Server.Disposal.Unit.Components } return entity.HasComponent() || - entity.HasComponent(); + entity.HasComponent(); } public bool TryInsert(IEntity entity) diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index e69389637a..3e8a2ffa05 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -470,7 +470,7 @@ namespace Content.Server.Kitchen.Components { var headCount = 0; - if (victim.TryGetComponent(out var body)) + if (victim.TryGetComponent(out var body)) { var headSlots = body.GetSlotsOfType(BodyPartType.Head); diff --git a/Content.Server/Metabolism/MetabolismComponent.cs b/Content.Server/Metabolism/MetabolismComponent.cs index b6d25f2bf6..7fbb8296fa 100644 --- a/Content.Server/Metabolism/MetabolismComponent.cs +++ b/Content.Server/Metabolism/MetabolismComponent.cs @@ -26,7 +26,7 @@ namespace Content.Server.Metabolism [RegisterComponent] public class MetabolismComponent : Component { - [ComponentDependency] private readonly IBody? _body = default!; + [ComponentDependency] private readonly SharedBodyComponent? _body = default!; public override string Name => "Metabolism"; diff --git a/Content.Server/Morgue/Components/BodyBagEntityStorageComponent.cs b/Content.Server/Morgue/Components/BodyBagEntityStorageComponent.cs index 0d80fcc8ab..ac64b1b9ad 100644 --- a/Content.Server/Morgue/Components/BodyBagEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/BodyBagEntityStorageComponent.cs @@ -44,7 +44,7 @@ namespace Content.Server.Morgue.Components protected override bool AddToContents(IEntity entity) { - if (entity.HasComponent() && !EntitySystem.Get().IsDown(entity)) return false; + if (entity.HasComponent() && !EntitySystem.Get().IsDown(entity)) return false; return base.AddToContents(entity); } diff --git a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs index 6aee6efc9a..919c363330 100644 --- a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs @@ -64,7 +64,7 @@ namespace Content.Server.Morgue.Components protected override bool AddToContents(IEntity entity) { - if (entity.HasComponent() && !EntitySystem.Get().IsDown(entity)) return false; + if (entity.HasComponent() && !EntitySystem.Get().IsDown(entity)) return false; return base.AddToContents(entity); } @@ -115,7 +115,7 @@ namespace Content.Server.Morgue.Components foreach (var entity in Contents.ContainedEntities) { count++; - if (!hasMob && entity.HasComponent()) hasMob = true; + if (!hasMob && entity.HasComponent()) hasMob = true; if (!hasSoul && entity.TryGetComponent(out var actor) && actor.PlayerSession != null) hasSoul = true; } Appearance?.SetData(MorgueVisuals.HasContents, count > 0); diff --git a/Content.Server/Nutrition/Components/DrinkComponent.cs b/Content.Server/Nutrition/Components/DrinkComponent.cs index 42f3da43d0..676766a7ce 100644 --- a/Content.Server/Nutrition/Components/DrinkComponent.cs +++ b/Content.Server/Nutrition/Components/DrinkComponent.cs @@ -187,7 +187,7 @@ namespace Content.Server.Nutrition.Components return false; } - if (!target.TryGetComponent(out IBody? body) || + if (!target.TryGetComponent(out SharedBodyComponent? body) || !body.TryGetMechanismBehaviors(out var stomachs)) { target.PopupMessage(Loc.GetString("You can't drink {0:theName}!", Owner)); diff --git a/Content.Server/Nutrition/Components/FoodComponent.cs b/Content.Server/Nutrition/Components/FoodComponent.cs index 7b285ec805..b4e0c44eab 100644 --- a/Content.Server/Nutrition/Components/FoodComponent.cs +++ b/Content.Server/Nutrition/Components/FoodComponent.cs @@ -103,7 +103,7 @@ namespace Content.Server.Nutrition.Components var trueTarget = target ?? user; - if (!trueTarget.TryGetComponent(out IBody? body) || + if (!trueTarget.TryGetComponent(out SharedBodyComponent? body) || !body.TryGetMechanismBehaviors(out var stomachs)) { return false; diff --git a/Content.Server/Recycling/Components/RecyclerComponent.cs b/Content.Server/Recycling/Components/RecyclerComponent.cs index 82b543ac5b..e5582c0d16 100644 --- a/Content.Server/Recycling/Components/RecyclerComponent.cs +++ b/Content.Server/Recycling/Components/RecyclerComponent.cs @@ -69,7 +69,7 @@ namespace Content.Server.Recycling.Components private bool CanGib(IEntity entity) { // We suppose this entity has a Recyclable component. - return entity.HasComponent() && !_safe && Powered; + return entity.HasComponent() && !_safe && Powered; } private void Recycle(IEntity entity) @@ -87,7 +87,7 @@ namespace Content.Server.Recycling.Components // Mobs are a special case! if (CanGib(entity)) { - entity.GetComponent().Gib(true); + entity.GetComponent().Gib(true); Bloodstain(); return; } @@ -159,7 +159,7 @@ namespace Content.Server.Recycling.Components victim.PopupMessageOtherClients(Loc.GetString("{0:theName} tries to recycle {0:themself}!", victim)); - if (victim.TryGetComponent(out var body)) + if (victim.TryGetComponent(out var body)) { body.Gib(true); } diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index 55f7ca3c51..2ce4ed45a5 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -208,7 +208,7 @@ namespace Content.Server.Storage.Components // only items that can be stored in an inventory, or a mob, can be eaten by a locker if (!entity.HasComponent() && - !entity.HasComponent()) + !entity.HasComponent()) continue; if (!AddToContents(entity)) diff --git a/Content.Server/Toilet/ToiletComponent.cs b/Content.Server/Toilet/ToiletComponent.cs index c96e35959d..0978a6cab3 100644 --- a/Content.Server/Toilet/ToiletComponent.cs +++ b/Content.Server/Toilet/ToiletComponent.cs @@ -144,7 +144,7 @@ namespace Content.Server.Toilet SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) { // check that victim even have head - if (victim.TryGetComponent(out var body) && + if (victim.TryGetComponent(out var body) && body.HasPartOfType(BodyPartType.Head)) { var othersMessage = Loc.GetString("{0:theName} sticks their head into {1:theName} and flushes it!", victim, Owner); diff --git a/Content.Shared/Body/Behavior/IMechanismBehavior.cs b/Content.Shared/Body/Behavior/IMechanismBehavior.cs deleted file mode 100644 index 4fb0dcc98c..0000000000 --- a/Content.Shared/Body/Behavior/IMechanismBehavior.cs +++ /dev/null @@ -1,142 +0,0 @@ -#nullable enable -using Content.Shared.Body.Components; -using Content.Shared.Body.Mechanism; -using Content.Shared.Body.Part; -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization.Manager.Attributes; - -namespace Content.Shared.Body.Behavior -{ - /// - /// Gives functionality to a when added to it. - /// - [ImplicitDataDefinitionForInheritors] - public interface IMechanismBehavior - { - /// - /// The body that owns the in which the - /// that owns this - /// is in. - /// - IBody? Body { get; } - - /// - /// The part in which the that owns this - /// is in. - /// - IBodyPart? Part { get; } - - /// - /// Upward reference to the parent that this - /// behavior is attached to. - /// - IMechanism Parent { get; } - - /// - /// The entity that owns . - /// For the entity owning the body that this mechanism may be in, - /// see 's . - /// - IEntity Owner { get; } - - /// - /// Called when this is added to a - /// , during . - /// If it is added after component initialization, - /// it is called immediately. - /// - /// - /// The mechanism that owns this . - /// - void Initialize(IMechanism parent); - - /// - /// Called when this is added to a - /// , during . - /// If it is added after component startup, it is called immediately. - /// - void Startup(); - - /// - /// Runs an update cycle on this . - /// - /// - /// The amount of seconds that passed since the last update. - /// - void Update(float frameTime); - - /// - /// Called when the containing is attached to a - /// . - /// For instance, attaching a head with a brain inside to a body. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The body that the containing was added to. - /// - void AddedToBody(IBody body); - - /// - /// Called when the parent is - /// added into a that is not attached to a - /// . - /// For instance, adding a brain to a dismembered head. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The part that the containing was added to. - /// - void AddedToPart(IBodyPart part); - - /// - /// Called when the parent is added to a - /// that is attached to a . - /// For instance, adding a brain to a head that is attached to a body. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The body that the containing was added to. - /// - /// - /// The part that the containing was added to. - /// - void AddedToPartInBody(IBody body, IBodyPart part); - - /// - /// Called when the parent is removed from a - /// . - /// For instance, removing a head with a brain inside from a body. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The body that the containing was removed from. - /// - void RemovedFromBody(IBody old); - - /// - /// Called when the parent is - /// removed from a that is not attached to a - /// . - /// For instance, removing a brain from a dismembered head. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The part that the containing was removed from. - /// - void RemovedFromPart(IBodyPart old); - - /// - /// Called when the parent is removed from a - /// that is attached to a . - /// For instance, removing a brain from a head that is attached to a body. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The body that the containing was removed from. - /// - /// - /// The part that the containing was removed from. - /// - void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart); - } -} diff --git a/Content.Shared/Body/Behavior/SharedMechanismBehavior.cs b/Content.Shared/Body/Behavior/SharedMechanismBehavior.cs new file mode 100644 index 0000000000..f67adc0db6 --- /dev/null +++ b/Content.Shared/Body/Behavior/SharedMechanismBehavior.cs @@ -0,0 +1,119 @@ +#nullable enable +using Content.Shared.Body.Components; +using Content.Shared.Body.Mechanism; +using Content.Shared.Body.Part; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization.Manager.Attributes; + +namespace Content.Shared.Body.Behavior +{ + /// + /// Gives functionality to a mechanism when added to it. + /// + [ImplicitDataDefinitionForInheritors] + public abstract class SharedMechanismBehavior + { + public abstract SharedBodyComponent? Body { get; } + + public abstract SharedBodyPartComponent? Part { get; } + + public abstract SharedMechanismComponent Parent { get; } + + /// + /// The entity that owns . + /// For the entity owning the body that this mechanism may be in, + /// see 's . + /// + public abstract IEntity Owner { get; } + + /// + /// Called when this behavior is added to a mechanism, during . + /// If it is added after component initialization, + /// it is called immediately. + /// + /// + /// The mechanism that owns this behavior. + /// + public abstract void Initialize(SharedMechanismComponent parent); + + /// + /// Called when this behavior is added to a mechanism, during . + /// If it is added after component startup, it is called immediately. + /// + public abstract void Startup(); + + /// + /// Runs an update cycle on this behavior. + /// + /// + /// The amount of seconds that passed since the last update. + /// + public abstract void Update(float frameTime); + + /// + /// Called when the containing part is attached to a body. + /// For instance, attaching a head with a brain inside to a body. + /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! + /// + /// + /// The body that the containing mechanism was added to. + /// + public abstract void AddedToBody(SharedBodyComponent body); + + /// + /// Called when the parent mechanism is added into a part that is not attached to a body. + /// For instance, adding a brain to a dismembered head. + /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! + /// + /// + /// The part that the containing mechanism was added to. + /// + public abstract void AddedToPart(SharedBodyPartComponent part); + + /// + /// Called when the parent mechanism is added to a part that is attached to a body. + /// For instance, adding a brain to a head that is attached to a body. + /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! + /// + /// + /// The body that the containing mechanism was added to. + /// + /// + /// The part that the containing mechanism was added to. + /// + public abstract void AddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part); + + /// + /// Called when the parent part is removed from a body. + /// For instance, removing a head with a brain inside from a body. + /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! + /// + /// + /// The body that the containing mechanism was removed from. + /// + public abstract void RemovedFromBody(SharedBodyComponent old); + + /// + /// Called when the parent mechanism is removed from a part that is not attached to a body. + /// For instance, removing a brain from a dismembered head. + /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! + /// + /// + /// The part that the containing mechanism was removed from. + /// + public abstract void RemovedFromPart(SharedBodyPartComponent old); + + /// + /// Called when the parent mechanism is removed from a part that is attached to a body. + /// For instance, removing a brain from a head that is attached to a body. + /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! + /// + /// + /// The body that the containing mechanism was removed from. + /// + /// + /// The part that the containing mechanism was removed from. + /// + public abstract void RemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart); + } +} diff --git a/Content.Shared/Body/Components/IBody.cs b/Content.Shared/Body/Components/IBody.cs deleted file mode 100644 index d3a92cca83..0000000000 --- a/Content.Shared/Body/Components/IBody.cs +++ /dev/null @@ -1,256 +0,0 @@ -#nullable enable -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using Content.Shared.Body.Part; -using Content.Shared.Body.Part.Property; -using Content.Shared.Body.Preset; -using Content.Shared.Body.Slot; -using Content.Shared.Body.Template; -using Robust.Shared.GameObjects; - -namespace Content.Shared.Body.Components -{ - /// - /// Component representing a collection of s - /// attached to each other. - /// - public interface IBody : IComponent, IBodyPartContainer - { - /// - /// The used to create this - /// . - /// - public BodyTemplatePrototype? Template { get; } - - /// - /// The used to create this - /// . - /// - public BodyPresetPrototype? Preset { get; } - - /// - /// An enumeration of the slots that make up this body, regardless - /// of if they contain a part or not. - /// - IEnumerable Slots { get; } - - /// - /// An enumeration of the parts on this body paired with the slots - /// that they are in. - /// - IEnumerable> Parts { get; } - - /// - /// An enumeration of the slots on this body without a part in them. - /// - IEnumerable EmptySlots { get; } - - /// - /// Finds the central , if any, - /// of this body. - /// - /// - /// The central if one exists, - /// null otherwise. - /// - BodyPartSlot? CenterSlot { get; } - - /// - /// Finds the central , if any, - /// of this body. - /// - /// - /// The central if one exists, - /// null otherwise. - /// - IBodyPart? CenterPart { get; } - - // TODO BODY Sensible templates - - /// - /// Attempts to add a part to the given slot. - /// - /// The slot to add this part to. - /// The part to add. - /// - /// Whether to check if the slot exists, or create one otherwise. - /// - /// - /// true if the part was added, false otherwise even if it was - /// already added. - /// - bool TryAddPart(string slotId, IBodyPart part); - - void SetPart(string slotId, IBodyPart part); - - /// - /// Checks if there is a in the given slot. - /// - /// The slot to look in. - /// - /// true if there is a part in the given , - /// false otherwise. - /// - bool HasPart(string slotId); - - /// - /// Checks if this contains the given . - /// - /// The part to look for. - /// - /// true if the given is attached to the body, - /// false otherwise. - /// - bool HasPart(IBodyPart part); - - /// - /// Removes the given from this body, - /// dropping other if they were hanging - /// off of it. - /// The part to remove. - /// - /// true if the part was removed, false otherwise - /// even if the part was already removed previously. - /// - /// - bool RemovePart(IBodyPart part); - - /// - /// Removes the body part in slot from this body, - /// if one exists. - /// - /// The slot to remove it from. - /// true if the part was removed, false otherwise. - bool RemovePart(string slotId); - - /// - /// Removes the body part from this body, if one exists. - /// - /// The part to remove from this body. - /// The slot that the part was in, if any. - /// - /// true if was removed, false otherwise. - /// - bool RemovePart(IBodyPart part, [NotNullWhen(true)] out BodyPartSlot? slotId); - - /// - /// Disconnects the given reference, potentially - /// dropping other BodyParts if they - /// were hanging off of it. - /// - /// The part to drop. - /// - /// All of the parts that were dropped, including the one in - /// . - /// - /// - /// true if the part was dropped, false otherwise. - /// - bool TryDropPart(BodyPartSlot slot, [NotNullWhen(true)] out Dictionary? dropped); - - /// - /// Recursively searches for if is connected to - /// the center. - /// - /// The body part to find the center for. - /// - /// true if it is connected to the center, false otherwise. - /// - bool ConnectedToCenter(IBodyPart part); - - /// - /// Returns whether the given part slot exists in this body. - /// - /// The slot to check for. - /// true if the slot exists in this body, false otherwise. - bool HasSlot(string slot); - - BodyPartSlot? GetSlot(IBodyPart part); - - /// - /// Finds the slot that the given resides in. - /// - /// - /// The to find the slot for. - /// - /// The slot found, if any. - /// true if a slot was found, false otherwise - bool TryGetSlot(IBodyPart part, [NotNullWhen(true)] out BodyPartSlot? slot); - - /// - /// Finds the in the given - /// if one exists. - /// - /// The part slot to search in. - /// The body part in that slot, if any. - /// true if found, false otherwise. - bool TryGetPart(string slotId, [NotNullWhen(true)] out IBodyPart? result); - - /// - /// Checks if a slot of the specified type exists on this body. - /// - /// The type to check for. - /// true if present, false otherwise. - bool HasSlotOfType(BodyPartType type); - - /// - /// Gets all slots of the specified type on this body. - /// - /// The type to check for. - /// An enumerable of the found slots. - IEnumerable GetSlotsOfType(BodyPartType type); - - /// - /// Checks if a part of the specified type exists on this body. - /// - /// The type to check for. - /// true if present, false otherwise. - bool HasPartOfType(BodyPartType type); - - /// - /// Gets all slots of the specified type on this body. - /// - /// The type to check for. - /// An enumerable of the found slots. - IEnumerable GetPartsOfType(BodyPartType type); - - /// - /// Finds all s with the given property in - /// this body. - /// - /// The property type to look for. - /// A list of parts with that property. - IEnumerable<(IBodyPart part, IBodyPartProperty property)> GetPartsWithProperty(Type type); - - /// - /// Finds all s with the given property in this body. - /// - /// The property type to look for. - /// A list of parts with that property. - IEnumerable<(IBodyPart part, T property)> GetPartsWithProperty() where T : class, IBodyPartProperty; - - // TODO BODY Make a slot object that makes sense to the human mind, and make it serializable. Imagine the possibilities! - /// - /// Retrieves the slot at the given index. - /// - /// The index to look in. - /// A pair of the slot name and part type occupying it. - BodyPartSlot SlotAt(int index); - - /// - /// Retrieves the part at the given index. - /// - /// The index to look in. - /// A pair of the part name and body part occupying it. - KeyValuePair PartAt(int index); - - /// - /// Gibs this body. - /// - /// - /// Whether or not to also gib this body's parts. - /// - void Gib(bool gibParts = false); - } -} diff --git a/Content.Shared/Body/Components/SharedBodyComponent.cs b/Content.Shared/Body/Components/SharedBodyComponent.cs index b1a5d9b6b1..e7f46f0f5d 100644 --- a/Content.Shared/Body/Components/SharedBodyComponent.cs +++ b/Content.Shared/Body/Components/SharedBodyComponent.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using Content.Shared.Body.Behavior; using Content.Shared.Body.Part; using Content.Shared.Body.Part.Property; using Content.Shared.Body.Preset; @@ -25,7 +26,7 @@ using Robust.Shared.ViewVariables; namespace Content.Shared.Body.Components { // TODO BODY Damage methods for collections of IDamageableComponents - public abstract class SharedBodyComponent : Component, IBody, ISerializationHooks + public abstract class SharedBodyComponent : Component, IBodyPartContainer, ISerializationHooks { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; @@ -55,13 +56,13 @@ namespace Content.Shared.Body.Components private Dictionary SlotIds { get; } = new(); [ViewVariables] - private Dictionary SlotParts { get; } = new(); + private Dictionary SlotParts { get; } = new(); [ViewVariables] public IEnumerable Slots => SlotIds.Values; [ViewVariables] - public IEnumerable> Parts => SlotParts; + public IEnumerable> Parts => SlotParts; [ViewVariables] public IEnumerable EmptySlots => Slots.Where(slot => slot.Part == null); @@ -71,7 +72,7 @@ namespace Content.Shared.Body.Components ? SlotIds.GetValueOrDefault(centerSlot) : null; - public IBodyPart? CenterPart => CenterSlot?.Part; + public SharedBodyPartComponent? CenterPart => CenterSlot?.Part; public override void Initialize() { @@ -119,9 +120,9 @@ namespace Content.Shared.Body.Components return slot; } - private Dictionary GetHangingParts(BodyPartSlot from) + private Dictionary GetHangingParts(BodyPartSlot from) { - var hanging = new Dictionary(); + var hanging = new Dictionary(); foreach (var connection in from.Connections) { @@ -135,7 +136,7 @@ namespace Content.Shared.Body.Components return hanging; } - protected virtual bool CanAddPart(string slotId, IBodyPart part) + protected virtual bool CanAddPart(string slotId, SharedBodyPartComponent part) { if (!SlotIds.TryGetValue(slotId, out var slot) || slot.CanAddPart(part)) @@ -146,7 +147,7 @@ namespace Content.Shared.Body.Components return true; } - protected virtual void OnAddPart(BodyPartSlot slot, IBodyPart part) + protected virtual void OnAddPart(BodyPartSlot slot, SharedBodyPartComponent part) { SlotParts[part] = slot; part.Body = this; @@ -162,7 +163,7 @@ namespace Content.Shared.Body.Components OnBodyChanged(); } - protected virtual void OnRemovePart(BodyPartSlot slot, IBodyPart part) + protected virtual void OnRemovePart(BodyPartSlot slot, SharedBodyPartComponent part) { SlotParts.Remove(part); @@ -203,7 +204,8 @@ namespace Content.Shared.Body.Components OnBodyChanged(); } - public bool TryAddPart(string slotId, IBodyPart part) + // TODO BODY Sensible templates + public bool TryAddPart(string slotId, SharedBodyPartComponent part) { DebugTools.AssertNotNull(part); DebugTools.AssertNotNull(slotId); @@ -217,7 +219,7 @@ namespace Content.Shared.Body.Components slot.TryAddPart(part); } - public void SetPart(string slotId, IBodyPart part) + public void SetPart(string slotId, SharedBodyPartComponent part) { if (!SlotIds.TryGetValue(slotId, out var slot)) { @@ -236,14 +238,14 @@ namespace Content.Shared.Body.Components slot.Part != null; } - public bool HasPart(IBodyPart part) + public bool HasPart(SharedBodyPartComponent part) { DebugTools.AssertNotNull(part); return SlotParts.ContainsKey(part); } - public bool RemovePart(IBodyPart part) + public bool RemovePart(SharedBodyPartComponent part) { DebugTools.AssertNotNull(part); @@ -259,7 +261,7 @@ namespace Content.Shared.Body.Components slot.RemovePart(); } - public bool RemovePart(IBodyPart part, [NotNullWhen(true)] out BodyPartSlot? slotId) + public bool RemovePart(SharedBodyPartComponent part, [NotNullWhen(true)] out BodyPartSlot? slotId) { DebugTools.AssertNotNull(part); @@ -279,7 +281,7 @@ namespace Content.Shared.Body.Components return true; } - public bool TryDropPart(BodyPartSlot slot, [NotNullWhen(true)] out Dictionary? dropped) + public bool TryDropPart(BodyPartSlot slot, [NotNullWhen(true)] out Dictionary? dropped) { DebugTools.AssertNotNull(slot); @@ -304,7 +306,7 @@ namespace Content.Shared.Body.Components return true; } - public bool ConnectedToCenter(IBodyPart part) + public bool ConnectedToCenter(SharedBodyPartComponent part) { return TryGetSlot(part, out var result) && ConnectedToCenterPartRecursion(result); @@ -343,7 +345,7 @@ namespace Content.Shared.Body.Components return SlotIds.ContainsKey(slot); } - public IEnumerable GetParts() + public IEnumerable GetParts() { foreach (var slot in SlotIds.Values) { @@ -354,7 +356,7 @@ namespace Content.Shared.Body.Components } } - public bool TryGetPart(string slotId, [NotNullWhen(true)] out IBodyPart? result) + public bool TryGetPart(string slotId, [NotNullWhen(true)] out SharedBodyPartComponent? result) { result = null; @@ -367,7 +369,7 @@ namespace Content.Shared.Body.Components return SlotIds.GetValueOrDefault(id); } - public BodyPartSlot? GetSlot(IBodyPart part) + public BodyPartSlot? GetSlot(SharedBodyPartComponent part) { return SlotParts.GetValueOrDefault(part); } @@ -377,12 +379,12 @@ namespace Content.Shared.Body.Components return (slot = GetSlot(slotId)) != null; } - public bool TryGetSlot(IBodyPart part, [NotNullWhen(true)] out BodyPartSlot? slot) + public bool TryGetSlot(SharedBodyPartComponent part, [NotNullWhen(true)] out BodyPartSlot? slot) { return (slot = GetSlot(part)) != null; } - public bool TryGetPartConnections(string slotId, [NotNullWhen(true)] out List? connections) + public bool TryGetPartConnections(string slotId, [NotNullWhen(true)] out List? connections) { if (!SlotIds.TryGetValue(slotId, out var slot)) { @@ -390,7 +392,7 @@ namespace Content.Shared.Body.Components return false; } - connections = new List(); + connections = new List(); foreach (var connection in slot.Connections) { if (connection.Part != null) @@ -439,7 +441,7 @@ namespace Content.Shared.Body.Components return false; } - public IEnumerable GetPartsOfType(BodyPartType type) + public IEnumerable GetPartsOfType(BodyPartType type) { foreach (var slot in GetSlotsOfType(type)) { @@ -450,7 +452,8 @@ namespace Content.Shared.Body.Components } } - public IEnumerable<(IBodyPart part, IBodyPartProperty property)> GetPartsWithProperty(Type type) + /// A list of parts with that property. + public IEnumerable<(SharedBodyPartComponent part, IBodyPartProperty property)> GetPartsWithProperty(Type type) { foreach (var slot in SlotIds.Values) { @@ -461,7 +464,7 @@ namespace Content.Shared.Body.Components } } - public IEnumerable<(IBodyPart part, T property)> GetPartsWithProperty() where T : class, IBodyPartProperty + public IEnumerable<(SharedBodyPartComponent part, T property)> GetPartsWithProperty() where T : class, IBodyPartProperty { foreach (var part in SlotParts.Keys) { @@ -509,9 +512,6 @@ namespace Content.Shared.Body.Components } } - /// - /// Called when the layout of this body changes. - /// private void OnBodyChanged() { // Calculate move speed based on this body. @@ -523,19 +523,7 @@ namespace Content.Shared.Body.Components Dirty(); } - /// - /// Returns the combined length of the distance to the nearest - /// that is a foot. - /// If you consider a a node map, then it will - /// look for a foot node from the given node. It can only search - /// through s with an - /// . - /// - /// - /// The distance to the foot if found, - /// otherwise. - /// - public float DistanceToNearestFoot(IBodyPart source) + public float DistanceToNearestFoot(SharedBodyPartComponent source) { if (source.PartType == BodyPartType.Foot && source.TryGetProperty(out var extension)) @@ -546,7 +534,7 @@ namespace Content.Shared.Body.Components return LookForFootRecursion(source); } - private float LookForFootRecursion(IBodyPart current, HashSet? searched = null) + private float LookForFootRecursion(SharedBodyPartComponent current, HashSet? searched = null) { searched ??= new HashSet(); @@ -555,13 +543,11 @@ namespace Content.Shared.Body.Components return float.MinValue; } - // Get all connected parts if the current part has an extension property if (!TryGetSlot(current, out var slot)) { return float.MinValue; } - // If a connected BodyPart is a foot, return this BodyPart's length. foreach (var connection in slot.Connections) { if (connection.PartType == BodyPartType.Foot && @@ -571,8 +557,6 @@ namespace Content.Shared.Body.Components } } - // Otherwise, get the recursion values of all connected BodyParts and - // store them in a list. var distances = new List(); foreach (var connection in slot.Connections) { @@ -589,8 +573,6 @@ namespace Content.Shared.Body.Components } } - // If one or more of the searches found a foot, return the smallest one - // and add this ones length. if (distances.Count > 0) { return distances.Min() + extProperty.Distance; @@ -605,7 +587,7 @@ namespace Content.Shared.Body.Components return SlotIds.Values.ElementAt(index); } - public KeyValuePair PartAt(int index) + public KeyValuePair PartAt(int index) { return SlotParts.ElementAt(index); } @@ -664,12 +646,68 @@ namespace Content.Shared.Body.Components part.Gib(); } } + + public bool TryGetMechanismBehaviors([NotNullWhen(true)] out List? behaviors) + { + behaviors = GetMechanismBehaviors().ToList(); + + if (behaviors.Count == 0) + { + behaviors = null; + return false; + } + + return true; + } + + public bool HasMechanismBehavior() where T : SharedMechanismBehavior + { + return Parts.Any(p => p.Key.HasMechanismBehavior()); + } + + // TODO cache these 2 methods jesus + public IEnumerable GetMechanismBehaviors() + { + foreach (var (part, _) in Parts) + foreach (var mechanism in part.Mechanisms) + foreach (var behavior in mechanism.Behaviors.Values) + { + yield return behavior; + } + } + + public IEnumerable GetMechanismBehaviors() where T : SharedMechanismBehavior + { + foreach (var (part, _) in Parts) + foreach (var mechanism in part.Mechanisms) + foreach (var behavior in mechanism.Behaviors.Values) + { + if (behavior is T tBehavior) + { + yield return tBehavior; + } + } + } + + public bool TryGetMechanismBehaviors([NotNullWhen(true)] out List? behaviors) + where T : SharedMechanismBehavior + { + behaviors = GetMechanismBehaviors().ToList(); + + if (behaviors.Count == 0) + { + behaviors = null; + return false; + } + + return true; + } } [Serializable, NetSerializable] public class BodyComponentState : ComponentState { - private Dictionary? _parts; + private Dictionary? _parts; public readonly (string slot, EntityUid partId)[] PartIds; @@ -678,7 +716,7 @@ namespace Content.Shared.Body.Components PartIds = partIds; } - public Dictionary Parts(IEntityManager? entityManager = null) + public Dictionary Parts(IEntityManager? entityManager = null) { if (_parts != null) { @@ -687,7 +725,7 @@ namespace Content.Shared.Body.Components entityManager ??= IoCManager.Resolve(); - var parts = new Dictionary(PartIds.Length); + var parts = new Dictionary(PartIds.Length); foreach (var (slot, partId) in PartIds) { @@ -696,7 +734,7 @@ namespace Content.Shared.Body.Components continue; } - if (!entity.TryGetComponent(out IBodyPart? part)) + if (!entity.TryGetComponent(out SharedBodyPartComponent? part)) { continue; } diff --git a/Content.Shared/Body/Mechanism/IMechanism.cs b/Content.Shared/Body/Mechanism/IMechanism.cs deleted file mode 100644 index 66a8f000e5..0000000000 --- a/Content.Shared/Body/Mechanism/IMechanism.cs +++ /dev/null @@ -1,178 +0,0 @@ -#nullable enable -using System; -using System.Collections.Generic; -using Content.Shared.Body.Behavior; -using Content.Shared.Body.Components; -using Content.Shared.Body.Part; -using Robust.Shared.GameObjects; - -namespace Content.Shared.Body.Mechanism -{ - public interface IMechanism : IComponent - { - /// - /// The body that owns the in which this - /// is in. - /// - IBody? Body { get; } - - /// - /// The part in which this is in. - /// - IBodyPart? Part { get; set; } - - /// - /// The behaviors attached to this - /// mapped by their type. - /// - IReadOnlyDictionary Behaviors { get; } - - /// - /// Max HP of this . - /// - int MaxDurability { get; set; } - - /// - /// Current HP of this . - /// - int CurrentDurability { get; set; } - - /// - /// At what HP this is completely destroyed. - /// - int DestroyThreshold { get; set; } - - /// - /// Armor of this against attacks. - /// - int Resistance { get; set; } - - /// - /// Determines a handful of things - mostly whether this - /// can fit into a . - /// - // TODO BODY OnSizeChanged - int Size { get; set; } - - /// - /// What kind of this - /// can be easily installed into. - /// - BodyPartCompatibility Compatibility { get; set; } - - /// - /// Adds a if this - /// does not have it already. - /// - /// The behavior type to add. - /// - /// True if the behavior already existed, false if it had to be created. - /// - bool EnsureBehavior(out T behavior) where T : IMechanismBehavior, new(); - - /// - /// Checks if this has the specified - /// . - /// - /// - /// The type of to check for. - /// - /// - /// true if it has the , false otherwise. - /// - bool HasBehavior() where T : IMechanismBehavior; - - /// - /// Removes the specified from this - /// if it has it. - /// - /// - /// The type of to remove. - /// - /// true if it was removed, false otherwise. - bool TryRemoveBehavior() where T : IMechanismBehavior; - - /// - /// Runs an update cycle for this . - /// - /// - /// The amount of seconds that passed since the last update. - /// - void Update(float frameTime); - - // TODO BODY Turn these into event listeners so they dont need to be exposed - /// - /// Called when the containing is attached to a - /// . - /// For instance, attaching a head with a brain inside to a body. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The body that this was added to. - /// - void AddedToBody(IBody body); - - /// - /// Called when the parent is - /// added into a that is not attached to a - /// . - /// For instance, adding a brain to a dismembered head. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The part that this was added to. - /// - void AddedToPart(IBodyPart part); - - /// - /// Called when the parent is added to a - /// that is attached to a . - /// For instance, adding a brain to a head that is attached to a body. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The body that this was added to. - /// - /// - /// The part that this was added to. - /// - void AddedToPartInBody(IBody body, IBodyPart part); - - /// - /// Called when the parent is removed from a - /// . - /// For instance, removing a head with a brain inside from a body. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The body that this was removed from. - /// - void RemovedFromBody(IBody old); - - /// - /// Called when the parent is - /// removed from a that is not attached to a - /// . - /// For instance, removing a brain from a dismembered head. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The part that this was removed from. - /// - void RemovedFromPart(IBodyPart old); - - /// - /// Called when the parent is removed from a - /// that is attached to a . - /// For instance, removing a brain from a head that is attached to a body. - /// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE! - /// - /// - /// The body that this was removed from. - /// - /// - /// The part that this was removed from. - /// - void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart); - } -} diff --git a/Content.Shared/Body/Mechanism/MechanismSystem.cs b/Content.Shared/Body/Mechanism/MechanismSystem.cs index 29691228fe..53d7655a66 100644 --- a/Content.Shared/Body/Mechanism/MechanismSystem.cs +++ b/Content.Shared/Body/Mechanism/MechanismSystem.cs @@ -11,7 +11,7 @@ namespace Content.Shared.Body.Mechanism { base.Update(frameTime); - foreach (var mechanism in ComponentManager.EntityQuery(true)) + foreach (var mechanism in ComponentManager.EntityQuery(true)) { mechanism.Update(frameTime); } diff --git a/Content.Shared/Body/Mechanism/SharedMechanismComponent.cs b/Content.Shared/Body/Mechanism/SharedMechanismComponent.cs index edaf42b92d..08d5cab806 100644 --- a/Content.Shared/Body/Mechanism/SharedMechanismComponent.cs +++ b/Content.Shared/Body/Mechanism/SharedMechanismComponent.cs @@ -14,23 +14,23 @@ using Robust.Shared.Utility; namespace Content.Shared.Body.Mechanism { - public abstract class SharedMechanismComponent : Component, IMechanism, ISerializationHooks + public abstract class SharedMechanismComponent : Component, ISerializationHooks { public override string Name => "Mechanism"; protected readonly Dictionary OptionsCache = new(); - protected IBody? BodyCache; + protected SharedBodyComponent? BodyCache; protected int IdHash; protected IEntity? PerformerCache; - private IBodyPart? _part; + private SharedBodyPartComponent? _part; - [DataField("behaviors", serverOnly: true)] private HashSet _behaviorTypes = new(); + [DataField("behaviors", serverOnly: true)] private HashSet _behaviorTypes = new(); - private readonly Dictionary _behaviors = new(); + private readonly Dictionary _behaviors = new(); - public IBody? Body => Part?.Body; + public SharedBodyComponent? Body => Part?.Body; - public IBodyPart? Part + public SharedBodyPartComponent? Part { get => _part; set @@ -69,7 +69,7 @@ namespace Content.Shared.Body.Mechanism } } - public IReadOnlyDictionary Behaviors => _behaviors; + public IReadOnlyDictionary Behaviors => _behaviors; [DataField("maxDurability")] public int MaxDurability { get; set; } = 10; @@ -82,8 +82,16 @@ namespace Content.Shared.Body.Mechanism [DataField("resistance")] public int Resistance { get; set; } = 0; // TODO BODY OnSizeChanged + /// + /// Determines whether this + /// can fit into a . + /// [DataField("size")] public int Size { get; set; } = 1; + /// + /// What kind of this + /// can be easily installed into. + /// [DataField("compatibility")] public BodyPartCompatibility Compatibility { get; set; } = BodyPartCompatibility.Universal; @@ -128,7 +136,7 @@ namespace Content.Shared.Body.Mechanism } } - public bool EnsureBehavior(out T behavior) where T : IMechanismBehavior, new() + public bool EnsureBehavior(out T behavior) where T : SharedMechanismBehavior, new() { if (_behaviors.TryGetValue(typeof(T), out var rawBehavior)) { @@ -144,12 +152,12 @@ namespace Content.Shared.Body.Mechanism return false; } - public bool HasBehavior() where T : IMechanismBehavior + public bool HasBehavior() where T : SharedMechanismBehavior { return _behaviors.ContainsKey(typeof(T)); } - public bool TryRemoveBehavior() where T : IMechanismBehavior + public bool TryRemoveBehavior() where T : SharedMechanismBehavior { return _behaviors.Remove(typeof(T)); } @@ -162,7 +170,8 @@ namespace Content.Shared.Body.Mechanism } } - public void AddedToBody(IBody body) + // TODO BODY Turn these into event listeners so they dont need to be exposed + public void AddedToBody(SharedBodyComponent body) { DebugTools.AssertNotNull(Body); DebugTools.AssertNotNull(body); @@ -173,7 +182,7 @@ namespace Content.Shared.Body.Mechanism } } - public void AddedToPart(IBodyPart part) + public void AddedToPart(SharedBodyPartComponent part) { DebugTools.AssertNotNull(Part); DebugTools.AssertNotNull(part); @@ -186,7 +195,7 @@ namespace Content.Shared.Body.Mechanism } } - public void AddedToPartInBody(IBody body, IBodyPart part) + public void AddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part) { DebugTools.AssertNotNull(Body); DebugTools.AssertNotNull(body); @@ -201,7 +210,7 @@ namespace Content.Shared.Body.Mechanism } } - public void RemovedFromBody(IBody old) + public void RemovedFromBody(SharedBodyComponent old) { DebugTools.AssertNull(Body); DebugTools.AssertNotNull(old); @@ -212,7 +221,7 @@ namespace Content.Shared.Body.Mechanism } } - public void RemovedFromPart(IBodyPart old) + public void RemovedFromPart(SharedBodyPartComponent old) { DebugTools.AssertNull(Part); DebugTools.AssertNotNull(old); @@ -225,7 +234,7 @@ namespace Content.Shared.Body.Mechanism } } - public void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart) + public void RemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart) { DebugTools.AssertNull(Body); DebugTools.AssertNotNull(oldBody); diff --git a/Content.Shared/Body/Part/BodyPartCompatibility.cs b/Content.Shared/Body/Part/BodyPartCompatibility.cs index 9a822c7d75..390bf8c904 100644 --- a/Content.Shared/Body/Part/BodyPartCompatibility.cs +++ b/Content.Shared/Body/Part/BodyPartCompatibility.cs @@ -5,7 +5,7 @@ using Robust.Shared.Serialization; namespace Content.Shared.Body.Part { /// - /// Determines whether two s can connect. + /// Determines whether two s can connect. /// [Serializable, NetSerializable] public enum BodyPartCompatibility diff --git a/Content.Shared/Body/Part/BodyPartExtensions.cs b/Content.Shared/Body/Part/BodyPartExtensions.cs deleted file mode 100644 index 7d9a8ef862..0000000000 --- a/Content.Shared/Body/Part/BodyPartExtensions.cs +++ /dev/null @@ -1,81 +0,0 @@ -#nullable enable -using System; -using System.Diagnostics.CodeAnalysis; -using Content.Shared.Body.Part.Property; - -namespace Content.Shared.Body.Part -{ - public static class BodyPartExtensions - { - /// - /// Checks if the given has the specified property. - /// - /// The to check in. - /// - /// The type of to check for. - /// - /// true if found, false otherwise. - public static bool HasProperty(this IBodyPart part, Type type) - { - return part.Owner.HasComponent(type); - } - - /// - /// Checks if the given has the specified property. - /// - /// The to check in. - /// - /// The type of to check for. - /// - /// true if found, false otherwise. - public static bool HasProperty(this IBodyPart part) where T : class, IBodyPartProperty - { - return part.HasProperty(typeof(T)); - } - - /// - /// Tries to retrieve the with the - /// specified type. - /// - /// The to search in. - /// - /// The type of to search for. - /// - /// - /// The property, if it was found. Null otherwise. - /// - /// - /// true if a component with the specified type was found, false otherwise. - /// - public static bool TryGetProperty(this IBodyPart part, Type type, - [NotNullWhen(true)] out IBodyPartProperty? property) - { - if (!part.Owner.TryGetComponent(type, out var component)) - { - property = null; - return false; - } - - return (property = component as IBodyPartProperty) != null; - } - - /// - /// Tries to retrieve the with the - /// specified type. - /// - /// The to search in. - /// - /// The type of to search for. - /// - /// - /// The property, if it was found. Null otherwise. - /// - /// - /// true if a component with the specified type was found, false otherwise. - /// - public static bool TryGetProperty(this IBodyPart part, [NotNullWhen(true)] out T? property) where T : class, IBodyPartProperty - { - return part.Owner.TryGetComponent(out property); - } - } -} diff --git a/Content.Shared/Body/Part/BodyPartSymmetry.cs b/Content.Shared/Body/Part/BodyPartSymmetry.cs index 0404d338ae..aaf6f958de 100644 --- a/Content.Shared/Body/Part/BodyPartSymmetry.cs +++ b/Content.Shared/Body/Part/BodyPartSymmetry.cs @@ -5,7 +5,7 @@ using Robust.Shared.Serialization; namespace Content.Shared.Body.Part { /// - /// Defines the symmetry of a . + /// Defines the symmetry of a . /// [Serializable, NetSerializable] public enum BodyPartSymmetry diff --git a/Content.Shared/Body/Part/BodyPartType.cs b/Content.Shared/Body/Part/BodyPartType.cs index 9855647493..40c58d0eb4 100644 --- a/Content.Shared/Body/Part/BodyPartType.cs +++ b/Content.Shared/Body/Part/BodyPartType.cs @@ -5,7 +5,7 @@ using Robust.Shared.Serialization; namespace Content.Shared.Body.Part { /// - /// Defines the type of a . + /// Defines the type of a . /// [Serializable, NetSerializable] public enum BodyPartType diff --git a/Content.Shared/Body/Part/IBodyPart.cs b/Content.Shared/Body/Part/IBodyPart.cs deleted file mode 100644 index cbf4e1342e..0000000000 --- a/Content.Shared/Body/Part/IBodyPart.cs +++ /dev/null @@ -1,131 +0,0 @@ -#nullable enable -using System.Collections.Generic; -using Content.Shared.Body.Components; -using Content.Shared.Body.Mechanism; -using Content.Shared.Body.Surgery; -using Robust.Shared.GameObjects; -using Robust.Shared.Map; - -namespace Content.Shared.Body.Part -{ - public interface IBodyPart : IComponent, IBodyPartContainer - { - /// - /// The to which this is - /// attached to. - /// - IBody? Body { get; set; } - - /// - /// The string to show when displaying this part's name to players. - /// - string DisplayName { get; } - - /// - /// that this is considered - /// to be. - /// For example, . - /// - BodyPartType PartType { get; } - - /// - /// Determines how many mechanisms can be fit inside this - /// . - /// - int Size { get; } - - // TODO BODY Mechanisms occupying different parts at the body level - /// - /// Collection of all s currently inside this - /// . - /// To add and remove from this list see and - /// - /// - IReadOnlyCollection Mechanisms { get; } - - /// - /// Whether or not the owning will die if all - /// s of this type are removed from it. - /// - public bool IsVital { get; } - - /// - /// The symmetry of this . - /// - public BodyPartSymmetry Symmetry { get; } - - /// - /// Checks if the given can be used on - /// the current state of this . - /// - /// True if it can be used, false otherwise. - bool SurgeryCheck(SurgeryType surgery); - - /// - /// Attempts to perform surgery on this with the given - /// tool. - /// - /// True if successful, false if there was an error. - public bool AttemptSurgery(SurgeryType toolType, IBodyPartContainer target, ISurgeon surgeon, - IEntity performer); - - /// - /// Checks if another can be connected to this one. - /// - /// The part to connect. - /// True if it can be connected, false otherwise. - bool CanAttachPart(IBodyPart part); - - /// - /// Checks if a can be added on this - /// . - /// - /// True if it can be added, false otherwise. - bool CanAddMechanism(IMechanism mechanism); - - /// - /// Tries to add a to this body. - /// - /// The mechanism to add. - /// - /// Whether or not to check if the mechanism is compatible. - /// Passing true does not guarantee it to be added, for example if - /// it was already added before. - /// - /// true if added, false otherwise even if it was already added. - bool TryAddMechanism(IMechanism mechanism, bool force = false); - - /// - /// Tries to remove the given from this - /// . - /// - /// The mechanism to remove. - /// True if it was removed, false otherwise. - bool RemoveMechanism(IMechanism mechanism); - - /// - /// Tries to remove the given from this - /// and drops it at the specified coordinates. - /// - /// The mechanism to remove. - /// The coordinates to drop it at. - /// True if it was removed, false otherwise. - bool RemoveMechanism(IMechanism mechanism, EntityCoordinates dropAt); - - /// - /// Tries to destroy the given from - /// this . - /// The mechanism won't be deleted if it is not in this body part. - /// - /// - /// True if the mechanism was in this body part and destroyed, - /// false otherwise. - /// - bool DeleteMechanism(IMechanism mechanism); - - /// - /// Gibs the body part. - /// - void Gib(); - } -} diff --git a/Content.Shared/Body/Part/IBodyPartAdded.cs b/Content.Shared/Body/Part/IBodyPartAdded.cs index 42a06c6d53..4f16560c24 100644 --- a/Content.Shared/Body/Part/IBodyPartAdded.cs +++ b/Content.Shared/Body/Part/IBodyPartAdded.cs @@ -11,7 +11,7 @@ namespace Content.Shared.Body.Part public interface IBodyPartAdded : IComponent { /// - /// Called when a is added to the + /// Called when a is added to the /// entity owning this component. /// /// Information about the part that was added. @@ -20,7 +20,7 @@ namespace Content.Shared.Body.Part public class BodyPartAddedEventArgs : EventArgs { - public BodyPartAddedEventArgs(string slot, IBodyPart part) + public BodyPartAddedEventArgs(string slot, SharedBodyPartComponent part) { Slot = slot; Part = part; @@ -34,6 +34,6 @@ namespace Content.Shared.Body.Part /// /// The part that was added. /// - public IBodyPart Part { get; } + public SharedBodyPartComponent Part { get; } } } diff --git a/Content.Shared/Body/Part/IBodyPartRemoved.cs b/Content.Shared/Body/Part/IBodyPartRemoved.cs index 9d9328905b..eeff0b8b7e 100644 --- a/Content.Shared/Body/Part/IBodyPartRemoved.cs +++ b/Content.Shared/Body/Part/IBodyPartRemoved.cs @@ -10,7 +10,7 @@ namespace Content.Shared.Body.Part public interface IBodyPartRemoved { /// - /// Called when a is removed from the + /// Called when a is removed from the /// entity owning this component. /// /// Information about the part that was removed. @@ -19,7 +19,7 @@ namespace Content.Shared.Body.Part public class BodyPartRemovedEventArgs : EventArgs { - public BodyPartRemovedEventArgs(string slot, IBodyPart part) + public BodyPartRemovedEventArgs(string slot, SharedBodyPartComponent part) { Slot = slot; Part = part; @@ -33,6 +33,6 @@ namespace Content.Shared.Body.Part /// /// The part that was removed. /// - public IBodyPart Part { get; } + public SharedBodyPartComponent Part { get; } } } diff --git a/Content.Shared/Body/Part/Property/BodyPartPropertyComponent.cs b/Content.Shared/Body/Part/Property/BodyPartPropertyComponent.cs index 29171369c6..e1f6e5f577 100644 --- a/Content.Shared/Body/Part/Property/BodyPartPropertyComponent.cs +++ b/Content.Shared/Body/Part/Property/BodyPartPropertyComponent.cs @@ -5,10 +5,10 @@ using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Shared.Body.Part.Property { /// - /// Property attachable to a . + /// Property attachable to a . /// For example, this is used to define the speed capabilities of a leg. /// The movement system will look for a on all - /// . + /// . /// public abstract class BodyPartPropertyComponent : Component, IBodyPartProperty { diff --git a/Content.Shared/Body/Part/Property/ExtensionComponent.cs b/Content.Shared/Body/Part/Property/ExtensionComponent.cs index 229ea88831..b613ee830a 100644 --- a/Content.Shared/Body/Part/Property/ExtensionComponent.cs +++ b/Content.Shared/Body/Part/Property/ExtensionComponent.cs @@ -5,7 +5,7 @@ using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Shared.Body.Part.Property { /// - /// Defines the length of a . + /// Defines the length of a . /// [RegisterComponent] public class ExtensionComponent : BodyPartPropertyComponent diff --git a/Content.Shared/Body/Part/Property/GraspComponent.cs b/Content.Shared/Body/Part/Property/GraspComponent.cs index cf6207b68c..6d021d0a6a 100644 --- a/Content.Shared/Body/Part/Property/GraspComponent.cs +++ b/Content.Shared/Body/Part/Property/GraspComponent.cs @@ -4,7 +4,7 @@ using Robust.Shared.GameObjects; namespace Content.Shared.Body.Part.Property { /// - /// Defines a as being able to grasp around an entity, + /// Defines a as being able to grasp around an entity, /// for example picking up an item. /// // TODO BODY Implement diff --git a/Content.Shared/Body/Part/Property/IBodyPartProperty.cs b/Content.Shared/Body/Part/Property/IBodyPartProperty.cs index 599b3ae812..ff3c5ba627 100644 --- a/Content.Shared/Body/Part/Property/IBodyPartProperty.cs +++ b/Content.Shared/Body/Part/Property/IBodyPartProperty.cs @@ -4,7 +4,7 @@ using Robust.Shared.GameObjects; namespace Content.Shared.Body.Part.Property { /// - /// Defines a property for a . + /// Defines a property for a . /// public interface IBodyPartProperty : IComponent { diff --git a/Content.Shared/Body/Part/Property/LegComponent.cs b/Content.Shared/Body/Part/Property/LegComponent.cs index 51033dd93d..1bc75378bd 100644 --- a/Content.Shared/Body/Part/Property/LegComponent.cs +++ b/Content.Shared/Body/Part/Property/LegComponent.cs @@ -5,7 +5,7 @@ using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Shared.Body.Part.Property { /// - /// Defines the speed at which a can move. + /// Defines the speed at which a can move. /// [RegisterComponent] public class LegComponent : BodyPartPropertyComponent diff --git a/Content.Shared/Body/Part/SharedBodyPartComponent.cs b/Content.Shared/Body/Part/SharedBodyPartComponent.cs index e0c72afd55..81a390553c 100644 --- a/Content.Shared/Body/Part/SharedBodyPartComponent.cs +++ b/Content.Shared/Body/Part/SharedBodyPartComponent.cs @@ -1,9 +1,12 @@ #nullable enable using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; +using Content.Shared.Body.Behavior; using Content.Shared.Body.Components; using Content.Shared.Body.Mechanism; +using Content.Shared.Body.Part.Property; using Content.Shared.Body.Surgery; using Content.Shared.NetIDs; using Robust.Shared.GameObjects; @@ -17,24 +20,24 @@ using Robust.Shared.ViewVariables; namespace Content.Shared.Body.Part { - public abstract class SharedBodyPartComponent : Component, IBodyPart + public abstract class SharedBodyPartComponent : Component, IBodyPartContainer { public override string Name => "BodyPart"; public override uint? NetID => ContentNetIDs.BODY_PART; - private IBody? _body; + private SharedBodyComponent? _body; // TODO BODY Remove [DataField("mechanisms")] - private List _mechanismIds = new(); + private readonly List _mechanismIds = new(); public IReadOnlyList MechanismIds => _mechanismIds; [ViewVariables] - private readonly HashSet _mechanisms = new(); + private readonly HashSet _mechanisms = new(); [ViewVariables] - public IBody? Body + public SharedBodyComponent? Body { get => _body; set @@ -59,13 +62,25 @@ namespace Content.Shared.Body.Part } } + /// + /// The string to show when displaying this part's name to players. + /// [ViewVariables] public string DisplayName => Name; + /// + /// that this is considered + /// to be. + /// For example, . + /// [ViewVariables] [DataField("partType")] public BodyPartType PartType { get; private set; } = BodyPartType.Other; + /// + /// Determines how many mechanisms can be fit inside this + /// . + /// [ViewVariables] [DataField("size")] public int Size { get; private set; } = 1; [ViewVariables] public int SizeUsed { get; private set; } @@ -74,7 +89,7 @@ namespace Content.Shared.Body.Part // TODO BODY surgerydata /// - /// What types of BodyParts this can easily attach to. + /// What types of BodyParts this can easily attach to. /// For the most part, most limbs aren't universal and require extra work to /// attach between types. /// @@ -82,17 +97,14 @@ namespace Content.Shared.Body.Part [DataField("compatibility")] public BodyPartCompatibility Compatibility { get; private set; } = BodyPartCompatibility.Universal; - /// - /// Set of all currently inside this - /// . - /// + // TODO BODY Mechanisms occupying different parts at the body level [ViewVariables] - public IReadOnlyCollection Mechanisms => _mechanisms; + public IReadOnlyCollection Mechanisms => _mechanisms; // TODO BODY Replace with a simulation of organs /// - /// Represents if body part is vital for creature. - /// If the last vital body part is removed creature dies + /// Whether or not the owning will die if all + /// s of this type are removed from it. /// [ViewVariables] [DataField("vital")] @@ -105,7 +117,7 @@ namespace Content.Shared.Body.Part [ViewVariables] public ISurgeryData? SurgeryDataComponent => Owner.GetComponentOrNull(); - protected virtual void OnAddMechanism(IMechanism mechanism) + protected virtual void OnAddMechanism(SharedMechanismComponent mechanism) { var prototypeId = mechanism.Owner.Prototype!.ID; @@ -120,7 +132,7 @@ namespace Content.Shared.Body.Part Dirty(); } - protected virtual void OnRemoveMechanism(IMechanism mechanism) + protected virtual void OnRemoveMechanism(SharedMechanismComponent mechanism) { _mechanismIds.Remove(mechanism.Owner.Prototype!.ID); mechanism.Part = null; @@ -176,11 +188,6 @@ namespace Content.Shared.Body.Part return SurgeryDataComponent?.CheckSurgery(surgery) ?? false; } - /// - /// Attempts to perform surgery on this with the given - /// tool. - /// - /// True if successful, false if there was an error. public bool AttemptSurgery(SurgeryType toolType, IBodyPartContainer target, ISurgeon surgeon, IEntity performer) { DebugTools.AssertNotNull(toolType); @@ -191,14 +198,14 @@ namespace Content.Shared.Body.Part return SurgeryDataComponent?.PerformSurgery(toolType, target, surgeon, performer) ?? false; } - public bool CanAttachPart(IBodyPart part) + public bool CanAttachPart(SharedBodyPartComponent part) { DebugTools.AssertNotNull(part); return SurgeryDataComponent?.CanAttachBodyPart(part) ?? false; } - public virtual bool CanAddMechanism(IMechanism mechanism) + public virtual bool CanAddMechanism(SharedMechanismComponent mechanism) { DebugTools.AssertNotNull(mechanism); @@ -208,19 +215,16 @@ namespace Content.Shared.Body.Part } /// - /// Tries to add a mechanism onto this body part. + /// Tries to add a to this part. /// - /// The mechanism to try to add. + /// The mechanism to add. /// - /// Whether or not to check if the mechanism can be added. + /// Whether or not to check if the mechanism is compatible. + /// Passing true does not guarantee it to be added, for example if + /// it was already added before. /// - /// - /// True if successful, false if there was an error - /// (e.g. not enough room in ). - /// Will return false even when forced if the mechanism is already - /// added in this . - /// - public bool TryAddMechanism(IMechanism mechanism, bool force = false) + /// true if added, false otherwise even if it was already added. + public bool TryAddMechanism(SharedMechanismComponent mechanism, bool force = false) { DebugTools.AssertNotNull(mechanism); @@ -239,7 +243,12 @@ namespace Content.Shared.Body.Part return true; } - public bool RemoveMechanism(IMechanism mechanism) + /// + /// Tries to remove the given from this part. + /// + /// The mechanism to remove. + /// True if it was removed, false otherwise. + public bool RemoveMechanism(SharedMechanismComponent mechanism) { DebugTools.AssertNotNull(mechanism); @@ -253,7 +262,14 @@ namespace Content.Shared.Body.Part return true; } - public bool RemoveMechanism(IMechanism mechanism, EntityCoordinates coordinates) + /// + /// Tries to remove the given from this + /// part and drops it at the specified coordinates. + /// + /// The mechanism to remove. + /// The coordinates to drop it at. + /// True if it was removed, false otherwise. + public bool RemoveMechanism(SharedMechanismComponent mechanism, EntityCoordinates coordinates) { if (RemoveMechanism(mechanism)) { @@ -264,7 +280,16 @@ namespace Content.Shared.Body.Part return false; } - public bool DeleteMechanism(IMechanism mechanism) + /// + /// Tries to destroy the given from + /// this part. + /// The mechanism won't be deleted if it is not in this body part. + /// + /// + /// True if the mechanism was in this body part and destroyed, + /// false otherwise. + /// + public bool DeleteMechanism(SharedMechanismComponent mechanism) { DebugTools.AssertNotNull(mechanism); @@ -277,7 +302,7 @@ namespace Content.Shared.Body.Part return true; } - private void AddedToBody(IBody body) + private void AddedToBody(SharedBodyComponent body) { Owner.Transform.LocalRotation = 0; Owner.Transform.AttachParent(body.Owner); @@ -289,7 +314,7 @@ namespace Content.Shared.Body.Part } } - private void RemovedFromBody(IBody old) + private void RemovedFromBody(SharedBodyComponent old) { if (!Owner.Transform.Deleted) { @@ -304,10 +329,13 @@ namespace Content.Shared.Body.Part } } - protected virtual void OnAddedToBody(IBody body) { } + protected virtual void OnAddedToBody(SharedBodyComponent body) { } - protected virtual void OnRemovedFromBody(IBody old) { } + protected virtual void OnRemovedFromBody(SharedBodyComponent old) { } + /// + /// Gibs the body part. + /// public virtual void Gib() { foreach (var mechanism in _mechanisms) @@ -315,12 +343,44 @@ namespace Content.Shared.Body.Part RemoveMechanism(mechanism); } } + + public bool HasProperty(Type type) + { + return Owner.HasComponent(type); + } + + public bool HasProperty() where T : class, IBodyPartProperty + { + return HasProperty(typeof(T)); + } + + public bool TryGetProperty(Type type, + [NotNullWhen(true)] out IBodyPartProperty? property) + { + if (!Owner.TryGetComponent(type, out var component)) + { + property = null; + return false; + } + + return (property = component as IBodyPartProperty) != null; + } + + public bool TryGetProperty([NotNullWhen(true)] out T? property) where T : class, IBodyPartProperty + { + return Owner.TryGetComponent(out property); + } + + public bool HasMechanismBehavior() where T : SharedMechanismBehavior + { + return Mechanisms.Any(m => m.HasBehavior()); + } } [Serializable, NetSerializable] public class BodyPartComponentState : ComponentState { - [NonSerialized] private List? _mechanisms; + [NonSerialized] private List? _mechanisms; public readonly EntityUid[] MechanismIds; @@ -329,7 +389,7 @@ namespace Content.Shared.Body.Part MechanismIds = mechanismIds; } - public List Mechanisms(IEntityManager? entityManager = null) + public List Mechanisms(IEntityManager? entityManager = null) { if (_mechanisms != null) { @@ -338,7 +398,7 @@ namespace Content.Shared.Body.Part entityManager ??= IoCManager.Resolve(); - var mechanisms = new List(MechanismIds.Length); + var mechanisms = new List(MechanismIds.Length); foreach (var id in MechanismIds) { @@ -347,7 +407,7 @@ namespace Content.Shared.Body.Part continue; } - if (!entity.TryGetComponent(out IMechanism? mechanism)) + if (!entity.TryGetComponent(out SharedMechanismComponent? mechanism)) { continue; } diff --git a/Content.Shared/Body/Preset/BodyPresetPrototype.cs b/Content.Shared/Body/Preset/BodyPresetPrototype.cs index 3cb5ef8736..49736b46df 100644 --- a/Content.Shared/Body/Preset/BodyPresetPrototype.cs +++ b/Content.Shared/Body/Preset/BodyPresetPrototype.cs @@ -11,7 +11,7 @@ using Robust.Shared.ViewVariables; namespace Content.Shared.Body.Preset { /// - /// Defines the s used in a . + /// Defines the parts used in a body. /// [Prototype("bodyPreset")] [Serializable, NetSerializable] diff --git a/Content.Shared/Body/Slot/BodyPartSlot.cs b/Content.Shared/Body/Slot/BodyPartSlot.cs index f976fbb2d5..3971c1b0bf 100644 --- a/Content.Shared/Body/Slot/BodyPartSlot.cs +++ b/Content.Shared/Body/Slot/BodyPartSlot.cs @@ -37,7 +37,7 @@ namespace Content.Shared.Body.Slot /// The part currently in this slot, if any. /// [ViewVariables] - public IBodyPart? Part { get; private set; } + public SharedBodyPartComponent? Part { get; private set; } /// /// List of slots that this slot connects to. @@ -45,21 +45,21 @@ namespace Content.Shared.Body.Slot [ViewVariables] public HashSet Connections { get; private set; } - public event Action? PartAdded; + public event Action? PartAdded; - public event Action? PartRemoved; + public event Action? PartRemoved; internal void SetConnectionsInternal(IEnumerable connections) { Connections = new HashSet(connections); } - public bool CanAddPart(IBodyPart part) + public bool CanAddPart(SharedBodyPartComponent part) { return Part == null && part.PartType == PartType; } - public bool TryAddPart(IBodyPart part) + public bool TryAddPart(SharedBodyPartComponent part) { if (!CanAddPart(part)) { @@ -70,7 +70,7 @@ namespace Content.Shared.Body.Slot return true; } - public void SetPart(IBodyPart part) + public void SetPart(SharedBodyPartComponent part) { if (Part != null) { diff --git a/Content.Shared/Body/Surgery/ISurgeon.cs b/Content.Shared/Body/Surgery/ISurgeon.cs index ec73351312..50f77dd281 100644 --- a/Content.Shared/Body/Surgery/ISurgeon.cs +++ b/Content.Shared/Body/Surgery/ISurgeon.cs @@ -12,7 +12,7 @@ namespace Content.Shared.Body.Surgery public interface ISurgeon { public delegate void MechanismRequestCallback( - IMechanism target, + SharedMechanismComponent target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer); @@ -25,10 +25,10 @@ namespace Content.Shared.Body.Surgery /// /// When performing a surgery, the /// may sometimes require selecting from a set of - /// s to operate on. + /// s to operate on. /// This function is called in that scenario, and it is expected that you call - /// the callback with one from the provided list. + /// the callback with one from the provided list. /// - public void RequestMechanism(IEnumerable options, MechanismRequestCallback callback); + public void RequestMechanism(IEnumerable options, MechanismRequestCallback callback); } } diff --git a/Content.Shared/Body/Surgery/SurgeryDataComponent.cs b/Content.Shared/Body/Surgery/SurgeryDataComponent.cs index cc076e05d1..ac4e2faff5 100644 --- a/Content.Shared/Body/Surgery/SurgeryDataComponent.cs +++ b/Content.Shared/Body/Surgery/SurgeryDataComponent.cs @@ -6,21 +6,21 @@ using Robust.Shared.GameObjects; namespace Content.Shared.Body.Surgery { /// - /// Represents the current surgery state of a . + /// Represents the current surgery state of a . /// public interface ISurgeryData : IComponent { public delegate void SurgeryAction(IBodyPartContainer container, ISurgeon surgeon, IEntity performer); /// - /// The this + /// The this /// is attached to. /// - public IBodyPart? Parent { get; } + public SharedBodyPartComponent? Parent { get; } /// /// The of the parent - /// . + /// . /// public BodyPartType? ParentType { get; } @@ -31,18 +31,18 @@ namespace Content.Shared.Body.Surgery public string GetDescription(); /// - /// Returns whether a can be added into the - /// this + /// Returns whether a can be added into the + /// this /// represents. /// - public bool CanAddMechanism(IMechanism mechanism); + public bool CanAddMechanism(SharedMechanismComponent mechanism); /// - /// Returns whether the given can be connected - /// to the this + /// Returns whether the given can be connected + /// to the this /// represents. /// - public bool CanAttachBodyPart(IBodyPart part); + public bool CanAttachBodyPart(SharedBodyPartComponent part); /// /// Gets the delegate corresponding to the surgery step using the given @@ -56,7 +56,7 @@ namespace Content.Shared.Body.Surgery /// /// Returns whether the given can be used to - /// perform a surgery on the this + /// perform a surgery on the this /// represents. /// public bool CheckSurgery(SurgeryType toolType) diff --git a/Content.Shared/Body/Template/BodyTemplatePrototype.cs b/Content.Shared/Body/Template/BodyTemplatePrototype.cs index dff28eee33..324b995c03 100644 --- a/Content.Shared/Body/Template/BodyTemplatePrototype.cs +++ b/Content.Shared/Body/Template/BodyTemplatePrototype.cs @@ -11,7 +11,7 @@ using Robust.Shared.ViewVariables; namespace Content.Shared.Body.Template { /// - /// Defines the layout of a . + /// Defines the layout of a body. /// [Prototype("bodyTemplate")] [Serializable, NetSerializable] diff --git a/Content.Shared/CharacterAppearance/HumanoidVisualLayersExtension.cs b/Content.Shared/CharacterAppearance/HumanoidVisualLayersExtension.cs index 3ebba4e824..bec83f47df 100644 --- a/Content.Shared/CharacterAppearance/HumanoidVisualLayersExtension.cs +++ b/Content.Shared/CharacterAppearance/HumanoidVisualLayersExtension.cs @@ -5,7 +5,7 @@ namespace Content.Shared.CharacterAppearance { public static class HumanoidVisualLayersExtension { - public static HumanoidVisualLayers? ToHumanoidLayer(this IBodyPart part) + public static HumanoidVisualLayers? ToHumanoidLayer(this SharedBodyPartComponent part) { return part.PartType switch { diff --git a/Content.Shared/Damage/DamageChangeParams.cs b/Content.Shared/Damage/DamageChangeParams.cs index 4bc7f0a3da..be802b8466 100644 --- a/Content.Shared/Damage/DamageChangeParams.cs +++ b/Content.Shared/Damage/DamageChangeParams.cs @@ -12,6 +12,7 @@ namespace Content.Shared.Damage /// may require it for extra data /// (such as selecting which limb to target). /// + // TODO BODY: Remove and pretend it never existed public class DamageChangeParams : EventArgs { } diff --git a/Content.Shared/Disposal/Components/SharedDisposalUnitComponent.cs b/Content.Shared/Disposal/Components/SharedDisposalUnitComponent.cs index d4263c3f24..5521b6b873 100644 --- a/Content.Shared/Disposal/Components/SharedDisposalUnitComponent.cs +++ b/Content.Shared/Disposal/Components/SharedDisposalUnitComponent.cs @@ -131,7 +131,7 @@ namespace Content.Shared.Disposal.Components // TODO: Probably just need a disposable tag. if (!entity.TryGetComponent(out SharedItemComponent? storable) && - !entity.HasComponent()) + !entity.HasComponent()) { return false; } diff --git a/Content.Shared/MedicalScanner/SharedMedicalScannerComponent.cs b/Content.Shared/MedicalScanner/SharedMedicalScannerComponent.cs index 77d05f7a62..c2b24308d1 100644 --- a/Content.Shared/MedicalScanner/SharedMedicalScannerComponent.cs +++ b/Content.Shared/MedicalScanner/SharedMedicalScannerComponent.cs @@ -82,7 +82,7 @@ namespace Content.Shared.MedicalScanner bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs) { - return eventArgs.Dragged.HasComponent(); + return eventArgs.Dragged.HasComponent(); } public abstract bool DragDropOn(DragDropEvent eventArgs);