* Power Commit 1 * Commit 2 * Powernet Part2, All components essentially complete * Commit 4 * Commit 5 * Commit 6 Creates prototypes * Finishes powernet code alpha Adds prototypes and logic for powernet updating and regeneration * Adds onremove functionality to all components Without these bits of logic nothing makes any sense! * And this * Fixes a lot of bugs * Fix powernet thinking devices are duplicates * Fix bug and add comments * woop woop thats the sound of the police
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using Content.Server.GameObjects.Components.Power;
|
|
using SS14.Shared.GameObjects.System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Content.Shared.GameObjects.EntitySystems
|
|
{
|
|
public class PowerSystem : EntitySystem
|
|
{
|
|
public List<Powernet> Powernets = new List<Powernet>();
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|