Predict gasthermomachines (#33837)

* Predict gasthermomachines

* despawn

* smellby
This commit is contained in:
metalgearsloth
2025-05-13 21:49:43 +10:00
committed by GitHub
parent 24141aa1e9
commit df2257cd92
16 changed files with 236 additions and 135 deletions

View File

@@ -4,13 +4,16 @@ using Content.Shared.Database;
using Content.Shared.Power.Components;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Network;
namespace Content.Shared.Power.EntitySystems;
public abstract class SharedPowerReceiverSystem : EntitySystem
{
[Dependency] private readonly INetManager _netMan = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPowerNetSystem _net = default!;
public abstract bool ResolveApc(EntityUid entity, [NotNullWhen(true)] ref SharedApcPowerReceiverComponent? component);
@@ -44,6 +47,15 @@ public abstract class SharedPowerReceiverSystem : EntitySystem
// it'll save a lot of confusion if 'always powered' means 'always powered'
if (!receiver.NeedsPower)
{
var powered = _net.IsPoweredCalculate(receiver);
// Server won't raise it here as it can raise the load event later with NeedsPower?
// This is mostly here for clientside predictions.
if (receiver.Powered != powered)
{
RaisePower((uid, receiver));
}
SetPowerDisabled(uid, false, receiver);
return true;
}
@@ -59,6 +71,19 @@ public abstract class SharedPowerReceiverSystem : EntitySystem
AudioParams.Default.WithVolume(-2f));
}
if (_netMan.IsClient && receiver.PowerDisabled)
{
var powered = _net.IsPoweredCalculate(receiver);
// Server won't raise it here as it can raise the load event later with NeedsPower?
// This is mostly here for clientside predictions.
if (receiver.Powered != powered)
{
receiver.Powered = powered;
RaisePower((uid, receiver));
}
}
return !receiver.PowerDisabled; // i.e. PowerEnabled
}