diff --git a/Content.Server/_FTL/AmbientHeater/AmbientHeaterComponent.cs b/Content.Server/_FTL/AmbientHeater/AmbientHeaterComponent.cs new file mode 100644 index 00000000000000..ed9351a823bf0a --- /dev/null +++ b/Content.Server/_FTL/AmbientHeater/AmbientHeaterComponent.cs @@ -0,0 +1,18 @@ +namespace Content.Server._FTL.AmbientHeater; + +[RegisterComponent] +public sealed class AmbientHeaterComponent : Component +{ + [DataField("targetTemperature")] + [ViewVariables(VVAccess.ReadWrite)] + public float TargetTemperature = 293.15f; + + [ViewVariables(VVAccess.ReadWrite)] + [DataField("heatPerSecond")] + public float HeatPerSecond = 100f; + + [ViewVariables(VVAccess.ReadOnly)] [DataField("requirePower")] + public bool RequiresPower = false; + + [ViewVariables(VVAccess.ReadOnly)] public bool Powered = false; +} diff --git a/Content.Server/_FTL/AmbientHeater/AmbientHeaterSystem.cs b/Content.Server/_FTL/AmbientHeater/AmbientHeaterSystem.cs new file mode 100644 index 00000000000000..181b783029e26a --- /dev/null +++ b/Content.Server/_FTL/AmbientHeater/AmbientHeaterSystem.cs @@ -0,0 +1,48 @@ +using System.Linq; +using Content.Server._FTL.AmbientHeater; +using Content.Server.Atmos.EntitySystems; +using Content.Server.Power.Components; +using Content.Server.Power.EntitySystems; +using Content.Server.Temperature.Systems; +using Robust.Server.GameObjects; + +namespace Content.Server._Frigid.AmbientHeater; + +public sealed class AmbientHeaterSystem : EntitySystem +{ + [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; + [Dependency] private readonly TransformSystem _transformSystem = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(HandlePowerChange); + } + + private void HandlePowerChange(EntityUid uid, AmbientHeaterComponent component, ref PowerChangedEvent args) + { + component.Powered = args.Powered; + } + + public override void Update(float frameTime) + { + base.Update(frameTime); + + foreach (var (heater, transform) in EntityQuery()) + { + if (heater.Powered == false && heater.RequiresPower) + continue; + + var ent = transform.ParentUid; + var grid = transform.GridUid; + var map = transform.MapUid; + var indices = _transformSystem.GetGridOrMapTilePosition(ent, transform); + var mixture = _atmosphereSystem.GetTileMixture(grid, map, indices, true); + if (mixture is { }) + { + if (mixture.Temperature <= heater.TargetTemperature) + mixture.Temperature += heater.HeatPerSecond * frameTime; + } + } + } +} diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/generators.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/generators.yml index 754c4787cf9bdb..f15f1e79321de6 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/generators.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/generators.yml @@ -167,10 +167,10 @@ - type: entity parent: [ BaseGenerator, ConstructibleMachine ] id: GeneratorPlasma - suffix: Plasma, 5kW + suffix: Plasma, 10kW components: - type: PowerSupplier - supplyRate: 5000 # 260 sec / sheet + supplyRate: 10000 - type: Sprite sprite: Structures/Power/Generation/portable_generator.rsi state: portgen0_1