Пример #1
0
        private static void Init(Action orig)
        {
            orig();

            HookAttribute.DisableHooks(typeof(SceneCatalogHooks));

            var lookups = SceneCatalog.allSceneDefs.ToDictionary(sd => sd.baseSceneName);

            Logger.LogInfo("Lodded dictionary for sceneNameOverride doping");

            var sceneDefinitions = RainOfStages.Instance.SceneDefinitions.OfType <SceneDefinition>();

            var overrideMapping     = MakeLinks(sceneDefinitions, def => def.reverseSceneNameOverrides);
            var destinationsMapping = MakeLinks(sceneDefinitions, def => def.destionationInjections);

            Weave(lookups, overrideMapping,
                  sd => sd.Destination.baseSceneName,
                  sd => sd.sceneNameOverrides,
                  (sd, data) => sd.sceneNameOverrides = data.ToList());

            Weave(lookups, destinationsMapping,
                  sd => sd.Destination,
                  sd => sd.destinations,
                  (sd, data) => sd.destinations = data.ToArray());
        }
Пример #2
0
        private static void Init(Action orig)
        {
            orig();
            HookAttribute.DisableHooks(typeof(SceneCatalogHooks));

            var lookups = SceneCatalog.allSceneDefs.ToDictionary(sd => sd.baseSceneName);

            Logger.LogInfo("Lodded dictionary for sceneNameOverride doping");

            var sceneDefinitions = RainOfStages.Instance.SceneDefinitions.OfType <SceneDefinition>();

            {
                var maps      = sceneDefinitions.SelectMany(destination => destination.destionationInjections.Select(origin => (destination, origin)));
                var mapGroups = maps.GroupBy(map => map.origin.baseSceneName);

                foreach (var mapGroup in mapGroups)
                {
                    var destinations = lookups[mapGroup.Key].destinations = lookups[mapGroup.Key].destinations.Union(mapGroup.Select(map => map.destination as SceneDef)).Distinct().ToArray();
                    foreach (var destination in destinations)
                    {
                        Logger.LogMessage($"Added destination {destination.baseSceneName} to SceneDef {mapGroup.Key}");
                    }
                }
            }

            {
                var maps      = sceneDefinitions.SelectMany(loadedSceneDef => loadedSceneDef.reverseSceneNameOverrides.Select(overridedScene => (loadedSceneDef, overridedScene)));
                var mapGroups = maps.GroupBy(map => map.overridedScene.baseSceneName);

                foreach (var mapGroup in mapGroups)
                {
                    var overridingScenes = lookups[mapGroup.Key].sceneNameOverrides = lookups[mapGroup.Key].sceneNameOverrides.Union(mapGroup.Select(map => map.loadedSceneDef.baseSceneName)).Distinct().ToList();

                    foreach (var overridingScene in overridingScenes)
                    {
                        Logger.LogMessage($"Added override {overridingScene} to SceneDef {mapGroup.Key}");
                    }
                }
            }
        }