Update puddle stickiness (#16597)
This commit is contained in:
@@ -25,6 +25,8 @@ using Solution = Content.Shared.Chemistry.Components.Solution;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Systems;
|
||||
|
||||
namespace Content.Server.Fluids.EntitySystems;
|
||||
|
||||
@@ -47,6 +49,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
[Dependency] private readonly StepTriggerSystem _stepTrigger = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
||||
[Dependency] private readonly TileFrictionController _tile = default!;
|
||||
[Dependency] private readonly SlowContactsSystem _slowContacts = default!;
|
||||
|
||||
public static float PuddleVolume = 1000;
|
||||
|
||||
@@ -242,6 +245,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
|
||||
_deletionQueue.Remove(uid);
|
||||
UpdateSlip(uid, component, args.Solution);
|
||||
UpdateSlow(uid, args.Solution);
|
||||
UpdateEvaporation(uid, args.Solution);
|
||||
UpdateAppearance(uid, component);
|
||||
}
|
||||
@@ -319,6 +323,26 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSlow(EntityUid uid, Solution solution)
|
||||
{
|
||||
var maxViscosity = 0f;
|
||||
foreach (var reagent in solution.Contents)
|
||||
{
|
||||
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.ReagentId);
|
||||
maxViscosity = Math.Max(maxViscosity, reagentProto.Viscosity);
|
||||
}
|
||||
if (maxViscosity > 0)
|
||||
{
|
||||
var comp = EnsureComp<SlowContactsComponent>(uid);
|
||||
var speed = 1 - maxViscosity;
|
||||
_slowContacts.ChangeModifiers(uid, speed, comp);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemComp<SlowContactsComponent>(uid);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandlePuddleExamined(EntityUid uid, PuddleComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (TryComp<StepTriggerComponent>(uid, out var slippery) && slippery.Active)
|
||||
|
||||
Reference in New Issue
Block a user