Example #1
0
 /// <summary>
 /// Register a continuous load from a device connected to the powernet
 /// </summary>
 public void AddDevice(PowerDeviceComponent device)
 {
     Deviceloadlist.Add(device);
     Load += device.Load;
     if (!device.Powered)
     {
         DepoweredDevices.Add(device);
     }
 }
Example #2
0
        /// <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();
        }