Skip to content

Commit

Permalink
bodypart refactor (#2718)
Browse files Browse the repository at this point in the history
* automatically pick body part appearance from species

* automatically pick body part appearance from species when attaching

* make setting organs and children on parts yml work

* giant body part refactor

* refactor deltav species body parts

* ???

* ???

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
  • Loading branch information
deltanedas authored Jan 18, 2025
1 parent e66d9e9 commit 71932a3
Show file tree
Hide file tree
Showing 26 changed files with 590 additions and 1,409 deletions.
4 changes: 4 additions & 0 deletions Content.Shared/Body/Systems/SharedBodySystem.Organs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ private void RemoveOrgan(Entity<OrganComponent> organEnt, EntityUid parentPartUi
return null;

Containers.EnsureContainer<ContainerSlot>(parentEnt, GetOrganContainerId(slotId));
// Shitmed Change: Don't throw when a slot already exists
if (parentEnt.Comp.Organs.TryGetValue(slotId, out var existing))
return existing;

var slot = new OrganSlot(slotId);
parentEnt.Comp.Organs.Add(slotId, slot);
return slot;
Expand Down
9 changes: 9 additions & 0 deletions Content.Shared/Body/Systems/SharedBodySystem.Parts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ private void OnMapInit(Entity<BodyPartComponent> ent, ref MapInitEvent args)
{
Containers.EnsureContainer<ContainerSlot>(ent, GetPartSlotContainerId(connection));
}

foreach (var organ in ent.Comp.Organs.Keys)
{
Containers.EnsureContainer<ContainerSlot>(ent, GetOrganContainerId(organ));
}
}

private void OnBodyPartRemove(Entity<BodyPartComponent> ent, ref ComponentRemove args)
Expand Down Expand Up @@ -465,6 +470,10 @@ public bool TryGetParentBodyPart(
return null;

Containers.EnsureContainer<ContainerSlot>(partUid, GetPartSlotContainerId(slotId));
// Shitmed Change: Don't throw if the slot already exists
if (part.Children.TryGetValue(slotId, out var existing))
return existing;

var partSlot = new BodyPartSlot(slotId, partType);
part.Children.Add(slotId, partSlot);
Dirty(partUid, part);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Humanoid.Markings;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared._Shitmed.Body.Part;

Expand All @@ -23,10 +23,9 @@ public sealed partial class BodyPartAppearanceComponent : Component

/// <summary>
/// ID of this custom base layer. Must be a <see cref="HumanoidSpeciesSpriteLayer"/>.
/// I don't actually know if these serializer props are necessary. I just lifted this from MS14 lol.
/// </summary>
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<HumanoidSpeciesSpriteLayer>)), AutoNetworkedField]
public string? ID { get; set; }
[DataField, AutoNetworkedField]
public ProtoId<HumanoidSpeciesSpriteLayer>? ID { get; set; }

/// <summary>
/// Color of this custom base layer. Null implies skin colour if the corresponding <see cref="HumanoidSpeciesSpriteLayer"/> is set to match skin.
Expand Down
65 changes: 21 additions & 44 deletions Resources/Prototypes/Body/Parts/animal.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,76 @@
# Shitmed Change: This file was mostly reorganized by shitmed to use composition

# Just copypasta of some human basic body parts for interaction,
# only differences for now is that limbs work in pairs,
# they are unextractable and can't be spawned (no surgery on Animals!?).

- type: entity
id: PartAnimal
parent: BaseItem
name: "animal body part"
abstract: true
parent: BasePart
id: PartAnimalBase
components:
# yes these sprites dont make sense i dont care its better than them being invisible
- type: Sprite
sprite: Mobs/Species/Reptilian/parts.rsi
- type: Damageable
damageContainer: OrganicPart # Shitmed
- type: BodyPart
- type: ContainerContainer
containers:
bodypart: !type:Container
ents: []
- type: Icon
sprite: Mobs/Species/Reptilian/parts.rsi
- type: StaticPrice
price: 50
- type: Tag
tags:
- Trash
- type: Gibbable
- type: Extractable
juiceSolution:
reagents:
- ReagentId: Fat
Quantity: 3
- ReagentId: Blood
Quantity: 10

- type: entity
parent: PartAnimalBase
id: HandsAnimal
name: animal hands
parent: PartAnimal
categories: [ HideSpawnMenu ]
components:
- type: Sprite
layers:
- state: l_hand
- state: r_hand
- type: Icon
state: l_hand # cba to make a state for it
- type: BodyPart
partType: Hand
#symmetry: Left
slotId: hands # Shitmed

- type: entity
parent: PartAnimalBase
id: LegsAnimal
name: animal legs
parent: PartAnimal
categories: [ HideSpawnMenu ]
components:
- type: Sprite
layers:
- state: l_leg
- state: r_leg
- type: Icon
state: l_leg # cba to make a state for it
- type: BodyPart
partType: Leg
slotId: legs # Shitmed
- type: MovementBodyPart

- type: entity
parent: PartAnimalBase
id: FeetAnimal
name: animal feet
parent: PartAnimal
categories: [ HideSpawnMenu ]
components:
- type: Sprite
layers:
- state: r_foot
- state: l_foot
- type: Icon
state: l_foot # cba to make a state for it
- type: BodyPart
partType: Foot
slotId: feet # Shitmed

- type: entity
parent: [ PartAnimalBase, BaseTorso ]
id: TorsoAnimal
name: animal torso
parent: PartAnimal
categories: [ HideSpawnMenu ]
components:
- type: Sprite
layers:
- state: torso_m
- type: BodyPart
partType: Torso
- type: Damageable
damageContainer: Biological
- type: Extractable
juiceSolution:
reagents:
- ReagentId: Fat
Quantity: 10
- ReagentId: Blood
Quantity: 20

# standard organs are good for most animals
children: # most animals have no hands (primate is unused) so just legs by default
legs:
id: legs
type: Leg
2 changes: 2 additions & 0 deletions Resources/Prototypes/Body/Parts/arachnid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
name: "arachnid body part"
abstract: true
components:
- type: BodyPart # Shitmed Change
species: Arachnid
- type: Extractable
juiceSolution:
reagents:
Expand Down
Loading

0 comments on commit 71932a3

Please sign in to comment.