Spill hand contents when dropping them in a fall (#3304)

* Spill hand contents when dropping them due to falling down

* Better approach

* cleanup

* grammar

* stupid
This commit is contained in:
Clyybber
2021-02-18 21:43:46 +01:00
committed by GitHub
parent 3766410178
commit c996021b5d
6 changed files with 50 additions and 33 deletions

View File

@@ -3,13 +3,14 @@ using Content.Shared.GameObjects.Components.Chemistry;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Content.Shared.GameObjects.Verbs;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
namespace Content.Server.GameObjects.Components.Fluids
{
[RegisterComponent]
public class SpillableComponent : Component
public class SpillableComponent : Component, IDropped
{
public override string Name => "Spillable";
@@ -51,11 +52,17 @@ namespace Content.Server.GameObjects.Components.Fluids
}
// Need this as when we split the component's owner may be deleted
var entityLocation = component.Owner.Transform.Coordinates;
var solution = solutionComponent.Drain(solutionComponent.DrainAvailable);
solution.SpillAt(entityLocation, "PuddleSmear");
solutionComponent.Drain(solutionComponent.DrainAvailable).SpillAt(component.Owner.Transform.Coordinates, "PuddleSmear");
}
}
}
void IDropped.Dropped(DroppedEventArgs eventArgs)
{
if (!eventArgs.Intentional && Owner.TryGetComponent(out ISolutionInteractionsComponent solutionComponent))
{
solutionComponent.Drain(solutionComponent.DrainAvailable).SpillAt(Owner.Transform.Coordinates, "PuddleSmear");
}
}
}
}