diff --git a/Content.Server/Damage/Systems/DamageOnLandSystem.cs b/Content.Server/Damage/Systems/DamageOnLandSystem.cs index 3cf103e6ee..ed5f55811f 100644 --- a/Content.Server/Damage/Systems/DamageOnLandSystem.cs +++ b/Content.Server/Damage/Systems/DamageOnLandSystem.cs @@ -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(uid)) + { + if (_safesolthrower.GetSafeThrow(user)) + return; + } + // DeltaV - end of Beergoggles enable safe throw _damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances); } } diff --git a/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs b/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs index 296b397146..28ea4c5718 100644 --- a/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs +++ b/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs @@ -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"); } diff --git a/Content.Shared/_DV/Chemistry/Components/SafeSolutionThrowerComponent.cs b/Content.Shared/_DV/Chemistry/Components/SafeSolutionThrowerComponent.cs new file mode 100644 index 0000000000..2a0456a593 --- /dev/null +++ b/Content.Shared/_DV/Chemistry/Components/SafeSolutionThrowerComponent.cs @@ -0,0 +1,10 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared._DV.Chemistry.Components; + +/// +/// 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. +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class SafeSolutionThrowerComponent : Component; diff --git a/Content.Shared/_DV/Chemistry/Systems/SafeSolutionThrowerSystem.cs b/Content.Shared/_DV/Chemistry/Systems/SafeSolutionThrowerSystem.cs new file mode 100644 index 0000000000..cf01b34553 --- /dev/null +++ b/Content.Shared/_DV/Chemistry/Systems/SafeSolutionThrowerSystem.cs @@ -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(_inventory.RelayEvent); + Subs.SubscribeWithRelay(OnSafeSolutionThrowAttempt); + } + + /// + /// Call this to check if a player can throw a solution safely. + /// + public bool GetSafeThrow(EntityUid playeruid) + { + var safeThrowEvent = new SafeSolutionThrowEvent(); + RaiseLocalEvent(playeruid, ref safeThrowEvent); + return safeThrowEvent.SafeThrow; + } + + private void OnSafeSolutionThrowAttempt(Entity ent, ref SafeSolutionThrowEvent args) + { + args.SafeThrow = true; + } +} + +/// +/// Raised on an entity and its inventory to determine if it can throw spillable objects safely. +/// +[ByRefEvent] +public record struct SafeSolutionThrowEvent(bool SafeThrow = false) : IInventoryRelayEvent +{ + SlotFlags IInventoryRelayEvent.TargetSlots => SlotFlags.HEAD | SlotFlags.MASK | SlotFlags.EYES; +} diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml b/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml index 98bb4f1c3c..0d48788332 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml @@ -107,6 +107,7 @@ - type: StealTarget stealGroup: ClothingEyesHudBeer - type: SolutionScanner + - type: SafeSolutionThrower # DeltaV - Beergoggles enable safe throw - type: entity parent: ClothingEyesBase