Files
Delta-v/Content.Shared/_DV/Chemistry/Systems/SafeSolutionThrowerSystem.cs
T
0vrseerandpre-commit-ci[bot] cb8f11b1eb Beer googles function as their description states. (#4091)
* SafeSolutionThrower Component

* Edge cases + poor attempt at angle fixing

* PhysicsSystem to fix rotation

* newline accidental

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* I hope the dv init relay isn't slop

* fix spacing

* RefRelayInventoryEvent is a protected method

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-08-03 08:35:20 +00:00

41 lines
1.3 KiB
C#

using Content.Shared.Inventory;
using Content.Shared._DV.Chemistry.Components;
namespace Content.Shared._DV.Chemistry.Systems;
public sealed class SafeSolutionThrowerSystem : EntitySystem
{
[Dependency] private readonly InventorySystem _inventory = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<InventoryComponent, SafeSolutionThrowEvent>(_inventory.RelayEvent);
Subs.SubscribeWithRelay<SafeSolutionThrowerComponent, SafeSolutionThrowEvent>(OnSafeSolutionThrowAttempt);
}
/// <summary>
/// Call this to check if a player can throw a solution safely.
/// </summary>
public bool GetSafeThrow(EntityUid playeruid)
{
var safeThrowEvent = new SafeSolutionThrowEvent();
RaiseLocalEvent(playeruid, ref safeThrowEvent);
return safeThrowEvent.SafeThrow;
}
private void OnSafeSolutionThrowAttempt(Entity<SafeSolutionThrowerComponent> ent, ref SafeSolutionThrowEvent args)
{
args.SafeThrow = true;
}
}
/// <summary>
/// Raised on an entity and its inventory to determine if it can throw spillable objects safely.
/// </summary>
[ByRefEvent]
public record struct SafeSolutionThrowEvent(bool SafeThrow = false) : IInventoryRelayEvent
{
SlotFlags IInventoryRelayEvent.TargetSlots => SlotFlags.HEAD | SlotFlags.MASK | SlotFlags.EYES;
}