From 1c58b6efc7df8b09f356a885886beef0bb0df7eb Mon Sep 17 00:00:00 2001 From: poklj Date: Wed, 25 Jun 2025 16:50:47 -0300 Subject: [PATCH] Fixup Sericulture to be clonable (#38516) * Add CloningEvent and an action entity prototype * Remove redundant action prototype from Yaml * Add a field that might be changed * CR * CR - guard statement and Dirty --- .../Sericulture/SericultureComponent.cs | 4 ++-- Content.Shared/Sericulture/SericultureSystem.cs | 16 ++++++++++++++++ .../Entities/Mobs/Species/arachnid.yml | 1 - 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Content.Shared/Sericulture/SericultureComponent.cs b/Content.Shared/Sericulture/SericultureComponent.cs index e0cc2b7d91..a07e96a34c 100644 --- a/Content.Shared/Sericulture/SericultureComponent.cs +++ b/Content.Shared/Sericulture/SericultureComponent.cs @@ -31,10 +31,10 @@ public sealed partial class SericultureComponent : Component /// /// The entity needed to actually preform sericulture. This will be granted (and removed) upon the entity's creation. /// - [DataField(required: true)] + [DataField] [ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] - public EntProtoId Action; + public EntProtoId Action = "ActionSericulture"; [AutoNetworkedField] [DataField("actionEntity")] diff --git a/Content.Shared/Sericulture/SericultureSystem.cs b/Content.Shared/Sericulture/SericultureSystem.cs index 8c10d0f3d0..e5942a433e 100644 --- a/Content.Shared/Sericulture/SericultureSystem.cs +++ b/Content.Shared/Sericulture/SericultureSystem.cs @@ -1,4 +1,5 @@ using Content.Shared.Actions; +using Content.Shared.Cloning.Events; using Content.Shared.DoAfter; using Content.Shared.Nutrition.EntitySystems; using Robust.Shared.Serialization; @@ -32,6 +33,21 @@ public abstract partial class SharedSericultureSystem : EntitySystem SubscribeLocalEvent(OnCompRemove); SubscribeLocalEvent(OnSericultureStart); SubscribeLocalEvent(OnSericultureDoAfter); + SubscribeLocalEvent(OnClone); + } + + private void OnClone(Entity ent, ref CloningEvent args) + { + if(!args.Settings.EventComponents.Contains(Factory.GetRegistration(ent.Comp.GetType()).Name)) + return; + + var comp = EnsureComp(args.CloneUid); + comp.PopupText = ent.Comp.PopupText; + comp.ProductionLength = ent.Comp.ProductionLength; + comp.HungerCost = ent.Comp.HungerCost; + comp.EntityProduced = ent.Comp.EntityProduced; + comp.MinHungerThreshold = ent.Comp.MinHungerThreshold; + Dirty(args.CloneUid, comp); } /// diff --git a/Resources/Prototypes/Entities/Mobs/Species/arachnid.yml b/Resources/Prototypes/Entities/Mobs/Species/arachnid.yml index a93b8e802e..110e6513da 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/arachnid.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/arachnid.yml @@ -13,7 +13,6 @@ - type: Hunger - type: Thirst - type: Sericulture - action: ActionSericulture productionLength: 2 entityProduced: MaterialWebSilk1 hungerCost: 4 # Should total to 25 total silk on full hunger -- 2.51.2