Esempio n. 1
0
    public void Heartbeat(float efficiency)
    {
        CirculatorySystemBase circulatorySystem = RelatedPart.HealthMaster.CirculatorySystem;

        if (circulatorySystem)
        {
            float pumpedReagent    = Math.Min(heartStrength * efficiency, circulatorySystem.ReadyBloodPool.Total);
            float totalWantedBlood = 0;
            foreach (BodyPart implant in RelatedPart.HealthMaster.ImplantList)
            {
                if (implant.IsBloodCirculated == false)
                {
                    continue;
                }
                totalWantedBlood += implant.BloodThroughput;
            }

            pumpedReagent = Math.Min(pumpedReagent, totalWantedBlood);
            ReagentMix SpareBlood = new ReagentMix();

            foreach (BodyPart implant in RelatedPart.HealthMaster.ImplantList)
            {
                if (implant.IsBloodCirculated == false)
                {
                    continue;
                }
                var BloodToGive = circulatorySystem.ReadyBloodPool.Take((implant.BloodThroughput / totalWantedBlood) * pumpedReagent);
                BloodToGive.Add(SpareBlood);
                SpareBlood.Clear();
                SpareBlood.Add(implant.BloodPumpedEvent(BloodToGive));
            }

            circulatorySystem.ReadyBloodPool.Add(SpareBlood);
        }
    }
Esempio n. 2
0
    public void Heartbeat(float efficiency)
    {
        CirculatorySystemBase circulatorySystem = RelatedPart.HealthMaster.CirculatorySystem;

        if (circulatorySystem)
        {
            //circulatorySystem.HeartBeat(heartStrength * TotalModified);
            //TODOH Balance all this stuff, Currently takes an eternity to suffocate
            // Logger.Log("heart Available  " + ReadyBloodPool);
            // Logger.Log("heart pumpedReagent " + pumpedReagent);

            float totalWantedBlood = 0;
            foreach (BodyPart implant in RelatedPart.HealthMaster.ImplantList)
            {
                if (implant.IsBloodCirculated == false)
                {
                    continue;
                }
                totalWantedBlood += implant.BloodThroughput * efficiency;
                // Due to how blood is implemented as a single pool with its solutes, we need to compensate for
                // consumed solutes.  This may change in the future if blood changes
                totalWantedBlood += implant.BloodContainer.MaxCapacity - implant.BloodContainer.ReagentMixTotal;
            }
            float toPump      = Mathf.Min(totalWantedBlood, heartStrength * efficiency);
            var   bloodToGive = circulatorySystem.ReadyBloodPool.Take(Mathf.Min(toPump, circulatorySystem.ReadyBloodPool.Total));
            if (bloodToGive.Total < toPump)
            {
                // Try to maintain blood levels in organs by taking the remainder from used
                circulatorySystem.UsedBloodPool.TransferTo(bloodToGive, Mathf.Min(toPump - bloodToGive.Total, circulatorySystem.UsedBloodPool.Total));
            }

            ReagentMix SpareBlood = new ReagentMix();
            foreach (BodyPart implant in RelatedPart.HealthMaster.ImplantList)
            {
                if (implant.IsBloodCirculated == false)
                {
                    continue;
                }
                ReagentMix transfer = bloodToGive.Take((implant.BloodThroughput * efficiency + implant.BloodContainer.MaxCapacity
                                                        - implant.BloodContainer.ReagentMixTotal) / totalWantedBlood * bloodToGive.Total);
                transfer.Add(SpareBlood);
                SpareBlood.Clear();
                SpareBlood.Add(implant.BloodPumpedEvent(transfer, efficiency));
            }
            circulatorySystem.ReadyBloodPool.Add(SpareBlood);
            circulatorySystem.ReadyBloodPool.Add(bloodToGive);
        }
    }