]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix udder wooly reagent creation V2 (#32905)
authorBaa <9057997+Baa14453@users.noreply.github.com>
Mon, 16 Dec 2024 12:53:21 +0000 (12:53 +0000)
committerGitHub <noreply@github.com>
Mon, 16 Dec 2024 12:53:21 +0000 (13:53 +0100)
* Changed comments to be more clear and uniform.
EggLayer uses NextGrowth instead of frame accumulation.
Egglayer uses much less energy to make eggs, and lay time is randomized for player and AI chicken.

* UdderComponent ReagentId can be changed now
UdderSystem and WoolySystem use SharedSolutionContainerSystem now

* Entities with udders can be examined to see a rough hunger level
udders and wooly stop reagent generation/extra nutrient usage once the solution container is full

* Moved stuff to Shared
AutoPausedField now

* Cleanup moving stuff to Shared

* Oops. Make UdderSystem sealed instead of abstract.

* Switch PopupEntity for PopupClient

* Didn't mean to delete Access

* new() instead of default! prototype
revert egglayer balance change
NextGrowth += timespan   in egglayer

* forgot [Datafield] for NextGrowth

* forgot NetworkedComponent again...

* Renaming Shared Animal to Shared Animals to match Server
Hopefully also resolve merge conflicts.

* Fix incorrect filename

* Update with requested changes
Put UdderSystem dependencies in alphabetical order.
Initialise NextGrowth for Udder and Wooly components on MapInitEvent.
Clean-up EggLayerSystem a little.
Re-write OnExamine function for UdderSystem, improving clarity.
Add full stops to end of udder examine locales.
And more :)

* Add some additional descriptions for cow hunger levels.

* Add Udder and Wooly quantity to AutoNetworkedField

* Account for less than starving threshold.

---------

Co-authored-by: sirionaut <sirionaut@gmail.com>
Co-authored-by: Sirionaut <148076704+Sirionaut@users.noreply.github.com>
Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
Content.Server/Animals/Components/EggLayerComponent.cs
Content.Server/Animals/Components/UdderComponent.cs [deleted file]
Content.Server/Animals/Systems/EggLayerSystem.cs
Content.Server/Polymorph/Systems/PolymorphSystem.cs
Content.Shared/Animals/UdderComponent.cs [new file with mode: 0644]
Content.Shared/Animals/UdderSystem.cs [moved from Content.Server/Animals/Systems/UdderSystem.cs with 62% similarity]
Content.Shared/Animals/WoolyComponent.cs [moved from Content.Server/Animals/Components/WoolyComponent.cs with 66% similarity]
Content.Shared/Animals/WoolySystem.cs [moved from Content.Server/Animals/Systems/WoolySystem.cs with 74% similarity]
Content.Shared/Nutrition/IngestionEvents.cs [moved from Content.Server/Nutrition/IngestionEvents.cs with 96% similarity]
Resources/Locale/en-US/animals/udder/udder-system.ftl

index a0f7de676e5fc0b93e48f6f83caa24c391006110..899bc97f47bb1fe6df32fde5ddf43763b58ed9ee 100644 (file)
@@ -1,3 +1,4 @@
+using Content.Server.Animals.Systems;
 using Content.Shared.Storage;
 using Robust.Shared.Audio;
 using Robust.Shared.Prototypes;
@@ -9,44 +10,47 @@ namespace Content.Server.Animals.Components;
 ///     It also grants an action to players who are controlling these entities, allowing them to do it manually.
 /// </summary>
 
-[RegisterComponent]
+[RegisterComponent, Access(typeof(EggLayerSystem)), AutoGenerateComponentPause]
 public sealed partial class EggLayerComponent : Component
 {
-    [DataField]
-    public EntProtoId EggLayAction = "ActionAnimalLayEgg";
+    /// <summary>
+    ///     The item that gets laid/spawned, retrieved from animal prototype.
+    /// </summary>
+    [DataField(required: true)]
+    public List<EntitySpawnEntry> EggSpawn = new();
 
     /// <summary>
-    ///     The amount of nutrient consumed on update.
+    ///     Player action.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
-    public float HungerUsage = 60f;
+    [DataField]
+    public EntProtoId EggLayAction = "ActionAnimalLayEgg";
+
+    [DataField]
+    public SoundSpecifier EggLaySound = new SoundPathSpecifier("/Audio/Effects/pop.ogg");
 
     /// <summary>
     ///     Minimum cooldown used for the automatic egg laying.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public float EggLayCooldownMin = 60f;
 
     /// <summary>
     ///     Maximum cooldown used for the automatic egg laying.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public float EggLayCooldownMax = 120f;
 
     /// <summary>
-    ///     Set during component init.
+    ///     The amount of nutrient consumed on update.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite)]
-    public float CurrentEggLayCooldown;
-
-    [DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
-    public List<EntitySpawnEntry> EggSpawn = default!;
-
     [DataField]
-    public SoundSpecifier EggLaySound = new SoundPathSpecifier("/Audio/Effects/pop.ogg");
-
-    [DataField]
-    public float AccumulatedFrametime;
+    public float HungerUsage = 60f;
 
     [DataField] public EntityUid? Action;
+
+    /// <summary>
+    ///     When to next try to produce.
+    /// </summary>
+    [DataField, AutoPausedField]
+    public TimeSpan NextGrowth = TimeSpan.Zero;
 }
diff --git a/Content.Server/Animals/Components/UdderComponent.cs b/Content.Server/Animals/Components/UdderComponent.cs
deleted file mode 100644 (file)
index 620f457..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-using Content.Server.Animals.Systems;
-using Content.Shared.Chemistry.Components;
-using Content.Shared.Chemistry.Reagent;
-using Content.Shared.FixedPoint;
-using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
-
-namespace Content.Server.Animals.Components
-
-/// <summary>
-///     Lets an entity produce milk. Uses hunger if present.
-/// </summary>
-{
-    [RegisterComponent, Access(typeof(UdderSystem))]
-    internal sealed partial class UdderComponent : Component
-    {
-        /// <summary>
-        ///     The reagent to produce.
-        /// </summary>
-        [DataField, ViewVariables(VVAccess.ReadOnly)]
-        public ProtoId<ReagentPrototype> ReagentId = "Milk";
-
-        /// <summary>
-        ///     The name of <see cref="Solution"/>.
-        /// </summary>
-        [DataField, ViewVariables(VVAccess.ReadOnly)]
-        public string SolutionName = "udder";
-
-        /// <summary>
-        ///     The solution to add reagent to.
-        /// </summary>
-        [DataField]
-        public Entity<SolutionComponent>? Solution = null;
-
-        /// <summary>
-        ///     The amount of reagent to be generated on update.
-        /// </summary>
-        [DataField, ViewVariables(VVAccess.ReadOnly)]
-        public FixedPoint2 QuantityPerUpdate = 25;
-
-        /// <summary>
-        ///     The amount of nutrient consumed on update.
-        /// </summary>
-        [DataField, ViewVariables(VVAccess.ReadWrite)]
-        public float HungerUsage = 10f;
-
-        /// <summary>
-        ///     How long to wait before producing.
-        /// </summary>
-        [DataField, ViewVariables(VVAccess.ReadWrite)]
-        public TimeSpan GrowthDelay = TimeSpan.FromMinutes(1);
-
-        /// <summary>
-        ///     When to next try to produce.
-        /// </summary>
-        [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
-        public TimeSpan NextGrowth = TimeSpan.FromSeconds(0);
-    }
-}
index 55d63808a4b9e16fc20bf6834d1820c200f363fa..3e552f1b387f641f6274e361206ed99a603cb08e 100644 (file)
@@ -7,15 +7,15 @@ using Content.Shared.Nutrition.Components;
 using Content.Shared.Nutrition.EntitySystems;
 using Content.Shared.Storage;
 using Robust.Server.Audio;
-using Robust.Server.GameObjects;
 using Robust.Shared.Player;
 using Robust.Shared.Random;
+using Robust.Shared.Timing;
 
 namespace Content.Server.Animals.Systems;
 
 /// <summary>
-///     Gives ability to produce eggs, produces endless if the 
-///     owner has no HungerComponent
+///     Gives the ability to lay eggs/other things;
+///     produces endlessly if the owner does not have a HungerComponent.
 /// </summary>
 public sealed class EggLayerSystem : EntitySystem
 {
@@ -23,6 +23,7 @@ public sealed class EggLayerSystem : EntitySystem
     [Dependency] private readonly ActionsSystem _actions = default!;
     [Dependency] private readonly AudioSystem _audio = default!;
     [Dependency] private readonly HungerSystem _hunger = default!;
+    [Dependency] private readonly IGameTiming _timing = default!;
     [Dependency] private readonly PopupSystem _popup = default!;
     [Dependency] private readonly MobStateSystem _mobState = default!;
 
@@ -37,7 +38,6 @@ public sealed class EggLayerSystem : EntitySystem
     public override void Update(float frameTime)
     {
         base.Update(frameTime);
-
         var query = EntityQueryEnumerator<EggLayerComponent>();
         while (query.MoveNext(out var uid, out var eggLayer))
         {
@@ -45,13 +45,17 @@ public sealed class EggLayerSystem : EntitySystem
             if (HasComp<ActorComponent>(uid))
                 continue;
 
-            eggLayer.AccumulatedFrametime += frameTime;
+            if (_timing.CurTime < eggLayer.NextGrowth)
+                continue;
+
+            // Randomize next growth time for more organic egglaying.
+            eggLayer.NextGrowth += TimeSpan.FromSeconds(_random.NextFloat(eggLayer.EggLayCooldownMin, eggLayer.EggLayCooldownMax));
 
-            if (eggLayer.AccumulatedFrametime < eggLayer.CurrentEggLayCooldown)
+            if (_mobState.IsDead(uid))
                 continue;
 
-            eggLayer.AccumulatedFrametime -= eggLayer.CurrentEggLayCooldown;
-            eggLayer.CurrentEggLayCooldown = _random.NextFloat(eggLayer.EggLayCooldownMin, eggLayer.EggLayCooldownMax);
+            // Hungerlevel check/modification is done in TryLayEgg()
+            // so it's used for player controlled chickens as well.
 
             TryLayEgg(uid, eggLayer);
         }
@@ -60,11 +64,12 @@ public sealed class EggLayerSystem : EntitySystem
     private void OnMapInit(EntityUid uid, EggLayerComponent component, MapInitEvent args)
     {
         _actions.AddAction(uid, ref component.Action, component.EggLayAction);
-        component.CurrentEggLayCooldown = _random.NextFloat(component.EggLayCooldownMin, component.EggLayCooldownMax);
+        component.NextGrowth = _timing.CurTime + TimeSpan.FromSeconds(_random.NextFloat(component.EggLayCooldownMin, component.EggLayCooldownMax));
     }
 
     private void OnEggLayAction(EntityUid uid, EggLayerComponent egglayer, EggLayInstantActionEvent args)
     {
+        // Cooldown is handeled by ActionAnimalLayEgg in types.yml.
         args.Handled = TryLayEgg(uid, egglayer);
     }
 
@@ -76,7 +81,7 @@ public sealed class EggLayerSystem : EntitySystem
         if (_mobState.IsDead(uid))
             return false;
 
-        // Allow infinitely laying eggs if they can't get hungry
+        // Allow infinitely laying eggs if they can't get hungry.
         if (TryComp<HungerComponent>(uid, out var hunger))
         {
             if (hunger.CurrentHunger < egglayer.HungerUsage)
index c9a71c53584f3fc70814dd4a471012bc10a75a16..1514d580dda093fc77c645afa4032d887af4d098 100644 (file)
@@ -2,7 +2,6 @@ using Content.Server.Actions;
 using Content.Server.Humanoid;
 using Content.Server.Inventory;
 using Content.Server.Mind.Commands;
-using Content.Server.Nutrition;
 using Content.Server.Polymorph.Components;
 using Content.Shared.Actions;
 using Content.Shared.Buckle;
@@ -13,6 +12,7 @@ using Content.Shared.IdentityManagement;
 using Content.Shared.Mind;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Mobs.Systems;
+using Content.Shared.Nutrition;
 using Content.Shared.Polymorph;
 using Content.Shared.Popups;
 using Robust.Server.Audio;
diff --git a/Content.Shared/Animals/UdderComponent.cs b/Content.Shared/Animals/UdderComponent.cs
new file mode 100644 (file)
index 0000000..d2767b0
--- /dev/null
@@ -0,0 +1,57 @@
+using Content.Shared.Chemistry.Components;
+using Content.Shared.Chemistry.Reagent;
+using Content.Shared.FixedPoint;
+using Robust.Shared.GameStates;
+using Robust.Shared.Prototypes;
+
+namespace Content.Shared.Animals;
+
+/// <summary>
+///     Gives the ability to produce a solution;
+///     produces endlessly if the owner does not have a HungerComponent.
+/// </summary>
+[RegisterComponent, AutoGenerateComponentState, AutoGenerateComponentPause, NetworkedComponent]
+public sealed partial class UdderComponent : Component
+{
+    /// <summary>
+    ///     The reagent to produce.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public ProtoId<ReagentPrototype> ReagentId = new();
+
+    /// <summary>
+    ///     The name of <see cref="Solution"/>.
+    /// </summary>
+    [DataField]
+    public string SolutionName = "udder";
+
+    /// <summary>
+    ///     The solution to add reagent to.
+    /// </summary>
+    [DataField, ViewVariables(VVAccess.ReadOnly)]
+    public Entity<SolutionComponent>? Solution = null;
+
+    /// <summary>
+    ///     The amount of reagent to be generated on update.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public FixedPoint2 QuantityPerUpdate = 25;
+
+    /// <summary>
+    ///     The amount of nutrient consumed on update.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public float HungerUsage = 10f;
+
+    /// <summary>
+    ///     How long to wait before producing.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public TimeSpan GrowthDelay = TimeSpan.FromMinutes(1);
+
+    /// <summary>
+    ///     When to next try to produce.
+    /// </summary>
+    [DataField, AutoPausedField, Access(typeof(UdderSystem))]
+    public TimeSpan NextGrowth = TimeSpan.Zero;
+}
similarity index 62%
rename from Content.Server/Animals/Systems/UdderSystem.cs
rename to Content.Shared/Animals/UdderSystem.cs
index 452ba54d6e1b7a95c1a64f26a0c09577a5869a29..cb6e5b307fe9e513c82fbc3aa5acd077bfb12cdb 100644 (file)
@@ -1,8 +1,7 @@
-using Content.Server.Animals.Components;
-using Content.Server.Popups;
-using Content.Shared.Chemistry.EntitySystems;
 using Content.Shared.Chemistry.Components;
+using Content.Shared.Chemistry.EntitySystems;
 using Content.Shared.DoAfter;
+using Content.Shared.Examine;
 using Content.Shared.IdentityManagement;
 using Content.Shared.Mobs.Systems;
 using Content.Shared.Nutrition.Components;
@@ -12,18 +11,17 @@ using Content.Shared.Udder;
 using Content.Shared.Verbs;
 using Robust.Shared.Timing;
 
-namespace Content.Server.Animals.Systems;
-
+namespace Content.Shared.Animals;
 /// <summary>
-///     Gives ability to produce milkable reagents, produces endless if the
-///     owner has no HungerComponent
+///     Gives the ability to produce milkable reagents;
+///     produces endlessly if the owner does not have a HungerComponent.
 /// </summary>
-internal sealed class UdderSystem : EntitySystem
+public sealed class UdderSystem : EntitySystem
 {
     [Dependency] private readonly HungerSystem _hunger = default!;
     [Dependency] private readonly IGameTiming _timing = default!;
     [Dependency] private readonly MobStateSystem _mobState = default!;
-    [Dependency] private readonly PopupSystem _popupSystem = default!;
+    [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
     [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
     [Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
 
@@ -31,26 +29,37 @@ internal sealed class UdderSystem : EntitySystem
     {
         base.Initialize();
 
+        SubscribeLocalEvent<UdderComponent, MapInitEvent>(OnMapInit);
         SubscribeLocalEvent<UdderComponent, GetVerbsEvent<AlternativeVerb>>(AddMilkVerb);
         SubscribeLocalEvent<UdderComponent, MilkingDoAfterEvent>(OnDoAfter);
+        SubscribeLocalEvent<UdderComponent, ExaminedEvent>(OnExamine);
+    }
+
+    private void OnMapInit(EntityUid uid, UdderComponent component, MapInitEvent args)
+    {
+        component.NextGrowth = _timing.CurTime + component.GrowthDelay;
     }
 
     public override void Update(float frameTime)
     {
         base.Update(frameTime);
-
         var query = EntityQueryEnumerator<UdderComponent>();
-        var now = _timing.CurTime;
         while (query.MoveNext(out var uid, out var udder))
         {
-            if (now < udder.NextGrowth)
+            if (_timing.CurTime < udder.NextGrowth)
                 continue;
 
-            udder.NextGrowth = now + udder.GrowthDelay;
+            udder.NextGrowth += udder.GrowthDelay;
 
             if (_mobState.IsDead(uid))
                 continue;
 
+            if (!_solutionContainerSystem.ResolveSolution(uid, udder.SolutionName, ref udder.Solution, out var solution))
+                continue;
+
+            if (solution.AvailableVolume == 0)
+                continue;
+
             // Actually there is food digestion so no problem with instant reagent generation "OnFeed"
             if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
             {
@@ -61,9 +70,6 @@ internal sealed class UdderSystem : EntitySystem
                 _hunger.ModifyHunger(uid, -udder.HungerUsage, hunger);
             }
 
-            if (!_solutionContainerSystem.ResolveSolution(uid, udder.SolutionName, ref udder.Solution))
-                continue;
-
             //TODO: toxins from bloodstream !?
             _solutionContainerSystem.TryAddReagent(udder.Solution.Value, udder.ReagentId, udder.QuantityPerUpdate, out _);
         }
@@ -99,7 +105,7 @@ internal sealed class UdderSystem : EntitySystem
         var quantity = solution.Volume;
         if (quantity == 0)
         {
-            _popupSystem.PopupEntity(Loc.GetString("udder-system-dry"), entity.Owner, args.Args.User);
+            _popupSystem.PopupClient(Loc.GetString("udder-system-dry"), entity.Owner, args.Args.User);
             return;
         }
 
@@ -109,7 +115,7 @@ internal sealed class UdderSystem : EntitySystem
         var split = _solutionContainerSystem.SplitSolution(entity.Comp.Solution.Value, quantity);
         _solutionContainerSystem.TryAddSolution(targetSoln.Value, split);
 
-        _popupSystem.PopupEntity(Loc.GetString("udder-system-success", ("amount", quantity), ("target", Identity.Entity(args.Args.Used.Value, EntityManager))), entity.Owner,
+        _popupSystem.PopupClient(Loc.GetString("udder-system-success", ("amount", quantity), ("target", Identity.Entity(args.Args.Used.Value, EntityManager))), entity.Owner,
             args.Args.User, PopupType.Medium);
     }
 
@@ -134,4 +140,50 @@ internal sealed class UdderSystem : EntitySystem
         };
         args.Verbs.Add(verb);
     }
+
+    /// <summary>
+    ///     Defines the text provided on examine.
+    ///     Changes depending on the amount of hunger the target has.
+    /// </summary>
+    private void OnExamine(Entity<UdderComponent> entity, ref ExaminedEvent args)
+    {
+
+        var entityIdentity = Identity.Entity(args.Examined, EntityManager);
+
+        string message;
+
+        // Check if the target has hunger, otherwise return not hungry.
+        if (!TryComp<HungerComponent>(entity, out var hunger))
+        {
+            message = Loc.GetString("udder-system-examine-none", ("entity", entityIdentity));
+            args.PushMarkup(message);
+            return;
+        }
+
+        // Choose the correct examine string based on HungerThreshold.
+        switch (_hunger.GetHungerThreshold(hunger))
+        {
+            case >= HungerThreshold.Overfed:
+                message = Loc.GetString("udder-system-examine-overfed", ("entity", entityIdentity));
+                break;
+
+            case HungerThreshold.Okay:
+                message = Loc.GetString("udder-system-examine-okay", ("entity", entityIdentity));
+                break;
+
+            case HungerThreshold.Peckish:
+                message = Loc.GetString("udder-system-examine-hungry", ("entity", entityIdentity));
+                break;
+
+            // There's a final hunger threshold called "dead" but animals don't actually die so we'll re-use this.
+            case <= HungerThreshold.Starving:
+                message = Loc.GetString("udder-system-examine-starved", ("entity", entityIdentity));
+                break;
+
+            default:
+                return;
+        }
+
+        args.PushMarkup(message);
+    }
 }
similarity index 66%
rename from Content.Server/Animals/Components/WoolyComponent.cs
rename to Content.Shared/Animals/WoolyComponent.cs
index c09c6f5e089e2e1ff70b577a4870cc8799edd971..1dfe523001ed47f719d3f8b8c9b0b76c578a4a25 100644 (file)
@@ -1,23 +1,22 @@
-using Content.Server.Animals.Systems;
 using Content.Shared.Chemistry.Components;
 using Content.Shared.Chemistry.Reagent;
 using Content.Shared.FixedPoint;
+using Robust.Shared.GameStates;
 using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
 
-namespace Content.Server.Animals.Components;
+namespace Content.Shared.Animals;
 
 /// <summary>
-///     Lets an entity produce wool fibers. Uses hunger if present.
+///     Gives the ability to produce wool fibers;
+///     produces endlessly if the owner does not have a HungerComponent.
 /// </summary>
-
-[RegisterComponent, Access(typeof(WoolySystem))]
+[RegisterComponent, AutoGenerateComponentState, AutoGenerateComponentPause, NetworkedComponent]
 public sealed partial class WoolyComponent : Component
 {
     /// <summary>
     ///     The reagent to grow.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadOnly)]
+    [DataField, AutoNetworkedField]
     public ProtoId<ReagentPrototype> ReagentId = "Fiber";
 
     /// <summary>
@@ -29,30 +28,30 @@ public sealed partial class WoolyComponent : Component
     /// <summary>
     ///     The solution to add reagent to.
     /// </summary>
-    [DataField]
+    [DataField, ViewVariables(VVAccess.ReadOnly)]
     public Entity<SolutionComponent>? Solution;
 
     /// <summary>
     ///     The amount of reagent to be generated on update.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadOnly)]
+    [DataField, AutoNetworkedField]
     public FixedPoint2 Quantity = 25;
 
     /// <summary>
     ///     The amount of nutrient consumed on update.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField, AutoNetworkedField]
     public float HungerUsage = 10f;
 
     /// <summary>
     ///     How long to wait before growing wool.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField, AutoNetworkedField]
     public TimeSpan GrowthDelay = TimeSpan.FromMinutes(1);
 
     /// <summary>
     ///     When to next try growing wool.
     /// </summary>
-    [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
-    public TimeSpan NextGrowth = TimeSpan.FromSeconds(0);
+    [DataField, AutoPausedField, Access(typeof(WoolySystem))]
+    public TimeSpan NextGrowth = TimeSpan.Zero;
 }
similarity index 74%
rename from Content.Server/Animals/Systems/WoolySystem.cs
rename to Content.Shared/Animals/WoolySystem.cs
index ef0ba086eaf66b395899f9bf18328fb67085e990..b7e0f52982cab95588d89f5eb5356eb34a64c785 100644 (file)
@@ -1,16 +1,15 @@
-using Content.Server.Animals.Components;
-using Content.Server.Nutrition;
 using Content.Shared.Chemistry.EntitySystems;
 using Content.Shared.Mobs.Systems;
+using Content.Shared.Nutrition;
 using Content.Shared.Nutrition.Components;
 using Content.Shared.Nutrition.EntitySystems;
 using Robust.Shared.Timing;
 
-namespace Content.Server.Animals.Systems;
+namespace Content.Shared.Animals;
 
 /// <summary>
-///     Gives ability to produce fiber reagents, produces endless if the
-///     owner has no HungerComponent
+///     Gives ability to produce fiber reagents;
+///     produces endlessly if the owner has no HungerComponent.
 /// </summary>
 public sealed class WoolySystem : EntitySystem
 {
@@ -24,6 +23,12 @@ public sealed class WoolySystem : EntitySystem
         base.Initialize();
 
         SubscribeLocalEvent<WoolyComponent, BeforeFullyEatenEvent>(OnBeforeFullyEaten);
+        SubscribeLocalEvent<WoolyComponent, MapInitEvent>(OnMapInit);
+    }
+
+    private void OnMapInit(EntityUid uid, WoolyComponent component, MapInitEvent args)
+    {
+        component.NextGrowth = _timing.CurTime + component.GrowthDelay;
     }
 
     public override void Update(float frameTime)
@@ -31,17 +36,22 @@ public sealed class WoolySystem : EntitySystem
         base.Update(frameTime);
 
         var query = EntityQueryEnumerator<WoolyComponent>();
-        var now = _timing.CurTime;
         while (query.MoveNext(out var uid, out var wooly))
         {
-            if (now < wooly.NextGrowth)
+            if (_timing.CurTime < wooly.NextGrowth)
                 continue;
 
-            wooly.NextGrowth = now + wooly.GrowthDelay;
+            wooly.NextGrowth += wooly.GrowthDelay;
 
             if (_mobState.IsDead(uid))
                 continue;
 
+            if (!_solutionContainer.ResolveSolution(uid, wooly.SolutionName, ref wooly.Solution, out var solution))
+                continue;
+
+            if (solution.AvailableVolume == 0)
+                continue;
+
             // Actually there is food digestion so no problem with instant reagent generation "OnFeed"
             if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
             {
@@ -52,9 +62,6 @@ public sealed class WoolySystem : EntitySystem
                 _hunger.ModifyHunger(uid, -wooly.HungerUsage, hunger);
             }
 
-            if (!_solutionContainer.ResolveSolution(uid, wooly.SolutionName, ref wooly.Solution))
-                continue;
-
             _solutionContainer.TryAddReagent(wooly.Solution.Value, wooly.ReagentId, wooly.Quantity, out _);
         }
     }
similarity index 96%
rename from Content.Server/Nutrition/IngestionEvents.cs
rename to Content.Shared/Nutrition/IngestionEvents.cs
index ae1d22fb71f4cfec2c13e2e7ada97505478ca8af..488605522ac766d8b543d3dc4842b39cd8fb3d0f 100644 (file)
@@ -1,4 +1,4 @@
-namespace Content.Server.Nutrition;
+namespace Content.Shared.Nutrition;
 
 /// <summary>
 ///     Raised directed at the consumer when attempting to ingest something.
index 8479ae08bff035aea221b0262b3f692f61198eb0..959a4fef59159d7597e32732ec36469e30ebdfdf 100644 (file)
@@ -5,3 +5,9 @@ udder-system-success = You fill {THE($target)} with {$amount}u from the udder.
 udder-system-dry = The udder is dry.
 
 udder-system-verb-milk = Milk
+
+udder-system-examine-overfed = {CAPITALIZE(SUBJECT($entity))} looks stuffed!
+udder-system-examine-okay = {CAPITALIZE(SUBJECT($entity))} looks content.
+udder-system-examine-hungry = {CAPITALIZE(SUBJECT($entity))} looks hungry.
+udder-system-examine-starved = {CAPITALIZE(SUBJECT($entity))} looks starved!
+udder-system-examine-none = {CAPITALIZE(SUBJECT($entity))} seems not to get hungry.