List <ItemInfo> GenerateItemList(ItemLocationMap itemLocations) { var alreadyAssingedItems = itemLocations .Where(l => l.IsUsed) .Select(l => l.ItemInfo) .ToArray(); var itemlist = itemLocations .Where(l => l.DefaultItem != null) .Select(l => l.DefaultItem) .Where(i => i.Identifier.LootType != LootType.ConstOrb && i.Identifier.LootType != LootType.ConstFamiliar && !genericItems.Contains(i)) .ToList(); AddOrbs(itemlist); AddFamiliars(itemlist); AddExtraItems(itemlist); itemlist = itemlist .Where(i => !alreadyAssingedItems.Contains(i) && !itemsToRemoveFromGame.Contains(i)) .ToList(); return(itemlist); }
ItemLocation GetUnusedItemLocationThatDontRequire(Requirement requirements) { var locations = itemLocations .Where(l => !l.IsUsed && GateCanBeOpenedWithoutSuppliedRequirements(l.Gate, requirements)); return(locations.SelectRandom(random)); }
void PutStarterProgressionItemInReachableLocation(Random random, ItemLocationMap itemLocations, ItemInfo starterProgressionItem) { var starterLocations = itemLocations .Where(l => l.Key.LevelId != 0 && l.Gate.Requires(R.None)) .ToArray(); var location = starterLocations.SelectRandom(random); PutItemAtLocation(starterProgressionItem, location); }
static void UpdateChecksTask(ItemLocationMap itemLocationMap) { var locations = itemLocationMap .Where(l => l.IsPickedUp && !(l is ExternalItemLocation)) .Select(l => LocationMap.GetLocationId(l.Key)) .ToArray(); ReconnectIfNeeded(); session.Locations.CompleteLocationChecks(locations); }
void SwapItemWithOtherNonProgressionItemsNotInRoom(Random random, ItemLocation itemLocation, ItemLocationMap itemLocations) { var roomToAvoid = itemLocation.Key.ToRoomItemKey(); var newItemLocation = itemLocations .Where(l => l.ItemInfo.Unlocks == R.None && l.Key.ToRoomItemKey() != roomToAvoid) .SelectRandom(random); var itemInfoToMove = itemLocation.ItemInfo; var newItemInfo = newItemLocation.ItemInfo; itemLocation.SetItem(newItemInfo); newItemLocation.SetItem(itemInfoToMove); }
void AddRandomItemsToLocationMap(Random random, bool isProgressionOnly) { PlaceStarterProgressionItems(random, itemLocations); if (!SeedOptions.GasMaw) { PlaceGasMaskInALegalSpot(random, itemLocations); } var alreadyAssingedItems = itemLocations .Where(l => l.IsUsed) .Select(l => l.ItemInfo) .ToArray(); var itemsThatUnlockProgression = UnlockingMap.AllProgressionItems .Where(i => alreadyAssingedItems.All(x => x.Identifier != i)) .Select(i => ItemInfoProvider.Get(i)) .ToList(); var unusedItemLocations = itemLocations .Where(l => !l.IsUsed) .ToList(); while (itemsThatUnlockProgression.Count > 0) { var item = itemsThatUnlockProgression.PopRandom(random); var location = unusedItemLocations.PopRandom(random); PutItemAtLocation(item, location); } if (!isProgressionOnly) { FillRemainingChests(random, itemLocations); } }
protected void FillRemainingChests(Random random, ItemLocationMap itemLocations) { var itemlist = GenerateItemList(itemLocations); var freeLocations = itemLocations .Where(l => !l.IsUsed) .ToList(); do { var location = freeLocations.PopRandom(random); var item = itemlist.Count > 0 ? itemlist.PopRandom(random) : genericItems.SelectRandom(random); PutItemAtLocation(item, location); } while (freeLocations.Count > 0); FixProgressiveNonProgressionItemsInSameRoom(random, itemLocations); }
protected void PlaceGasMaskInALegalSpot(Random random, ItemLocationMap itemLocations) { var levelIdsToAvoid = new List <int>(3) { 1 }; var minimalMawRequirements = R.None; if (!SeedOptions.Inverted) { minimalMawRequirements |= R.GateAccessToPast; //for non inverted seeds we dont know pyramid keys are required as it can be a classic past seed /*var isWatermaskRequiredForMaw = UnlockingMap.PyramidKeysUnlock != R.GateMaw * && UnlockingMap.PyramidKeysUnlock != R.GateCavesOfBanishment; * * if (isWatermaskRequiredForMaw) * minimalMawRequirements |= R.Swimming;*/ levelIdsToAvoid.Add(2); //library if (UnlockingMap.PyramidKeysUnlock != R.GateSealedCaves) { levelIdsToAvoid.Add(9); //xarion skelleton } } else { minimalMawRequirements |= R.Swimming; minimalMawRequirements |= UnlockingMap.PyramidKeysUnlock; } var GasMaskLocation = itemLocations .Where(l => !l.IsUsed && !levelIdsToAvoid.Contains(l.Key.LevelId) && l.Gate.CanBeOpenedWith(minimalMawRequirements)) .SelectRandom(random); PutItemAtLocation(ItemInfoProvider.Get(EInventoryRelicType.AirMask), GasMaskLocation); }
void FixProgressiveNonProgressionItemsInSameRoom(Random random, ItemLocationMap itemLocations) { var progressiveItemLocationsPerType = itemLocations .Where(l => l.ItemInfo.Unlocks == R.None) .Where(l => l.ItemInfo is ProgressiveItemInfo) .GroupBy(l => l.ItemInfo); foreach (var progressiveItemLocations in progressiveItemLocationsPerType) { RoomItemKey roomkey = null; foreach (var itemLocation in progressiveItemLocations) { if (roomkey == null) { roomkey = itemLocation.Key.ToRoomItemKey(); } else if (roomkey == itemLocation.Key.ToRoomItemKey()) { SwapItemWithOtherNonProgressionItemsNotInRoom(random, itemLocation, itemLocations); } } } }