Fix eating the whole stack of uranium. (#41092)
* I hate stack system!!! * a lil bit of fixing, as a treat * humgry * mmm burger --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9591314ac4
commit
9a10a19072
@@ -364,6 +364,9 @@ public sealed partial class IngestionSystem : EntitySystem
|
||||
|
||||
var split = _solutionContainer.SplitSolution(solution.Value, transfer);
|
||||
|
||||
if (beforeEv.Refresh)
|
||||
_solutionContainer.TryAddSolution(solution.Value, split);
|
||||
|
||||
var ingestEv = new IngestingEvent(food, split, forceFed);
|
||||
RaiseLocalEvent(entity, ref ingestEv);
|
||||
|
||||
@@ -373,9 +376,6 @@ public sealed partial class IngestionSystem : EntitySystem
|
||||
var afterEv = new IngestedEvent(args.User, entity, split, forceFed);
|
||||
RaiseLocalEvent(food, ref afterEv);
|
||||
|
||||
if (afterEv.Refresh)
|
||||
_solutionContainer.TryAddSolution(solution.Value, split);
|
||||
|
||||
_stomach.TryTransferSolution(stomachToUse.Value.Owner, split, stomachToUse);
|
||||
|
||||
if (!afterEv.Destroy)
|
||||
|
||||
@@ -111,6 +111,10 @@ public record struct BeforeIngestedEvent(FixedPoint2 Min, FixedPoint2 Max, Solut
|
||||
// Whether this event, and therefore eat attempt, should be cancelled.
|
||||
public bool Cancelled;
|
||||
|
||||
// When and if we eat this solution, should we actually remove solution or should it get replaced?
|
||||
// This bool basically only exists because of stackable system.
|
||||
public bool Refresh;
|
||||
|
||||
public bool TryNewMinimum(FixedPoint2 newMin)
|
||||
{
|
||||
if (newMin > Max)
|
||||
@@ -130,6 +134,12 @@ public record struct BeforeIngestedEvent(FixedPoint2 Min, FixedPoint2 Max, Solut
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised on an entity while it is eating
|
||||
/// </summary>
|
||||
/// <param name="Food">The item being ingested</param>
|
||||
/// <param name="Split">The solution being ingested</param>
|
||||
/// <param name="ForceFed">Whether or not we're being forced</param>
|
||||
[ByRefEvent]
|
||||
public record struct IngestingEvent(EntityUid Food, Solution Split, bool ForceFed);
|
||||
|
||||
@@ -143,10 +153,6 @@ public record struct IngestingEvent(EntityUid Food, Solution Split, bool ForceFe
|
||||
[ByRefEvent]
|
||||
public record struct IngestedEvent(EntityUid User, EntityUid Target, Solution Split, bool ForceFed)
|
||||
{
|
||||
// Should we refill the solution now that we've eaten it?
|
||||
// This bool basically only exists because of stackable system.
|
||||
public bool Refresh;
|
||||
|
||||
// Should we destroy the ingested entity?
|
||||
public bool Destroy;
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ public abstract partial class SharedStackSystem : EntitySystem
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
||||
[Dependency] private readonly SharedStorageSystem _storage = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
// TODO: These should be in the prototype.
|
||||
public static readonly int[] DefaultSplitAmounts = { 1, 5, 10, 20, 30, 50 };
|
||||
@@ -162,6 +161,9 @@ public abstract partial class SharedStackSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
// If we've made it this far, we should refresh the solution when this item is eaten provided it's not the last one in the stack!
|
||||
args.Refresh = eaten.Comp.Count > 1;
|
||||
|
||||
/*
|
||||
Edible stacked items is near completely evil so we must choose one of the following:
|
||||
- Option 1: Eat the entire solution each bite and reduce the stack by 1.
|
||||
@@ -178,18 +180,7 @@ public abstract partial class SharedStackSystem : EntitySystem
|
||||
|
||||
private void OnEaten(Entity<StackComponent> eaten, ref IngestedEvent args)
|
||||
{
|
||||
if (!TryUse(eaten.AsNullable(), 1))
|
||||
return;
|
||||
|
||||
// We haven't eaten the whole stack yet or are unable to eat it completely.
|
||||
if (eaten.Comp.Count > 0)
|
||||
{
|
||||
args.Refresh = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Here to tell the food system to do destroy stuff.
|
||||
args.Destroy = true;
|
||||
ReduceCount(eaten.AsNullable(), 1);
|
||||
}
|
||||
|
||||
private void OnStackAlternativeInteract(Entity<StackComponent> ent, ref GetVerbsEvent<AlternativeVerb> args)
|
||||
|
||||
Reference in New Issue
Block a user