Files
Delta-v/Content.Shared/_Impstation/Tools/SolutionRefuelSystem.cs
T
c81f09747e Impstation Port - #2575 And #2351 (#3845)
* It begins

* Fixes

* MIssed a Comp+system

* Update muzzleflashes.yml

* Some fixes, new issues

* Ouroboros to BASALISK

* More fixes

* More changes

* Update meta.json

* I FEEEXED IT!!!

* Delete muzzle_synd.png

* Update uplink_catalog.yml

* Update projectiles.yml

* Update projectiles.yml

* fixes

* Update pyrotechnic.yml

* Make our suits protect from self damage

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Adjustments

* Update SharedToolSystem.Welder.cs

* Update uplink_catalog.yml

* Update ReagentTankComponent.cs

* Update Resources/Prototypes/_Impstation/Catalog/Fills/Boxes/syndicate.yml

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Fixes

* Update Content.Shared/_Impstation/Weapons/Ranged/DamageOnShootSystem.cs

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Update tags.yml

* Changes

* I am commitiing this and asking for help

* Fixes

* Fixes

* Doing a thing

* Thing is done

* Update Resources/Prototypes/_Impstation/Entities/Objects/Weapons/Guns/Special/basilisk.yml

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Update Content.Shared/_Impstation/Weapons/Ranged/DamageOnShootProtectionComponent.cs

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Update Content.Shared/_Impstation/Tools/SolutionRefuelSystem.cs

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Update Content.Shared/_Impstation/Weapons/Ranged/DamageOnShootComponent.cs

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Update Content.Shared/_Impstation/Tools/SolutionRefuelComponent.cs

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Update Content.Shared/Tools/Systems/SharedToolSystem.Welder.cs

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* More fixes

* Update SharedToolSystem.Welder.cs

* Update SharedToolSystem.Welder.cs

* LETS TRY

* FUCK GO BACK

This Partially reverts commit de3bd33873.

* Update ReagentTankComponent.cs

* Update meta.json

* Indentation fixes

* Update syndicate.yml

* FIXED (I think)

* Fixes

* Update anaconda.yml

* Update leviathan.yml

* Nuke 2

* All set!

* Update Resources/Prototypes/_Impstation/Catalog/Fills/Backpacks/duffelbag.yml

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Update Content.Shared/_Impstation/Weapons/Ranged/DamageOnShootSystem.cs

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Update Resources/Locale/en-US/_Impstation/tools/solution-refuel-component.ftl

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

* Update Content.Shared/_Impstation/Tools/SolutionRefuelSystem.cs

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Avalon <jfbentley1@gmail.com>

---------

Signed-off-by: Avalon <jfbentley1@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tobias Berger <toby@tobot.dev>
2025-06-12 20:55:35 +02:00

86 lines
3.5 KiB
C#

using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Tools.Components;
namespace Content.Shared.Tools.Systems;
public abstract partial class SharedToolSystem
{
public void InitializeSolutionRefuel()
{
SubscribeLocalEvent<SolutionRefuelComponent, ExaminedEvent>(SolutionRefuelExamine);
SubscribeLocalEvent<SolutionRefuelComponent, AfterInteractEvent>(OnSolutionRefuelAfterInteract);
}
public (FixedPoint2 fuel, FixedPoint2 capacity) GetSolutionFuelAndCapacity(EntityUid uid, SolutionRefuelComponent? welder = null, SolutionContainerManagerComponent? solutionContainer = null)
{
if (!Resolve(uid, ref welder, ref solutionContainer))
return default;
if (!SolutionContainerSystem.TryGetSolution(
(uid, solutionContainer),
welder.FuelSolutionName,
out _,
out var fuelSolution))
{
return default;
}
return (fuelSolution.GetTotalPrototypeQuantity(welder.FuelReagent), fuelSolution.MaxVolume);
}
private void SolutionRefuelExamine(Entity<SolutionRefuelComponent> entity, ref ExaminedEvent args)
{
using (args.PushGroup(nameof(SolutionRefuelComponent)))
{
if (args.IsInDetailsRange)
{
var (fuel, capacity) = GetSolutionFuelAndCapacity(entity.Owner, entity.Comp);
args.PushMarkup(Loc.GetString("solution-refuel-component-on-examine-detailed-message",
("colorName", fuel < capacity / FixedPoint2.New(4f) ? "darkorange" : "orange"),
("fuelLeft", fuel),
("fuelCapacity", capacity)));
}
}
}
private void OnSolutionRefuelAfterInteract(Entity<SolutionRefuelComponent> entity, ref AfterInteractEvent args)
{
if (args.Handled)
return;
if (args.Target is not { Valid: true } target || !args.CanReach)
return;
if (TryComp(target, out ReagentTankComponent? tank)
&& tank.TankType == ReagentTankType.Fuel
&& SolutionContainerSystem.TryGetDrainableSolution(target, out var targetSoln, out var targetSolution)
&& _whitelist.CheckBoth(entity, tank.FuelBlacklist, tank.FuelWhitelist)
&& SolutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.FuelSolutionName, out var solutionComp, out var welderSolution))
{
var trans = FixedPoint2.Min(welderSolution.AvailableVolume, targetSolution.Volume);
if (trans > 0)
{
var drained = SolutionContainerSystem.Drain(target, targetSoln.Value, trans);
SolutionContainerSystem.TryAddSolution(solutionComp.Value, drained);
_audioSystem.PlayPredicted(entity.Comp.WelderRefill, entity, user: args.User);
_popup.PopupClient(Loc.GetString("welder-component-after-interact-refueled-message"), entity, args.User);
}
else if (welderSolution.AvailableVolume <= 0)
{
_popup.PopupClient(Loc.GetString("solution-refuel-component-already-full", ("target", entity)), entity, args.User);
}
else
{
_popup.PopupClient(Loc.GetString("welder-component-no-fuel-in-tank", ("owner", args.Target)), entity, args.User);
}
args.Handled = true;
}
}
}