Пример #1
0
        void ProgressionManager_SetChallengeRoomAsCompleted(On.ProgressionManager.orig_SetChallengeRoomAsCompleted orig, ProgressionManager self, string roomKey)
        {
            //if this is a rando file, go ahead and give the item we expect to get
            if (randoStateManager.IsRandomizedFile)
            {
                LocationRO powerSealLocation = null;
                foreach (LocationRO location in RandomizerConstants.GetAdvancedRandoLocationList())
                {
                    if (location.LocationName.Equals(roomKey))
                    {
                        powerSealLocation = location;
                    }
                }

                if (powerSealLocation == null)
                {
                    throw new RandomizerException($"Challenge room with room key '{roomKey}' was not found in the list of locations. This will need to be corrected for this challenge room to work.");
                }

                RandoItemRO challengeRoomRandoItem = RandomizerStateManager.Instance.CurrentLocationToItemMapping[powerSealLocation];

                Console.WriteLine($"Challenge room '{powerSealLocation.PrettyLocationName}' completed. Providing rando item '{challengeRoomRandoItem}'.");
                //Handle timeshards
                if (EItems.TIME_SHARD.Equals(challengeRoomRandoItem.Item))
                {
                    Manager <InventoryManager> .Instance.CollectTimeShard(1);

                    //Set this item to have been collected in the state manager
                    randoStateManager.GetSeedForFileSlot(randoStateManager.CurrentFileSlot).CollectedItems.Add(challengeRoomRandoItem);
                }
                else
                {
                    //Before adding the item to the inventory, add this item to the override
                    RandomizerStateManager.Instance.AddTempRandoItemOverride(challengeRoomRandoItem.Item);
                    Manager <InventoryManager> .Instance.AddItem(challengeRoomRandoItem.Item, 1);

                    //Now remove the override
                    RandomizerStateManager.Instance.RemoveTempRandoItemOverride(challengeRoomRandoItem.Item);
                }

                //I want to try to have a dialog popup say what the player got.
                DialogSequence challengeSequence = ScriptableObject.CreateInstance <DialogSequence>();
                challengeSequence.dialogID = "RANDO_ITEM";
                challengeSequence.name     = challengeRoomRandoItem.Item.ToString();
                challengeSequence.choices  = new List <DialogSequenceChoice>();
                AwardItemPopupParams challengeAwardItemParams = new AwardItemPopupParams(challengeSequence, true);
                Manager <UIManager> .Instance.ShowView <AwardItemPopup>(EScreenLayers.PROMPT, challengeAwardItemParams, true);
            }


            //For now calling the orig method once we are done so the game still things we are collecting seals. We can change this later.
            orig(self, roomKey);
        }
        private static void CollectItemForBeatableSeedCheck(RandoItemRO itemToCollect, ref SamplePlayerRO player)
        {
            //Handle the various types of items
            switch (itemToCollect.Item)
            {
            case EItems.WINGSUIT:
                player.HasWingsuit = true;
                break;

            case EItems.GRAPLOU:
                player.HasRopeDart = true;
                break;

            case EItems.MAGIC_BOOTS:
                player.HasNinjaTabis = true;
                break;

            case EItems.KEY_OF_CHAOS:
                player.NoteCount++;
                break;

            case EItems.KEY_OF_COURAGE:
                player.NoteCount++;
                break;

            case EItems.KEY_OF_HOPE:
                player.NoteCount++;
                break;

            case EItems.KEY_OF_LOVE:
                player.NoteCount++;
                break;

            case EItems.KEY_OF_STRENGTH:
                player.NoteCount++;
                break;

            case EItems.KEY_OF_SYMBIOSIS:
                player.NoteCount++;
                break;

            default:
                //Some other item, just throw it in
                player.AdditionalItems.Add(itemToCollect);
                break;
            }
        }
Пример #3
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);
        }
Пример #4
0
        /// <summary>
        /// The initial generation of the dictionary of dialog replacement based on the currently randomized item locations
        /// </summary>
        /// <returns>A Dictionary containing keys of locationdialogID and values of replacementdialogID</returns>
        ///
        public static Dictionary <string, string> GenerateDialogMappingforItems()
        {
            Dictionary <string, string>          dialogmap         = new Dictionary <string, string>();
            Dictionary <EItems, string>          itemToDialogIDMap = GetDialogIDtoItems();
            Dictionary <LocationRO, RandoItemRO> current           = RandomizerStateManager.Instance.CurrentLocationToItemMapping;

            /* OLD
             * foreach (KeyValuePair<LocationRO, RandoItemRO> KVP in current)
             * {
             *  Console.WriteLine($"Dialog mapping -- {KVP.Key.PrettyLocationName}");
             *  EItems LocationChecked = (EItems)Enum.Parse(typeof(EItems), KVP.Key.PrettyLocationName);
             *  RandoItemRO ItemActuallyFound = KVP.Value;
             *
             *  if (ItemtoDialogIDMap.ContainsKey(LocationChecked) && ItemtoDialogIDMap.ContainsKey(ItemActuallyFound.Item))
             *  {
             *      dialogmap.Add(ItemtoDialogIDMap[LocationChecked], ItemtoDialogIDMap[ItemActuallyFound.Item]);
             *      Console.WriteLine($"We mapped item dialog {ItemtoDialogIDMap[ItemActuallyFound.Item]} to the location {ItemtoDialogIDMap[LocationChecked]}");
             *  }
             * }
             */

            //I am gonna keep the mappings limited to basic locations since the advanced locations are handled by another process.
            foreach (LocationRO location in RandomizerConstants.GetRandoLocationList())
            {
                Console.WriteLine($"Dialog mapping -- {location.PrettyLocationName}");
                EItems      locationChecked   = (EItems)Enum.Parse(typeof(EItems), location.PrettyLocationName);
                RandoItemRO itemActuallyFound = current[location];

                if (itemToDialogIDMap.ContainsKey(locationChecked) && itemToDialogIDMap.ContainsKey(itemActuallyFound.Item))
                {
                    dialogmap.Add(itemToDialogIDMap[locationChecked], itemToDialogIDMap[itemActuallyFound.Item]);
                    Console.WriteLine($"We mapped item dialog {itemToDialogIDMap[itemActuallyFound.Item]} to the location {itemToDialogIDMap[locationChecked]}");
                }
            }

            return(dialogmap);
        }
        /// <summary>
        /// Parses the mappings string from the seed to create the mappings collection for this seed.
        /// </summary>
        /// <param name="seed">Seed whos mappings we wish to parse.</param>
        /// <returns>Collection of mappings.</returns>
        public static Dictionary <LocationRO, RandoItemRO> ParseLocationToItemMappings(SeedRO seed)
        {
            //Prep
            Dictionary <LocationRO, RandoItemRO> mappings          = new Dictionary <LocationRO, RandoItemRO>();
            Dictionary <string, LocationRO>      officialLocations = new Dictionary <string, LocationRO>();
            Dictionary <string, RandoItemRO>     officialItems     = new Dictionary <string, RandoItemRO>();

            //Fill official collections for easy searching
            foreach (LocationRO location in RandomizerConstants.GetRandoLocationList())
            {
                officialLocations.Add(location.LocationName, location);
            }

            foreach (RandoItemRO item in RandomizerConstants.GetRandoItemList())
            {
                officialItems.Add(item.Name, item);
            }

            foreach (RandoItemRO item in RandomizerConstants.GetNotesList())
            {
                officialItems.Add(item.Name, item);
            }

            //loading for advanced seeds
            if (seed.Settings[SettingType.Difficulty].Equals(SettingValue.Advanced))
            {
                //locations
                foreach (LocationRO location in RandomizerConstants.GetAdvancedRandoLocationList())
                {
                    officialLocations.Add(location.LocationName, location);
                }
                //items
                foreach (RandoItemRO item in RandomizerConstants.GetAdvancedRandoItemList())
                {
                    officialItems.Add(item.Name, item);
                }
            }

            //Split up all the mappings
            string[] mappingsArr = seed.MappingInfo.Split(',');

            foreach (string mappingStr in mappingsArr)
            {
                //Split off the location and item string
                string[]    mappingArr = mappingStr.Split('~');
                LocationRO  location   = null;
                RandoItemRO item       = new RandoItemRO();


                //Get the LocationRO and RandoItemRO from the list of known items
                if (officialLocations.ContainsKey(mappingArr[0]))
                {
                    location = officialLocations[mappingArr[0]];
                }
                else
                {
                    //If for some reason something that could not be mapped to an official location, let's fail for now.
                    throw new RandomizerException($"Location named '{mappingArr[0]}' could not be located in collection of official locations.");
                }

                if (officialItems.ContainsKey(mappingArr[1]))
                {
                    item = officialItems[mappingArr[1]];
                }
                else
                {
                    //If for some reason something that could not be mapped to an official location, let's fail for now.
                    throw new RandomizerException($"Item named '{mappingArr[1]}' could not be located in collection of official items.");
                }

                //We get here, then we are good. Save off this mapping and move on.
                mappings.Add(location, item);
            }

            Console.WriteLine("Mapping parsed successfully!");
            return(mappings);
        }
Пример #6
0
        public void Load(string load)
        {
            Console.WriteLine($"Received value during mod option load: '{load}'");
            //Split on delimeter to get all seeds
            string[] seeds = load.Split(RANDO_OPTION_VALUE_DELIM);
            Console.WriteLine("load data split into seeds");
            for (int i = 1; i < seeds.Length; i++)
            {
                string seedDetails = seeds[i];
                Console.WriteLine($"Adding '{seedDetails}' to state manager.");

                //find necessary indicies in the string
                int randoTypeIndex    = seedDetails.IndexOf(RANDO_OPTION_TYPE_DELIM);
                int randoSettingIndex = seedDetails.IndexOf(RANDO_OPTION_SETTING_DELIM);

                string seedSub = seedDetails.Substring(0, randoTypeIndex);
                Console.WriteLine($"Extracted seed '{seedSub}' from seed split {i}");

                //This will parse the seed into an int. If the value cannot be parsed for some reason, seed will be 0
                Int32.TryParse(seedSub, out int seed);

                //Need to check if there are settings for this seed. If so, consider them when getting the seedtype. If not, the rest of the string is the seedtype.
                string seedTypeSub = randoSettingIndex != -1 ? seedDetails.Substring(randoTypeIndex + 1, randoSettingIndex - (randoTypeIndex + 1)) : seedDetails.Substring(randoTypeIndex + 1);
                Console.WriteLine($"Extracted seedtype '{seedTypeSub}' from seed split {i}");

                //This will pull out the seed type. If there is none, default it.
                SeedType seedType = SeedType.None;
                if (seedTypeSub != null && Enum.IsDefined(typeof(SeedType), seedTypeSub)) //using IsDefined because I dont have TryParse in this .NET version T_T
                {
                    seedType = (SeedType)Enum.Parse(typeof(SeedType), seedTypeSub);
                }

                //If there are settings, I need to pull them out as well
                Dictionary <SettingType, SettingValue> seedSettings = new Dictionary <SettingType, SettingValue>();
                List <RandoItemRO> collectedRandoItemList           = new List <RandoItemRO>();
                string             mappingString = "";

                if (randoSettingIndex != -1)
                {
                    string seedSettingSub = seedDetails.Substring(seedDetails.IndexOf(RANDO_OPTION_SETTING_DELIM) + 1);
                    Console.WriteLine($"Extracted seed settings '{seedSettingSub}' from seed split {i}");

                    string[] splitSeedSettings = seedSettingSub.Split(RANDO_OPTION_SETTING_DELIM);

                    foreach (string setting in splitSeedSettings)
                    {
                        //handle collected item loading
                        if (setting.StartsWith("CollectedItems="))
                        {
                            string collectedItemsRaw = setting.Substring(setting.IndexOf(RANDO_OPTION_SETTING_VALUE_DELIM) + 1);
                            //split further to get each rando item
                            string[]     collectedItems = collectedItemsRaw.Split(RANDO_OPTION_ITEM_DELIM);
                            SaveGameSlot save           = Manager <SaveManager> .Instance.GetSaveSlot(i - 1);

                            foreach (string collectedItem in collectedItems)
                            {
                                try
                                {
                                    RandoItemRO randoItemFromModSave = RandoItemRO.ParseString(collectedItem);

                                    if (save.Items.ContainsKey(randoItemFromModSave.Item))
                                    {
                                        collectedRandoItemList.Add(randoItemFromModSave);
                                        Console.WriteLine($"Added item '{collectedItem}' to Collected Item pool for file slot '{i}'.");
                                    }
                                    else
                                    {
                                        Console.WriteLine($"Item '{randoItemFromModSave.Item}' was not in the game save so we are ignoring it.");
                                    }
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine($"ERROR WHILE LOADING FROM MOD SAVE FILE: Found an item that could not be processed. Item in question '{collectedItem}'. Skipping item.");
                                    continue;
                                }
                            }
                        }
                        else if (setting.StartsWith("Mappings="))
                        {
                            //Load mappings string
                            mappingString = setting.Substring(setting.IndexOf(RANDO_OPTION_SETTING_VALUE_DELIM) + 1);
                        }
                        else //Other settings
                        {
                            string[] splitSeedSetting = setting.Split(RANDO_OPTION_SETTING_VALUE_DELIM);
                            if (splitSeedSetting.Length == 2)
                            {
                                string splitSeedSettingType  = splitSeedSetting[0];
                                string splitSeedSettingValue = splitSeedSetting[1];

                                Console.WriteLine($"Split setting '{splitSeedSettingType}' with value '{splitSeedSettingValue}' added to seed split {i}");

                                if ((splitSeedSettingType != null && Enum.IsDefined(typeof(SettingType), splitSeedSettingType)) && (splitSeedSettingValue != null && Enum.IsDefined(typeof(SettingValue), splitSeedSettingValue)))
                                {
                                    seedSettings.Add((SettingType)Enum.Parse(typeof(SettingType), splitSeedSettingType), (SettingValue)Enum.Parse(typeof(SettingValue), splitSeedSettingValue));
                                }
                            }
                            else
                            {
                                Console.WriteLine($"ERROR WHILE LOADING FROM MOD SAVE FILE: Setting not properly formatted in file. Setting in question '{setting}'. Throwing it away and moving on.");
                            }
                        }
                    }
                }

                stateManager.AddSeed(i, seedType, seed, seedSettings, collectedRandoItemList, mappingString);
                Console.WriteLine($"'{seeds[i]}' added to state manager successfully.");
            }

            Console.WriteLine("Loading into state manager complete.");
        }