Fix throwable solution (#4590)
* Fix throwable solution * Revert previous commit * Change Spillable and SpillBehavior * Fix sloth's suggestion. Add more documents
This commit is contained in:
@@ -10,13 +10,32 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
[DataDefinition]
|
||||
public class SpillBehavior : IThresholdBehavior
|
||||
{
|
||||
[DataField("solution")]
|
||||
public string? Solution;
|
||||
|
||||
/// <summary>
|
||||
/// If there is a SpillableComponent on IEntity owner use it to create a puddle/smear.
|
||||
/// 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>
|
||||
public void Execute(IEntity owner, DestructibleSystem system)
|
||||
{
|
||||
// TODO see if this is correct
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(owner, SpillableComponent.SolutionName, out var solution))
|
||||
return;
|
||||
var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
|
||||
|
||||
solution.SpillAt(owner.Transform.Coordinates, "PuddleSmear", false);
|
||||
|
||||
if (owner.TryGetComponent(out SpillableComponent? spillableComponent) &&
|
||||
solutionContainerSystem.TryGetSolution(owner.Uid, spillableComponent.SolutionName,
|
||||
out var compSolution))
|
||||
{
|
||||
compSolution.SpillAt(owner.Transform.Coordinates, "PuddleSmear", false);
|
||||
}
|
||||
else if (Solution != null &&
|
||||
solutionContainerSystem.TryGetSolution(owner.Uid, Solution, out var behaviorSolution))
|
||||
{
|
||||
behaviorSolution.SpillAt(owner.Transform.Coordinates, "PuddleSmear", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user