/// <summary> /// This is called whenever blood is pumped through the circulatory system by a heartbeat. /// Can happen multiple times if there's multiple hearts. Pushes out old blood and brings /// in new blood, up to the part's capacity. /// </summary> /// <param name="bloodIn">Incoming blood</param> /// <returns>Whatever is left over from bloodIn</returns> public ReagentMix BloodPumpedEvent(ReagentMix bloodIn) { //Maybe have a dynamic 50% other blood in this blood // if (bloodReagent != requiredReagent) // { // return HandleWrongBloodReagent(bloodReagent, amountOfBloodReagentPumped); // } //bloodReagent.Subtract() //BloodContainer.Add(bloodReagent); //Maybe have damage from high/low blood levels and high blood pressure BloodContainer.CurrentReagentMix.TransferTo(HealthMaster.CirculatorySystem.UsedBloodPool, float.MaxValue); if ((BloodContainer.ReagentMixTotal + bloodIn.Total) > BloodContainer.MaxCapacity) { float BloodToTake = BloodContainer.MaxCapacity - BloodContainer.ReagentMixTotal; bloodIn.TransferTo(BloodContainer.CurrentReagentMix, BloodToTake); } else { bloodIn.TransferTo(BloodContainer.CurrentReagentMix, bloodIn.Total); } BloodContainer.OnReagentMixChanged?.Invoke(); BloodContainer.ReagentsChanged(); BloodWasPumped(); return(bloodIn); }
public void TransferTo(MixAndVolume toTransfer, Vector2 amount) { if (float.IsNaN(amount.x) == false) { Mix.TransferTo(toTransfer.Mix, amount.x); } if (float.IsNaN(amount.y) == false) { toTransfer.gasMix = toTransfer.gasMix + gasMix.RemoveMoles(amount.y); } }
public void TransferTo(MixAndVolume toTransfer, Vector2 amount) { Mix.TransferTo(toTransfer.Mix, amount.x); if (float.IsNaN(amount.y) == false) { toTransfer.gasMix = toTransfer.gasMix + gasMix.RemoveMoles(amount.y); if (toTransfer.gasMix.Gases.Any(x => x < 0)) { Logger.Log("0!!!"); } } }
public void Bleed(float amount) { var bloodLoss = new ReagentMix(); ReadyBloodPool.TransferTo(bloodLoss, amount); MatrixManager.ReagentReact(bloodLoss, healthMaster.gameObject.RegisterTile().WorldPositionServer); }
public void EqualiseWithMultiple(List <PipeData> others) { float TotalVolume = Volume; foreach (var Pipe in others) { TotalVolume += PipeFunctions.PipeOrNet(Pipe).Volume; } float TotalReagents = Mix.Total; foreach (var Pipe in others) { TotalReagents += PipeFunctions.PipeOrNet(Pipe).Mix.Total; } float TargetDensity = TotalReagents / TotalVolume; foreach (var Pipe in others) { PipeFunctions.PipeOrNet(Pipe).Mix.TransferTo(Mix, PipeFunctions.PipeOrNet(Pipe).Mix.Total); } foreach (var Pipe in others) { Mix.TransferTo(PipeFunctions.PipeOrNet(Pipe).Mix, TargetDensity * PipeFunctions.PipeOrNet(Pipe).Volume); } }
/// <summary> /// This is called whenever blood is pumped through the circulatory system by a heartbeat. /// Can happen multiple times if there's multiple hearts. Pushes out old blood and brings /// in new blood, up to the part's capacity. /// </summary> /// <param name="bloodIn">Incoming blood</param> /// <returns>Whatever is left over from bloodIn</returns> public void BloodPumpedEvent(ReagentMix bloodIn) { //Maybe have damage from high/low blood levels and high blood pressure BloodContainer.CurrentReagentMix.TransferTo(HealthMaster.CirculatorySystem.UsedBloodPool, (BloodContainer.CurrentReagentMix.Total + bloodIn.Total) - BloodThroughput); bloodIn.TransferTo(BloodContainer.CurrentReagentMix, bloodIn.Total); BloodContainer.OnReagentMixChanged?.Invoke(); BloodContainer.ReagentsChanged(); BloodWasPumped(); }