Ejemplo n.º 1
0
        public BioBoosterUpgradeHandler() : base(CyclopsModule.BioReactorBoosterID)
        {
            this.MaxCount = CyBioReactorMono.MaxBoosters;

            OnFinishedUpgrades += (SubRoot cyclops) =>
            {
                List <CyBioReactorMono> bioreactors = CyclopsManager.GetBioReactors(cyclops);

                if (bioreactors == null)
                {
                    return;
                }

                QuickLogger.Debug($"Handling BioBooster at {this.Count}");
                foreach (CyBioReactorMono reactor in bioreactors)
                {
                    reactor.UpdateBoosterCount(this.Count);
                }
            };

            OnFirstTimeMaxCountReached += () =>
            {
                ErrorMessage.AddMessage(BioReactorBooster.MaxBoostAchived);
            };

            IsAllowedToRemove += (SubRoot cyclops, Pickupable item, bool verbose) =>
            {
                List <CyBioReactorMono> bioreactors = CyclopsManager.GetBioReactors(cyclops);

                if (bioreactors == null)
                {
                    return(true);
                }

                foreach (CyBioReactorMono reactor in bioreactors)
                {
                    if (!reactor.HasRoomToShrink())
                    {
                        if (Time.time > errorDelay)
                        {
                            errorDelay = Time.time + delayInterval;
                            ErrorMessage.AddMessage(BioReactorBooster.CannotRemove);
                        }

                        return(false);
                    }
                }

                return(true);
            };
        }
Ejemplo n.º 2
0
        internal static void Postfix(uGUI_InventoryTab __instance)
        {
            // This event happens whenever the player opens their PDA.
            // We will make a series of checks to see if what they have opened is the Cyclops Bioreactor item container.

            if (__instance is null)
            {
                return; // Safety check
            }
            if (!Player.main.IsInSub() || !Player.main.currentSub.isCyclops)
            {
                return; // If not in Cyclops then all is irrelevant
            }
            if (__instance.storage is null)
            {
                return; // Safety check
            }
            ItemsContainer containerObj = __instance.storage.container;

            if (containerObj is null)
            {
                return; // If this isn't a non-null ItemsContainer, then it's not what we want.
            }
            string label = containerObj._label;

            if (label != CyBioReactor.StorageLabel)
            {
                return; // Not a Cyclops Bioreactor storage
            }
            List <CyBioReactorMono> reactors = CyclopsManager.GetBioReactors(Player.main.currentSub);

            if (reactors is null || reactors.Count == 0)
            {
                return; // Cyclops has no bioreactors
            }
            // Look for the reactor that matches the container we just opened.
            CyBioReactorMono reactor = reactors.Find(r => r.Container == containerObj);

            if (reactor is null)
            {
                return; // Didn't find the reactor we were looking for. Could it be on another cyclops?
            }
            Dictionary <InventoryItem, uGUI_ItemIcon> lookup = __instance.storage.items;

            reactor.ConnectToInventory(lookup); // Found!
        }