]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixup Sericulture to be clonable (#38516)
authorpoklj <compgeek223@gmail.com>
Wed, 25 Jun 2025 19:50:47 +0000 (16:50 -0300)
committerGitHub <noreply@github.com>
Wed, 25 Jun 2025 19:50:47 +0000 (21:50 +0200)
* 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

Content.Shared/Sericulture/SericultureComponent.cs
Content.Shared/Sericulture/SericultureSystem.cs
Resources/Prototypes/Entities/Mobs/Species/arachnid.yml

index e0cc2b7d917470f59ab8a9153075da8c4b1a5e37..a07e96a34cf4e86c54997dedef874d3f573c2d99 100644 (file)
@@ -31,10 +31,10 @@ public sealed partial class SericultureComponent : Component
     /// <summary>
     /// The entity needed to actually preform sericulture. This will be granted (and removed) upon the entity's creation.
     /// </summary>
-    [DataField(required: true)]
+    [DataField]
     [ViewVariables(VVAccess.ReadWrite)]
     [AutoNetworkedField]
-    public EntProtoId Action;
+    public EntProtoId Action = "ActionSericulture";
 
     [AutoNetworkedField]
     [DataField("actionEntity")]
index 8c10d0f3d05074aad2d650590d9df94a37dab435..e5942a433e0b9400038a101bbd2a17b0fa6ed44f 100644 (file)
@@ -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<SericultureComponent, ComponentShutdown>(OnCompRemove);
         SubscribeLocalEvent<SericultureComponent, SericultureActionEvent>(OnSericultureStart);
         SubscribeLocalEvent<SericultureComponent, SericultureDoAfterEvent>(OnSericultureDoAfter);
+        SubscribeLocalEvent<SericultureComponent, CloningEvent>(OnClone);
+    }
+
+    private void OnClone(Entity<SericultureComponent> ent, ref CloningEvent args)
+    {
+        if(!args.Settings.EventComponents.Contains(Factory.GetRegistration(ent.Comp.GetType()).Name))
+            return;
+
+        var comp = EnsureComp<SericultureComponent>(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);
     }
 
     /// <summary>
index a93b8e802e5b8d05cf17b4f17cb98c178d72e437..110e6513da14fd57cda22d975cf752ad76c61f19 100644 (file)
@@ -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