Skip to content

Commit

Permalink
Smokable's buff/change
Browse files Browse the repository at this point in the history
  • Loading branch information
BuggsWorth committed Jul 16, 2024
1 parent 2751da6 commit f04dca3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
12 changes: 11 additions & 1 deletion Content.Server/Nutrition/EntitySystems/SmokingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ 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;

/// <summary>
/// We keep a list of active smokables, because iterating all existing smokables would be dumb.
/// </summary>
private readonly HashSet<EntityUid> _active = new();
private readonly Dictionary<EntityUid, FixedPoint2> _initialVolume = new();

public override void Initialize()
{
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions Content.Shared/Nutrition/Components/SmokableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ public sealed partial class SmokableComponent : Component
[DataField("solution")]
public string Solution { get; private set; } = "smokable";

/// <summary>
/// Solution inhale amount per second.
/// </summary>
[DataField("inhaleAmount"), ViewVariables(VVAccess.ReadWrite)]
public FixedPoint2 InhaleAmount { get; private set; } = FixedPoint2.New(0.1f);

[DataField("state")]
public SmokableState State { get; set; } = SmokableState.Unlit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
reagents:
- ReagentId: THC
Quantity: 20

- type: entity
id: JointRainbow
parent: Joint
Expand All @@ -42,7 +42,7 @@
- type: SolutionContainerManager
solutions:
smokable:
maxVol: 20
maxVol: 30
reagents:
- ReagentId: SpaceDrugs
Quantity: 4
Expand Down Expand Up @@ -83,7 +83,7 @@
- type: SolutionContainerManager
solutions:
smokable:
maxVol: 30
maxVol: 40
reagents:
- ReagentId: THC
Quantity: 20
Expand All @@ -101,7 +101,7 @@
- type: SolutionContainerManager
solutions:
smokable:
maxVol: 20
maxVol: 40
reagents:
- ReagentId: SpaceDrugs
Quantity: 4
Expand Down

0 comments on commit f04dca3

Please sign in to comment.