コード例 #1
0
        /// <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;
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
        /// <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);
            }
        }
コード例 #4
0
        /// <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);
                }
            }
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
 /// <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);
 }