Converts the particle accelerator over to ECS + misc (#17075)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,22 +1,28 @@
|
||||
using Content.Server.ParticleAccelerator.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
|
||||
namespace Content.Server.ParticleAccelerator.EntitySystems
|
||||
{
|
||||
public sealed partial class ParticleAcceleratorSystem
|
||||
{
|
||||
private void InitializePowerBoxSystem()
|
||||
{
|
||||
SubscribeLocalEvent<ParticleAcceleratorPowerBoxComponent, PowerConsumerReceivedChanged>(PowerBoxReceivedChanged);
|
||||
}
|
||||
namespace Content.Server.ParticleAccelerator.EntitySystems;
|
||||
|
||||
private void PowerBoxReceivedChanged(
|
||||
EntityUid uid,
|
||||
ParticleAcceleratorPowerBoxComponent component,
|
||||
ref PowerConsumerReceivedChanged args)
|
||||
{
|
||||
if (TryComp(uid, out ParticleAcceleratorPartComponent? paPart))
|
||||
paPart.Master?.PowerBoxReceivedChanged(args);
|
||||
}
|
||||
public sealed partial class ParticleAcceleratorSystem
|
||||
{
|
||||
private void InitializePowerBoxSystem()
|
||||
{
|
||||
SubscribeLocalEvent<ParticleAcceleratorPowerBoxComponent, PowerConsumerReceivedChanged>(PowerBoxReceivedChanged);
|
||||
}
|
||||
|
||||
private void PowerBoxReceivedChanged(EntityUid uid, ParticleAcceleratorPowerBoxComponent component, ref PowerConsumerReceivedChanged args)
|
||||
{
|
||||
if (!TryComp<ParticleAcceleratorPartComponent>(uid, out var part))
|
||||
return;
|
||||
if (!TryComp<ParticleAcceleratorControlBoxComponent>(part.Master, out var controller))
|
||||
return;
|
||||
|
||||
var master = part.Master!.Value;
|
||||
if (controller.Enabled && args.ReceivedPower >= args.DrawRate * ParticleAcceleratorControlBoxComponent.RequiredPowerRatio)
|
||||
PowerOn(master, comp: controller);
|
||||
else
|
||||
PowerOff(master, comp: controller);
|
||||
|
||||
UpdateUI(master, controller);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user