Remove component.Initialize calls (#18230)

This commit is contained in:
metalgearsloth
2023-07-26 22:37:52 +10:00
committed by GitHub
parent 32d8fd2cc7
commit b478d5326b
9 changed files with 91 additions and 153 deletions

View File

@@ -0,0 +1,49 @@
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);
}
public void BaseNetConnectorInit<T>(BaseNetConnectorComponent<T> component)
{
if (component.NeedsNet)
{
component.TryFindAndSetNet();
}
}
}

View File

@@ -17,6 +17,7 @@ namespace Content.Server.Power.EntitySystems
public sealed class PowerNetSystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly PowerNetConnectorSystem _powerNetConnector = default!;
[Dependency] private readonly IParallelManager _parMan = default!;
private readonly PowerState _powerState = new();
@@ -101,6 +102,7 @@ namespace Content.Server.Power.EntitySystems
private void PowerConsumerInit(EntityUid uid, PowerConsumerComponent component, ComponentInit args)
{
_powerNetConnector.BaseNetConnectorInit(component);
AllocLoad(component.NetworkLoad);
}
@@ -121,6 +123,7 @@ namespace Content.Server.Power.EntitySystems
private void PowerSupplierInit(EntityUid uid, PowerSupplierComponent component, ComponentInit args)
{
_powerNetConnector.BaseNetConnectorInit(component);
AllocSupply(component.NetworkSupply);
}