From 4dc858b3f1d98c7e561da978c6ddfa0dd645d88e Mon Sep 17 00:00:00 2001 From: gluesniffler Date: Sun, 17 Nov 2024 16:12:21 -0400 Subject: [PATCH] The hills are green --- .../Body/Systems/SharedBodySystem.Body.cs | 2 + .../Body/Systems/SharedBodySystem.Parts.cs | 12 ++++ .../SurgeryPartRemovedConditionComponent.cs | 8 ++- .../Medical/Surgery/SharedSurgerySystem.cs | 6 ++ .../Prototypes/Body/Prototypes/arachnid.yml | 1 + .../Prototypes/Body/Prototypes/diona.yml | 1 + .../Prototypes/Body/Prototypes/dwarf.yml | 1 + .../Body/Prototypes/gingerbread.yml | 1 + .../Prototypes/Body/Prototypes/human.yml | 1 + Resources/Prototypes/Body/Prototypes/ipc.yml | 1 + Resources/Prototypes/Body/Prototypes/moth.yml | 1 + .../Prototypes/Body/Prototypes/primate.yml | 1 + .../Prototypes/Body/Prototypes/reptilian.yml | 1 + .../Prototypes/Body/Prototypes/shadowkin.yml | 3 +- .../Prototypes/Body/Prototypes/skeleton.yml | 1 + .../Prototypes/Body/Prototypes/slime.yml | 1 + Resources/Prototypes/Body/Prototypes/vox.yml | 1 + .../Prototypes/Entities/Surgery/surgeries.yml | 65 +++++++++++++++++++ 18 files changed, 106 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs index 9dbe3936e76..9e2ed6eb84d 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs @@ -383,6 +383,8 @@ public virtual HashSet GibPart( ref gibs, playAudio: false, launchImpulse: GibletLaunchImpulse * splatModifier, launchImpulseVariance: GibletLaunchImpulseVariance, launchCone: splatCone); } + var enableEvent = new BodyPartEnableChangedEvent(false); + RaiseLocalEvent(partId, ref enableEvent); var ev = new BodyPartDroppedEvent((partId, part)); RaiseLocalEvent(bodyEnt, ref ev); } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs index be03fa6f404..37f889dea29 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs @@ -566,6 +566,18 @@ public bool AttachPartToRoot( && Containers.Insert(partId, body.RootContainer); } + /// + /// Returns true if this parentId supports attaching a new part to the specified slot. + /// + public bool CanAttachToSlot( + EntityUid parentId, + string slotId, + BodyPartComponent? parentPart = null) + { + return Resolve(parentId, ref parentPart, logMissing: false) + && parentPart.Children.ContainsKey(slotId); + } + #endregion #region Attach/Detach diff --git a/Content.Shared/Medical/Surgery/Conditions/SurgeryPartRemovedConditionComponent.cs b/Content.Shared/Medical/Surgery/Conditions/SurgeryPartRemovedConditionComponent.cs index fb51ab5b060..1ad5025480b 100644 --- a/Content.Shared/Medical/Surgery/Conditions/SurgeryPartRemovedConditionComponent.cs +++ b/Content.Shared/Medical/Surgery/Conditions/SurgeryPartRemovedConditionComponent.cs @@ -6,9 +6,15 @@ namespace Content.Shared.Medical.Surgery.Conditions; [RegisterComponent, NetworkedComponent] public sealed partial class SurgeryPartRemovedConditionComponent : Component { + /// + /// Requires that the parent part can attach a new part to this slot. + /// + [DataField(required: true)] + public string Connection = string.Empty; + [DataField] public BodyPartType Part; [DataField] public BodyPartSymmetry? Symmetry; -} \ No newline at end of file +} diff --git a/Content.Shared/Medical/Surgery/SharedSurgerySystem.cs b/Content.Shared/Medical/Surgery/SharedSurgerySystem.cs index d7b049b0245..7fa0f94525e 100644 --- a/Content.Shared/Medical/Surgery/SharedSurgerySystem.cs +++ b/Content.Shared/Medical/Surgery/SharedSurgerySystem.cs @@ -171,6 +171,12 @@ private void OnOrganConditionValid(Entity ent, r private void OnPartRemovedConditionValid(Entity ent, ref SurgeryValidEvent args) { + if (!_body.CanAttachToSlot(args.Part, ent.Comp.Connection)) + { + args.Cancelled = true; + return; + } + var results = _body.GetBodyChildrenOfType(args.Body, ent.Comp.Part, symmetry: ent.Comp.Symmetry); if (results is not { } || !results.Any()) return; diff --git a/Resources/Prototypes/Body/Prototypes/arachnid.yml b/Resources/Prototypes/Body/Prototypes/arachnid.yml index 97af67933cb..880b5add037 100644 --- a/Resources/Prototypes/Body/Prototypes/arachnid.yml +++ b/Resources/Prototypes/Body/Prototypes/arachnid.yml @@ -23,6 +23,7 @@ - left arm - right leg - left leg + - head right arm: part: RightArmArachnid connections: diff --git a/Resources/Prototypes/Body/Prototypes/diona.yml b/Resources/Prototypes/Body/Prototypes/diona.yml index 12ca203988c..33a65bdc5c3 100644 --- a/Resources/Prototypes/Body/Prototypes/diona.yml +++ b/Resources/Prototypes/Body/Prototypes/diona.yml @@ -16,6 +16,7 @@ - left arm - right leg - left leg + - head organs: stomach: OrganDionaStomachNymph lungs: OrganDionaLungsNymph diff --git a/Resources/Prototypes/Body/Prototypes/dwarf.yml b/Resources/Prototypes/Body/Prototypes/dwarf.yml index 592492688b7..fb5a1753ae4 100644 --- a/Resources/Prototypes/Body/Prototypes/dwarf.yml +++ b/Resources/Prototypes/Body/Prototypes/dwarf.yml @@ -17,6 +17,7 @@ - left arm - right leg - left leg + - head organs: heart: OrganDwarfHeart lungs: OrganHumanLungs diff --git a/Resources/Prototypes/Body/Prototypes/gingerbread.yml b/Resources/Prototypes/Body/Prototypes/gingerbread.yml index d5355be6412..d7a5d7bc1c4 100644 --- a/Resources/Prototypes/Body/Prototypes/gingerbread.yml +++ b/Resources/Prototypes/Body/Prototypes/gingerbread.yml @@ -17,6 +17,7 @@ - left arm - right leg - left leg + - head organs: heart: OrganHumanHeart lungs: OrganHumanLungs diff --git a/Resources/Prototypes/Body/Prototypes/human.yml b/Resources/Prototypes/Body/Prototypes/human.yml index 7a0f3bb5a7b..b46e5049bbd 100644 --- a/Resources/Prototypes/Body/Prototypes/human.yml +++ b/Resources/Prototypes/Body/Prototypes/human.yml @@ -17,6 +17,7 @@ - left arm - right leg - left leg + - head organs: heart: OrganHumanHeart lungs: OrganHumanLungs diff --git a/Resources/Prototypes/Body/Prototypes/ipc.yml b/Resources/Prototypes/Body/Prototypes/ipc.yml index 8c42c351381..1927362df5d 100644 --- a/Resources/Prototypes/Body/Prototypes/ipc.yml +++ b/Resources/Prototypes/Body/Prototypes/ipc.yml @@ -16,6 +16,7 @@ - right arm - left leg - right leg + - head organs: brain: PositronicBrain heart: OrganIPCPump diff --git a/Resources/Prototypes/Body/Prototypes/moth.yml b/Resources/Prototypes/Body/Prototypes/moth.yml index 7ebeda7fefa..5cf63a1499a 100644 --- a/Resources/Prototypes/Body/Prototypes/moth.yml +++ b/Resources/Prototypes/Body/Prototypes/moth.yml @@ -23,6 +23,7 @@ - left arm - right leg - left leg + - head right arm: part: RightArmMoth connections: diff --git a/Resources/Prototypes/Body/Prototypes/primate.yml b/Resources/Prototypes/Body/Prototypes/primate.yml index bfeb90d8ed5..4e73003b672 100644 --- a/Resources/Prototypes/Body/Prototypes/primate.yml +++ b/Resources/Prototypes/Body/Prototypes/primate.yml @@ -15,6 +15,7 @@ connections: - hands - legs + - head organs: lungs: OrganAnimalLungs stomach: OrganAnimalStomach diff --git a/Resources/Prototypes/Body/Prototypes/reptilian.yml b/Resources/Prototypes/Body/Prototypes/reptilian.yml index 1e9ebd54a48..97f9956b770 100644 --- a/Resources/Prototypes/Body/Prototypes/reptilian.yml +++ b/Resources/Prototypes/Body/Prototypes/reptilian.yml @@ -23,6 +23,7 @@ - left arm - right leg - left leg + - head right arm: part: RightArmReptilian connections: diff --git a/Resources/Prototypes/Body/Prototypes/shadowkin.yml b/Resources/Prototypes/Body/Prototypes/shadowkin.yml index dddad7bdb5d..840b110d3e2 100644 --- a/Resources/Prototypes/Body/Prototypes/shadowkin.yml +++ b/Resources/Prototypes/Body/Prototypes/shadowkin.yml @@ -17,6 +17,7 @@ - right arm - left leg - right leg + - head organs: heart: OrganShadowkinHeart stomach: OrganShadowkinStomach @@ -45,4 +46,4 @@ right foot: part: RightFootShadowkin left foot: - part: LeftFootShadowkin \ No newline at end of file + part: LeftFootShadowkin diff --git a/Resources/Prototypes/Body/Prototypes/skeleton.yml b/Resources/Prototypes/Body/Prototypes/skeleton.yml index 16d08365610..998d01cc499 100644 --- a/Resources/Prototypes/Body/Prototypes/skeleton.yml +++ b/Resources/Prototypes/Body/Prototypes/skeleton.yml @@ -14,6 +14,7 @@ - left arm - right leg - left leg + - head right arm: part: RightArmSkeleton connections: diff --git a/Resources/Prototypes/Body/Prototypes/slime.yml b/Resources/Prototypes/Body/Prototypes/slime.yml index b57c5eceb44..df246bb0d23 100644 --- a/Resources/Prototypes/Body/Prototypes/slime.yml +++ b/Resources/Prototypes/Body/Prototypes/slime.yml @@ -14,6 +14,7 @@ - left arm - right leg - left leg + - head organs: core: SentientSlimeCore lungs: OrganSlimeLungs diff --git a/Resources/Prototypes/Body/Prototypes/vox.yml b/Resources/Prototypes/Body/Prototypes/vox.yml index 2a1f6d9dca7..42cbb7e0855 100644 --- a/Resources/Prototypes/Body/Prototypes/vox.yml +++ b/Resources/Prototypes/Body/Prototypes/vox.yml @@ -17,6 +17,7 @@ - left arm - right leg - left leg + - head organs: heart: OrganHumanHeart lungs: OrganVoxLungs diff --git a/Resources/Prototypes/Entities/Surgery/surgeries.yml b/Resources/Prototypes/Entities/Surgery/surgeries.yml index ef2ef688324..43d8adfd6ed 100644 --- a/Resources/Prototypes/Entities/Surgery/surgeries.yml +++ b/Resources/Prototypes/Entities/Surgery/surgeries.yml @@ -76,6 +76,7 @@ - type: SurgeryPartCondition part: Torso - type: SurgeryPartRemovedCondition + connection: head part: Head - type: entity @@ -92,6 +93,7 @@ - type: SurgeryPartCondition part: Torso - type: SurgeryPartRemovedCondition + connection: left arm part: Arm symmetry: Left @@ -109,6 +111,7 @@ - type: SurgeryPartCondition part: Torso - type: SurgeryPartRemovedCondition + connection: right arm part: Arm symmetry: Right @@ -126,6 +129,7 @@ - type: SurgeryPartCondition part: Torso - type: SurgeryPartRemovedCondition + connection: left leg part: Leg symmetry: Left @@ -143,6 +147,7 @@ - type: SurgeryPartCondition part: Torso - type: SurgeryPartRemovedCondition + connection: right leg part: Leg symmetry: Right @@ -161,6 +166,7 @@ part: Arm symmetry: Left - type: SurgeryPartRemovedCondition + connection: left hand part: Hand symmetry: Left @@ -179,6 +185,7 @@ part: Arm symmetry: Right - type: SurgeryPartRemovedCondition + connection: right hand part: Hand symmetry: Right @@ -197,6 +204,7 @@ part: Leg symmetry: Left - type: SurgeryPartRemovedCondition + connection: left foot part: Foot symmetry: Left @@ -215,9 +223,66 @@ part: Leg symmetry: Right - type: SurgeryPartRemovedCondition + connection: right foot part: Foot symmetry: Right +# Surgery for animals - They have a single legs/hands entity. + +- type: entity + parent: SurgeryBase + id: SurgeryAttachLegs + name: Attach Legs + categories: [ HideSpawnMenu ] + components: + - type: Surgery + requirement: SurgeryOpenIncision + steps: + - SurgeryStepInsertFeature + - SurgeryStepSealWounds + - type: SurgeryPartCondition + part: Torso + - type: SurgeryPartRemovedCondition + connection: legs + part: Leg + symmetry: None + +- type: entity + parent: SurgeryBase + id: SurgeryAttachHands + name: Attach Hands + categories: [ HideSpawnMenu ] + components: + - type: Surgery + requirement: SurgeryOpenIncision + steps: + - SurgeryStepInsertFeature + - SurgeryStepSealWounds + - type: SurgeryPartCondition + part: Torso + - type: SurgeryPartRemovedCondition + connection: hands + part: Hand + symmetry: Left # shitcode i guess because of ui icons + +- type: entity + parent: SurgeryBase + id: SurgeryAttachFeet + name: Attach Feet + categories: [ HideSpawnMenu ] + components: + - type: Surgery + requirement: SurgeryOpenIncision + steps: + - SurgeryStepInsertFeature + - SurgeryStepSealWounds + - type: SurgeryPartCondition + part: Torso + - type: SurgeryPartRemovedCondition + connection: feet + part: Foot + symmetry: None + #- type: entity # parent: SurgeryBase # id: SurgeryAlienEmbryoRemoval