From f04dca3ea5b5d87d17498c895ae5525eb91d972a Mon Sep 17 00:00:00 2001 From: BuggsWorth Date: Tue, 16 Jul 2024 14:51:39 -0400 Subject: [PATCH] Smokable's buff/change --- .../Nutrition/EntitySystems/SmokingSystem.cs | 12 +++++++++++- .../Nutrition/Components/SmokableComponent.cs | 6 ------ .../Consumable/Smokeables/Cigarettes/joints.yml | 8 ++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Content.Server/Nutrition/EntitySystems/SmokingSystem.cs b/Content.Server/Nutrition/EntitySystems/SmokingSystem.cs index a33c944c9948..3a4313eb4842 100644 --- a/Content.Server/Nutrition/EntitySystems/SmokingSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/SmokingSystem.cs @@ -35,6 +35,7 @@ public sealed partial class SmokingSystem : EntitySystem [Dependency] private readonly ForensicsSystem _forensics = default!; private const float UpdateTimer = 3f; + private const float SmokableDuration = 360f; private float _timer; @@ -42,6 +43,7 @@ public sealed partial class SmokingSystem : EntitySystem /// We keep a list of active smokables, because iterating all existing smokables would be dumb. /// private readonly HashSet _active = new(); + private readonly Dictionary _initialVolume = new(); public override void Initialize() { @@ -119,6 +121,11 @@ public override void Update(float frameTime) continue; } + if (!_initialVolume.ContainsKey(uid)) + { + _initialVolume[uid] = solution.Volume; + } + if (smokable.ExposeTemperature > 0 && smokable.ExposeVolume > 0) { var transform = Transform(uid); @@ -130,11 +137,14 @@ public override void Update(float frameTime) } } - var inhaledSolution = _solutionContainerSystem.SplitSolution(soln.Value, smokable.InhaleAmount * _timer); + var storedVolume = _initialVolume[uid]; + var inhaleAmount = storedVolume / (SmokableDuration / UpdateTimer); + var inhaledSolution = _solutionContainerSystem.SplitSolution(soln.Value, inhaleAmount); if (solution.Volume == FixedPoint2.Zero) { RaiseLocalEvent(uid, new SmokableSolutionEmptyEvent(), true); + _initialVolume.Remove(uid); } if (inhaledSolution.Volume == FixedPoint2.Zero) diff --git a/Content.Shared/Nutrition/Components/SmokableComponent.cs b/Content.Shared/Nutrition/Components/SmokableComponent.cs index 26c17bbd6ebe..84681ecc5178 100644 --- a/Content.Shared/Nutrition/Components/SmokableComponent.cs +++ b/Content.Shared/Nutrition/Components/SmokableComponent.cs @@ -10,12 +10,6 @@ public sealed partial class SmokableComponent : Component [DataField("solution")] public string Solution { get; private set; } = "smokable"; - /// - /// Solution inhale amount per second. - /// - [DataField("inhaleAmount"), ViewVariables(VVAccess.ReadWrite)] - public FixedPoint2 InhaleAmount { get; private set; } = FixedPoint2.New(0.1f); - [DataField("state")] public SmokableState State { get; set; } = SmokableState.Unlit; diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/joints.yml b/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/joints.yml index 9a0d96e89eaf..4bbab21e20c1 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/joints.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/joints.yml @@ -28,7 +28,7 @@ reagents: - ReagentId: THC Quantity: 20 - + - type: entity id: JointRainbow parent: Joint @@ -42,7 +42,7 @@ - type: SolutionContainerManager solutions: smokable: - maxVol: 20 + maxVol: 30 reagents: - ReagentId: SpaceDrugs Quantity: 4 @@ -83,7 +83,7 @@ - type: SolutionContainerManager solutions: smokable: - maxVol: 30 + maxVol: 40 reagents: - ReagentId: THC Quantity: 20 @@ -101,7 +101,7 @@ - type: SolutionContainerManager solutions: smokable: - maxVol: 20 + maxVol: 40 reagents: - ReagentId: SpaceDrugs Quantity: 4