2022-08-30 14:36:46 +12:00
|
|
|
using Content.Server.Fluids.EntitySystems;
|
2021-09-06 15:49:44 +02:00
|
|
|
using Content.Shared.Chemistry.Components;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Chemistry.Reaction;
|
|
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2021-11-03 16:48:03 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
2023-05-14 18:35:10 +03:00
|
|
|
using Content.Shared.Movement.Components;
|
2023-06-03 22:34:43 +03:00
|
|
|
using Content.Shared.Movement.Systems;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Slippery;
|
2022-08-30 14:36:46 +12:00
|
|
|
using Content.Shared.StepTrigger.Components;
|
2022-07-10 02:28:37 -07:00
|
|
|
using Content.Shared.StepTrigger.Systems;
|
2020-09-21 17:51:07 +02:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Chemistry.TileReactions
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class SpillTileReaction : ITileReaction
|
2020-09-21 17:51:07 +02:00
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("launchForwardsMultiplier")] private float _launchForwardsMultiplier = 1;
|
|
|
|
|
[DataField("requiredSlipSpeed")] private float _requiredSlipSpeed = 6;
|
|
|
|
|
[DataField("paralyzeTime")] private float _paralyzeTime = 1;
|
2020-09-21 17:51:07 +02:00
|
|
|
|
2024-02-01 11:39:10 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// <see cref="SlipperyComponent.SuperSlippery"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField("superSlippery")] private bool _superSlippery;
|
|
|
|
|
|
2024-05-12 17:34:52 -07:00
|
|
|
public FixedPoint2 TileReact(TileRef tile,
|
|
|
|
|
ReagentPrototype reagent,
|
|
|
|
|
FixedPoint2 reactVolume,
|
2024-08-09 01:27:27 +02:00
|
|
|
IEntityManager entityManager,
|
|
|
|
|
List<ReagentData>? data)
|
2020-09-21 17:51:07 +02:00
|
|
|
{
|
2024-02-01 11:39:10 +01:00
|
|
|
if (reactVolume < 5)
|
|
|
|
|
return FixedPoint2.Zero;
|
2020-09-21 17:51:07 +02:00
|
|
|
|
2023-04-10 15:37:03 +10:00
|
|
|
if (entityManager.EntitySysManager.GetEntitySystem<PuddleSystem>()
|
2024-08-09 01:27:27 +02:00
|
|
|
.TrySpillAt(tile, new Solution(reagent.ID, reactVolume, data), out var puddleUid, false, false))
|
2020-09-21 17:51:07 +02:00
|
|
|
{
|
2023-04-10 15:37:03 +10:00
|
|
|
var slippery = entityManager.EnsureComponent<SlipperyComponent>(puddleUid);
|
2020-09-21 17:51:07 +02:00
|
|
|
slippery.LaunchForwardsMultiplier = _launchForwardsMultiplier;
|
|
|
|
|
slippery.ParalyzeTime = _paralyzeTime;
|
2024-02-01 11:39:10 +01:00
|
|
|
slippery.SuperSlippery = _superSlippery;
|
|
|
|
|
entityManager.Dirty(puddleUid, slippery);
|
2020-09-21 17:51:07 +02:00
|
|
|
|
2023-04-10 15:37:03 +10:00
|
|
|
var step = entityManager.EnsureComponent<StepTriggerComponent>(puddleUid);
|
|
|
|
|
entityManager.EntitySysManager.GetEntitySystem<StepTriggerSystem>().SetRequiredTriggerSpeed(puddleUid, _requiredSlipSpeed, step);
|
2022-08-30 14:36:46 +12:00
|
|
|
|
2024-03-17 05:27:22 +03:00
|
|
|
var slow = entityManager.EnsureComponent<SpeedModifierContactsComponent>(puddleUid);
|
2023-05-14 18:35:10 +03:00
|
|
|
var speedModifier = 1 - reagent.Viscosity;
|
2024-03-17 05:27:22 +03:00
|
|
|
entityManager.EntitySysManager.GetEntitySystem<SpeedModifierContactsSystem>().ChangeModifiers(puddleUid, speedModifier, slow);
|
2023-05-14 18:35:10 +03:00
|
|
|
|
2020-09-21 17:51:07 +02:00
|
|
|
return reactVolume;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-03 16:48:03 -07:00
|
|
|
return FixedPoint2.Zero;
|
2020-09-21 17:51:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|