Skip to content

Commit

Permalink
Update DeepFryer to Delta-V's
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 committed Oct 6, 2024
1 parent 48f2ce3 commit 1250699
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions Content.Server/Nyanotrasen/Kitchen/EntitySystems/DeepFryerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Server.Audio;
using Content.Server.Cargo.Systems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Construction;
using Content.Server.DoAfter;
using Content.Server.Fluids.EntitySystems;
Expand All @@ -14,6 +15,7 @@
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Storage.EntitySystems;
using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems;
using Content.Server.UserInterface;
Expand All @@ -27,7 +29,7 @@
using Content.Shared.Database;
using Content.Shared.Destructible;
using Content.Shared.DoAfter;
using Content.Shared.EntityEffects; // Frontier
using Content.Shared.EntityEffects;
using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Hands.Components;
Expand Down Expand Up @@ -108,7 +110,7 @@ public override void Initialize()
SubscribeLocalEvent<DeepFryerComponent, MachineDeconstructedEvent>(OnDeconstruct);
SubscribeLocalEvent<DeepFryerComponent, DestructionEventArgs>(OnDestruction);
SubscribeLocalEvent<DeepFryerComponent, ThrowHitByEvent>(OnThrowHitBy);
SubscribeLocalEvent<DeepFryerComponent, SolutionContainerChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<DeepFryerComponent, SolutionChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<DeepFryerComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
SubscribeLocalEvent<DeepFryerComponent, InteractUsingEvent>(OnInteractUsing);

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

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

/// <summary>
Expand Down Expand Up @@ -315,7 +314,7 @@ private void DeepFry(EntityUid uid, DeepFryerComponent component, EntityUid item
// just in case the attempt is relevant to any system in the future.
//
// The blacklist overrides all.
if (component.Blacklist != null && _whitelistSystem.IsValid(component.Blacklist, item)) // Frontier: use new whitelist system
if (component.Blacklist != null && _whitelistSystem.IsWhitelistPass(component.Blacklist, item))
{
_popupSystem.PopupEntity(
Loc.GetString("deep-fryer-blacklist-item-failed",
Expand Down Expand Up @@ -357,7 +356,7 @@ private void DeepFry(EntityUid uid, DeepFryerComponent component, EntityUid item
_ => 10
} * component.SolutionSizeCoefficient);

if (component.Whitelist != null && _whitelistSystem.IsValid(component.Whitelist, item) || // Frontier: use new whitelist system
if (component.Whitelist != null && _whitelistSystem.IsWhitelistPass(component.Whitelist, item) ||
beingEvent.TurnIntoFood)
MakeEdible(uid, component, item, solutionQuantity);
else
Expand Down Expand Up @@ -385,7 +384,8 @@ private void OnInitDeepFryer(EntityUid uid, DeepFryerComponent component, Compon
{
//JJ Comment - not sure this works. Need to check if Reagent.ToString is correct.
_prototypeManager.TryIndex<ReagentPrototype>(reagent.Reagent.ToString(), out var proto);
var effectsArgs = new EntityEffectReagentArgs(uid, // Frontier: ReagentEffectArgs<EntityEffectReagentArgs

var effectsArgs = new EntityEffectReagentArgs(uid,
EntityManager,
null,
component.Solution,
Expand All @@ -395,7 +395,7 @@ private void OnInitDeepFryer(EntityUid uid, DeepFryerComponent component, Compon
1f);
foreach (var effect in component.UnsafeOilVolumeEffects)
{
if (!EntityEffectExt.ShouldApply(effect, effectsArgs, _random)) // Frontier: effect.ShouldApply<EntityEffectExt.ShouldApply
if (!effect.ShouldApply(effectsArgs, _random))
continue;
effect.Effect(effectsArgs);
}
Expand Down Expand Up @@ -498,7 +498,7 @@ private void OnThrowHitBy(EntityUid uid, DeepFryerComponent component, ThrowHitB
args.Handled = true;
}

private void OnSolutionChange(EntityUid uid, DeepFryerComponent component, SolutionContainerChangedEvent args)
private void OnSolutionChange(EntityUid uid, DeepFryerComponent component, SolutionChangedEvent args)
{
UpdateUserInterface(uid, component);
UpdateAmbientSound(uid, component);
Expand All @@ -507,6 +507,7 @@ private void OnSolutionChange(EntityUid uid, DeepFryerComponent component, Solut
private void OnRelayMovement(EntityUid uid, DeepFryerComponent component,
ref ContainerRelayMovementEntityEvent args)
{

if (!_containerSystem.Remove(args.Entity, component.Storage, destination: Transform(uid).Coordinates))
return;

Expand Down Expand Up @@ -535,13 +536,10 @@ private void OnRemoveItem(EntityUid uid, DeepFryerComponent component, DeepFryer

var user = args.Actor;

if (user != null)
{
_handsSystem.TryPickupAnyHand(user, removedItem);
_handsSystem.TryPickupAnyHand(user, removedItem);

_adminLogManager.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user)} took {ToPrettyString(args.Item)} out of {ToPrettyString(uid)}.");
}
_adminLogManager.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user)} took {ToPrettyString(args.Item)} out of {ToPrettyString(uid)}.");

_audioSystem.PlayPvs(component.SoundRemoveItem, uid, AudioParamsInsertRemove);

Expand Down Expand Up @@ -613,8 +611,7 @@ private void OnClearSlagStart(EntityUid uid, DeepFryerComponent component, DeepF
{
var user = args.Actor;

if (user == null ||
!TryGetActiveHandSolutionContainer(uid, user, out var heldItem, out var heldSolution,
if (!TryGetActiveHandSolutionContainer(uid, user, out var heldItem, out var heldSolution,
out var transferAmount))
return;

Expand All @@ -629,7 +626,7 @@ private void OnClearSlagStart(EntityUid uid, DeepFryerComponent component, DeepF
return;
}

var delay = Math.Clamp((float) wasteVolume * 0.1f, 1f, 5f);
var delay = TimeSpan.FromSeconds(Math.Clamp((float) wasteVolume * 0.1f, 1f, 5f));

var ev = new ClearSlagDoAfterEvent(heldSolution.Value.Comp.Solution, transferAmount);

Expand All @@ -645,6 +642,7 @@ private void OnClearSlagStart(EntityUid uid, DeepFryerComponent component, DeepF
_doAfterSystem.TryStartDoAfter(doAfterArgs);
}

[Obsolete("Obsolete")]
private void OnRemoveAllItems(EntityUid uid, DeepFryerComponent component, DeepFryerRemoveAllItemsMessage args)
{
if (component.Storage.ContainedEntities.Count == 0)
Expand All @@ -654,11 +652,8 @@ private void OnRemoveAllItems(EntityUid uid, DeepFryerComponent component, DeepF

var user = args.Actor;

if (user != null)
{
_adminLogManager.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user)} removed all items from {ToPrettyString(uid)}.");
}
_adminLogManager.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user)} removed all items from {ToPrettyString(uid)}.");

_audioSystem.PlayPvs(component.SoundRemoveItem, uid, AudioParamsInsertRemove);

Expand Down Expand Up @@ -765,4 +760,4 @@ public BeingDeepFriedEvent(EntityUid deepFryer, EntityUid item)
DeepFryer = deepFryer;
Item = item;
}
}
}

0 comments on commit 1250699

Please sign in to comment.