From 1e6a1a9ddf8fac4d5fc3bdc0bd0971a6d1c1a7c4 Mon Sep 17 00:00:00 2001 From: Memeji Dankiri <39416235+Memeji@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:14:18 -0500 Subject: [PATCH] Update LewdTraitSystem.cs --- .../FloofStation/Traits/LewdTraitSystem.cs | 94 ++++++++----------- 1 file changed, 41 insertions(+), 53 deletions(-) diff --git a/Content.Server/FloofStation/Traits/LewdTraitSystem.cs b/Content.Server/FloofStation/Traits/LewdTraitSystem.cs index 5c5f084ce08..1429488a47a 100644 --- a/Content.Server/FloofStation/Traits/LewdTraitSystem.cs +++ b/Content.Server/FloofStation/Traits/LewdTraitSystem.cs @@ -268,73 +268,61 @@ private void AttemptMilk(Entity lewd, EntityUid userUid, public override void Update(float frameTime) { base.Update(frameTime); - var queryCum = EntityQueryEnumerator(); //SquirtProducerComponent -unused , - var queryMilk = EntityQueryEnumerator(); + var now = _timing.CurTime; + var query = AllEntityQuery(); //SquirtProducerComponent -unused - while (queryCum.MoveNext(out var uid, out var containerCum)) + while (query.MoveNext(out var uid, out var containerCum, out var containerMilk)) // out var containerSquirt -unused { - if (now < containerCum.NextGrowth) - continue; - - containerCum.NextGrowth = now + containerCum.GrowthDelay; - if (_mobState.IsDead(uid)) continue; - if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger)) + if (!(now < containerCum.NextGrowth)) { - if (_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay) - continue; - - _hunger.ModifyHunger(uid, -containerCum.HungerUsage, hunger); + containerCum.NextGrowth = now + containerCum.GrowthDelay; + + // Actually there is food digestion so no problem with instant reagent generation "OnFeed" + if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger)) + { + // Is there enough nutrition to produce reagent? + if (!(_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay)) + _hunger.ModifyHunger(uid, -containerCum.HungerUsage, hunger); + } + + if (_solutionContainer.ResolveSolution(uid, containerCum.SolutionName, ref containerCum.Solution)) + _solutionContainer.TryAddReagent(containerCum.Solution.Value, containerCum.ReagentId, containerCum.QuantityPerUpdate, out _); } - if (!_solutionContainer.ResolveSolution(uid, containerCum.SolutionName, ref containerCum.Solution)) - continue; - - _solutionContainer.TryAddReagent(containerCum.Solution.Value, containerCum.ReagentId, containerCum.QuantityPerUpdate, out _); - } - - while (queryMilk.MoveNext(out var uid, out var containerMilk)) - { - if (now < containerMilk.NextGrowth) - continue; - - containerMilk.NextGrowth = now + containerMilk.GrowthDelay; - - if (_mobState.IsDead(uid)) - continue; - - if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger)) + if (!(now < containerMilk.NextGrowth)) { - if (_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay) - continue; + containerMilk.NextGrowth = now + containerMilk.GrowthDelay; - _hunger.ModifyHunger(uid, -containerMilk.HungerUsage, hunger); - } + if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger)) + { + if (!(_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay)) + _hunger.ModifyHunger(uid, -containerMilk.HungerUsage, hunger); + } - if (!_solutionContainer.ResolveSolution(uid, containerMilk.SolutionName, ref containerMilk.Solution)) - continue; + if (_solutionContainer.ResolveSolution(uid, containerMilk.SolutionName, ref containerMilk.Solution)) + _solutionContainer.TryAddReagent(containerMilk.Solution.Value, containerMilk.ReagentId, containerMilk.QuantityPerUpdate, out _); + } - _solutionContainer.TryAddReagent(containerMilk.Solution.Value, containerMilk.ReagentId, containerMilk.QuantityPerUpdate, out _); + //if (!(now < containerSquirt.NextGrowth)) //Unused-Trait is WIP + //{ + // containerSquirt.NextGrowth = now + containerSquirt.GrowthDelay; + + // + // if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger)) + // { + // + // if (!(_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay)) + // _hunger.ModifyHunger(uid, -containerSquirt.HungerUsage, hunger); + // } + + // if (_solutionContainer.ResolveSolution(uid, containerSquirt.SolutionName, ref containerSquirt.Solution)) + // _solutionContainer.TryAddReagent(containerSquirt.Solution.Value, containerSquirt.ReagentId, containerSquirt.QuantityPerUpdate, out _); + //} } - - //if (!(now < containerSquirt.NextGrowth)) //Unused-Trait is WIP - //{ - // containerSquirt.NextGrowth = now + containerSquirt.GrowthDelay; - - // - // if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger)) - // { - // - // if (!(_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay)) - // _hunger.ModifyHunger(uid, -containerSquirt.HungerUsage, hunger); - // } - - // if (_solutionContainer.ResolveSolution(uid, containerSquirt.SolutionName, ref containerSquirt.Solution)) - // _solutionContainer.TryAddReagent(containerSquirt.Solution.Value, containerSquirt.ReagentId, containerSquirt.QuantityPerUpdate, out _); - //} } #endregion }