@@ -1,4 +1,4 @@
|
||||
using Content.Server.GameObjects.Components.Power.Chargers;
|
||||
using Content.Server.GameObjects.Components.Power.Chargers;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
@@ -6,19 +6,18 @@ using Robust.Shared.GameObjects.Systems;
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal class CellChargerSystem : EntitySystem
|
||||
internal class BaseChargerSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
EntityQuery = new TypeEntityQuery(typeof(PowerCellChargerComponent));
|
||||
EntityQuery = new TypeEntityQuery(typeof(BaseCharger));
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var entity in RelevantEntities)
|
||||
{
|
||||
var comp = entity.GetComponent<PowerCellChargerComponent>();
|
||||
comp.OnUpdate(frameTime);
|
||||
entity.GetComponent<BaseCharger>().OnUpdate(frameTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Content.Server.GameObjects.Components.Power.PowerNetComponents;
|
||||
using Robust.Server.Interfaces.Timing;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
internal class BatteryDischargerSystem : EntitySystem
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPauseManager _pauseManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
EntityQuery = new TypeEntityQuery(typeof(BatteryDischargerComponent));
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var entity in RelevantEntities)
|
||||
{
|
||||
if (_pauseManager.IsEntityPaused(entity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entity.GetComponent<BatteryDischargerComponent>().Update(frameTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Content.Server.GameObjects.Components.Power.PowerNetComponents;
|
||||
using Robust.Server.Interfaces.Timing;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
internal class BatteryStorageSystem : EntitySystem
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPauseManager _pauseManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
EntityQuery = new TypeEntityQuery(typeof(BatteryStorageComponent));
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var entity in RelevantEntities)
|
||||
{
|
||||
if (_pauseManager.IsEntityPaused(entity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entity.GetComponent<BatteryStorageComponent>().Update(frameTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Server.Interfaces.Timing;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
class PowerApcSystem : EntitySystem
|
||||
public sealed class ApcSystem : EntitySystem
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPauseManager _pauseManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
EntityQuery = new TypeEntityQuery(typeof(ApcComponent));
|
||||
@@ -13,10 +21,20 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
var uniqueApcNets = new HashSet<IApcNet>(); //could be improved by maintaining set instead of getting collection every frame
|
||||
foreach (var entity in RelevantEntities)
|
||||
{
|
||||
var comp = entity.GetComponent<ApcComponent>();
|
||||
comp.OnUpdate();
|
||||
if (_pauseManager.IsEntityPaused(entity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var apc = entity.GetComponent<ApcComponent>();
|
||||
uniqueApcNets.Add(apc.Net);
|
||||
entity.GetComponent<ApcComponent>().Update();
|
||||
}
|
||||
foreach (var apcNet in uniqueApcNets)
|
||||
{
|
||||
apcNet.Update(frameTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
foreach (var entity in RelevantEntities)
|
||||
{
|
||||
var comp = entity.GetComponent<SmesComponent>();
|
||||
comp.OnUpdate();
|
||||
entity.GetComponent<SmesComponent>().OnUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Shared.GameObjects.EntitySystems
|
||||
{
|
||||
public class PowerSystem : EntitySystem
|
||||
{
|
||||
public List<Powernet> Powernets = new List<Powernet>();
|
||||
|
||||
private IComponentManager componentManager;
|
||||
|
||||
private int _lastUid = 0;
|
||||
|
||||
public PowerSystem()
|
||||
{
|
||||
EntityQuery = new TypeEntityQuery(typeof(PowerDeviceComponent));
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
componentManager = IoCManager.Resolve<IComponentManager>();
|
||||
}
|
||||
|
||||
public int NewUid()
|
||||
{
|
||||
return ++_lastUid;
|
||||
}
|
||||
|
||||
public override void Update(float frametime)
|
||||
{
|
||||
for (int i = 0; i < Powernets.Count; i++)
|
||||
{
|
||||
var powernet = Powernets[i];
|
||||
if (powernet.Dirty)
|
||||
{
|
||||
//Tell all the wires of this net to be prepared to create/join new powernets
|
||||
foreach (var wire in powernet.WireList)
|
||||
{
|
||||
wire.Regenerating = true;
|
||||
}
|
||||
|
||||
foreach (var wire in powernet.WireList)
|
||||
{
|
||||
//Only a few wires should pass this if check since each will create and take all the others into its powernet
|
||||
if (wire.Regenerating)
|
||||
wire.SpreadPowernet();
|
||||
}
|
||||
|
||||
//At this point all wires will have found/joined new powernet, all capable nodes will have joined them as well and removed themselves from nodelist
|
||||
powernet.DirtyKill();
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var powernet in Powernets)
|
||||
{
|
||||
powernet.Update(frametime);
|
||||
}
|
||||
|
||||
// Draw power for devices not connected to anything.
|
||||
foreach (var entity in EntityManager.GetEntities(EntityQuery))
|
||||
{
|
||||
var device = entity.GetComponent<PowerDeviceComponent>();
|
||||
device.ProcessInternalPower(frametime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Content.Server.GameObjects.Components.Power.Chargers;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal class WeaponCapacitorChargerSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
EntityQuery = new TypeEntityQuery(typeof(WeaponCapacitorChargerComponent));
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var entity in RelevantEntities)
|
||||
{
|
||||
var comp = entity.GetComponent<WeaponCapacitorChargerComponent>();
|
||||
comp.OnUpdate(frameTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user