Revert 'Revert 'Solution Entities'' (#23168)

This commit is contained in:
TemporalOroboros
2023-12-29 04:47:43 -08:00
committed by GitHub
parent 93e1af2f8d
commit d23c8d5c19
180 changed files with 3541 additions and 2956 deletions

View File

@@ -13,7 +13,6 @@ namespace Content.Server.Power.EntitySystems;
/// </summary>
public sealed class RiggableSystem : EntitySystem
{
[Dependency] private readonly SolutionContainerSystem _solutionsSystem = default!;
[Dependency] private readonly ExplosionSystem _explosionSystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
@@ -22,17 +21,17 @@ public sealed class RiggableSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent<RiggableComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<RiggableComponent, BeingMicrowavedEvent>(OnMicrowaved);
SubscribeLocalEvent<RiggableComponent, SolutionChangedEvent>(OnSolutionChanged);
SubscribeLocalEvent<RiggableComponent, SolutionContainerChangedEvent>(OnSolutionChanged);
}
private void OnRejuvenate(EntityUid uid, RiggableComponent component, RejuvenateEvent args)
private void OnRejuvenate(Entity<RiggableComponent> entity, ref RejuvenateEvent args)
{
component.IsRigged = false;
entity.Comp.IsRigged = false;
}
private void OnMicrowaved(EntityUid uid, RiggableComponent component, BeingMicrowavedEvent args)
private void OnMicrowaved(Entity<RiggableComponent> entity, ref BeingMicrowavedEvent args)
{
if (TryComp<BatteryComponent>(uid, out var batteryComponent))
if (TryComp<BatteryComponent>(entity, out var batteryComponent))
{
if (batteryComponent.CurrentCharge == 0)
return;
@@ -41,21 +40,21 @@ public sealed class RiggableSystem : EntitySystem
args.Handled = true;
// What the fuck are you doing???
Explode(uid, batteryComponent, args.User);
Explode(entity.Owner, batteryComponent, args.User);
}
private void OnSolutionChanged(EntityUid uid, RiggableComponent component, SolutionChangedEvent args)
private void OnSolutionChanged(Entity<RiggableComponent> entity, ref SolutionContainerChangedEvent args)
{
if (args.SolutionId != component.Solution)
if (args.SolutionId != entity.Comp.Solution)
return;
var wasRigged = component.IsRigged;
var quantity = args.Solution.GetReagentQuantity(component.RequiredQuantity.Reagent);
component.IsRigged = quantity >= component.RequiredQuantity.Quantity;
var wasRigged = entity.Comp.IsRigged;
var quantity = args.Solution.GetReagentQuantity(entity.Comp.RequiredQuantity.Reagent);
entity.Comp.IsRigged = quantity >= entity.Comp.RequiredQuantity.Quantity;
if (component.IsRigged && !wasRigged)
if (entity.Comp.IsRigged && !wasRigged)
{
_adminLogger.Add(LogType.Explosion, LogImpact.Medium, $"{ToPrettyString(uid)} has been rigged up to explode when used.");
_adminLogger.Add(LogType.Explosion, LogImpact.Medium, $"{ToPrettyString(entity.Owner)} has been rigged up to explode when used.");
}
}

View File

@@ -1,5 +1,5 @@
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
@@ -20,11 +20,17 @@ public sealed partial class ChemicalFuelGeneratorAdapterComponent : Component
public string Reagent = "WeldingFuel";
/// <summary>
/// The solution on the <see cref="SolutionContainerManagerComponent"/> to use.
/// The name of <see cref="Solution"/>.
/// </summary>
[DataField("solution")]
[ViewVariables(VVAccess.ReadWrite)]
public string Solution = "tank";
public string SolutionName = "tank";
/// <summary>
/// The solution on the <see cref="SolutionContainerManagerComponent"/> to use.
/// </summary>
[DataField("solutionRef")]
public Entity<SolutionComponent>? Solution = null;
/// <summary>
/// Value to multiply reagent amount by to get fuel amount.

View File

@@ -1,10 +1,10 @@
using Content.Server.Audio;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Materials;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.FixedPoint;
using Content.Shared.Popups;
using Content.Shared.Power.Generator;
@@ -65,23 +65,23 @@ public sealed class GeneratorSystem : SharedGeneratorSystem
_materialStorage.EjectAllMaterial(uid);
}
private void ChemicalEmpty(EntityUid uid, ChemicalFuelGeneratorAdapterComponent component, GeneratorEmpty args)
private void ChemicalEmpty(Entity<ChemicalFuelGeneratorAdapterComponent> entity, ref GeneratorEmpty args)
{
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out var solution))
if (!_solutionContainer.ResolveSolution(entity.Owner, entity.Comp.SolutionName, ref entity.Comp.Solution, out var solution))
return;
var spillSolution = _solutionContainer.SplitSolution(uid, solution, solution.Volume);
_puddle.TrySpillAt(uid, spillSolution, out _);
var spillSolution = _solutionContainer.SplitSolution(entity.Comp.Solution.Value, solution.Volume);
_puddle.TrySpillAt(entity.Owner, spillSolution, out _);
}
private void ChemicalGetClogged(EntityUid uid, ChemicalFuelGeneratorAdapterComponent component, ref GeneratorGetCloggedEvent args)
private void ChemicalGetClogged(Entity<ChemicalFuelGeneratorAdapterComponent> entity, ref GeneratorGetCloggedEvent args)
{
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out var solution))
if (!_solutionContainer.ResolveSolution(entity.Owner, entity.Comp.SolutionName, ref entity.Comp.Solution, out var solution))
return;
foreach (var reagentQuantity in solution)
{
if (reagentQuantity.Reagent.Prototype != component.Reagent)
if (reagentQuantity.Reagent.Prototype != entity.Comp.Reagent)
{
args.Clogged = true;
return;
@@ -89,32 +89,29 @@ public sealed class GeneratorSystem : SharedGeneratorSystem
}
}
private void ChemicalUseFuel(EntityUid uid, ChemicalFuelGeneratorAdapterComponent component, GeneratorUseFuel args)
private void ChemicalUseFuel(Entity<ChemicalFuelGeneratorAdapterComponent> entity, ref GeneratorUseFuel args)
{
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out var solution))
if (!_solutionContainer.ResolveSolution(entity.Owner, entity.Comp.SolutionName, ref entity.Comp.Solution, out var solution))
return;
var availableReagent = solution.GetTotalPrototypeQuantity(component.Reagent).Value;
var availableReagent = solution.GetTotalPrototypeQuantity(entity.Comp.Reagent).Value;
var toRemove = RemoveFractionalFuel(
ref component.FractionalReagent,
ref entity.Comp.FractionalReagent,
args.FuelUsed,
component.Multiplier * FixedPoint2.Epsilon.Float(),
entity.Comp.Multiplier * FixedPoint2.Epsilon.Float(),
availableReagent);
solution.RemoveReagent(component.Reagent, FixedPoint2.FromCents(toRemove));
_solutionContainer.RemoveReagent(entity.Comp.Solution.Value, entity.Comp.Reagent, FixedPoint2.FromCents(toRemove));
}
private void ChemicalGetFuel(
EntityUid uid,
ChemicalFuelGeneratorAdapterComponent component,
ref GeneratorGetFuelEvent args)
private void ChemicalGetFuel(Entity<ChemicalFuelGeneratorAdapterComponent> entity, ref GeneratorGetFuelEvent args)
{
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out var solution))
if (!_solutionContainer.ResolveSolution(entity.Owner, entity.Comp.SolutionName, ref entity.Comp.Solution, out var solution))
return;
var availableReagent = solution.GetTotalPrototypeQuantity(component.Reagent).Float();
var reagent = component.FractionalReagent * FixedPoint2.Epsilon.Float() + availableReagent;
args.Fuel = reagent * component.Multiplier;
var availableReagent = solution.GetTotalPrototypeQuantity(entity.Comp.Reagent).Float();
var reagent = entity.Comp.FractionalReagent * FixedPoint2.Epsilon.Float() + availableReagent;
args.Fuel = reagent * entity.Comp.Multiplier;
}
private void SolidUseFuel(EntityUid uid, SolidFuelGeneratorAdapterComponent component, GeneratorUseFuel args)