internal BioEnergy(Pickupable pickupable, float energy) { Pickupable = pickupable; RemainingEnergy = energy; MaxEnergy = BaseBioReactor.GetCharge(pickupable.GetTechType()); }
public static void Postfix(WaterPark __instance, WaterParkCreature creature) { if (!Main.Config.AlterraGenOverflow && !Main.Config.BioReactorOverflow && !Main.Config.OceanBreeding) { return; } var items = __instance.items; var techType = creature.pickupable.GetTechType(); if (!items.Contains(creature) || __instance.HasFreeSpace() || BaseBioReactor.GetCharge(techType) <= 0f) { return; } var hasBred = false; foreach (var waterParkItem in items) { var parkCreature = waterParkItem as WaterParkCreature; var parkCreatureTechType = parkCreature is not null && parkCreature.pickupable != null?parkCreature.pickupable.GetTechType() : TechType.None; if (parkCreature == null || parkCreature == creature || !parkCreature.GetCanBreed() || parkCreatureTechType != techType || parkCreatureTechType.ToString().Contains("Egg")) { continue; } if (BaseBioReactor.GetCharge(parkCreatureTechType) > -1) { if (Main.Config.AlterraGenOverflow && !Main.Config.AlterraGenBlackList.Contains(parkCreatureTechType) && QModServices.Main.ModPresent("FCSEnergySolutions")) { hasBred = AGT.TryBreedIntoAlterraGen(__instance, parkCreatureTechType, parkCreature); } if (Main.Config.BioReactorOverflow && !Main.Config.BioReactorBlackList.Contains(parkCreatureTechType) && !hasBred) { var baseBioReactors = __instance.gameObject.GetComponentInParent <SubRoot>()?.gameObject .GetComponentsInChildren <BaseBioReactor>() ?.Where(baseBioReactor => baseBioReactor.container.HasRoomFor(parkCreature.pickupable)) .ToList() ?? new List <BaseBioReactor>(); if (baseBioReactors.Count > 0) { hasBred = true; baseBioReactors.Shuffle(); var baseBioReactor = baseBioReactors.First(); CoroutineHost.StartCoroutine(SpawnCreature(__instance, parkCreatureTechType, baseBioReactor.container)); } } if (Main.Config.OceanBreeding && Main.Config.OceanBreedWhiteList.Contains(parkCreatureTechType) && !hasBred && __instance.transform.position.y < 0) { CoroutineHost.StartCoroutine(SpawnCreature(__instance, parkCreatureTechType, null)); hasBred = true; } } if (hasBred) { creature.ResetBreedTime(); parkCreature.ResetBreedTime(); } break; } }