Example #1
0
        void InventoryManager_AddItem(On.InventoryManager.orig_AddItem orig, InventoryManager self, EItems itemId, int quantity)
        {
            LocationRO randoItemCheck;

            if (itemId != EItems.TIME_SHARD) //killing the timeshard noise in the logs
            {
                Console.WriteLine($"Called InventoryManager_AddItem method. Looking to give x{quantity} amount of item '{itemId}'.");
            }

            //Wierd Ruxxtin logic stuff
            if (EItems.NONE.Equals(itemId))
            {
                Console.WriteLine("Looks like Ruxxtin has a timeshard.");
            }

            //Lets make sure that the item they are collecting is supposed to be randomized
            if (randoStateManager.IsRandomizedFile && !RandomizerStateManager.Instance.HasTempOverrideOnRandoItem(itemId) && randoStateManager.IsLocationRandomized(itemId, out randoItemCheck))
            {
                //Based on the item that is attempting to be added, determine what SHOULD be added instead
                RandoItemRO randoItemId = randoStateManager.CurrentLocationToItemMapping[randoItemCheck];
                Console.WriteLine($"Randomizer magic engage! Game wants item '{itemId}', giving it rando item '{randoItemId}' with a quantity of '{quantity}'");

                //If that item is the windmill shuriken, immediately activate it and the mod option
                if (EItems.WINDMILL_SHURIKEN.Equals(randoItemId.Item))
                {
                    OnToggleWindmillShuriken();
                }
                else if (EItems.TIME_SHARD.Equals(randoItemId.Item)) //Handle timeshards
                {
                    Manager <InventoryManager> .Instance.CollectTimeShard(quantity);

                    randoStateManager.GetSeedForFileSlot(randoStateManager.CurrentFileSlot).CollectedItems.Add(randoItemId);
                    return; //Collecting timeshards internally call add item so I dont need to do it again.
                }

                //Set the itemId to the new item
                itemId = randoItemId.Item;
                //Set this item to have been collected in the state manager
                randoStateManager.GetSeedForFileSlot(randoStateManager.CurrentFileSlot).CollectedItems.Add(randoItemId);

                //Save
                Save.seedData = randomizerSaveMethod.GenerateSaveData();
            }

            //Call original add with items
            orig(self, itemId, quantity);
        }
        private void InventoryManagerOnAddItem(On.InventoryManager.orig_AddItem orig, InventoryManager self, EItems itemId, int quantity)
        {
            if (!_hcMode)
            {
                orig(self, itemId, quantity);
                return;
            }

            switch (itemId)
            {
            case EItems.BASIC_SCROLL:
                Manager <SkinManager> .Instance.EquipSkin(ESkin.DARK_MESSENGER);

                break;

            case EItems.TIME_SHARD:
                orig(self, itemId, 0);
                break;

            default:
                orig(self, itemId, quantity);
                break;
            }
        }