コード例 #1
0
        public static IEnumerator AddToReactor(SubRoot subRoot, TechType fishType, Vector2int sizePerFish, BaseBioReactor reactor)
        {
            CoroutineTask <GameObject> task = CraftData.GetPrefabForTechTypeAsync(fishType, false);

            yield return(task);

            GameObject prefab = task.GetResult();

            prefab.SetActive(false);

            if (!reactor.container.HasRoomFor(sizePerFish.x, sizePerFish.y))
            {
                int breedCount = 1;

                if (QModServices.Main.ModPresent("FCSEnergySolutions"))
                {
                    AGCompat.TryOverflowIntoAlterraGens(subRoot, fishType, ref breedCount);
                }

                if (QModServices.Main.ModPresent("CyclopsBioReactor") && breedCount > 0)
                {
                    CBRCompat.TryOverflowIntoCyclopsBioreactors(subRoot, fishType, ref breedCount);
                }

                if (breedCount > 0)
                {
                    Main.TryOverflowIntoBioreactors(subRoot, fishType, ref breedCount);
                }

                yield break;
            }

            GameObject gameObject = GameObject.Instantiate(prefab);

            Pickupable pickupable = gameObject.EnsureComponent <Pickupable>();

#if SUBNAUTICA_EXP
            TaskResult <Pickupable> taskResult = new TaskResult <Pickupable>();
            yield return(pickupable.PickupAsync(taskResult, false));

            pickupable = taskResult.Get();
#else
            pickupable.Pickup(false);
#endif
            reactor.container.AddItem(pickupable);
            yield break;
        }
コード例 #2
0
        private static IEnumerator AddItemToAlterraGen(SubRoot subRoot, TechType fishType, IFCSStorage container)
        {
            CoroutineTask <GameObject> task = CraftData.GetPrefabForTechTypeAsync(fishType, false);

            yield return(task);

            GameObject prefab = task.GetResult();

            prefab.SetActive(false);

            int breedCount = 1;

            if (!container.CanBeStored(breedCount, fishType))
            {
                if (QModServices.Main.ModPresent("CyclopsBioReactor"))
                {
                    CBRCompat.TryOverflowIntoCyclopsBioreactors(subRoot, fishType, ref breedCount);
                }

                if (breedCount > 0)
                {
                    Main.TryOverflowIntoBioreactors(subRoot, fishType, ref breedCount);
                }

                yield break;
            }

            if (breedCount == 0)
            {
                yield break;
            }

            GameObject gameObject = GameObject.Instantiate(prefab);
            Pickupable pickupable = gameObject.EnsureComponent <Pickupable>();

#if SUBNAUTICA_EXP
            TaskResult <Pickupable> taskResult = new TaskResult <Pickupable>();
            yield return(pickupable.PickupAsync(taskResult, false));

            pickupable = taskResult.Get();
#else
            pickupable.Pickup(false);
#endif
            container.AddItemToContainer(new InventoryItem(pickupable));

            yield break;
        }