Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ambient when adding oil to fryer #1082

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading