]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add ability to shake fizzy drinks so they spray in peoples' faces (#25574)
authorTayrtahn <tayrtahn@gmail.com>
Thu, 18 Apr 2024 01:49:58 +0000 (21:49 -0400)
committerGitHub <noreply@github.com>
Thu, 18 Apr 2024 01:49:58 +0000 (11:49 +1000)
* Implemented Shakeable

* Prevent shaking open Openables

* Prevent shaking empty drinks. Moved part of DrinkSystem to Shared.

* DrinkSystem can have a little more prediction, as a treat

* Cleanup

* Overhauled PressurizedDrink

* Make soda cans/bottles and champagne shakeable. The drink shaker too, for fun.

* We do a little refactoring.
PressurizedDrink is now PressurizedSolution, and fizziness now only works on solutions containing a reagent marked as fizzy.

* Documentation, cleanup, and tweaks.

* Changed fizziness calculation to use a cubic-out easing curve.

* Removed broken YAML that has avoid the linter's wrath for far too long

* Changed reagent fizzy bool to fizziness float.
Solution fizzability now scales with reagent proportion.

* Rename file to match changed class name

* DoAfter improvements. Cancel if the user moves away; block if no hands.

* Match these filenames too

* And this one

* guh

* Updated to use Shared puddle methods

* Various fixes and improvements.

* Made AttemptShakeEvent a struct

* AttemptAddFizzinessEvent too

25 files changed:
Content.Client/Nutrition/EntitySystems/DrinkSystem.cs [new file with mode: 0644]
Content.Server/Nutrition/Components/PressurizedDrinkComponent.cs [deleted file]
Content.Server/Nutrition/EntitySystems/DrinkSystem.cs
Content.Shared/Chemistry/Reagent/ReagentPrototype.cs
Content.Shared/Nutrition/Components/DrinkComponent.cs [moved from Content.Server/Nutrition/Components/DrinkComponent.cs with 66% similarity]
Content.Shared/Nutrition/Components/PressurizedSolutionComponent.cs [new file with mode: 0644]
Content.Shared/Nutrition/Components/ShakeableComponent.cs [new file with mode: 0644]
Content.Shared/Nutrition/EntitySystems/OpenableSystem.cs
Content.Shared/Nutrition/EntitySystems/PressurizedSolutionSystem.cs [new file with mode: 0644]
Content.Shared/Nutrition/EntitySystems/ShakeableSystem.cs [new file with mode: 0644]
Content.Shared/Nutrition/EntitySystems/SharedDrinkSystem.cs [new file with mode: 0644]
Resources/Audio/Items/attributions.yml
Resources/Audio/Items/soda_shake.ogg [new file with mode: 0644]
Resources/Audio/Items/soda_spray.ogg [new file with mode: 0644]
Resources/Locale/en-US/nutrition/components/pressurized-solution-component.ftl [new file with mode: 0644]
Resources/Locale/en-US/nutrition/components/shakeable-component.ftl [new file with mode: 0644]
Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks-cartons.yml
Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_bottles.yml
Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_cans.yml
Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_fun.yml
Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_special.yml
Resources/Prototypes/Reagents/Consumable/Drink/alcohol.yml
Resources/Prototypes/Reagents/Consumable/Drink/base_drink.yml
Resources/Prototypes/Reagents/Consumable/Drink/drinks.yml
Resources/Prototypes/Reagents/Consumable/Drink/soda.yml

diff --git a/Content.Client/Nutrition/EntitySystems/DrinkSystem.cs b/Content.Client/Nutrition/EntitySystems/DrinkSystem.cs
new file mode 100644 (file)
index 0000000..16dbecb
--- /dev/null
@@ -0,0 +1,7 @@
+using Content.Shared.Nutrition.EntitySystems;
+
+namespace Content.Client.Nutrition.EntitySystems;
+
+public sealed class DrinkSystem : SharedDrinkSystem
+{
+}
diff --git a/Content.Server/Nutrition/Components/PressurizedDrinkComponent.cs b/Content.Server/Nutrition/Components/PressurizedDrinkComponent.cs
deleted file mode 100644 (file)
index aafb3bc..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-using Content.Server.Nutrition.EntitySystems;
-using Robust.Shared.Audio;
-
-namespace Content.Server.Nutrition.Components;
-
-/// <summary>
-/// Lets a drink burst open when thrown while closed.
-/// Requires <see cref="DrinkComponent"/> and <see cref="OpenableComponent"/> to work.
-/// </summary>
-[RegisterComponent, Access(typeof(DrinkSystem))]
-public sealed partial class PressurizedDrinkComponent : Component
-{
-    /// <summary>
-    /// Chance for the drink to burst when thrown while closed.
-    /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
-    public float BurstChance = 0.25f;
-
-    /// <summary>
-    /// Sound played when the drink bursts.
-    /// </summary>
-    [DataField]
-    public SoundSpecifier BurstSound = new SoundPathSpecifier("/Audio/Effects/flash_bang.ogg")
-    {
-        Params = AudioParams.Default.WithVolume(-4)
-    };
-}
index 74637d4813709fab565dc7505b7aa8eed24e15e2..aa2ed71d8f36ecfd4be76dc665e5cf54e9742933 100644 (file)
@@ -5,7 +5,6 @@ using Content.Server.Chemistry.ReagentEffects;
 using Content.Server.Fluids.EntitySystems;
 using Content.Server.Forensics;
 using Content.Server.Inventory;
-using Content.Server.Nutrition.Components;
 using Content.Server.Popups;
 using Content.Shared.Administration.Logs;
 using Content.Shared.Body.Components;
@@ -16,7 +15,6 @@ using Content.Shared.Chemistry.EntitySystems;
 using Content.Shared.Chemistry.Reagent;
 using Content.Shared.Database;
 using Content.Shared.DoAfter;
-using Content.Shared.Examine;
 using Content.Shared.FixedPoint;
 using Content.Shared.IdentityManagement;
 using Content.Shared.Interaction;
@@ -25,24 +23,21 @@ using Content.Shared.Mobs.Systems;
 using Content.Shared.Nutrition;
 using Content.Shared.Nutrition.Components;
 using Content.Shared.Nutrition.EntitySystems;
-using Content.Shared.Throwing;
 using Content.Shared.Verbs;
 using Robust.Shared.Audio;
 using Robust.Shared.Audio.Systems;
 using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
-using Robust.Shared.Random;
 using Robust.Shared.Utility;
 
 namespace Content.Server.Nutrition.EntitySystems;
 
-public sealed class DrinkSystem : EntitySystem
+public sealed class DrinkSystem : SharedDrinkSystem
 {
     [Dependency] private readonly BodySystem _body = default!;
     [Dependency] private readonly FlavorProfileSystem _flavorProfile = default!;
     [Dependency] private readonly FoodSystem _food = default!;
     [Dependency] private readonly IPrototypeManager _proto = default!;
-    [Dependency] private readonly IRobustRandom _random = default!;
     [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
     [Dependency] private readonly MobStateSystem _mobState = default!;
     [Dependency] private readonly OpenableSystem _openable = default!;
@@ -66,33 +61,10 @@ public sealed class DrinkSystem : EntitySystem
         SubscribeLocalEvent<DrinkComponent, ComponentInit>(OnDrinkInit);
         // run before inventory so for bucket it always tries to drink before equipping (when empty)
         // run after openable so its always open -> drink
-        SubscribeLocalEvent<DrinkComponent, UseInHandEvent>(OnUse, before: new[] { typeof(ServerInventorySystem) }, after: new[] { typeof(OpenableSystem) });
+        SubscribeLocalEvent<DrinkComponent, UseInHandEvent>(OnUse, before: [typeof(ServerInventorySystem)], after: [typeof(OpenableSystem)]);
         SubscribeLocalEvent<DrinkComponent, AfterInteractEvent>(AfterInteract);
         SubscribeLocalEvent<DrinkComponent, GetVerbsEvent<AlternativeVerb>>(AddDrinkVerb);
-        // put drink amount after opened
-        SubscribeLocalEvent<DrinkComponent, ExaminedEvent>(OnExamined, after: new[] { typeof(OpenableSystem) });
         SubscribeLocalEvent<DrinkComponent, ConsumeDoAfterEvent>(OnDoAfter);
-
-        SubscribeLocalEvent<PressurizedDrinkComponent, LandEvent>(OnPressurizedDrinkLand);
-    }
-
-    private FixedPoint2 DrinkVolume(EntityUid uid, DrinkComponent? component = null)
-    {
-        if (!Resolve(uid, ref component))
-            return FixedPoint2.Zero;
-
-        if (!_solutionContainer.TryGetSolution(uid, component.Solution, out _, out var sol))
-            return FixedPoint2.Zero;
-
-        return sol.Volume;
-    }
-
-    public bool IsEmpty(EntityUid uid, DrinkComponent? component = null)
-    {
-        if (!Resolve(uid, ref component))
-            return true;
-
-        return DrinkVolume(uid, component) <= 0;
     }
 
     /// <summary>
@@ -129,38 +101,6 @@ public sealed class DrinkSystem : EntitySystem
         return total;
     }
 
-    private void OnExamined(Entity<DrinkComponent> entity, ref ExaminedEvent args)
-    {
-        TryComp<OpenableComponent>(entity, out var openable);
-        if (_openable.IsClosed(entity.Owner, null, openable) || !args.IsInDetailsRange || !entity.Comp.Examinable)
-            return;
-
-        var empty = IsEmpty(entity, entity.Comp);
-        if (empty)
-        {
-            args.PushMarkup(Loc.GetString("drink-component-on-examine-is-empty"));
-            return;
-        }
-
-        if (HasComp<ExaminableSolutionComponent>(entity))
-        {
-            //provide exact measurement for beakers
-            args.PushText(Loc.GetString("drink-component-on-examine-exact-volume", ("amount", DrinkVolume(entity, entity.Comp))));
-        }
-        else
-        {
-            //general approximation
-            var remainingString = (int) _solutionContainer.PercentFull(entity) switch
-            {
-                100 => "drink-component-on-examine-is-full",
-                > 66 => "drink-component-on-examine-is-mostly-full",
-                > 33 => HalfEmptyOrHalfFull(args),
-                _ => "drink-component-on-examine-is-mostly-empty",
-            };
-            args.PushMarkup(Loc.GetString(remainingString));
-        }
-    }
-
     private void AfterInteract(Entity<DrinkComponent> entity, ref AfterInteractEvent args)
     {
         if (args.Handled || args.Target == null || !args.CanReach)
@@ -177,25 +117,6 @@ public sealed class DrinkSystem : EntitySystem
         args.Handled = TryDrink(args.User, args.User, entity.Comp, entity);
     }
 
-    private void OnPressurizedDrinkLand(Entity<PressurizedDrinkComponent> entity, ref LandEvent args)
-    {
-        if (!TryComp<DrinkComponent>(entity, out var drink) || !TryComp<OpenableComponent>(entity, out var openable))
-            return;
-
-        if (!openable.Opened &&
-            _random.Prob(entity.Comp.BurstChance) &&
-            _solutionContainer.TryGetSolution(entity.Owner, drink.Solution, out var soln, out var interactions))
-        {
-            // using SetOpen instead of TryOpen to not play 2 sounds
-            _openable.SetOpen(entity, true, openable);
-
-            var solution = _solutionContainer.SplitSolution(soln.Value, interactions.Volume);
-            _puddle.TrySpillAt(entity, solution, out _);
-
-            _audio.PlayPvs(entity.Comp.BurstSound, entity);
-        }
-    }
-
     private void OnDrinkInit(Entity<DrinkComponent> entity, ref ComponentInit args)
     {
         if (TryComp<DrainableSolutionComponent>(entity, out var existingDrainable))
@@ -433,16 +354,4 @@ public sealed class DrinkSystem : EntitySystem
 
         ev.Verbs.Add(verb);
     }
-
-    // some see half empty, and others see half full
-    private string HalfEmptyOrHalfFull(ExaminedEvent args)
-    {
-        string remainingString = "drink-component-on-examine-is-half-full";
-
-        if (TryComp<MetaDataComponent>(args.Examiner, out var examiner) && examiner.EntityName.Length > 0
-            && string.Compare(examiner.EntityName.Substring(0, 1), "m", StringComparison.InvariantCultureIgnoreCase) > 0)
-            remainingString = "drink-component-on-examine-is-half-empty";
-
-        return remainingString;
-    }
 }
index 5d6d9d21208efce5e063d8ec88732f391da02ca4..df1b1aa20b49bf26521361dd1c1259c6e1da3a3a 100644 (file)
@@ -104,6 +104,13 @@ namespace Content.Shared.Chemistry.Reagent
         [DataField]
         public bool Slippery;
 
+        /// <summary>
+        /// How easily this reagent becomes fizzy when aggitated.
+        /// 0 - completely flat, 1 - fizzes up when nudged.
+        /// </summary>
+        [DataField]
+        public float Fizziness;
+
         /// <summary>
         /// How much reagent slows entities down if it's part of a puddle.
         /// 0 - no slowdown; 1 - can't move.
similarity index 66%
rename from Content.Server/Nutrition/Components/DrinkComponent.cs
rename to Content.Shared/Nutrition/Components/DrinkComponent.cs
index 20d47cda88c97cbc04e0b544ca8da1e4a67984a0..17baaef5a37ca982f9b19962857cac036ad45791 100644 (file)
@@ -1,28 +1,30 @@
-using Content.Server.Nutrition.EntitySystems;
+using Content.Shared.Nutrition.EntitySystems;
 using Content.Shared.FixedPoint;
 using Robust.Shared.Audio;
+using Robust.Shared.GameStates;
 
-namespace Content.Server.Nutrition.Components;
+namespace Content.Shared.Nutrition.Components;
 
-[RegisterComponent, Access(typeof(DrinkSystem))]
+[NetworkedComponent, AutoGenerateComponentState]
+[RegisterComponent, Access(typeof(SharedDrinkSystem))]
 public sealed partial class DrinkComponent : Component
 {
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public string Solution = "drink";
 
-    [DataField]
+    [DataField, AutoNetworkedField]
     public SoundSpecifier UseSound = new SoundPathSpecifier("/Audio/Items/drink.ogg");
 
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField, AutoNetworkedField]
     public FixedPoint2 TransferAmount = FixedPoint2.New(5);
 
     /// <summary>
     /// How long it takes to drink this yourself.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField, AutoNetworkedField]
     public float Delay = 1;
 
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField, AutoNetworkedField]
     public bool Examinable = true;
 
     /// <summary>
@@ -30,12 +32,12 @@ public sealed partial class DrinkComponent : Component
     /// This means other systems such as equipping on use can run.
     /// Example usecase is the bucket.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public bool IgnoreEmpty;
 
     /// <summary>
     ///     This is how many seconds it takes to force feed someone this drink.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField, AutoNetworkedField]
     public float ForceFeedDelay = 3;
 }
diff --git a/Content.Shared/Nutrition/Components/PressurizedSolutionComponent.cs b/Content.Shared/Nutrition/Components/PressurizedSolutionComponent.cs
new file mode 100644 (file)
index 0000000..7060f3b
--- /dev/null
@@ -0,0 +1,106 @@
+using Content.Shared.Nutrition.EntitySystems;
+using Robust.Shared.Audio;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Nutrition.Components;
+
+/// <summary>
+/// Represents a solution container that can hold the pressure from a solution that
+/// gets fizzy when aggitated, and can spray the solution when opened or thrown.
+/// Handles simulating the fizziness of the solution, responding to aggitating events,
+/// and spraying the solution out when opening or throwing the entity.
+/// </summary>
+[NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
+[RegisterComponent, Access(typeof(PressurizedSolutionSystem))]
+public sealed partial class PressurizedSolutionComponent : Component
+{
+    /// <summary>
+    /// The name of the solution to use.
+    /// </summary>
+    [DataField]
+    public string Solution = "drink";
+
+    /// <summary>
+    /// The sound to play when the solution sprays out of the container.
+    /// </summary>
+    [DataField]
+    public SoundSpecifier SpraySound = new SoundPathSpecifier("/Audio/Items/soda_spray.ogg");
+
+    /// <summary>
+    /// The longest amount of time that the solution can remain fizzy after being aggitated.
+    /// Put another way, how long the solution will remain fizzy when aggitated the maximum amount.
+    /// Used to calculate the current fizziness level.
+    /// </summary>
+    [DataField]
+    public TimeSpan FizzinessMaxDuration = TimeSpan.FromSeconds(120);
+
+    /// <summary>
+    /// The time at which the solution will be fully settled after being shaken.
+    /// </summary>
+    [DataField, AutoNetworkedField, AutoPausedField]
+    public TimeSpan FizzySettleTime;
+
+    /// <summary>
+    /// How much to increase the solution's fizziness each time it's shaken.
+    /// This assumes the solution has maximum fizzability.
+    /// A value of 1 will maximize it with a single shake, and a value of
+    /// 0.5 will increase it by half with each shake.
+    /// </summary>
+    [DataField]
+    public float FizzinessAddedOnShake = 1.0f;
+
+    /// <summary>
+    /// How much to increase the solution's fizziness when it lands after being thrown.
+    /// This assumes the solution has maximum fizzability.
+    /// </summary>
+    [DataField]
+    public float FizzinessAddedOnLand = 0.25f;
+
+    /// <summary>
+    /// How much to modify the chance of spraying when the entity is opened.
+    /// Increasing this effectively increases the fizziness value when checking if it should spray.
+    /// </summary>
+    [DataField]
+    public float SprayChanceModOnOpened = -0.01f; // Just enough to prevent spraying at 0 fizziness
+
+    /// <summary>
+    /// How much to modify the chance of spraying when the entity is shaken.
+    /// Increasing this effectively increases the fizziness value when checking if it should spray.
+    /// </summary>
+    [DataField]
+    public float SprayChanceModOnShake = -1; // No spraying when shaken by default
+
+    /// <summary>
+    /// How much to modify the chance of spraying when the entity lands after being thrown.
+    /// Increasing this effectively increases the fizziness value when checking if it should spray.
+    /// </summary>
+    [DataField]
+    public float SprayChanceModOnLand = 0.25f;
+
+    /// <summary>
+    /// Holds the current randomly-rolled threshold value for spraying.
+    /// If fizziness exceeds this value when the entity is opened, it will spray.
+    /// By rolling this value when the entity is aggitated, we can have randomization
+    /// while still having prediction!
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public float SprayFizzinessThresholdRoll;
+
+    /// <summary>
+    /// Popup message shown to user when sprayed by the solution.
+    /// </summary>
+    [DataField]
+    public LocId SprayHolderMessageSelf = "pressurized-solution-spray-holder-self";
+
+    /// <summary>
+    /// Popup message shown to others when a user is sprayed by the solution.
+    /// </summary>
+    [DataField]
+    public LocId SprayHolderMessageOthers = "pressurized-solution-spray-holder-others";
+
+    /// <summary>
+    /// Popup message shown above the entity when the solution sprays without a target.
+    /// </summary>
+    [DataField]
+    public LocId SprayGroundMessage = "pressurized-solution-spray-ground";
+}
diff --git a/Content.Shared/Nutrition/Components/ShakeableComponent.cs b/Content.Shared/Nutrition/Components/ShakeableComponent.cs
new file mode 100644 (file)
index 0000000..cc1c08a
--- /dev/null
@@ -0,0 +1,50 @@
+using Robust.Shared.Audio;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Nutrition.Components;
+
+/// <summary>
+/// Adds a "Shake" verb to the entity's verb menu.
+/// Handles checking the entity can be shaken, displaying popups when shaking,
+/// and raising a ShakeEvent when a shake occurs.
+/// Reacting to being shaken is left up to other components.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class ShakeableComponent : Component
+{
+    /// <summary>
+    /// How long it takes to shake this item.
+    /// </summary>
+    [DataField]
+    public TimeSpan ShakeDuration = TimeSpan.FromSeconds(1f);
+
+    /// <summary>
+    /// Does the entity need to be in the user's hand in order to be shaken?
+    /// </summary>
+    [DataField]
+    public bool RequireInHand;
+
+    /// <summary>
+    /// Label to display in the verbs menu for this item's shake action.
+    /// </summary>
+    [DataField]
+    public LocId ShakeVerbText = "shakeable-verb";
+
+    /// <summary>
+    /// Text that will be displayed to the user when shaking this item.
+    /// </summary>
+    [DataField]
+    public LocId ShakePopupMessageSelf = "shakeable-popup-message-self";
+
+    /// <summary>
+    /// Text that will be displayed to other users when someone shakes this item.
+    /// </summary>
+    [DataField]
+    public LocId ShakePopupMessageOthers = "shakeable-popup-message-others";
+
+    /// <summary>
+    /// The sound that will be played when shaking this item.
+    /// </summary>
+    [DataField]
+    public SoundSpecifier ShakeSound = new SoundPathSpecifier("/Audio/Items/soda_shake.ogg");
+}
index 0ad0877d2220e84954ff6cd37a624ae20d090ec9..2934ced8b4a7107e7e034e08453ad60cec115d65 100644 (file)
@@ -16,9 +16,9 @@ namespace Content.Shared.Nutrition.EntitySystems;
 /// </summary>
 public sealed partial class OpenableSystem : EntitySystem
 {
-    [Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
-    [Dependency] protected readonly SharedAudioSystem Audio = default!;
-    [Dependency] protected readonly SharedPopupSystem Popup = default!;
+    [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+    [Dependency] private readonly SharedAudioSystem _audio = default!;
+    [Dependency] private readonly SharedPopupSystem _popup = default!;
 
     public override void Initialize()
     {
@@ -31,6 +31,8 @@ public sealed partial class OpenableSystem : EntitySystem
         SubscribeLocalEvent<OpenableComponent, AfterInteractEvent>(HandleIfClosed);
         SubscribeLocalEvent<OpenableComponent, GetVerbsEvent<Verb>>(AddOpenCloseVerbs);
         SubscribeLocalEvent<OpenableComponent, SolutionTransferAttemptEvent>(OnTransferAttempt);
+        SubscribeLocalEvent<OpenableComponent, AttemptShakeEvent>(OnAttemptShake);
+        SubscribeLocalEvent<OpenableComponent, AttemptAddFizzinessEvent>(OnAttemptAddFizziness);
     }
 
     private void OnInit(EntityUid uid, OpenableComponent comp, ComponentInit args)
@@ -100,6 +102,20 @@ public sealed partial class OpenableSystem : EntitySystem
         }
     }
 
+    private void OnAttemptShake(Entity<OpenableComponent> entity, ref AttemptShakeEvent args)
+    {
+        // Prevent shaking open containers
+        if (entity.Comp.Opened)
+            args.Cancelled = true;
+    }
+
+    private void OnAttemptAddFizziness(Entity<OpenableComponent> entity, ref AttemptAddFizzinessEvent args)
+    {
+        // Can't add fizziness to an open container
+        if (entity.Comp.Opened)
+            args.Cancelled = true;
+    }
+
     /// <summary>
     /// Returns true if the entity either does not have OpenableComponent or it is opened.
     /// Drinks that don't have OpenableComponent are automatically open, so it returns true.
@@ -126,7 +142,7 @@ public sealed partial class OpenableSystem : EntitySystem
             return false;
 
         if (user != null)
-            Popup.PopupEntity(Loc.GetString(comp.ClosedPopup, ("owner", uid)), user.Value, user.Value);
+            _popup.PopupEntity(Loc.GetString(comp.ClosedPopup, ("owner", uid)), user.Value, user.Value);
 
         return true;
     }
@@ -139,13 +155,13 @@ public sealed partial class OpenableSystem : EntitySystem
         if (!Resolve(uid, ref comp))
             return;
 
-        Appearance.SetData(uid, OpenableVisuals.Opened, comp.Opened, appearance);
+        _appearance.SetData(uid, OpenableVisuals.Opened, comp.Opened, appearance);
     }
 
     /// <summary>
     /// Sets the opened field and updates open visuals.
     /// </summary>
-    public void SetOpen(EntityUid uid, bool opened = true, OpenableComponent? comp = null)
+    public void SetOpen(EntityUid uid, bool opened = true, OpenableComponent? comp = null, EntityUid? user = null)
     {
         if (!Resolve(uid, ref comp, false) || opened == comp.Opened)
             return;
@@ -155,12 +171,12 @@ public sealed partial class OpenableSystem : EntitySystem
 
         if (opened)
         {
-            var ev = new OpenableOpenedEvent();
+            var ev = new OpenableOpenedEvent(user);
             RaiseLocalEvent(uid, ref ev);
         }
         else
         {
-            var ev = new OpenableClosedEvent();
+            var ev = new OpenableClosedEvent(user);
             RaiseLocalEvent(uid, ref ev);
         }
 
@@ -176,8 +192,8 @@ public sealed partial class OpenableSystem : EntitySystem
         if (!Resolve(uid, ref comp, false) || comp.Opened)
             return false;
 
-        SetOpen(uid, true, comp);
-        Audio.PlayPredicted(comp.Sound, uid, user);
+        SetOpen(uid, true, comp, user);
+        _audio.PlayPredicted(comp.Sound, uid, user);
         return true;
     }
 
@@ -190,9 +206,9 @@ public sealed partial class OpenableSystem : EntitySystem
         if (!Resolve(uid, ref comp, false) || !comp.Opened || !comp.Closeable)
             return false;
 
-        SetOpen(uid, false, comp);
+        SetOpen(uid, false, comp, user);
         if (comp.CloseSound != null)
-            Audio.PlayPredicted(comp.CloseSound, uid, user);
+            _audio.PlayPredicted(comp.CloseSound, uid, user);
         return true;
     }
 }
@@ -201,10 +217,10 @@ public sealed partial class OpenableSystem : EntitySystem
 /// Raised after an Openable is opened.
 /// </summary>
 [ByRefEvent]
-public record struct OpenableOpenedEvent;
+public record struct OpenableOpenedEvent(EntityUid? User = null);
 
 /// <summary>
 /// Raised after an Openable is closed.
 /// </summary>
 [ByRefEvent]
-public record struct OpenableClosedEvent;
+public record struct OpenableClosedEvent(EntityUid? User = null);
diff --git a/Content.Shared/Nutrition/EntitySystems/PressurizedSolutionSystem.cs b/Content.Shared/Nutrition/EntitySystems/PressurizedSolutionSystem.cs
new file mode 100644 (file)
index 0000000..d63b8e7
--- /dev/null
@@ -0,0 +1,285 @@
+using Content.Shared.Chemistry.Reagent;
+using Content.Shared.Chemistry.EntitySystems;
+using Content.Shared.Hands.EntitySystems;
+using Content.Shared.Nutrition.Components;
+using Content.Shared.Throwing;
+using Content.Shared.IdentityManagement;
+using Robust.Shared.Audio.Systems;
+using Robust.Shared.Random;
+using Robust.Shared.Timing;
+using Robust.Shared.Prototypes;
+using Robust.Shared.Network;
+using Content.Shared.Fluids;
+using Content.Shared.Popups;
+
+namespace Content.Shared.Nutrition.EntitySystems;
+
+public sealed partial class PressurizedSolutionSystem : EntitySystem
+{
+    [Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
+    [Dependency] private readonly OpenableSystem _openable = default!;
+    [Dependency] private readonly SharedAudioSystem _audio = default!;
+    [Dependency] private readonly SharedHandsSystem _hands = default!;
+    [Dependency] private readonly SharedPopupSystem _popup = default!;
+    [Dependency] private readonly SharedPuddleSystem _puddle = default!;
+    [Dependency] private readonly INetManager _net = default!;
+    [Dependency] private readonly IGameTiming _timing = default!;
+    [Dependency] private readonly IRobustRandom _random = default!;
+    [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<PressurizedSolutionComponent, MapInitEvent>(OnMapInit);
+        SubscribeLocalEvent<PressurizedSolutionComponent, ShakeEvent>(OnShake);
+        SubscribeLocalEvent<PressurizedSolutionComponent, OpenableOpenedEvent>(OnOpened);
+        SubscribeLocalEvent<PressurizedSolutionComponent, LandEvent>(OnLand);
+        SubscribeLocalEvent<PressurizedSolutionComponent, SolutionContainerChangedEvent>(OnSolutionUpdate);
+    }
+
+    /// <summary>
+    /// Helper method for checking if the solution's fizziness is high enough to spray.
+    /// <paramref name="chanceMod"/> is added to the actual fizziness for the comparison.
+    /// </summary>
+    private bool SprayCheck(Entity<PressurizedSolutionComponent> entity, float chanceMod = 0)
+    {
+        return Fizziness((entity, entity.Comp)) + chanceMod > entity.Comp.SprayFizzinessThresholdRoll;
+    }
+
+    /// <summary>
+    /// Calculates how readily the contained solution becomes fizzy.
+    /// </summary>
+    private float SolutionFizzability(Entity<PressurizedSolutionComponent> entity)
+    {
+        if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp.Solution, out var _, out var solution))
+            return 0;
+
+        // An empty solution can't be fizzy
+        if (solution.Volume <= 0)
+            return 0;
+
+        var totalFizzability = 0f;
+
+        // Check each reagent in the solution
+        foreach (var reagent in solution.Contents)
+        {
+            if (_prototypeManager.TryIndex(reagent.Reagent.Prototype, out ReagentPrototype? reagentProto) && reagentProto != null)
+            {
+                // What portion of the solution is this reagent?
+                var proportion = (float) (reagent.Quantity / solution.Volume);
+                totalFizzability += reagentProto.Fizziness * proportion;
+            }
+        }
+
+        return totalFizzability;
+    }
+
+    /// <summary>
+    /// Increases the fizziness level of the solution by the given amount,
+    /// scaled by the solution's fizzability.
+    /// 0 will result in no change, and 1 will maximize fizziness.
+    /// Also rerolls the spray threshold.
+    /// </summary>
+    private void AddFizziness(Entity<PressurizedSolutionComponent> entity, float amount)
+    {
+        var fizzability = SolutionFizzability(entity);
+
+        // Can't add fizziness if the solution isn't fizzy
+        if (fizzability <= 0)
+            return;
+
+        // Make sure nothing is preventing fizziness from being added
+        var attemptEv = new AttemptAddFizzinessEvent(entity, amount);
+        RaiseLocalEvent(entity, ref attemptEv);
+        if (attemptEv.Cancelled)
+            return;
+
+        // Scale added fizziness by the solution's fizzability
+        amount *= fizzability;
+
+        // Convert fizziness to time
+        var duration = amount * entity.Comp.FizzinessMaxDuration;
+
+        // Add to the existing settle time, if one exists. Otherwise, add to the current time
+        var start = entity.Comp.FizzySettleTime > _timing.CurTime ? entity.Comp.FizzySettleTime : _timing.CurTime;
+        var newTime = start + duration;
+
+        // Cap the maximum fizziness
+        var maxEnd = _timing.CurTime + entity.Comp.FizzinessMaxDuration;
+        if (newTime > maxEnd)
+            newTime = maxEnd;
+
+        entity.Comp.FizzySettleTime = newTime;
+
+        // Roll a new fizziness threshold
+        RollSprayThreshold(entity);
+    }
+
+    /// <summary>
+    /// Helper method. Performs a <see cref="SprayCheck"/>. If it passes, calls <see cref="TrySpray"/>. If it fails, <see cref="AddFizziness"/>.
+    /// </summary>
+    private void SprayOrAddFizziness(Entity<PressurizedSolutionComponent> entity, float chanceMod = 0, float fizzinessToAdd = 0, EntityUid? user = null)
+    {
+        if (SprayCheck(entity, chanceMod))
+            TrySpray((entity, entity.Comp), user);
+        else
+            AddFizziness(entity, fizzinessToAdd);
+    }
+
+    /// <summary>
+    /// Randomly generates a new spray threshold.
+    /// This is the value used to compare fizziness against when doing <see cref="SprayCheck"/>.
+    /// Since RNG will give different results between client and server, this is run on the server
+    /// and synced to the client by marking the component dirty.
+    /// We roll this in advance, rather than during <see cref="SprayCheck"/>, so that the value (hopefully)
+    /// has time to get synced to the client, so we can try be accurate with prediction.
+    /// </summary>
+    private void RollSprayThreshold(Entity<PressurizedSolutionComponent> entity)
+    {
+        // Can't predict random, so we wait for the server to tell us
+        if (!_net.IsServer)
+            return;
+
+        entity.Comp.SprayFizzinessThresholdRoll = _random.NextFloat();
+        Dirty(entity, entity.Comp);
+    }
+
+    #region Public API
+
+    /// <summary>
+    /// Does the entity contain a solution capable of being fizzy?
+    /// </summary>
+    public bool CanSpray(Entity<PressurizedSolutionComponent?> entity)
+    {
+        if (!Resolve(entity, ref entity.Comp, false))
+            return false;
+
+        return SolutionFizzability((entity, entity.Comp)) > 0;
+    }
+
+    /// <summary>
+    /// Attempts to spray the solution onto the given entity, or the ground if none is given.
+    /// Fails if the solution isn't able to be sprayed.
+    /// </summary>
+    public bool TrySpray(Entity<PressurizedSolutionComponent?> entity, EntityUid? target = null)
+    {
+        if (!Resolve(entity, ref entity.Comp))
+            return false;
+
+        if (!CanSpray(entity))
+            return false;
+
+        if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp.Solution, out var soln, out var interactions))
+            return false;
+
+        // If the container is openable, open it
+        _openable.SetOpen(entity, true);
+
+        // Get the spray solution from the container
+        var solution = _solutionContainer.SplitSolution(soln.Value, interactions.Volume);
+
+        // Spray the solution onto the ground and anyone nearby
+        if (TryComp<TransformComponent>(entity, out var transform))
+            _puddle.TrySplashSpillAt(entity, transform.Coordinates, solution, out _, sound: false);
+
+        var drinkName = Identity.Entity(entity, EntityManager);
+
+        if (target != null)
+        {
+            var victimName = Identity.Entity(target.Value, EntityManager);
+
+            var selfMessage = Loc.GetString(entity.Comp.SprayHolderMessageSelf, ("victim", victimName), ("drink", drinkName));
+            var othersMessage = Loc.GetString(entity.Comp.SprayHolderMessageOthers, ("victim", victimName), ("drink", drinkName));
+            _popup.PopupPredicted(selfMessage, othersMessage, target.Value, target.Value);
+        }
+        else
+        {
+            // Show a popup to everyone in PVS range
+            if (_timing.IsFirstTimePredicted)
+                _popup.PopupEntity(Loc.GetString(entity.Comp.SprayGroundMessage, ("drink", drinkName)), entity);
+        }
+
+        _audio.PlayPredicted(entity.Comp.SpraySound, entity, target);
+
+        // We just used all our fizziness, so clear it
+        TryClearFizziness(entity);
+
+        return true;
+    }
+
+    /// <summary>
+    /// What is the current fizziness level of the solution, from 0 to 1?
+    /// </summary>
+    public double Fizziness(Entity<PressurizedSolutionComponent?> entity)
+    {
+        // No component means no fizz
+        if (!Resolve(entity, ref entity.Comp, false))
+            return 0;
+
+        // No negative fizziness
+        if (entity.Comp.FizzySettleTime <= _timing.CurTime)
+            return 0;
+
+        var currentDuration = entity.Comp.FizzySettleTime - _timing.CurTime;
+        return Easings.InOutCubic((float) Math.Min(currentDuration / entity.Comp.FizzinessMaxDuration, 1));
+    }
+
+    /// <summary>
+    /// Attempts to clear any fizziness in the solution.
+    /// </summary>
+    /// <remarks>Rolls a new spray threshold.</remarks>
+    public void TryClearFizziness(Entity<PressurizedSolutionComponent?> entity)
+    {
+        if (!Resolve(entity, ref entity.Comp))
+            return;
+
+        entity.Comp.FizzySettleTime = TimeSpan.Zero;
+
+        // Roll a new fizziness threshold
+        RollSprayThreshold((entity, entity.Comp));
+    }
+
+    #endregion
+
+    #region Event Handlers
+    private void OnMapInit(Entity<PressurizedSolutionComponent> entity, ref MapInitEvent args)
+    {
+        RollSprayThreshold(entity);
+    }
+
+    private void OnOpened(Entity<PressurizedSolutionComponent> entity, ref OpenableOpenedEvent args)
+    {
+        // Make sure the opener is actually holding the drink
+        var held = args.User != null && _hands.IsHolding(args.User.Value, entity, out _);
+
+        SprayOrAddFizziness(entity, entity.Comp.SprayChanceModOnOpened, -1, held ? args.User : null);
+    }
+
+    private void OnShake(Entity<PressurizedSolutionComponent> entity, ref ShakeEvent args)
+    {
+        SprayOrAddFizziness(entity, entity.Comp.SprayChanceModOnShake, entity.Comp.FizzinessAddedOnShake, args.Shaker);
+    }
+
+    private void OnLand(Entity<PressurizedSolutionComponent> entity, ref LandEvent args)
+    {
+        SprayOrAddFizziness(entity, entity.Comp.SprayChanceModOnLand, entity.Comp.FizzinessAddedOnLand);
+    }
+
+    private void OnSolutionUpdate(Entity<PressurizedSolutionComponent> entity, ref SolutionContainerChangedEvent args)
+    {
+        if (args.SolutionId != entity.Comp.Solution)
+            return;
+
+        // If the solution is no longer capable of being fizzy, clear any built up fizziness
+        if (SolutionFizzability(entity) <= 0)
+            TryClearFizziness((entity, entity.Comp));
+    }
+
+    #endregion
+}
+
+[ByRefEvent]
+public record struct AttemptAddFizzinessEvent(Entity<PressurizedSolutionComponent> Entity, float Amount)
+{
+    public bool Cancelled;
+}
diff --git a/Content.Shared/Nutrition/EntitySystems/ShakeableSystem.cs b/Content.Shared/Nutrition/EntitySystems/ShakeableSystem.cs
new file mode 100644 (file)
index 0000000..39890aa
--- /dev/null
@@ -0,0 +1,155 @@
+using Content.Shared.DoAfter;
+using Content.Shared.Hands.EntitySystems;
+using Content.Shared.IdentityManagement;
+using Content.Shared.Nutrition.Components;
+using Content.Shared.Popups;
+using Content.Shared.Verbs;
+using Robust.Shared.Audio.Systems;
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.Nutrition.EntitySystems;
+
+public sealed partial class ShakeableSystem : EntitySystem
+{
+    [Dependency] private readonly SharedPopupSystem _popup = default!;
+    [Dependency] private readonly SharedAudioSystem _audio = default!;
+    [Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
+    [Dependency] private readonly SharedHandsSystem _hands = default!;
+
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<ShakeableComponent, GetVerbsEvent<Verb>>(AddShakeVerb);
+        SubscribeLocalEvent<ShakeableComponent, ShakeDoAfterEvent>(OnShakeDoAfter);
+    }
+
+    private void AddShakeVerb(EntityUid uid, ShakeableComponent component, GetVerbsEvent<Verb> args)
+    {
+        if (args.Hands == null || !args.CanAccess || !args.CanInteract)
+            return;
+
+        if (!CanShake((uid, component), args.User))
+            return;
+
+        var shakeVerb = new Verb()
+        {
+            Text = Loc.GetString(component.ShakeVerbText),
+            Act = () => TryStartShake((args.Target, component), args.User)
+        };
+        args.Verbs.Add(shakeVerb);
+    }
+
+    private void OnShakeDoAfter(Entity<ShakeableComponent> entity, ref ShakeDoAfterEvent args)
+    {
+        if (args.Handled || args.Cancelled)
+            return;
+
+        TryShake((entity, entity.Comp), args.User);
+    }
+
+    /// <summary>
+    /// Attempts to start the doAfter to shake the entity.
+    /// Fails and returns false if the entity cannot be shaken for any reason.
+    /// If successful, displays popup messages, plays shake sound, and starts the doAfter.
+    /// </summary>
+    public bool TryStartShake(Entity<ShakeableComponent?> entity, EntityUid user)
+    {
+        if (!Resolve(entity, ref entity.Comp))
+            return false;
+
+        if (!CanShake(entity, user))
+            return false;
+
+        var doAfterArgs = new DoAfterArgs(EntityManager,
+            user,
+            entity.Comp.ShakeDuration,
+            new ShakeDoAfterEvent(),
+            eventTarget: entity,
+            target: user,
+            used: entity)
+        {
+            NeedHand = true,
+            BreakOnDamage = true,
+            DistanceThreshold = 1,
+            MovementThreshold = 0.01f,
+            BreakOnHandChange = entity.Comp.RequireInHand,
+        };
+        if (entity.Comp.RequireInHand)
+            doAfterArgs.BreakOnHandChange = true;
+
+        if (!_doAfter.TryStartDoAfter(doAfterArgs))
+            return false;
+
+        var userName = Identity.Entity(user, EntityManager);
+        var shakeableName = Identity.Entity(entity, EntityManager);
+
+        var selfMessage = Loc.GetString(entity.Comp.ShakePopupMessageSelf, ("user", userName), ("shakeable", shakeableName));
+        var othersMessage = Loc.GetString(entity.Comp.ShakePopupMessageOthers, ("user", userName), ("shakeable", shakeableName));
+        _popup.PopupPredicted(selfMessage, othersMessage, user, user);
+
+        _audio.PlayPredicted(entity.Comp.ShakeSound, entity, user);
+
+        return true;
+    }
+
+    /// <summary>
+    /// Attempts to shake the entity, skipping the doAfter.
+    /// Fails and returns false if the entity cannot be shaken for any reason.
+    /// If successful, raises a ShakeEvent on the entity.
+    /// </summary>
+    public bool TryShake(Entity<ShakeableComponent?> entity, EntityUid? user = null)
+    {
+        if (!Resolve(entity, ref entity.Comp))
+            return false;
+
+        if (!CanShake(entity, user))
+            return false;
+
+        var ev = new ShakeEvent(user);
+        RaiseLocalEvent(entity, ref ev);
+
+        return true;
+    }
+
+
+    /// <summary>
+    /// Is it possible for the given user to shake the entity?
+    /// </summary>
+    public bool CanShake(Entity<ShakeableComponent?> entity, EntityUid? user = null)
+    {
+        if (!Resolve(entity, ref entity.Comp, false))
+            return false;
+
+        // If required to be in hand, fail if the user is not holding this entity
+        if (user != null && entity.Comp.RequireInHand && !_hands.IsHolding(user.Value, entity, out _))
+            return false;
+
+        var attemptEv = new AttemptShakeEvent();
+        RaiseLocalEvent(entity, ref attemptEv);
+        if (attemptEv.Cancelled)
+            return false;
+        return true;
+    }
+}
+
+/// <summary>
+/// Raised when a ShakeableComponent is shaken, after the doAfter completes.
+/// </summary>
+[ByRefEvent]
+public record struct ShakeEvent(EntityUid? Shaker);
+
+/// <summary>
+/// Raised when trying to shake a ShakeableComponent. If cancelled, the
+/// entity will not be shaken.
+/// </summary>
+[ByRefEvent]
+public record struct AttemptShakeEvent()
+{
+    public bool Cancelled;
+}
+
+[Serializable, NetSerializable]
+public sealed partial class ShakeDoAfterEvent : SimpleDoAfterEvent
+{
+}
diff --git a/Content.Shared/Nutrition/EntitySystems/SharedDrinkSystem.cs b/Content.Shared/Nutrition/EntitySystems/SharedDrinkSystem.cs
new file mode 100644 (file)
index 0000000..7cae3b9
--- /dev/null
@@ -0,0 +1,90 @@
+using Content.Shared.Chemistry.Components.SolutionManager;
+using Content.Shared.Chemistry.EntitySystems;
+using Content.Shared.Examine;
+using Content.Shared.FixedPoint;
+using Content.Shared.Nutrition.Components;
+
+namespace Content.Shared.Nutrition.EntitySystems;
+
+public abstract partial class SharedDrinkSystem : EntitySystem
+{
+    [Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
+    [Dependency] private readonly OpenableSystem _openable = default!;
+
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<DrinkComponent, AttemptShakeEvent>(OnAttemptShake);
+        SubscribeLocalEvent<DrinkComponent, ExaminedEvent>(OnExamined);
+    }
+
+    protected void OnAttemptShake(Entity<DrinkComponent> entity, ref AttemptShakeEvent args)
+    {
+        if (IsEmpty(entity, entity.Comp))
+            args.Cancelled = true;
+    }
+
+    protected void OnExamined(Entity<DrinkComponent> entity, ref ExaminedEvent args)
+    {
+        TryComp<OpenableComponent>(entity, out var openable);
+        if (_openable.IsClosed(entity.Owner, null, openable) || !args.IsInDetailsRange || !entity.Comp.Examinable)
+            return;
+
+        var empty = IsEmpty(entity, entity.Comp);
+        if (empty)
+        {
+            args.PushMarkup(Loc.GetString("drink-component-on-examine-is-empty"));
+            return;
+        }
+
+        if (HasComp<ExaminableSolutionComponent>(entity))
+        {
+            //provide exact measurement for beakers
+            args.PushText(Loc.GetString("drink-component-on-examine-exact-volume", ("amount", DrinkVolume(entity, entity.Comp))));
+        }
+        else
+        {
+            //general approximation
+            var remainingString = (int) _solutionContainer.PercentFull(entity) switch
+            {
+                100 => "drink-component-on-examine-is-full",
+                > 66 => "drink-component-on-examine-is-mostly-full",
+                > 33 => HalfEmptyOrHalfFull(args),
+                _ => "drink-component-on-examine-is-mostly-empty",
+            };
+            args.PushMarkup(Loc.GetString(remainingString));
+        }
+    }
+
+    protected FixedPoint2 DrinkVolume(EntityUid uid, DrinkComponent? component = null)
+    {
+        if (!Resolve(uid, ref component))
+            return FixedPoint2.Zero;
+
+        if (!_solutionContainer.TryGetSolution(uid, component.Solution, out _, out var sol))
+            return FixedPoint2.Zero;
+
+        return sol.Volume;
+    }
+
+    protected bool IsEmpty(EntityUid uid, DrinkComponent? component = null)
+    {
+        if (!Resolve(uid, ref component))
+            return true;
+
+        return DrinkVolume(uid, component) <= 0;
+    }
+
+    // some see half empty, and others see half full
+    private string HalfEmptyOrHalfFull(ExaminedEvent args)
+    {
+        string remainingString = "drink-component-on-examine-is-half-full";
+
+        if (TryComp<MetaDataComponent>(args.Examiner, out var examiner) && examiner.EntityName.Length > 0
+            && string.Compare(examiner.EntityName.Substring(0, 1), "m", StringComparison.InvariantCultureIgnoreCase) > 0)
+            remainingString = "drink-component-on-examine-is-half-empty";
+
+        return remainingString;
+    }
+}
index c6fea50bd2505d48d49eb43a7abfa07c2576c463..675e4fff24ed1a26f610af23f50347300c844179 100644 (file)
   copyright: "User Hanbaal on freesound.org. Converted to ogg by TheShuEd"
   source: "https://freesound.org/people/Hanbaal/sounds/178669/"
 
+- files: ["soda_shake.ogg"]
+  license: "CC-BY-NC-4.0"
+  copyright: "User mcmast on freesound.org. Converted and edited by Tayrtahn"
+  source: "https://freesound.org/people/mcmast/sounds/456703/"
+
+- files: ["soda_spray.ogg"]
+  license: "CC0-1.0"
+  copyright: "User Hajisounds on freesound.org. Converted and edited by Tayrtahn"
+  source: "https://freesound.org/people/Hajisounds/sounds/709149/"
+
 - files: ["newton_cradle.ogg"]
   license: "CC-BY-4.0"
   copyright: "User LoafDV on freesound.org. Converted to ogg end edited by lzk228"
diff --git a/Resources/Audio/Items/soda_shake.ogg b/Resources/Audio/Items/soda_shake.ogg
new file mode 100644 (file)
index 0000000..a596379
Binary files /dev/null and b/Resources/Audio/Items/soda_shake.ogg differ
diff --git a/Resources/Audio/Items/soda_spray.ogg b/Resources/Audio/Items/soda_spray.ogg
new file mode 100644 (file)
index 0000000..f4a5a3e
Binary files /dev/null and b/Resources/Audio/Items/soda_spray.ogg differ
diff --git a/Resources/Locale/en-US/nutrition/components/pressurized-solution-component.ftl b/Resources/Locale/en-US/nutrition/components/pressurized-solution-component.ftl
new file mode 100644 (file)
index 0000000..a227d81
--- /dev/null
@@ -0,0 +1,3 @@
+pressurized-solution-spray-holder-self = { CAPITALIZE(THE($drink)) } sprays on you!
+pressurized-solution-spray-holder-others = { CAPITALIZE(THE($drink)) } sprays on { THE($victim) }!
+pressurized-solution-spray-ground = The contents of { THE($drink) } spray out!
diff --git a/Resources/Locale/en-US/nutrition/components/shakeable-component.ftl b/Resources/Locale/en-US/nutrition/components/shakeable-component.ftl
new file mode 100644 (file)
index 0000000..acc1ecd
--- /dev/null
@@ -0,0 +1,3 @@
+shakeable-verb = Shake
+shakeable-popup-message-others = { CAPITALIZE(THE($user)) } shakes { THE($shakeable) }
+shakeable-popup-message-self = You shake { THE($shakeable) }
index d60134fce0eb341dbe284176c748988ddaf332b8..aef0c5a8f5ad25f19edecb28b2cdc8e0fd0adb47 100644 (file)
@@ -15,6 +15,9 @@
     solutions:
       drink:
         maxVol: 50
+  - type: PressurizedSolution
+    solution: drink
+  - type: Shakeable
   - type: Sprite
     state: icon
   - type: Item
index 0c7707c5f205eb5020518edf241e33de093f938d..73b1e06f9bbbb4c30794a55ec6b282759e64e9ad 100644 (file)
@@ -39,6 +39,9 @@
   - type: PhysicalComposition
     materialComposition:
       Plastic: 100
+  - type: PressurizedSolution
+    solution: drink
+  - type: Shakeable
 
 - type: entity
   parent: DrinkBottlePlasticBaseFull
index 585e5ed14d91fee980ab561f88209966324f27b9..7dcd3fa6039eb0614ada69b625b3531e7d42e3bb 100644 (file)
@@ -6,7 +6,7 @@
   components:
   - type: Drink
   - type: Openable
-  - type: PressurizedDrink
+  - type: Shakeable
   - type: SolutionContainerManager
     solutions:
       drink:
@@ -34,6 +34,8 @@
     solution: drink
   - type: DrainableSolution
     solution: drink
+  - type: PressurizedSolution
+    solution: drink
   - type: Appearance
   - type: GenericVisualizer
     visuals:
index 2fd2331f91efc8d9c7d44f6553dc7c591008d90c..ef6208b69d4090729e49895bac4db7cbeb539069 100644 (file)
   - type: RandomFillSolution
     solution: drink
     weightedRandomId: RandomFillMopwata
+  - type: PressurizedSolution
+    solution: drink
+  - type: Shakeable
   - type: Appearance
   - type: GenericVisualizer
     visuals:
index c80398e349661c92ec800c49e2d82d86dad3133d..a7f1bdbec6bc2621b60678cf3a19a9c494cfaabe 100644 (file)
@@ -9,6 +9,7 @@
       drink:
         maxVol: 100
   - type: Drink
+  - type: Shakeable # Doesn't do anything, but I mean...
   - type: FitsInDispenser
     solution: drink
   - type: DrawableSolution
index 44eba0f848c7330bc8e015d1ec141e8e1650c42b..ef02161165529b61fb6f47006dc88a851fd4d14a 100644 (file)
@@ -39,6 +39,7 @@
   metamorphicMaxFillLevels: 5
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: false
+  fizziness: 0.6
 
 - type: reagent
   id: Beer
@@ -55,6 +56,7 @@
   metamorphicMaxFillLevels: 6
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: true
+  fizziness: 0.6
 
 - type: reagent
   id: BlueCuracao
       - !type:AdjustReagent
         reagent: Ethanol
         amount: 0.3
+  fizziness: 0.8
 
 # Mixed Alcohol
 
       - !type:AdjustReagent
         reagent: Ethanol
         amount: 0.15
+  fizziness: 0.3
 
 - type: reagent
   id: BlackRussian
       - !type:AdjustReagent
         reagent: Ethanol
         amount: 0.07
+  fizziness: 0.2
 
 - type: reagent
   id: DemonsBlood
   metamorphicMaxFillLevels: 4
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: true
+  fizziness: 0.3
 
 - type: reagent
   id: DevilsKiss
   metamorphicMaxFillLevels: 5
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: true
+  fizziness: 0.15
 
 - type: reagent
   id: GargleBlaster
       - !type:AdjustReagent
         reagent: Ethanol
         amount: 0.07
+  fizziness: 0.4 # A little high, but it has fizz in the name
 
 - type: reagent
   id: GinTonic
       - !type:AdjustReagent
         reagent: Ethanol
         amount: 0.07
+  fizziness: 0.4
 
 - type: reagent
   id: Gildlager
   metamorphicMaxFillLevels: 6
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: false
+  fizziness: 0.6
 
 - type: reagent
   id: IrishCarBomb
   metamorphicMaxFillLevels: 2
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: false
+  fizziness: 0.7
 
 - type: reagent
   id: Margarita
   metamorphicMaxFillLevels: 5
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: true
+  fizziness: 0.4
 
 - type: reagent
   id: Mojito
   metamorphicMaxFillLevels: 6
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: false
+  fizziness: 0.3
 
 - type: reagent
   id: Moonshine
   metamorphicMaxFillLevels: 5
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: true
+  fizziness: 0.4
 
 - type: reagent
   id: PinaColada
   metamorphicMaxFillLevels: 6
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: true
+  fizziness: 0.3
 
 - type: reagent
   id: SuiDream
   metamorphicMaxFillLevels: 5
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: false
+  fizziness: 0.2
 
 - type: reagent
   id: SyndicateBomb
   metamorphicMaxFillLevels: 6
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: true
+  fizziness: 0.6
 
 - type: reagent
   id: TequilaSunrise
   metamorphicMaxFillLevels: 3
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: false
+  fizziness: 0.2
 
 - type: reagent
   id: ThreeMileIsland
       - !type:AdjustReagent
         reagent: Ethanol
         amount: 0.07
+  fizziness: 0.4
 
 - type: reagent
   id: WhiskeyCola
       - !type:AdjustReagent
         reagent: Ethanol
         amount: 0.07
+  fizziness: 0.3
 
 - type: reagent
   id: WhiskeySoda
       - !type:AdjustReagent
         reagent: Ethanol
         amount: 0.07
+  fizziness: 0.4
 
 - type: reagent
   id: WhiteGilgamesh
         - !type:AdjustReagent
           reagent: Ethanol
           amount: 0.15
+  fizziness: 0.5
 
 - type: reagent
   id: WhiteRussian
index 9984b4c0cf6712222e043982ceedb76885f2bc00..19a5e1bf8f153e107e74ef1aa25c1881deb757be 100644 (file)
@@ -40,6 +40,7 @@
     collection: FootstepSticky
     params:
       volume: 6
+  fizziness: 0.5
 
 - type: reagent
   id: BaseAlcohol
@@ -75,4 +76,4 @@
   footstepSound:
     collection: FootstepSticky
     params:
-      volume: 6
\ No newline at end of file
+      volume: 6
index 5c09b3c909b58b15dd937e44382ee0a1cabdc82b..71de67adb9900f02a7b9f1b542d37ca28a395ed1 100644 (file)
         damage:
           types:
             Poison: 1
+  fizziness: 0.5
 
 - type: reagent
   id: SodaWater
   physicalDesc: reagent-physical-desc-fizzy
   flavor: fizzy
   color: "#619494"
+  fizziness: 0.8
 
 - type: reagent
   id: SoyLatte
   physicalDesc: reagent-physical-desc-fizzy
   flavor: tonicwater
   color: "#0064C8"
+  fizziness: 0.4
 
 - type: reagent
   id: Water
       effects:
         - !type:SatiateThirst
           factor: 1
+  fizziness: 0.3
 
 - type: reagent
   id: Posca
   metamorphicMaxFillLevels: 3
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: false
+  fizziness: 0.3
 
 - type: reagent
   id: Rewriter
   metamorphicMaxFillLevels: 5
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: true
+  fizziness: 0.3
 
 - type: reagent
   id: Mopwata
index ba5adc4f2aec8af142b4aca039dbb45cb81e9316..3dda5b5329ac38c58165afe573249704c4882d78 100644 (file)
@@ -59,6 +59,7 @@
       - !type:AdjustReagent
         reagent: Theobromine
         amount: 0.05
+  fizziness: 0.4
 
 - type: reagent
   id: GrapeSoda
@@ -84,6 +85,7 @@
   metamorphicMaxFillLevels: 5
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: true
+  fizziness: 0
 
 - type: reagent
   id: LemonLime
   physicalDesc: reagent-physical-desc-fizzy
   flavor: pwrgamesoda
   color: "#9385bf"
+  fizziness: 0.9 # gamers crave the fizz
 
 - type: reagent
   id: RootBeer
   metamorphicMaxFillLevels: 7
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: false
+  fizziness: 0.4
 
 - type: reagent
   id: SolDry