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>
This commit is contained in:
0vrseer 2025-08-03 04:35:20 -04:00 committed by GitHub
parent c058a71fa1
commit cb8f11b1eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 78 additions and 0 deletions

View File

@ -1,6 +1,8 @@
using Content.Server.Damage.Components;
using Content.Shared.Damage;
using Content.Shared.Throwing;
using Content.Shared._DV.Chemistry.Systems; // DeltaV - Beergoggles enable safe throw
using Content.Shared.Nutrition.Components; // DeltaV - Beergoggles enable safe throw
namespace Content.Server.Damage.Systems
{
@ -10,6 +12,7 @@ namespace Content.Server.Damage.Systems
public sealed class DamageOnLandSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly SafeSolutionThrowerSystem _safesolthrower = default!; // DeltaV - Beergoggles enable safe throw
public override void Initialize()
{
@ -19,6 +22,13 @@ namespace Content.Server.Damage.Systems
private void DamageOnLand(EntityUid uid, DamageOnLandComponent component, ref LandEvent args)
{
// DeltaV - start of Beergoggles enable safe throw
if (args.User is { } user && HasComp<DrinkComponent>(uid))
{
if (_safesolthrower.GetSafeThrow(user))
return;
}
// DeltaV - end of Beergoggles enable safe throw
_damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances);
}
}

View File

@ -15,11 +15,16 @@ using Content.Shared.Spillable;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Player;
using Content.Shared._DV.Chemistry.Systems; // DeltaV Beergoggles enable safe throw
using Robust.Shared.Physics.Systems; // DeltaV Beergoggles enable safe throw
namespace Content.Server.Fluids.EntitySystems;
public sealed partial class PuddleSystem
{
[Dependency] private readonly SharedPhysicsSystem _physics = default!; // DeltaV - Beergoggles enable safe throw
[Dependency] private readonly SafeSolutionThrowerSystem _safesolthrower = default!; // DeltaV - Beergoggles enable safe throw
protected override void InitializeSpillable()
{
base.InitializeSpillable();
@ -113,6 +118,14 @@ public sealed partial class PuddleSystem
if (args.User != null)
{
// DeltaV - start of Beergoggles enable safe throw
if (_safesolthrower.GetSafeThrow(args.User.Value))
{
_physics.SetAngularVelocity(entity, 0);
Transform(entity).LocalRotation = Angle.Zero;
return;
}
// DeltaV - end of Beergoggles enable safe throw
_adminLogger.Add(LogType.Landed,
$"{ToPrettyString(entity.Owner):entity} spilled a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution} on landing");
}
@ -134,6 +147,10 @@ public sealed partial class PuddleSystem
if (!_solutionContainerSystem.TryGetSolution(ent.Owner, ent.Comp.SolutionName, out _, out var solution) || solution.Volume <= 0)
return;
// DeltaV - start of Beergoggles enable safe throw
if (_safesolthrower.GetSafeThrow(args.PlayerUid))
return;
// DeltaV - end of Beergoggles enable safe throw
args.Cancel("pacified-cannot-throw-spill");
}

View File

@ -0,0 +1,10 @@
using Robust.Shared.GameStates;
namespace Content.Shared._DV.Chemistry.Components;
/// <summary>
/// Allows an entity to safely throw solutions without spilling them.
/// Works when added either directly to an entity or to a piece of clothing worn by that entity.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class SafeSolutionThrowerComponent : Component;

View File

@ -0,0 +1,40 @@
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;
}

View File

@ -107,6 +107,7 @@
- type: StealTarget
stealGroup: ClothingEyesHudBeer
- type: SolutionScanner
- type: SafeSolutionThrower # DeltaV - Beergoggles enable safe throw
- type: entity
parent: ClothingEyesBase