/// <summary> /// Set the distributable power for a particular subsystem. /// </summary> /// <param name="subsystemType">The subsystem type.</param> /// <param name="newDistributablePowerFraction">The new distributable power fraction.</param> public void SetSubsystemDistributablePowerFraction(PoweredSubsystemType subsystemType, float newDistributablePowerFraction) { int index = (int)subsystemType; if (poweredSubsystems[index].powerConfiguration != SubsystemPowerConfiguration.Collective) { return; } poweredSubsystems[index].distributablePowerFraction = newDistributablePowerFraction; }
/// <summary> /// Get the distributable power currently available for a particular subsystem. /// </summary> /// <param name="subsystemType">The subsystem type.</param> /// <returns>The distributable power available to the subsystem.</returns> public float GetSubsystemDistributablePower(PoweredSubsystemType subsystemType) { int index = (int)subsystemType; switch (poweredSubsystems[index].powerConfiguration) { case SubsystemPowerConfiguration.Collective: return(poweredSubsystems[index].distributablePowerFraction * distributablePowerFraction * TotalPower); case SubsystemPowerConfiguration.Independent: return(0f); default: return(0f); } }
/// <summary> /// Get the fixed (non-distributable) power that a subsystem can access. /// </summary> /// <param name="subsystemType">The subsystem type.</param> /// <returns>The fixed power available to the subsystem.</returns> public float GetSubsystemFixedPower(PoweredSubsystemType subsystemType) { int index = (int)subsystemType; switch (poweredSubsystems[index].powerConfiguration) { case SubsystemPowerConfiguration.Collective: return(poweredSubsystems[index].fixedPowerFraction * TotalPower); case SubsystemPowerConfiguration.Independent: return(poweredSubsystems[index].independentPowerOutput); default: return(0f); } }
/// <summary> /// Draw the stored power for a given subsystem. /// </summary> /// <param name="subsystemType">The type of subsystem.</param> /// <param name="amount">The amount of power to draw.</param> /// <returns>Whether the power was successfully drawn.</returns> public bool DrawStoredPower(PoweredSubsystemType subsystemType, float amount) { int index = (int)subsystemType; switch (poweredSubsystems[index].powerConfiguration) { case SubsystemPowerConfiguration.Unpowered: return(true); default: if (poweredSubsystems[index].currentStorageValue >= amount) { poweredSubsystems[index].currentStorageValue -= amount; return(true); } else { return(false); } } }
/// <summary> /// Check if there is a given amount of stored power available for a subsystem. /// </summary> /// <param name="subsystemType">The subsystem type.</param> /// <param name="amount">The amount to query for.</param> /// <returns>Whether or not there is enough stored power.</returns> public bool HasStoredPower(PoweredSubsystemType subsystemType, float amount) { int index = (int)subsystemType; return(poweredSubsystems[index].currentStorageValue >= amount); }
/// <summary> /// Get the power storage capacity for a given subsystem. /// </summary> /// <param name="subsystemType">The type of subsystem.</param> /// <returns>The power storage capacity for the subsystem.</returns> public float GetStorageCapacity(PoweredSubsystemType subsystemType) { int index = (int)subsystemType; return(poweredSubsystems[index].storageCapacity); }
/// <summary> /// Get the stored power for a given subsystem. /// </summary> /// <param name="subsystemType">The subsystem type.</param> /// <returns>The stored power for the subsystem.</returns> public float GetStoredPower(PoweredSubsystemType subsystemType) { int index = (int)subsystemType; return(poweredSubsystems[index].currentStorageValue); }
/// <summary> /// Get the power configuration of a particular powered subsystem. /// </summary> /// <param name="subsystemType">The powered subsystem type.</param> /// <returns>The power configuration of the subsystem.</returns> public SubsystemPowerConfiguration GetPowerConfiguration(PoweredSubsystemType subsystemType) { return(poweredSubsystems[(int)subsystemType].powerConfiguration); }