Fix udder wooly reagent creation V2 (#32905)
* 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>
This commit is contained in:
@@ -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 (eggLayer.AccumulatedFrametime < eggLayer.CurrentEggLayCooldown)
|
||||
if (_timing.CurTime < eggLayer.NextGrowth)
|
||||
continue;
|
||||
|
||||
eggLayer.AccumulatedFrametime -= eggLayer.CurrentEggLayCooldown;
|
||||
eggLayer.CurrentEggLayCooldown = _random.NextFloat(eggLayer.EggLayCooldownMin, eggLayer.EggLayCooldownMax);
|
||||
// Randomize next growth time for more organic egglaying.
|
||||
eggLayer.NextGrowth += TimeSpan.FromSeconds(_random.NextFloat(eggLayer.EggLayCooldownMin, eggLayer.EggLayCooldownMax));
|
||||
|
||||
if (_mobState.IsDead(uid))
|
||||
continue;
|
||||
|
||||
// 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)
|
||||
|
||||
Reference in New Issue
Block a user