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);
        }
        void DetectNewScreens()
        {
            foundScreens.Clear();

            foreach (var screen in GetScreens())
            {
                if (hookedScreens.Contains(screen))
                {
                    foundScreens.Add(screen);

                    if (screen.GetType() == GamePlayScreenType)
                    {
                        itemLocationMap = ((GameplayScreen)hookedScreens[screen]).ItemLocations;
                    }

                    continue;
                }

                if (!Screen.RegisteredTypes.TryGetValue(screen.GetType(), out var handlerType))
                {
                    continue;
                }

                var screenHandler = (Screen)Activator.CreateInstance(handlerType, this, screen);
                hookedScreens.Add(screenHandler);
                foundScreens.Add(screen);

                screenHandler.Initialize(itemLocationMap, (GCM)Dynamic.GCM);
            }

            if (foundScreens.Count != hookedScreens.Count)
            {
                hookedScreens.Filter(foundScreens, s => s.Unload());
            }
        }
示例#3
0
        public override void Initialize(ItemLocationMap _, GCM gameContentManager)
        {
            GameContentManager = gameContentManager;

            var saveFile      = (GameSave)Dynamic.SaveFile;
            var seed          = saveFile.GetSeed();
            var fillingMethod = saveFile.GetFillingMethod();

            if (!seed.HasValue)
            {
                seed = Seed.Zero;
            }

            Console.Out.WriteLine($"Seed: {seed}");

            seedOptions = seed.Value.Options;

            ItemLocations = Randomizer.Randomize(seed.Value, fillingMethod);
            ItemLocations.BaseOnSave(Level.GameSave);

            ItemTrackerUplink.UpdateState(ItemTrackerState.FromItemLocationMap(ItemLocations));

            LevelReflected._random = new DeRandomizer(LevelReflected._random, seed.Value);

            ItemManipulator.Initialize(ItemLocations);
        }
        public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager)
        {
            if (!IsUsedAsSeedSelectionMenu)
            {
                return;
            }

            gcm = gameContentManager;

            Dynamic._menuTitle               = "Select Seed";
            Dynamic._displayCharacters       = new string[Seed.Length];
            Dynamic._displayCharacterOrigins = new Vector2[Seed.Length];

            okButton = MenuEntry.Create("OK", OnOkayEntrySelected);

            ChangeAvailableButtons(
                MenuEntry.Create("DEL", OnDeleteCharacter),
                okButton,
                MenuEntry.Create("", () => { }, false),
                MenuEntry.Create("New", OnGenerateSelected),
                MenuEntry.Create("Flags", OnOptionsSelected),
                MenuEntry.Create("", () => { }, false),
                MenuEntry.Create("Settings", OnSettingsSelected)
                );
        }
示例#5
0
        public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager)
        {
            var hud = ((object)Dynamic._minimapHud).AsDynamic();

            hud._minimap = DeepClone(Dynamic._minimap);

            itemLocations = itemLocationMap;

            Dynamic._removeMarkerText = (string)Dynamic._removeMarkerText + " / Show where to go next";

            foreach (var roomkey in DisabledCheckpoints)
            {
                foreach (var block in GetRoom(roomkey).Blocks.Values)
                {
                    block.IsCheckpoint = false;
                }
            }

            foreach (var roomkey in BossRooms)
            {
                foreach (var block in GetRoom(roomkey).Blocks.Values)
                {
                    block.IsBoss = true;
                }
            }
        }
        public override ItemLocationMap GenerateItemLocationMap(bool isProgressionOnly)
        {
            AddRandomItemsToLocationMap(isProgressionOnly);

            itemLocations = new ItemLocationMap(ItemInfoProvider, UnlockingMap, Seed.Options);

            return(itemLocations);
        }
示例#7
0
        public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager)
        {
            var randomizerVersion = Assembly.GetExecutingAssembly().GetName().Version;
            var newVersionString  = $"TsRandomizer: v{randomizerVersion}, Timespinner: {Dynamic._versionNumber}";

            Dynamic._versionNumber = newVersionString;
            Dynamic.RefreshSizes();
        }
示例#8
0
        public static void OnChangeRoom(Level level, SeedOptions seedOptions, ItemLocationMap itemLocations, int levelId, int roomId)
        {
            var roomKey = new RoomItemKey(levelId, roomId);

            if (RoomTriggers.TryGetValue(roomKey, out var trigger))
            {
                trigger.trigger(level, itemLocations[roomKey], seedOptions);
            }
        }
 FullRandomItemLocationRandomizer(
     SeedOptions options,
     ItemInfoProvider itemInfoProvider,
     ItemUnlockingMap unlockingMap,
     ItemLocationMap itemLocationMap,
     bool progressionOnly
     ) : base(options, itemInfoProvider, itemLocationMap, unlockingMap, progressionOnly)
 {
 }
 ForwardFillingItemLocationRandomizer(
     Seed seed, ItemInfoProvider itemProvider, ItemUnlockingMap unlockingMap, ItemLocationMap itemLocationMap, bool progressionOnly)
     : base(seed.Options, itemProvider, itemLocationMap, unlockingMap, progressionOnly)
 {
     random = new Random((int)seed.Id);
     availableRequirements  = Requirement.None;
     unlockableRequirements = unlockingMap.AllUnlockableRequirements;
     placedItems            = new Dictionary <ItemInfo, ItemLocation>();
     paths = new Dictionary <ItemInfo, Gate>();
 }
示例#11
0
        public override ItemLocationMap GenerateItemLocationMap(bool isProgressionOnly)
        {
            var random = new Random((int)Seed.Id);

            itemLocations = new ItemLocationMap(ItemInfoProvider, UnlockingMap, Seed.Options);

            AddRandomItemsToLocationMap(random, isProgressionOnly);

            return(itemLocations);
        }
示例#12
0
        public static void OnChangeRoom(
            Level level, SeedOptions seedOptions, ItemLocationMap itemLocations, int levelId, int roomId)
        {
            var roomKey = new RoomItemKey(levelId, roomId);

            if (TextReplacers.TryGetValue(roomKey, out var replacer))
            {
                replacer.replacer(level, itemLocations, seedOptions);
            }
        }
        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);
        }
 protected void PlaceStarterProgressionItems(Random random, ItemLocationMap itemLocations)
 {
     if (SeedOptions.StartWithTalaria || SeedOptions.Inverted)
     {
         GiveOrbsToMom(random, itemLocations, false);
     }
     else
     {
         PlaceStarterProgressionItem(random, itemLocations);
     }
 }
示例#15
0
        public static void OnChangeRoom(
            Level level, SeedOptions seedOptions, SettingCollection gameSettings, ItemLocationMap itemLocations, ScreenManager screenManager,
            int levelId, int roomId)
        {
            var roomKey = new RoomItemKey(levelId, roomId);

            if (RoomTriggers.TryGetValue(roomKey, out var trigger))
            {
                trigger.trigger(level, itemLocations[roomKey], seedOptions, gameSettings, screenManager);
            }
        }
示例#16
0
        public void Should_generate_beatable_seed_in_1_pass()
        {
            var seed          = new Seed(1U, SeedOptions.None);
            var unlockingMap  = new ItemUnlockingMap(seed);
            var itemProvder   = new ItemInfoProvider(SeedOptions.None, unlockingMap);
            var itemLocations = new ItemLocationMap(itemProvder, unlockingMap, SeedOptions.None);

            ForwardFillingItemLocationRandomizer.AddRandomItemsToLocationMap(seed, itemProvder, unlockingMap, itemLocations, true);

            Assert.That(itemLocations.IsBeatable(), Is.True);
        }
示例#17
0
        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);
        }
        public void With_doubejump_timestop_spindle_and_cardD_should_get_access_to_past()
        {
            var unlockingMap  = new ItemUnlockingMap(Seed.Zero);
            var itemLocations = new ItemLocationMap(new ItemInfoProvider(SeedOptions.None, unlockingMap), unlockingMap, SeedOptions.None);

            var accessableLocations = itemLocations.GetReachableLocations(
                Requirement.DoubleJump | Requirement.GateAccessToPast | Requirement.Swimming)
                                      .ToArray();

            Assert.That(Contains(accessableLocations, new ItemKey(3, 3, 648, 272)));
        }
        public void With_given_requirements_shoud_mark_captians_chests_as_available()
        {
            var unlockingMap  = new ItemUnlockingMap(Seed.Zero);
            var itemLocations = new ItemLocationMap(new ItemInfoProvider(SeedOptions.None, unlockingMap), unlockingMap, SeedOptions.None);

            var accessableLocations = itemLocations.GetReachableLocations(
                Requirement.GassMask | Requirement.AntiWeed | Requirement.Swimming | Requirement.GateLakeSirineRight | Requirement.DoubleJump)
                                      .ToArray();

            Assert.That(Contains(accessableLocations, new ItemKey(1, 18, 1320, 189)));
            Assert.That(Contains(accessableLocations, new ItemKey(1, 18, 1272, 192)));
            Assert.That(Contains(accessableLocations, new ItemKey(1, 18, 1368, 192)));
        }
        public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager)
        {
            if (!ConnectCommand.IsWaitingForDifficulty)
            {
                SetSelectedMenuItemByIndex(0);
            }
            else
            {
                SetSeedAndFillingMethod(ConnectCommand.Seed, FillingMethod.Archipelago, ConnectCommand.Settings);
                HookOnDifficultySelected(ConnectCommand.OnDifficultySelectedHook);

                ConnectCommand.IsWaitingForDifficulty = false;
            }
        }
        public void With_no_items_only_6_item_locatios_should_be_accessable()
        {
            var unlockingMap  = new ItemUnlockingMap(Seed.Zero);
            var itemLocations = new ItemLocationMap(new ItemInfoProvider(SeedOptions.None, unlockingMap), unlockingMap, SeedOptions.None);

            var accessableLocations = itemLocations.GetReachableLocations(Requirement.None).ToArray();

            Assert.That(Contains(accessableLocations, ItemKey.TutorialMeleeOrb));
            Assert.That(Contains(accessableLocations, ItemKey.TutorialSpellOrb));
            Assert.That(Contains(accessableLocations, new ItemKey(1, 1, 1528, 144)));
            Assert.That(Contains(accessableLocations, new ItemKey(1, 15, 264, 144)));
            Assert.That(Contains(accessableLocations, new ItemKey(1, 25, 296, 176)));
            Assert.That(Contains(accessableLocations, new ItemKey(1, 9, 600, 192)));
        }
示例#22
0
        public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager)
        {
            Action <GameSave> originalReloadSaveAction = Dynamic._reloadSaveAction;

            void ReloadSave(GameSave gameSave)
            {
                itemLocationMap.Initialize(gameSave);

                ItemTrackerUplink.UpdateState(ItemTrackerState.FromItemLocationMap(itemLocationMap));

                originalReloadSaveAction(gameSave);
            }

            Dynamic._reloadSaveAction = (Action <GameSave>)ReloadSave;
        }
        public void Should_fill_tuturial_with_melee_and_spellorb(uint seedIndex)
        {
            var seed          = new Seed(seedIndex, SeedOptions.None);
            var unlockingMap  = new ItemUnlockingMap(seed);
            var itemProvider  = new ItemInfoProvider(SeedOptions.None, unlockingMap);
            var itemLocations = new ItemLocationMap(itemProvider, unlockingMap, SeedOptions.None);

            FullRandomItemLocationRandomizer.AddRandomItemsToLocationMap(seed, itemProvider, unlockingMap, itemLocations, true);

            Assert.That(itemLocations[ItemKey.TutorialMeleeOrb].ItemInfo.Identifier.LootType, Is.EqualTo(LootType.Orb));
            Assert.That(itemLocations[ItemKey.TutorialMeleeOrb].ItemInfo.Identifier.OrbSlot, Is.EqualTo(EOrbSlot.Melee));

            Assert.That(itemLocations[ItemKey.TutorialSpellOrb].ItemInfo.Identifier.LootType, Is.EqualTo(LootType.Orb));
            Assert.That(itemLocations[ItemKey.TutorialSpellOrb].ItemInfo.Identifier.OrbSlot, Is.EqualTo(EOrbSlot.Spell));
        }
示例#24
0
        public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager)
        {
            if (!IsUsedAsArchipelagoSelectionMenu)
            {
                return;
            }

            Dynamic._menuTitle = "Enter Credentials";

            serverMenuEntry   = MenuEntry.Create(ServerPrefix, _ => { });
            userMenuEntry     = MenuEntry.Create(UserPrefix, _ => { });
            passwordMenuEntry = MenuEntry.Create(PasswordPrefix, _ => { });
            connectMenuEntry  = MenuEntry.Create("Connect", OnConnectEntrySelected, false);

            ChangeAvailableButtons(serverMenuEntry, userMenuEntry, passwordMenuEntry, connectMenuEntry);
        }
        static void WriteProgressionChain(StreamWriter file, ItemLocationMap itemLocations)
        {
            file.WriteLine();
            file.WriteLine("Progression Chain:");

            var depth            = 0;
            var progressionChain = itemLocations.GetProgressionChain();

            do
            {
                WriteItemList(file, progressionChain.Locations, depth);

                depth++;
                progressionChain = progressionChain.Sub;
            } while (progressionChain != null);
        }
        protected void GiveOrbsToMom(Random random, ItemLocationMap itemLocations, bool useLightwallAsSpell)
        {
            var orbTypes = Helper.GetAllOrbs();

            var spellOrbTypes = useLightwallAsSpell
                                ? orbTypes.Where(orbType => orbType == EInventoryOrbType.Barrier)
                                : orbTypes.Where(orbType => orbType != EInventoryOrbType.Barrier);
            var meleeOrbTypes = orbTypes.Where(orbType => orbType != EInventoryOrbType.Pink);             //To annoying as each attack consumes aura power

            var spellOrbType = spellOrbTypes.SelectRandom(random);

            PutItemAtLocation(ItemInfoProvider.Get(spellOrbType, EOrbSlot.Spell), itemLocations[ItemKey.TutorialSpellOrb]);

            var meleeOrbType = meleeOrbTypes.SelectRandom(random);

            PutItemAtLocation(ItemInfoProvider.Get(meleeOrbType, EOrbSlot.Melee), itemLocations[ItemKey.TutorialMeleeOrb]);
        }
示例#27
0
        public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager)
        {
            if (!IsUsedAsSeedOptionsMenu)
            {
                return;
            }

            Dynamic._menuTitle = "Select Seed Options";

            var relicInventory = ((object)Dynamic._relicInventory).AsDynamic();

            relicInventory.ColumnCount = 1;
            relicInventory.SetColumnWidth(226 * Dynamic.Zoom, Dynamic.Zoom);

            HookOnSelectedAction(relicInventory);

            UpdateMenuItems(Dynamic._relicInventory);
        }
示例#28
0
        public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager)
        {
            if (!IsUsedAsSeedSelectionMenu)
            {
                return;
            }

            Dynamic._menuTitle = "Select Seed";

            okButton = MenuEntry.Create("OK", OnOkayEntrySelected);

            ChangeAvailableButtons(
                okButton,
                MenuEntry.Create("", () => { }, false),
                MenuEntry.Create("New", OnGenerateSelected),
                MenuEntry.Create("Options", OnOptionsSelected)
                );
        }
        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);
        }