Some work on the mess that is this power code.
Jesus. Tons of fixes, refactors and other things. The powernet's code is still awful though.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using SS14.Shared.GameObjects.System;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -12,6 +14,21 @@ namespace Content.Shared.GameObjects.EntitySystems
|
||||
{
|
||||
public List<Powernet> Powernets = new List<Powernet>();
|
||||
|
||||
private IComponentManager componentManager;
|
||||
|
||||
private int _lastUid = 0;
|
||||
|
||||
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++)
|
||||
@@ -20,12 +37,12 @@ namespace Content.Shared.GameObjects.EntitySystems
|
||||
if (powernet.Dirty)
|
||||
{
|
||||
//Tell all the wires of this net to be prepared to create/join new powernets
|
||||
foreach (var wire in powernet.Wirelist)
|
||||
foreach (var wire in powernet.WireList)
|
||||
{
|
||||
wire.Regenerating = true;
|
||||
}
|
||||
|
||||
foreach (var wire in powernet.Wirelist)
|
||||
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)
|
||||
@@ -38,10 +55,16 @@ namespace Content.Shared.GameObjects.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var powernet in Powernets)
|
||||
foreach (var powernet in Powernets)
|
||||
{
|
||||
powernet.Update(frametime);
|
||||
}
|
||||
|
||||
// Draw power for devices not connected to anything.
|
||||
foreach (var device in componentManager.GetComponents<PowerDeviceComponent>())
|
||||
{
|
||||
device.ProcessInternalPower(frametime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user