using Content.Shared.Popups;
using Content.Shared.Udder;
using Content.Shared.Verbs;
+using Robust.Shared.Containers;
using Robust.Shared.Timing;
namespace Content.Shared.Animals;
SubscribeLocalEvent<UdderComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<UdderComponent, GetVerbsEvent<AlternativeVerb>>(AddMilkVerb);
SubscribeLocalEvent<UdderComponent, MilkingDoAfterEvent>(OnDoAfter);
+ SubscribeLocalEvent<UdderComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
}
private void OnMapInit(EntityUid uid, UdderComponent component, MapInitEvent args)
component.NextGrowth = _timing.CurTime + component.GrowthDelay;
}
+ private void OnEntRemoved(Entity<UdderComponent> entity, ref EntRemovedFromContainerMessage args)
+ {
+ // Make sure the removed entity was our contained solution
+ if (entity.Comp.Solution == null || args.Entity != entity.Comp.Solution.Value.Owner)
+ return;
+
+ // Cleared our cached reference to the solution entity
+ entity.Comp.Solution = null;
+ }
+
public override void Update(float frameTime)
{
base.Update(frameTime);
using Content.Shared.Nutrition;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
+using Robust.Shared.Containers;
using Robust.Shared.Timing;
namespace Content.Shared.Animals;
SubscribeLocalEvent<WoolyComponent, BeforeFullyEatenEvent>(OnBeforeFullyEaten);
SubscribeLocalEvent<WoolyComponent, MapInitEvent>(OnMapInit);
+ SubscribeLocalEvent<WoolyComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
}
private void OnMapInit(EntityUid uid, WoolyComponent component, MapInitEvent args)
component.NextGrowth = _timing.CurTime + component.GrowthDelay;
}
+ private void OnEntRemoved(Entity<WoolyComponent> entity, ref EntRemovedFromContainerMessage args)
+ {
+ // Make sure the removed entity was our contained solution
+ if (entity.Comp.Solution == null || args.Entity != entity.Comp.Solution.Value.Owner)
+ return;
+
+ // Clear our cached reference to the solution entity
+ entity.Comp.Solution = null;
+ }
+
public override void Update(float frameTime)
{
base.Update(frameTime);