mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +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>
94 lines
3 KiB
C#
94 lines
3 KiB
C#
using Content.Server.Chemistry.Components;
|
|
using Content.Server.Power.Components;
|
|
using Content.Server.Power.EntitySystems;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.Chemistry;
|
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
using Content.Shared.Placeable;
|
|
using Content.Shared.Power;
|
|
|
|
namespace Content.Server.Chemistry.EntitySystems;
|
|
|
|
public sealed class SolutionHeaterSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly PowerReceiverSystem _powerReceiver = default!;
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
|
|
|
/// <inheritdoc/>
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SolutionHeaterComponent, PowerChangedEvent>(OnPowerChanged);
|
|
SubscribeLocalEvent<SolutionHeaterComponent, ItemPlacedEvent>(OnItemPlaced);
|
|
SubscribeLocalEvent<SolutionHeaterComponent, ItemRemovedEvent>(OnItemRemoved);
|
|
}
|
|
|
|
private void TurnOn(EntityUid uid)
|
|
{
|
|
_appearance.SetData(uid, SolutionHeaterVisuals.IsOn, true);
|
|
EnsureComp<ActiveSolutionHeaterComponent>(uid);
|
|
}
|
|
|
|
public bool TryTurnOn(EntityUid uid, ItemPlacerComponent? placer = null)
|
|
{
|
|
if (!Resolve(uid, ref placer))
|
|
return false;
|
|
|
|
if (placer.PlacedEntities.Count <= 0 || !_powerReceiver.IsPowered(uid))
|
|
return false;
|
|
|
|
TurnOn(uid);
|
|
return true;
|
|
}
|
|
|
|
public void TurnOff(EntityUid uid)
|
|
{
|
|
_appearance.SetData(uid, SolutionHeaterVisuals.IsOn, false);
|
|
RemComp<ActiveSolutionHeaterComponent>(uid);
|
|
}
|
|
|
|
private void OnPowerChanged(Entity<SolutionHeaterComponent> entity, ref PowerChangedEvent args)
|
|
{
|
|
var placer = Comp<ItemPlacerComponent>(entity);
|
|
if (args.Powered && placer.PlacedEntities.Count > 0)
|
|
{
|
|
TurnOn(entity);
|
|
}
|
|
else
|
|
{
|
|
TurnOff(entity);
|
|
}
|
|
}
|
|
|
|
private void OnItemPlaced(Entity<SolutionHeaterComponent> entity, ref ItemPlacedEvent args)
|
|
{
|
|
TryTurnOn(entity);
|
|
}
|
|
|
|
private void OnItemRemoved(Entity<SolutionHeaterComponent> entity, ref ItemRemovedEvent args)
|
|
{
|
|
var placer = Comp<ItemPlacerComponent>(entity);
|
|
if (placer.PlacedEntities.Count == 0) // Last entity was removed
|
|
TurnOff(entity);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
var query = EntityQueryEnumerator<ActiveSolutionHeaterComponent, SolutionHeaterComponent, ItemPlacerComponent>();
|
|
while (query.MoveNext(out _, out _, out var heater, out var placer))
|
|
{
|
|
var energy = heater.HeatPerSecond * frameTime;
|
|
foreach (var heatingEntity in placer.PlacedEntities)
|
|
{
|
|
foreach (var (_, soln) in _solutionContainer.EnumerateSolutions(heatingEntity))
|
|
{
|
|
_solutionContainer.AddThermalEnergy(soln, energy);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|