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
This commit is contained in:
poklj
2025-06-25 16:50:47 -03:00
committed by GitHub
parent 76d11cc0e1
commit 1c58b6efc7
3 changed files with 18 additions and 3 deletions

View 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>