Skip to content

Commit

Permalink
Play ambient when adding oil to fryer (#1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
GreaseMonk authored Mar 4, 2024
1 parent e4c1186 commit 6e2fe0c
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public override void Initialize()
SubscribeLocalEvent<DeepFryerComponent, MachineDeconstructedEvent>(OnDeconstruct);
SubscribeLocalEvent<DeepFryerComponent, DestructionEventArgs>(OnDestruction);
SubscribeLocalEvent<DeepFryerComponent, ThrowHitByEvent>(OnThrowHitBy);
SubscribeLocalEvent<DeepFryerComponent, SolutionChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<DeepFryerComponent, SolutionContainerChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<DeepFryerComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
SubscribeLocalEvent<DeepFryerComponent, InteractUsingEvent>(OnInteractUsing);

Expand Down Expand Up @@ -181,15 +181,19 @@ public FixedPoint2 GetWasteVolume(EntityUid uid, DeepFryerComponent component)
/// </summary>
public FixedPoint2 GetOilPurity(EntityUid uid, DeepFryerComponent component)
{
return GetOilVolume(uid, component) / component.Solution.Volume;
if (component.Solution.Volume > 0)
return GetOilVolume(uid, component) / component.Solution.Volume;
return FixedPoint2.Zero;
}

/// <summary>
/// Returns a percentage of how much of the total volume is usable oil.
/// </summary>
public FixedPoint2 GetOilLevel(EntityUid uid, DeepFryerComponent component)
{
return GetOilVolume(uid, component) / component.Solution.MaxVolume;
if (component.Solution.Volume > 0)
return GetOilVolume(uid, component) / component.Solution.Volume;
return FixedPoint2.Zero;
}

/// <summary>
Expand Down Expand Up @@ -491,7 +495,7 @@ private void OnThrowHitBy(EntityUid uid, DeepFryerComponent component, ThrowHitB
args.Handled = true;
}

private void OnSolutionChange(EntityUid uid, DeepFryerComponent component, SolutionChangedEvent args)
private void OnSolutionChange(EntityUid uid, DeepFryerComponent component, SolutionContainerChangedEvent args)
{
UpdateUserInterface(uid, component);
UpdateAmbientSound(uid, component);
Expand Down

0 comments on commit 6e2fe0c

Please sign in to comment.