From: Guillaume E <262623+quatre@users.noreply.github.com> Date: Fri, 28 Jun 2024 18:49:39 +0000 (+0200) Subject: Make miners respect AtmosDeviceUpdateEvent.dt (#29522) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=c38859b77a29e3534179bfdfe7ea562d69909444;p=space-station-14.git Make miners respect AtmosDeviceUpdateEvent.dt (#29522) Miners' prototype have been changed to reflect this (I read somewhere that we have about 1 atmos tick/0.5s, my tests show more like 1/0.53 but that looks close enough). This also means that miner's spawnAmount is now expressed in mol/s. See: #18781 --- diff --git a/Content.Server/Atmos/Piping/Other/Components/GasMinerComponent.cs b/Content.Server/Atmos/Piping/Other/Components/GasMinerComponent.cs index e6d8ec790d..18a0b9b078 100644 --- a/Content.Server/Atmos/Piping/Other/Components/GasMinerComponent.cs +++ b/Content.Server/Atmos/Piping/Other/Components/GasMinerComponent.cs @@ -25,6 +25,9 @@ namespace Content.Server.Atmos.Piping.Other.Components [DataField("spawnTemperature")] public float SpawnTemperature { get; set; } = Atmospherics.T20C; + /// + /// Number of moles created per second when the miner is working. + /// [ViewVariables(VVAccess.ReadWrite)] [DataField("spawnAmount")] public float SpawnAmount { get; set; } = Atmospherics.MolesCellStandard * 20f; diff --git a/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs b/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs index aa206dbc68..2505c8189f 100644 --- a/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs +++ b/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs @@ -24,18 +24,22 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems private void OnMinerUpdated(Entity ent, ref AtmosDeviceUpdateEvent args) { var miner = ent.Comp; - if (!CheckMinerOperation(ent, out var environment) || !miner.Enabled || !miner.SpawnGas.HasValue || miner.SpawnAmount <= 0f) + + // SpawnAmount is declared in mol/s so to get the amount of gas we hope to mine, we have to multiply this by + // how long we have been waiting to spawn it. + var toSpawn = miner.SpawnAmount * args.dt; + if (!CheckMinerOperation(ent, toSpawn, out var environment) || !miner.Enabled || !miner.SpawnGas.HasValue || toSpawn <= 0f) return; // Time to mine some gas. var merger = new GasMixture(1) { Temperature = miner.SpawnTemperature }; - merger.SetMoles(miner.SpawnGas.Value, miner.SpawnAmount); + merger.SetMoles(miner.SpawnGas.Value, toSpawn); _atmosphereSystem.Merge(environment, merger); } - private bool CheckMinerOperation(Entity ent, [NotNullWhen(true)] out GasMixture? environment) + private bool CheckMinerOperation(Entity ent, float toSpawn, [NotNullWhen(true)] out GasMixture? environment) { var (uid, miner) = ent; var transform = Transform(uid); @@ -59,7 +63,7 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems // External pressure above threshold. if (!float.IsInfinity(miner.MaxExternalPressure) && - environment.Pressure > miner.MaxExternalPressure - miner.SpawnAmount * miner.SpawnTemperature * Atmospherics.R / environment.Volume) + environment.Pressure > miner.MaxExternalPressure - toSpawn * miner.SpawnTemperature * Atmospherics.R / environment.Volume) { miner.Broken = true; return false; diff --git a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/miners.yml b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/miners.yml index 2231fc4ddc..6d10b1521e 100644 --- a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/miners.yml +++ b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/miners.yml @@ -30,7 +30,7 @@ - type: AtmosDevice - type: GasMiner maxExternalPressure: 300 - spawnAmount: 200 + spawnAmount: 400 - type: entity name: O2 gas miner