/// <summary> /// Kills a powernet after it is marked dirty and its component have already been regenerated by the powernet system /// </summary> public void DirtyKill() { Wirelist.Clear(); while (Nodelist.Count != 0) { Nodelist[0].DisconnectFromPowernet(); } Generatorlist.Clear(); Deviceloadlist.Clear(); DepoweredDevices.Clear(); PowerStorageSupplierlist.Clear(); PowerStorageConsumerlist.Clear(); RemoveFromSystem(); }
/// <summary> /// Combines two powernets when they connect via powertransfer components /// </summary> public void MergePowernets(Powernet toMerge) { //TODO: load balance reconciliation between powernets on merge tick here foreach (var wire in toMerge.Wirelist) { wire.Parent = this; } Wirelist.AddRange(toMerge.Wirelist); toMerge.Wirelist.Clear(); foreach (var node in toMerge.Nodelist) { node.Parent = this; } Nodelist.AddRange(toMerge.Nodelist); toMerge.Nodelist.Clear(); foreach (var generator in toMerge.Generatorlist) { Generatorlist.Add(generator.Key, generator.Value); } toMerge.Generatorlist.Clear(); foreach (var device in toMerge.Deviceloadlist) { Deviceloadlist.Add(device); } toMerge.Deviceloadlist.Clear(); DepoweredDevices.AddRange(toMerge.DepoweredDevices); toMerge.DepoweredDevices.Clear(); PowerStorageSupplierlist.AddRange(toMerge.PowerStorageSupplierlist); toMerge.PowerStorageSupplierlist.Clear(); PowerStorageConsumerlist.AddRange(toMerge.PowerStorageConsumerlist); toMerge.PowerStorageConsumerlist.Clear(); toMerge.RemoveFromSystem(); }