示例#1
0
        private void ConsumePower(float timeDeltaMs, float output)
        {
            if (!SourceComp.HasCapacityRemainingByType(MyResourceDistributorComponent.ElectricityId))
            {
                return;
            }

            float consumptionPerMillisecond = output / (SourceComp.ProductionToCapacityMultiplier * 1000f);
            float consumedPower             = timeDeltaMs * consumptionPerMillisecond;

            if (consumedPower == 0)
            {
                return;
            }

            if ((CurrentStoredPower - consumedPower) <= 0)
            {
                SourceComp.SetOutput(0);
                CurrentStoredPower = 0;
                TimeRemaining      = 0;
            }
            else
            {
                CurrentStoredPower -= consumedPower;
                if (m_isFull)
                {
                    m_isFull.Value = false;
                }
            }
            m_storedPower.Value = CurrentStoredPower;
        }