mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-13 12:21:11 +03:00
* Everything except the YAML slop... * She solution on my manager till I sajfslkahfsjakfhaskjfshajksafhfsakhfasjfas * another 1000 lines * fix chem dispenser size * go my shnelf * Implicit ass * rider is being mean for some reason * dasdas * borger * better formatting go! * clothes/bloodstream * Cartons * cups and bottles * mmm soder * bar drinks * Spray bottles and some size tweaks with hindsight * 99 bottles of beer on the wall I hate YAML * push that shit * mmm burger * Sneed * sheets * condiments * mmm yummy * fridge yummyfood * meat... * sub 300 * burger... * bready * let them eat cake * does she know how to make a grilled cheese? * pizza pie! * misc shit * soup or salad * Food and drinks, vanquished * the cubes!!! * Almost free from YAML... * fix test fails and some yaml issues * fix prediction, almost done * fix all test fails * remove master merge artifacts and undo autonetworking * review and compatibility * graaah * unfuck master merge I hate github * merg conflicts * sfsa * ehoop * sadas * afsafsaasf * merge conflicts * fucked up the merge conflicts * merge conflict is fucked I might need to completely redo this branch * test fail * no calcium???? --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
70 lines
2.7 KiB
C#
70 lines
2.7 KiB
C#
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
using Content.Shared.FixedPoint;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared.Chemistry.EntitySystems;
|
|
|
|
public sealed class SolutionRegenerationSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SolutionRegenerationComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<SolutionRegenerationComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
|
}
|
|
|
|
private void OnMapInit(Entity<SolutionRegenerationComponent> ent, ref MapInitEvent args)
|
|
{
|
|
ent.Comp.NextRegenTime = _timing.CurTime + ent.Comp.Duration;
|
|
|
|
Dirty(ent);
|
|
}
|
|
|
|
// Workaround for https://github.com/space-wizards/space-station-14/pull/35314
|
|
private void OnEntRemoved(Entity<SolutionRegenerationComponent> ent, ref EntRemovedFromContainerMessage args)
|
|
{
|
|
// Make sure the removed entity was our contained solution and clear our cached reference
|
|
if (args.Entity == ent.Comp.SolutionRef?.Owner)
|
|
ent.Comp.SolutionRef = null;
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
// TODO: SolutionRegenerationComponent on Solution Entities!
|
|
var query = EntityQueryEnumerator<SolutionRegenerationComponent, SolutionManagerComponent>();
|
|
while (query.MoveNext(out var uid, out var regen, out var manager))
|
|
{
|
|
if (_timing.CurTime < regen.NextRegenTime)
|
|
continue;
|
|
|
|
// timer ignores if its full, it's just a fixed cycle
|
|
regen.NextRegenTime += regen.Duration;
|
|
// Needs to be networked and dirtied so that the client can reroll it during prediction
|
|
Dirty(uid, regen);
|
|
if (!_solutionContainer.ResolveSolution((uid, manager),
|
|
regen.SolutionName,
|
|
ref regen.SolutionRef,
|
|
out var solution))
|
|
continue;
|
|
|
|
var amount = FixedPoint2.Min(solution.AvailableVolume, regen.Generated.Volume);
|
|
if (amount <= FixedPoint2.Zero)
|
|
continue;
|
|
|
|
// Don't bother cloning and splitting if adding the whole thing
|
|
var generated = amount == regen.Generated.Volume
|
|
? regen.Generated
|
|
: regen.Generated.Clone().SplitSolution(amount);
|
|
|
|
_solutionContainer.TryAddSolution(regen.SolutionRef.Value, generated);
|
|
}
|
|
}
|
|
}
|