using Content.Shared.Chemistry.EntitySystems; using Content.Server.Fluids.EntitySystems; using Content.Shared.Fluids.Components; using JetBrains.Annotations; namespace Content.Server.Destructible.Thresholds.Behaviors { [UsedImplicitly] [DataDefinition] public sealed partial class SpillBehavior : IThresholdBehavior { [DataField] public string? Solution; /// /// If there is a SpillableComponent on EntityUidowner use it to create a puddle/smear. /// Or whatever solution is specified in the behavior itself. /// If none are available do nothing. /// /// Entity on which behavior is executed /// system calling the behavior /// public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null) { var solutionContainerSystem = system.EntityManager.System(); var spillableSystem = system.EntityManager.System(); var coordinates = system.EntityManager.GetComponent(owner).Coordinates; if (system.EntityManager.TryGetComponent(owner, out SpillableComponent? spillableComponent) && solutionContainerSystem.TryGetSolution(owner, spillableComponent.SolutionName, out _, out var compSolution)) { spillableSystem.TrySplashSpillAt(owner, coordinates, compSolution, out _, false, user: cause); } else if (Solution != null && solutionContainerSystem.TryGetSolution(owner, Solution, out _, out var behaviorSolution)) { spillableSystem.TrySplashSpillAt(owner, coordinates, behaviorSolution, out _, user: cause); } } } }