From: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Date: Sat, 16 Aug 2025 15:03:50 +0000 (+0200) Subject: Predict MessyDrinker (#39660) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=529d7ff2922788c13997a26b61e384119116648d;p=space-station-14.git Predict MessyDrinker (#39660) init --- diff --git a/Content.Server/Nutrition/Components/MessyDrinkerComponent.cs b/Content.Shared/Nutrition/Components/MessyDrinkerComponent.cs similarity index 71% rename from Content.Server/Nutrition/Components/MessyDrinkerComponent.cs rename to Content.Shared/Nutrition/Components/MessyDrinkerComponent.cs index 5519c5d983..c077db8231 100644 --- a/Content.Server/Nutrition/Components/MessyDrinkerComponent.cs +++ b/Content.Shared/Nutrition/Components/MessyDrinkerComponent.cs @@ -1,30 +1,31 @@ using Content.Shared.FixedPoint; using Content.Shared.Nutrition.Prototypes; +using Robust.Shared.GameStates; using Robust.Shared.Prototypes; -namespace Content.Server.Nutrition.Components; +namespace Content.Shared.Nutrition.Components; /// /// Entities with this component occasionally spill some of the solution they're ingesting. /// -[RegisterComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class MessyDrinkerComponent : Component { - [DataField] + [DataField, AutoNetworkedField] public float SpillChance = 0.2f; /// /// The amount of solution that is spilled when procs. /// - [DataField] + [DataField, AutoNetworkedField] public FixedPoint2 SpillAmount = 1.0; /// /// The types of food prototypes we can spill /// - [DataField] + [DataField, AutoNetworkedField] public List> SpillableTypes = new List> { "Drink" }; - [DataField] + [DataField, AutoNetworkedField] public LocId? SpillMessagePopup; } diff --git a/Content.Server/Nutrition/EntitySystems/MessyDrinkerSystem.cs b/Content.Shared/Nutrition/EntitySystems/MessyDrinkerSystem.cs similarity index 58% rename from Content.Server/Nutrition/EntitySystems/MessyDrinkerSystem.cs rename to Content.Shared/Nutrition/EntitySystems/MessyDrinkerSystem.cs index dc8c11bb7f..bf084e6054 100644 --- a/Content.Server/Nutrition/EntitySystems/MessyDrinkerSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/MessyDrinkerSystem.cs @@ -1,18 +1,18 @@ -using Content.Server.Fluids.EntitySystems; -using Content.Server.Nutrition.Components; -using Content.Shared.Nutrition; -using Content.Shared.Nutrition.EntitySystems; +using Content.Shared.Fluids; +using Content.Shared.Nutrition.Components; using Content.Shared.Popups; +using Content.Shared.Random.Helpers; using Robust.Shared.Random; +using Robust.Shared.Timing; -namespace Content.Server.Nutrition.EntitySystems; +namespace Content.Shared.Nutrition.EntitySystems; public sealed class MessyDrinkerSystem : EntitySystem { - [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IngestionSystem _ingestion = default!; - [Dependency] private readonly PuddleSystem _puddle = default!; + [Dependency] private readonly SharedPuddleSystem _puddle = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly IGameTiming _timing = default!; public override void Initialize() { @@ -35,11 +35,14 @@ public sealed class MessyDrinkerSystem : EntitySystem if (ev.ForceFed) return; - if (!_random.Prob(ent.Comp.SpillChance)) + // TODO: Replace with RandomPredicted once the engine PR is merged + var seed = SharedRandomExtensions.HashCodeCombine(new() { (int)_timing.CurTick.Value, GetNetEntity(ent).Id }); + var rand = new System.Random(seed); + if (!rand.Prob(ent.Comp.SpillChance)) return; if (ent.Comp.SpillMessagePopup != null) - _popup.PopupEntity(Loc.GetString(ent.Comp.SpillMessagePopup), ent, ent, PopupType.MediumCaution); + _popup.PopupPredicted(Loc.GetString(ent.Comp.SpillMessagePopup), null, ent, ent, PopupType.MediumCaution); var split = ev.Split.SplitSolution(ent.Comp.SpillAmount);