Revert 'Revert 'Solution Entities'' (#23168)
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Placeable;
|
||||
|
||||
namespace Content.Server.Chemistry.EntitySystems;
|
||||
@@ -13,7 +13,7 @@ public sealed class SolutionHeaterSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly PowerReceiverSystem _powerReceiver = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solution = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
@@ -51,41 +51,41 @@ public sealed class SolutionHeaterSystem : EntitySystem
|
||||
RemComp<ActiveSolutionHeaterComponent>(uid);
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, SolutionHeaterComponent component, ref PowerChangedEvent args)
|
||||
private void OnPowerChanged(Entity<SolutionHeaterComponent> entity, ref PowerChangedEvent args)
|
||||
{
|
||||
var placer = Comp<ItemPlacerComponent>(uid);
|
||||
var placer = Comp<ItemPlacerComponent>(entity);
|
||||
if (args.Powered && placer.PlacedEntities.Count > 0)
|
||||
{
|
||||
TurnOn(uid);
|
||||
TurnOn(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
TurnOff(uid);
|
||||
TurnOff(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRefreshParts(EntityUid uid, SolutionHeaterComponent component, RefreshPartsEvent args)
|
||||
private void OnRefreshParts(Entity<SolutionHeaterComponent> entity, ref RefreshPartsEvent args)
|
||||
{
|
||||
var heatRating = args.PartRatings[component.MachinePartHeatMultiplier] - 1;
|
||||
var heatRating = args.PartRatings[entity.Comp.MachinePartHeatMultiplier] - 1;
|
||||
|
||||
component.HeatPerSecond = component.BaseHeatPerSecond * MathF.Pow(component.PartRatingHeatMultiplier, heatRating);
|
||||
entity.Comp.HeatPerSecond = entity.Comp.BaseHeatPerSecond * MathF.Pow(entity.Comp.PartRatingHeatMultiplier, heatRating);
|
||||
}
|
||||
|
||||
private void OnUpgradeExamine(EntityUid uid, SolutionHeaterComponent component, UpgradeExamineEvent args)
|
||||
private void OnUpgradeExamine(Entity<SolutionHeaterComponent> entity, ref UpgradeExamineEvent args)
|
||||
{
|
||||
args.AddPercentageUpgrade("solution-heater-upgrade-heat", component.HeatPerSecond / component.BaseHeatPerSecond);
|
||||
args.AddPercentageUpgrade("solution-heater-upgrade-heat", entity.Comp.HeatPerSecond / entity.Comp.BaseHeatPerSecond);
|
||||
}
|
||||
|
||||
private void OnItemPlaced(EntityUid uid, SolutionHeaterComponent comp, ref ItemPlacedEvent args)
|
||||
private void OnItemPlaced(Entity<SolutionHeaterComponent> entity, ref ItemPlacedEvent args)
|
||||
{
|
||||
TryTurnOn(uid);
|
||||
TryTurnOn(entity);
|
||||
}
|
||||
|
||||
private void OnItemRemoved(EntityUid uid, SolutionHeaterComponent component, ref ItemRemovedEvent args)
|
||||
private void OnItemRemoved(Entity<SolutionHeaterComponent> entity, ref ItemRemovedEvent args)
|
||||
{
|
||||
var placer = Comp<ItemPlacerComponent>(uid);
|
||||
var placer = Comp<ItemPlacerComponent>(entity);
|
||||
if (placer.PlacedEntities.Count == 0) // Last entity was removed
|
||||
TurnOff(uid);
|
||||
TurnOff(entity);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
@@ -97,13 +97,13 @@ public sealed class SolutionHeaterSystem : EntitySystem
|
||||
{
|
||||
foreach (var heatingEntity in placer.PlacedEntities)
|
||||
{
|
||||
if (!TryComp<SolutionContainerManagerComponent>(heatingEntity, out var solution))
|
||||
if (!TryComp<SolutionContainerManagerComponent>(heatingEntity, out var container))
|
||||
continue;
|
||||
|
||||
var energy = heater.HeatPerSecond * frameTime;
|
||||
foreach (var s in solution.Solutions.Values)
|
||||
foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((heatingEntity, container)))
|
||||
{
|
||||
_solution.AddThermalEnergy(heatingEntity, s, energy);
|
||||
_solutionContainer.AddThermalEnergy(soln, energy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user