public override void Unload()
 {
     try
     {
         if (settings != null)
         {
             gcm.UpdateMinimapColors(settings);
         }
     }
     catch
     {
         // ignored
     }
 }
        public static GameScreen Create(ScreenManager screenManager)
        {
            GCM gcm = screenManager.AsDynamic().GCM;

            void Noop()
            {
                var gameplayScreen = screenManager.FirstOrDefault <GameplayScreen>();

                if (gameplayScreen != null && gameplayScreen.Settings != null)
                {
                    gcm.UpdateMinimapColors(gameplayScreen.Settings);
                }
            }

            gcm.LoadAllResources(screenManager.AsDynamic().GeneralContentManager, screenManager.GraphicsDevice);

            return((GameScreen)Activator.CreateInstance(JournalMenuType, GameSave.DemoSave, gcm, (Action)Noop));
        }
Example #3
0
        public override void Initialize(ItemLocationMap _, GCM gameContentManager)
        {
            GameContentManager = gameContentManager;

            var saveFile      = Save;
            var seed          = saveFile.GetSeed();
            var fillingMethod = saveFile.GetFillingMethod();
            var settings      = saveFile.GetSettings();

            ScreenManager.Log.SetSettings(settings);
            gameContentManager.UpdateMinimapColors(settings);

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

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

            seedOptions = seed.Value.Options;
            Settings    = settings;

            try
            {
                ItemLocations = Randomizer.Randomize(seed.Value, fillingMethod, Level.GameSave);
            }
            catch (ConnectionFailedException e)
            {
                SendBackToMainMenu(e.Message);
                return;
            }

            ItemLocations.Initialize(Level.GameSave);

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

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

            ItemManipulator.Initialize(ItemLocations);

            if (settings.DamageRando.Value != "Off")
            {
                OrbDamageManager.PopulateOrbLookups(Level.GameSave, settings.DamageRando.Value, settings.DamageRandoOverrides.Value);
            }

            BestiaryManager.UpdateBestiary(Level, settings);
            if (!saveFile.GetSaveBool("IsFightingBoss"))
            {
                BestiaryManager.RefreshBossSaveFlags(Level);
            }

            if (seedOptions.Archipelago)
            {
                Client.SetStatus(ArchipelagoClientState.ClientPlaying);

                deathLinkService = new DeathLinker(settings, Client.GetDeathLinkService());
            }

#if DEBUG
            ScreenManager.Console.AddCommand(new TeleportCommand(() => Level));
            ScreenManager.Console.AddCommand(new GiveRelicCommand(() => Level));
            ScreenManager.Console.AddCommand(new GiveOrbCommand(() => Level));
            ScreenManager.Console.AddCommand(new GiveFamiliarCommand(() => Level));
#endif
        }