Skip to content

Commit

Permalink
The hills are green
Browse files Browse the repository at this point in the history
  • Loading branch information
gluesniffler committed Nov 17, 2024
1 parent 5eeac51 commit 4dc858b
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Content.Shared/Body/Systems/SharedBodySystem.Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ public virtual HashSet<EntityUid> 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);
}
Expand Down
12 changes: 12 additions & 0 deletions Content.Shared/Body/Systems/SharedBodySystem.Parts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,18 @@ public bool AttachPartToRoot(
&& Containers.Insert(partId, body.RootContainer);
}

/// <summary>
/// Returns true if this parentId supports attaching a new part to the specified slot.
/// </summary>
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ namespace Content.Shared.Medical.Surgery.Conditions;
[RegisterComponent, NetworkedComponent]
public sealed partial class SurgeryPartRemovedConditionComponent : Component
{
/// <summary>
/// Requires that the parent part can attach a new part to this slot.
/// </summary>
[DataField(required: true)]
public string Connection = string.Empty;

[DataField]
public BodyPartType Part;

[DataField]
public BodyPartSymmetry? Symmetry;
}
}
6 changes: 6 additions & 0 deletions Content.Shared/Medical/Surgery/SharedSurgerySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ private void OnOrganConditionValid(Entity<SurgeryOrganConditionComponent> ent, r

private void OnPartRemovedConditionValid(Entity<SurgeryPartRemovedConditionComponent> 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;
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/arachnid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- left arm
- right leg
- left leg
- head
right arm:
part: RightArmArachnid
connections:
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- left arm
- right leg
- left leg
- head
organs:
stomach: OrganDionaStomachNymph
lungs: OrganDionaLungsNymph
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/dwarf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- left arm
- right leg
- left leg
- head
organs:
heart: OrganDwarfHeart
lungs: OrganHumanLungs
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/gingerbread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- left arm
- right leg
- left leg
- head
organs:
heart: OrganHumanHeart
lungs: OrganHumanLungs
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/human.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- left arm
- right leg
- left leg
- head
organs:
heart: OrganHumanHeart
lungs: OrganHumanLungs
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/ipc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- right arm
- left leg
- right leg
- head
organs:
brain: PositronicBrain
heart: OrganIPCPump
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/moth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- left arm
- right leg
- left leg
- head
right arm:
part: RightArmMoth
connections:
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/primate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
connections:
- hands
- legs
- head
organs:
lungs: OrganAnimalLungs
stomach: OrganAnimalStomach
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/reptilian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- left arm
- right leg
- left leg
- head
right arm:
part: RightArmReptilian
connections:
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Body/Prototypes/shadowkin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- right arm
- left leg
- right leg
- head
organs:
heart: OrganShadowkinHeart
stomach: OrganShadowkinStomach
Expand Down Expand Up @@ -45,4 +46,4 @@
right foot:
part: RightFootShadowkin
left foot:
part: LeftFootShadowkin
part: LeftFootShadowkin
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/skeleton.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- left arm
- right leg
- left leg
- head
right arm:
part: RightArmSkeleton
connections:
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/slime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- left arm
- right leg
- left leg
- head
organs:
core: SentientSlimeCore
lungs: OrganSlimeLungs
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Body/Prototypes/vox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- left arm
- right leg
- left leg
- head
organs:
heart: OrganHumanHeart
lungs: OrganVoxLungs
Expand Down
65 changes: 65 additions & 0 deletions Resources/Prototypes/Entities/Surgery/surgeries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
- type: SurgeryPartCondition
part: Torso
- type: SurgeryPartRemovedCondition
connection: head
part: Head

- type: entity
Expand All @@ -92,6 +93,7 @@
- type: SurgeryPartCondition
part: Torso
- type: SurgeryPartRemovedCondition
connection: left arm
part: Arm
symmetry: Left

Expand All @@ -109,6 +111,7 @@
- type: SurgeryPartCondition
part: Torso
- type: SurgeryPartRemovedCondition
connection: right arm
part: Arm
symmetry: Right

Expand All @@ -126,6 +129,7 @@
- type: SurgeryPartCondition
part: Torso
- type: SurgeryPartRemovedCondition
connection: left leg
part: Leg
symmetry: Left

Expand All @@ -143,6 +147,7 @@
- type: SurgeryPartCondition
part: Torso
- type: SurgeryPartRemovedCondition
connection: right leg
part: Leg
symmetry: Right

Expand All @@ -161,6 +166,7 @@
part: Arm
symmetry: Left
- type: SurgeryPartRemovedCondition
connection: left hand
part: Hand
symmetry: Left

Expand All @@ -179,6 +185,7 @@
part: Arm
symmetry: Right
- type: SurgeryPartRemovedCondition
connection: right hand
part: Hand
symmetry: Right

Expand All @@ -197,6 +204,7 @@
part: Leg
symmetry: Left
- type: SurgeryPartRemovedCondition
connection: left foot
part: Foot
symmetry: Left

Expand All @@ -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
Expand Down

0 comments on commit 4dc858b

Please sign in to comment.