public static void Postfix(WaterPark __instance, WaterParkCreature creature)
        {
            List <WaterParkItem> items = __instance.items;

            if (!items.Contains(creature) || __instance.HasFreeSpace() || BaseBioReactor.GetCharge(creature.pickupable.GetTechType()) == -1)
            {
                return;
            }

            List <BaseBioReactor> baseBioReactors = __instance.gameObject.GetComponentInParent <SubRoot>().gameObject.GetComponentsInChildren <BaseBioReactor>().ToList();
            bool hasBred = false;

            foreach (WaterParkItem waterParkItem in items)
            {
                var      parkCreature         = waterParkItem as WaterParkCreature;
                TechType parkCreatureTechType = parkCreature?.pickupable?.GetTechType() ?? TechType.None;
                if (parkCreature != null && parkCreature != creature && parkCreature.GetCanBreed() && parkCreatureTechType == creature.pickupable.GetTechType() && !parkCreatureTechType.ToString().Contains("Egg"))
                {
                    if (BaseBioReactor.GetCharge(parkCreatureTechType) > -1)
                    {
                        if (QModServices.Main.ModPresent("FCSEnergySolutions"))
                        {
                            hasBred = AGT.TryBreedIntoAlterraGen(__instance, parkCreatureTechType, parkCreature);
                        }

                        if (!hasBred)
                        {
                            foreach (BaseBioReactor baseBioReactor in baseBioReactors)
                            {
                                if (baseBioReactor.container.HasRoomFor(parkCreature.pickupable))
                                {
                                    creature.ResetBreedTime();
                                    parkCreature.ResetBreedTime();
                                    hasBred = true;
                                    CoroutineHost.StartCoroutine(SpawnCreature(__instance, parkCreature, baseBioReactor.container));
                                    break;
                                }
                            }
                        }
                    }

                    creature.ResetBreedTime();
                    parkCreature.ResetBreedTime();
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }