bool CutsceneHasPlayed_IsTrue(On.CutsceneHasPlayed.orig_IsTrue orig, CutsceneHasPlayed self) { LocationRO cutsceneCheck; if (randoStateManager.IsRandomizedFile && RandomizerConstants.GetCutsceneMappings().ContainsKey(self.cutsceneId) && randoStateManager.IsLocationRandomized(RandomizerConstants.GetCutsceneMappings()[self.cutsceneId], out cutsceneCheck)) { //Check to make sure this is a cutscene i am configured to check, then check to make sure I actually have the item that is mapped to it Console.WriteLine($"Rando cutscene magic ahoy! Handling rando cutscene '{self.cutsceneId}' | Linked Item: {RandomizerConstants.GetCutsceneMappings()[self.cutsceneId]} | Rando Item: {randoStateManager.CurrentLocationToItemMapping[cutsceneCheck]}"); //Check to see if I have the item that is at this check. //if (Manager<InventoryManager>.Instance.GetItemQuantity(randoStateManager.CurrentLocationToItemMapping[cutsceneCheck].Item) >= 1) if (randoStateManager.GetSeedForFileSlot(randoStateManager.CurrentFileSlot).CollectedItems.Contains(randoStateManager.CurrentLocationToItemMapping[cutsceneCheck])) { //Return true, this cutscene has "been played" Console.WriteLine($"Have rando item '{randoStateManager.CurrentLocationToItemMapping[cutsceneCheck]}' for cutscene '{self.cutsceneId}'. Progress Manager on if cutscene has played: '{Manager<ProgressionManager>.Instance.HasCutscenePlayed(self.cutsceneId)}'. Returning that we have already seen cutscene."); return(self.mustHavePlayed == true); } else { //Havent seen the cutscene yet. Play it so i can get the item! Console.WriteLine($"Do not have rando item '{randoStateManager.CurrentLocationToItemMapping[cutsceneCheck]}' for cutscene '{self.cutsceneId}'. Progress Manager on if cutscene has played: '{Manager<ProgressionManager>.Instance.HasCutscenePlayed(self.cutsceneId)}'. Returning that we have not seen cutscene yet."); return(self.mustHavePlayed == false); } } else //call the orig method { return(orig(self)); } }
/// <summary> /// Check through the mappings for any location that is represented by vanilla location item(since that is the key used to uniquely identify locations). /// </summary> /// <param name="vanillaLocationItem">EItem being used to look up location.</param> /// <param name="locationFromItem">Out parameter used to return the location found.</param> /// <returns>true if location was found, otherwise false(location item will be null in this case)</returns> public bool IsLocationRandomized(EItems vanillaLocationItem, out LocationRO locationFromItem) { bool isLocationRandomized = false; locationFromItem = null; //We'll check through notes first foreach (RandoItemRO note in RandomizerConstants.GetNotesList()) { if (note.Item.Equals(vanillaLocationItem)) { locationFromItem = new LocationRO(note.Name); if (CurrentLocationToItemMapping.ContainsKey(locationFromItem)) { isLocationRandomized = true; } else { //Then we know for certain it was not randomized. No reason to continue. locationFromItem = null; return(false); } } } //If it wasn't a note we'll look through the rest of the items if (!isLocationRandomized) { //Real quick, check Climbing Claws because it is special if (EItems.CLIMBING_CLAWS.Equals(vanillaLocationItem)) { locationFromItem = new LocationRO("Climbing_Claws"); return(true); } foreach (RandoItemRO item in RandomizerConstants.GetRandoItemList()) { if (item.Item.Equals(vanillaLocationItem)) { locationFromItem = new LocationRO(item.Name); if (CurrentLocationToItemMapping.ContainsKey(locationFromItem)) { isLocationRandomized = true; } else { //Then we know for certain it was not randomized. locationFromItem = null; return(false); } } } } //Return whether we found it or not. return(isLocationRandomized); }
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); }
bool HasItem_IsTrue(On.HasItem.orig_IsTrue orig, HasItem self) { bool hasItem = false; LocationRO check; //Check to make sure this is an item that was randomized and make sure we are not ignoring this specific trigger check if (randoStateManager.IsRandomizedFile && randoStateManager.IsLocationRandomized(self.item, out check) && !RandomizerConstants.GetSpecialTriggerNames().Contains(self.Owner.name)) { if (self.transform.parent != null && "InteractionZone".Equals(self.Owner.name) && RandomizerConstants.GetSpecialTriggerNames().Contains(self.transform.parent.name) && EItems.KEY_OF_LOVE != self.item) { //Special triggers that need to use normal logic, call orig method. This also includes the trigger check for the key of love on the sunken door because yeah. Console.WriteLine($"While checking if player HasItem in an interaction zone, found parent object '{self.transform.parent.name}' in ignore logic. Calling orig HasItem logic."); return(orig(self)); } //OLD WAY //Don't actually check for the item i have, check to see if I have the item that was at it's location. //int itemQuantity = Manager<InventoryManager>.Instance.GetItemQuantity(randoStateManager.CurrentLocationToItemMapping[check].Item); //NEW WAY //Don't actually check for the item I have, check to see if I have done this check before. We'll do this by seeing if the item at its location has been collected yet or not int itemQuantity = randoStateManager.GetSeedForFileSlot(randoStateManager.CurrentFileSlot).CollectedItems.Contains(randoStateManager.CurrentLocationToItemMapping[check]) ? randoStateManager.CurrentLocationToItemMapping[check].Quantity : 0; switch (self.conditionOperator) { case EConditionOperator.LESS_THAN: hasItem = itemQuantity < self.quantityToHave; break; case EConditionOperator.LESS_OR_EQUAL: hasItem = itemQuantity <= self.quantityToHave; break; case EConditionOperator.EQUAL: hasItem = itemQuantity == self.quantityToHave; break; case EConditionOperator.GREATER_OR_EQUAL: hasItem = itemQuantity >= self.quantityToHave; break; case EConditionOperator.GREATER_THAN: hasItem = itemQuantity > self.quantityToHave; break; } Console.WriteLine($"Rando inventory check complete for check '{self.Owner.name}'. Item '{self.item}' || Actual Item Check '{randoStateManager.CurrentLocationToItemMapping[check]}' || Current Check '{self.conditionOperator}' || Expected Quantity '{self.quantityToHave}' || Actual Quantity '{itemQuantity}' || Condition Result '{hasItem}'."); return(hasItem); } else //Call orig method { Console.WriteLine("HasItem check was not randomized. Doing vanilla checks."); Console.WriteLine($"Is randomized file : '{randoStateManager.IsRandomizedFile}' | Is location '{self.item}' randomized: '{randoStateManager.IsLocationRandomized(self.item, out check)}' | Not in the special triggers list: '{!RandomizerConstants.GetSpecialTriggerNames().Contains(self.Owner.name)}'|"); return(orig(self)); } }