add fuel costs back to finishing welding (#27030)

* add fuel costs back to welding

* ack

* meh

* eek!
This commit is contained in:
Nemanja
2024-04-19 19:20:30 -04:00
committed by GitHub
parent 299da35c87
commit a47c5561a9
26 changed files with 403 additions and 466 deletions

View File

@@ -1,40 +1,63 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Popups;
using Content.Server.Tools.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.FixedPoint;
using Content.Shared.Tools.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;
namespace Content.Server.Tools
namespace Content.Server.Tools;
public sealed class ToolSystem : SharedToolSystem
{
// TODO move tool system to shared, and make it a friend of Tool Component.
public sealed partial class ToolSystem : SharedToolSystem
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
public override void TurnOn(Entity<WelderComponent> entity, EntityUid? user)
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
public override void Initialize()
base.TurnOn(entity, user);
var xform = Transform(entity);
if (xform.GridUid is { } gridUid)
{
base.Initialize();
InitializeWelders();
var position = _transformSystem.GetGridOrMapTilePosition(entity.Owner, xform);
_atmosphereSystem.HotspotExpose(gridUid, position, 700, 50, entity.Owner, true);
}
}
public override void Update(float frameTime)
public override void Update(float frameTime)
{
base.Update(frameTime);
UpdateWelders(frameTime);
}
//todo move to shared once you can remove reagents from shared without it freaking out.
private void UpdateWelders(float frameTime)
{
var query = EntityQueryEnumerator<WelderComponent, SolutionContainerManagerComponent>();
while (query.MoveNext(out var uid, out var welder, out var solutionContainer))
{
base.Update(frameTime);
if (!welder.Enabled)
continue;
UpdateWelders(frameTime);
}
welder.WelderTimer += frameTime;
protected override bool IsWelder(EntityUid uid)
{
return HasComp<WelderComponent>(uid);
if (welder.WelderTimer < welder.WelderUpdateTimer)
continue;
if (!SolutionContainerSystem.ResolveSolution((uid, solutionContainer), welder.FuelSolutionName, ref welder.FuelSolution, out var solution))
continue;
SolutionContainerSystem.RemoveReagent(welder.FuelSolution.Value, welder.FuelReagent, welder.FuelConsumption * welder.WelderTimer);
if (solution.GetTotalPrototypeQuantity(welder.FuelReagent) <= FixedPoint2.Zero)
{
ItemToggle.Toggle(uid, predicted: false);
}
Dirty(uid, welder);
welder.WelderTimer -= welder.WelderUpdateTimer;
}
}
}