mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* Hope I'm not forgetting anything... * They call me the sender the way I'm sending it. * remove commented out YAML * last of the slop * fix test fails * first batch of test fails * no more test fails * make cryo pods work again. * Make cryo work better-er * I didn't like that a firesuit helmet was so effective on its own so I decided to be a dick about it. * review.com * oop * actually real quick do this * fix YAML issues * IHeatContainer my beloved <3 * borger * not networked :( * jackets * burgeewqjfrwjkhaskfjfsahjkfsahjkfsahjkfsajhkfsa * utter yaml nonsense * phishing --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using Content.Server.Power.Components;
|
|
using Content.Shared.Placeable;
|
|
using Content.Shared.Temperature;
|
|
using Content.Shared.Temperature.Components;
|
|
using Content.Shared.Temperature.Systems;
|
|
|
|
namespace Content.Server.Temperature.Systems;
|
|
|
|
/// <summary>
|
|
/// Handles the server-only parts of <see cref="SharedEntityHeaterSystem"/>
|
|
/// </summary>
|
|
public sealed partial class EntityHeaterSystem : SharedEntityHeaterSystem
|
|
{
|
|
[Dependency] private TemperatureSystem _temperature = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<EntityHeaterComponent, MapInitEvent>(OnMapInit);
|
|
}
|
|
|
|
private void OnMapInit(Entity<EntityHeaterComponent> ent, ref MapInitEvent args)
|
|
{
|
|
// Set initial power level
|
|
if (TryComp<ApcPowerReceiverComponent>(ent, out var power))
|
|
power.Load = SettingPower(ent.Comp.Setting, ent.Comp.Power);
|
|
}
|
|
|
|
public override void Update(float deltaTime)
|
|
{
|
|
var query = EntityQueryEnumerator<EntityHeaterComponent, ItemPlacerComponent, ApcPowerReceiverComponent>();
|
|
while (query.MoveNext(out _, out _, out var placer, out var power))
|
|
{
|
|
if (!power.Powered)
|
|
continue;
|
|
|
|
// divide by total entities to encourage the use of multiple grills
|
|
// excess would just be wasted in the air but that's not worth simulating
|
|
// if you want a heater thermomachine just use that...
|
|
var energy = power.PowerReceived * deltaTime;
|
|
foreach (var ent in placer.PlacedEntities)
|
|
{
|
|
_temperature.ChangeHeat(ent, energy / placer.PlacedEntities.Count);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <remarks>
|
|
/// <see cref="ApcPowerReceiverComponent"/> doesn't exist on the client, so we need
|
|
/// this server-only override to handle setting the network load.
|
|
/// </remarks>
|
|
protected override void ChangeSetting(Entity<EntityHeaterComponent> ent, EntityHeaterSetting setting, EntityUid? user = null)
|
|
{
|
|
base.ChangeSetting(ent, setting, user);
|
|
|
|
if (!TryComp<ApcPowerReceiverComponent>(ent, out var power))
|
|
return;
|
|
|
|
power.Load = SettingPower(setting, ent.Comp.Power);
|
|
}
|
|
}
|