Ipc/fix battery alert (#5345)
* Move SiliconChargeSystem to shared under _DV namespace * Remove SiliconHeatEffects * Fixup system to match _DV and shared * Update usages of other systems * Move CVar to server/replicated * Remove unused systems
This commit is contained in:
parent
ae8bfec6cb
commit
47ea823edd
|
|
@ -1,7 +1,7 @@
|
|||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Lightning;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server._EE.Silicon.Charge;
|
||||
using Content.Shared._DV.Silicons.Charge.Systems; // DeltaV - Moved IPC charge to shared
|
||||
using Content.Shared._EE.Silicon.DeadStartupButton;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Damage;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using Content.Shared.Power.Components;
|
||||
using Content.Shared._EE.Silicon.Systems;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Server._EE.Silicon.Charge;
|
||||
using Content.Shared._DV.Silicons.Charge.Systems; // DeltaV - Moved IPC charge to shared
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Shared.Humanoid;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,5 +43,5 @@ public sealed partial class CCVars : CVars
|
|||
/// TODO: Move this to the proper file. I dunno which, just not the main one.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> SiliconNpcUpdateTime =
|
||||
CVarDef.Create("silicon.npcupdatetime", 1.5f, CVar.SERVERONLY);
|
||||
CVarDef.Create("silicon.npcupdatetime", 1.5f, CVar.SERVER | CVar.REPLICATED); // DeltaV - Move IPC charge to shared
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,15 @@ using Robust.Shared.Random;
|
|||
using Content.Shared._EE.Silicon.Components;
|
||||
using Content.Shared.Power.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Temperature.Components;
|
||||
using Content.Shared.Atmos.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared._EE.Silicon.Systems;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Shared.Mind.Components;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.CCVar;
|
||||
using SharedCVars = Content.Shared.CCVar.CCVars;
|
||||
using Content.Shared.PowerCell.Components;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.PowerCell;
|
||||
|
|
@ -24,13 +20,11 @@ using Content.Shared.Movement.Components;
|
|||
using Robust.Shared.Physics.Components;
|
||||
// End TheDen
|
||||
|
||||
namespace Content.Server._EE.Silicon.Charge;
|
||||
namespace Content.Shared._DV.Silicons.Charge.Systems;
|
||||
|
||||
public sealed class SiliconChargeSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _moveMod = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IConfigurationManager _config = default!;
|
||||
|
|
@ -91,7 +85,7 @@ public sealed class SiliconChargeSystem : EntitySystem
|
|||
// Check if the Silicon is an NPC, and if so, follow the delay as specified in the CVAR.
|
||||
if (siliconComp.EntityType.Equals(SiliconType.Npc))
|
||||
{
|
||||
var updateTime = _config.GetCVar(CCVars.SiliconNpcUpdateTime);
|
||||
var updateTime = _config.GetCVar(SharedCVars.SiliconNpcUpdateTime);
|
||||
if (_timing.CurTime - siliconComp.LastDrainTime < TimeSpan.FromSeconds(updateTime))
|
||||
continue;
|
||||
|
||||
|
|
@ -126,7 +120,6 @@ public sealed class SiliconChargeSystem : EntitySystem
|
|||
// Maybe it doesn't matter, and stuff should just use static drain?
|
||||
if (!siliconComp.EntityType.Equals(SiliconType.Npc)) // Don't bother checking heat if it's an NPC. It's a waste of time, and it'd be delayed due to the update time.
|
||||
{
|
||||
drainRateFinalAddi += SiliconHeatEffects(silicon, siliconComp, frameTime) - 1; // This will need to be changed at some point if we allow external batteries, since the heat of the Silicon might not be applicable.
|
||||
drainRateFinalAddi += SiliconMovementEffects(silicon, siliconComp); // TheDen - IPC Dynamic Power draw // Removes between 90% and 0% of the total power draw.
|
||||
}
|
||||
|
||||
|
|
@ -167,52 +160,6 @@ public sealed class SiliconChargeSystem : EntitySystem
|
|||
}
|
||||
}
|
||||
|
||||
private float SiliconHeatEffects(EntityUid silicon, SiliconComponent siliconComp, float frameTime)
|
||||
{
|
||||
if (!TryComp<TemperatureComponent>(silicon, out var temperComp)
|
||||
|| !TryComp<ThermalRegulatorComponent>(silicon, out var thermalComp))
|
||||
return 0;
|
||||
|
||||
// If the Silicon is hot, drain the battery faster, if it's cold, drain it slower, capped.
|
||||
var upperThresh = thermalComp.NormalBodyTemperature + thermalComp.ThermalRegulationTemperatureThreshold;
|
||||
var upperThreshHalf = thermalComp.NormalBodyTemperature + thermalComp.ThermalRegulationTemperatureThreshold * 0.5f;
|
||||
|
||||
// Check if the silicon is in a hot environment.
|
||||
if (temperComp.CurrentTemperature > upperThreshHalf)
|
||||
{
|
||||
// Divide the current temp by the max comfortable temp capped to 4, then add that to the multiplier.
|
||||
var hotTempMulti = Math.Min(temperComp.CurrentTemperature / upperThreshHalf, 4);
|
||||
|
||||
// If the silicon is hot enough, it has a chance to catch fire.
|
||||
|
||||
siliconComp.OverheatAccumulator += frameTime;
|
||||
if (!(siliconComp.OverheatAccumulator >= 5))
|
||||
return hotTempMulti;
|
||||
|
||||
siliconComp.OverheatAccumulator -= 5;
|
||||
|
||||
if (!EntityManager.TryGetComponent<FlammableComponent>(silicon, out var flamComp)
|
||||
|| flamComp is { OnFire: true }
|
||||
|| !(temperComp.CurrentTemperature > temperComp.HeatDamageThreshold))
|
||||
return hotTempMulti;
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("silicon-overheating"), silicon, silicon, PopupType.MediumCaution);
|
||||
if (!_random.Prob(Math.Clamp(temperComp.CurrentTemperature / (upperThresh * 5), 0.001f, 0.9f)))
|
||||
return hotTempMulti;
|
||||
|
||||
// GoobStation: Replaced by KillOnOverheatSystem
|
||||
//_flammable.AdjustFireStacks(silicon, Math.Clamp(siliconComp.FireStackMultiplier, -10, 10), flamComp);
|
||||
//_flammable.Ignite(silicon, silicon, flamComp);
|
||||
return hotTempMulti;
|
||||
}
|
||||
|
||||
// Check if the silicon is in a cold environment.
|
||||
if (temperComp.CurrentTemperature < thermalComp.NormalBodyTemperature)
|
||||
return 0.5f + temperComp.CurrentTemperature / thermalComp.NormalBodyTemperature * 0.5f;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TheDen - IPC Dynamic Power draw
|
||||
private float SiliconMovementEffects(EntityUid silicon, SiliconComponent siliconComp)
|
||||
{
|
||||
Loading…
Reference in New Issue