2024-09-02 06:26:04 -05:00
|
|
|
using Content.Shared.Chemistry.EntitySystems;
|
2021-12-05 04:18:30 +01:00
|
|
|
using Content.Server.Fluids.EntitySystems;
|
2024-03-03 00:36:36 -05:00
|
|
|
using Content.Shared.Fluids.Components;
|
2021-01-10 16:10:28 +01:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Destructible.Thresholds.Behaviors
|
2021-01-10 16:10:28 +01:00
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class SpillBehavior : IThresholdBehavior
|
2021-01-10 16:10:28 +01:00
|
|
|
{
|
2023-12-29 04:47:43 -08:00
|
|
|
[DataField]
|
2021-09-15 12:46:43 +02:00
|
|
|
public string? Solution;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-12-05 18:09:01 +01:00
|
|
|
/// If there is a SpillableComponent on EntityUidowner use it to create a puddle/smear.
|
2021-09-15 12:46:43 +02:00
|
|
|
/// Or whatever solution is specified in the behavior itself.
|
|
|
|
|
/// If none are available do nothing.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="owner">Entity on which behavior is executed</param>
|
|
|
|
|
/// <param name="system">system calling the behavior</param>
|
2023-02-10 17:45:38 -06:00
|
|
|
/// <param name="cause"></param>
|
|
|
|
|
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
|
2021-01-10 16:10:28 +01:00
|
|
|
{
|
2024-09-02 06:26:04 -05:00
|
|
|
var solutionContainerSystem = system.EntityManager.System<SharedSolutionContainerSystem>();
|
2024-05-12 17:34:52 -07:00
|
|
|
var spillableSystem = system.EntityManager.System<PuddleSystem>();
|
2021-09-15 12:46:43 +02:00
|
|
|
|
2021-11-09 21:24:35 +01:00
|
|
|
var coordinates = system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates;
|
2021-01-10 16:10:28 +01:00
|
|
|
|
2021-11-09 21:24:35 +01:00
|
|
|
if (system.EntityManager.TryGetComponent(owner, out SpillableComponent? spillableComponent) &&
|
2023-12-29 04:47:43 -08:00
|
|
|
solutionContainerSystem.TryGetSolution(owner, spillableComponent.SolutionName, out _, out var compSolution))
|
2021-09-15 12:46:43 +02:00
|
|
|
{
|
2023-04-10 15:37:03 +10:00
|
|
|
spillableSystem.TrySplashSpillAt(owner, coordinates, compSolution, out _, false, user: cause);
|
2021-09-15 12:46:43 +02:00
|
|
|
}
|
|
|
|
|
else if (Solution != null &&
|
2023-12-29 04:47:43 -08:00
|
|
|
solutionContainerSystem.TryGetSolution(owner, Solution, out _, out var behaviorSolution))
|
2021-09-15 12:46:43 +02:00
|
|
|
{
|
2023-04-10 15:37:03 +10:00
|
|
|
spillableSystem.TrySplashSpillAt(owner, coordinates, behaviorSolution, out _, user: cause);
|
2021-09-15 12:46:43 +02:00
|
|
|
}
|
2021-01-10 16:10:28 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|