/// <summary> /// Update one of the loads from a deviceconnected to the powernet /// </summary> public void UpdateDevice(PowerDeviceComponent device, float oldLoad) { if (DeviceLoadList.Contains(device)) { Load -= oldLoad; Load += device.Load; } }
/// <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); } }
public override void Initialize() { base.Initialize(); _userInterface = Owner.GetComponent <ServerUserInterfaceComponent>().GetBoundUserInterface(SolarControlConsoleUiKey.Key); _userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage; _powerDevice = Owner.GetComponent <PowerDeviceComponent>(); _powerSolarSystem = _entitySystemManager.GetEntitySystem <PowerSolarSystem>(); }
/// <summary> /// Remove a continuous load from a device connected to the powernet /// </summary> public void RemoveDevice(PowerDeviceComponent device) { if (DeviceLoadList.Contains(device)) { Load -= device.Load; DeviceLoadList.Remove(device); if (DepoweredDevices.Contains(device)) { DepoweredDevices.Remove(device); } } else { Logger.WarningS("power", "We tried to remove device {0} twice from {1}, somehow.", device.Owner, this); } }
/// <summary> /// Remove a continuous load from a device connected to the powernet /// </summary> public void RemoveDevice(PowerDeviceComponent device) { if (Deviceloadlist.Contains(device)) { Load -= device.Load; Deviceloadlist.Remove(device); if (DepoweredDevices.Contains(device)) { DepoweredDevices.Remove(device); } } else { var name = device.Owner.Prototype.Name; Logger.Log(String.Format("We tried to remove a device twice from the same powernet somehow, prototype {0}", name)); } }
/// <summary> /// Returns whether or not a power device is in this powernet's load list. /// </summary> /// <param name="device">The device to check for.</param> /// <returns>True if the device is in the load list, false otherwise.</returns> public bool HasDevice(PowerDeviceComponent device) { return(DeviceLoadList.Contains(device)); }