2023-07-26 22:37:52 +10:00
|
|
|
using Content.Server.Power.Components;
|
|
|
|
|
using Content.Server.Power.NodeGroups;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Power.EntitySystems;
|
|
|
|
|
|
|
|
|
|
public sealed class PowerNetConnectorSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
SubscribeLocalEvent<ApcComponent, ComponentInit>(OnApcInit);
|
|
|
|
|
SubscribeLocalEvent<ApcPowerProviderComponent, ComponentInit>(OnApcPowerProviderInit);
|
|
|
|
|
SubscribeLocalEvent<BatteryChargerComponent, ComponentInit>(OnBatteryChargerInit);
|
|
|
|
|
SubscribeLocalEvent<BatteryDischargerComponent, ComponentInit>(OnBatteryDischargerInit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnPowerSupplierInit(EntityUid uid, PowerSupplierComponent component, ComponentInit args)
|
|
|
|
|
{
|
|
|
|
|
BaseNetConnectorInit(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnBatteryDischargerInit(EntityUid uid, BatteryDischargerComponent component, ComponentInit args)
|
|
|
|
|
{
|
|
|
|
|
BaseNetConnectorInit(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnBatteryChargerInit(EntityUid uid, BatteryChargerComponent component, ComponentInit args)
|
|
|
|
|
{
|
|
|
|
|
BaseNetConnectorInit(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnApcPowerProviderInit(EntityUid uid, ApcPowerProviderComponent component, ComponentInit args)
|
|
|
|
|
{
|
|
|
|
|
BaseNetConnectorInit(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnApcInit(EntityUid uid, ApcComponent component, ComponentInit args)
|
|
|
|
|
{
|
|
|
|
|
BaseNetConnectorInit(component);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-25 20:40:42 +02:00
|
|
|
public void BaseNetConnectorInit<T>(BaseNetConnectorComponent<T> component) where T : class
|
2023-07-26 22:37:52 +10:00
|
|
|
{
|
|
|
|
|
if (component.NeedsNet)
|
|
|
|
|
{
|
|
|
|
|
component.TryFindAndSetNet();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|