Exemple #1
0
    public void Heartbeat(float efficiency)
    {
        if (efficiency > 1)
        {
            efficiency = 1;
        }
        CirculatorySystemBase circulatorySystem = RelatedPart.HealthMaster.CirculatorySystem;

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

            foreach (BodyPart implant in RelatedPart.HealthMaster.BodyPartList)
            {
                if (implant.IsBloodCirculated == false)
                {
                    continue;
                }
                var BloodToGive = circulatorySystem.ReadyBloodPool.Take((implant.BloodThroughput / totalWantedBlood) * pumpedReagent);
                implant.BloodPumpedEvent(BloodToGive);
            }
        }
    }
Exemple #2
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);
        }
    }
Exemple #3
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);
        }
    }
Exemple #4
0
    public void Heartbeat(float efficiency)
    {
        if (efficiency > 1)
        {
            efficiency = 1;
        }
        CirculatorySystemBase circulatorySystem = RelatedPart.HealthMaster.CirculatorySystem;

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

            foreach (BodyPart implant in RelatedPart.HealthMaster.BodyPartList)
            {
                if (implant.IsBloodCirculated == false)
                {
                    continue;
                }
                var BloodToGive = circulatorySystem.ReadyBloodPool.Take((implant.BloodThroughput / totalWantedBlood) * pumpedReagent);
                implant.BloodPumpedEvent(BloodToGive);
            }
            if (RelatedPart.HealthMaster.IsDead)
            {
                return;                                              //For some reason the heart will randomly still continue to try and beat after death.
            }
            if (RelatedPart.BloodContainer.CurrentReagentMix.MajorMixReagent == salt || RelatedPart.BloodContainer.AmountOfReagent(salt) * 100 > dangerSaltLevel)
            {
                Chat.AddActionMsgToChat(RelatedPart.HealthMaster.gameObject,
                                        "<color=red>Your body spasms as a jolt of pain surges all over your body then into your heart!</color>",
                                        $"<color=red>{RelatedPart.HealthMaster.playerScript.visibleName} spasms before holding " +
                                        $"{RelatedPart.HealthMaster.playerScript.characterSettings.TheirPronoun(RelatedPart.HealthMaster.playerScript)} chest in shock before falling to the ground!</color>");
                RelatedPart.HealthMaster.Death();
            }
        }
    }