Files
crystall-punk-14/Content.Server/Chemistry/TileReactions/SpillTileReaction.cs
Zachary Higgs 241d0e12e2 Fix SuperSlippery And StepTriggers persisting when UpdateSlip is called (#34525)
* Fix superSlippery and stepTrigger values persist

- made values in SpillTileReaction's public so we can query the
prototype

- made the default values for slippery component and
StepTriggerComponent based on default constants
for easier resetting

- added a calculation and check in UpdateSlips to check
if a super slip is present as well as Update
relevant steptrigger and slip values based on the contents of the
solution

* The worlds biggest change

---------

Co-authored-by: Myra <vascreeper@yahoo.com>
2025-02-17 21:53:23 +01:00

61 lines
2.4 KiB
C#

using Content.Server.Fluids.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Slippery;
using Content.Shared.StepTrigger.Components;
using Content.Shared.StepTrigger.Systems;
using JetBrains.Annotations;
using Robust.Shared.Map;
namespace Content.Server.Chemistry.TileReactions
{
[UsedImplicitly]
[DataDefinition]
public sealed partial class SpillTileReaction : ITileReaction
{
[DataField("launchForwardsMultiplier")] public float LaunchForwardsMultiplier = 1;
[DataField("requiredSlipSpeed")] public float RequiredSlipSpeed = 6;
[DataField("paralyzeTime")] public float ParalyzeTime = 1;
/// <summary>
/// <see cref="SlipperyComponent.SuperSlippery"/>
/// </summary>
[DataField("superSlippery")] public bool SuperSlippery;
public FixedPoint2 TileReact(TileRef tile,
ReagentPrototype reagent,
FixedPoint2 reactVolume,
IEntityManager entityManager,
List<ReagentData>? data)
{
if (reactVolume < 5)
return FixedPoint2.Zero;
if (entityManager.EntitySysManager.GetEntitySystem<PuddleSystem>()
.TrySpillAt(tile, new Solution(reagent.ID, reactVolume, data), out var puddleUid, false, false))
{
var slippery = entityManager.EnsureComponent<SlipperyComponent>(puddleUid);
slippery.LaunchForwardsMultiplier = LaunchForwardsMultiplier;
slippery.ParalyzeTime = ParalyzeTime;
slippery.SuperSlippery = SuperSlippery;
entityManager.Dirty(puddleUid, slippery);
var step = entityManager.EnsureComponent<StepTriggerComponent>(puddleUid);
entityManager.EntitySysManager.GetEntitySystem<StepTriggerSystem>().SetRequiredTriggerSpeed(puddleUid, RequiredSlipSpeed, step);
var slow = entityManager.EnsureComponent<SpeedModifierContactsComponent>(puddleUid);
var speedModifier = 1 - reagent.Viscosity;
entityManager.EntitySysManager.GetEntitySystem<SpeedModifierContactsSystem>().ChangeModifiers(puddleUid, speedModifier, slow);
return reactVolume;
}
return FixedPoint2.Zero;
}
}
}