コード例 #1
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 == null || !CyBioReactorMono.PdaIsOpen)
            {
                return;
            }

            ItemsContainer   containerObj = __instance.storage.container;
            CyBioReactorMono reactor      = CyBioReactorMono.OpenInPda;

            reactor.ConnectToInventory(__instance.storage.items);
        }
コード例 #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!
        }