Example #1
0
        /*********
        ** Private methods
        *********/
        private static void ReloadCustomChests(object sender, EventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            MegaStorageMod.ModMonitor.VerboseLog("SaveManager: ReloadCustomChests");
            LegacyHelper.FixLegacyOptions();
            StateManager.PlacedChests.Clear();
            foreach (var location in CommonHelper.GetLocations())
            {
                var placedChests = location.Objects.Pairs
                                   .Where(c => c.Value is Chest chest && CustomChestFactory.ShouldBeCustomChest(chest))
                                   .ToDictionary(
                    c => c.Key,
                    c => c.Value.ToCustomChest(c.Key));

                foreach (var placedChest in placedChests)
                {
                    var pos         = placedChest.Key;
                    var customChest = placedChest.Value;
                    MegaStorageMod.ModMonitor.VerboseLog($"Loading Chest at: {location.Name}: {customChest.Name} ({pos})");
                    location.objects[placedChest.Key] = customChest;
                    StateManager.PlacedChests.Add(new Tuple <GameLocation, Vector2>(location, pos), customChest);
                }
            }
        }
Example #2
0
        private static void ReAddCustomChests(object sender, EventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            MegaStorageMod.ModMonitor.VerboseLog("SaveManager: ReAddCustomChests");
            LegacyHelper.FixLegacyOptions();
            foreach (var placedChest in StateManager.PlacedChests)
            {
                var location    = placedChest.Key.Item1;
                var pos         = placedChest.Key.Item2;
                var customChest = placedChest.Value;
                MegaStorageMod.ModMonitor.VerboseLog($"ReAddCustomChests in {location.Name}: {customChest.Name} ({pos})");
                location.objects[pos] = customChest;
            }
        }