Exemplo n.º 1
0
        private IEnumerator Dungeon_TriggerEvents(On.Dungeon.orig_TriggerEvents orig, Dungeon self, Room openingRoom, HeroMobCommon opener, bool canTriggerDungeonEvent)
        {
            SeedCollection collection = SeedCollection.GetMostCurrentSeeds(self.ShipName, self.Level);

            if (collection == null || !collection.Enabled || isHumanWrapper.Value)
            {
                yield return(self.StartCoroutine(orig(self, openingRoom, opener, canTriggerDungeonEvent)));

                yield break;
            }
            else
            {
                // Load seeds for each door from files/somewhere
                // Restore the seed for this room openingRoom
                RandomGenerator.RestoreSeed();

                // Calls TriggerEvents the proper number of times. Hangs on this call.
                // Random deviation seems to appear while this Coroutine is running, possibly due to monster random actions?
                // Could fix this by storing all before/after seeds, but doesn't that seem lame?
                // Would like to find a way of only wrapping the Random calls with this so that there is less UnityEngine.Random.seed
                // noise from other sources that occur during the runtime.
                // The above will probably not work, so instead wrap everything EXCEPT for the wait in the Random Save/Restore
                // Possible error from SpawnWaves, SpawnMobs (cause they have dedicated Coroutines that run)
                yield return(self.StartCoroutine(orig(self, openingRoom, opener, canTriggerDungeonEvent)));

                // I'm going to cheat for now and SKIP the saving step - the same exact seed is ALWAYS used for RandomGenerator
                // When using RandomGenerator seeds.
                //mod.Log("Saving Seed!");
                //RandomGenerator.SaveSeed();

                yield break;
            }
        }
Exemplo n.º 2
0
        public static void Clear()
        {
            inputs = new Dictionary <int, List <TASInput> >();
            Dungeon d = SingletonManager.Get <Dungeon>(false);

            SeedCollection.ReadAll();
            seeds = SeedCollection.GetMostCurrentSeeds(d.ShipName, d.Level);
            if (seeds == null)
            {
                seeds = SeedCollection.Create();
            }
        }
Exemplo n.º 3
0
        private void InputManager_Update(On.InputManager.orig_Update orig, InputManager self)
        {
            orig(self);
            Dungeon d = SingletonManager.Get <Dungeon>(false);

            if (!overwriteWrapper.Value)
            {
                SeedCollection.UnLoad();
            }
            else
            {
                if (!SeedCollection.Loaded)
                {
                    mod.Log("Reinitializing SeedCollection because it isn't loaded!");
                    SeedCollection.ReadAll();
                }
            }
            if (d == null)
            {
                return;
            }
            if (Input.GetKeyUp((KeyCode)Enum.Parse(typeof(KeyCode), saveKeyWrapper.Value)))
            {
                mod.Log("Saving SeedData to SeedCollection!");
                SeedCollection best = SeedCollection.GetMostCurrentSeeds(d.ShipName, d.Level);
                if (best == null)
                {
                    mod.Log("Creating new SeedCollection because there were no matching SeedCollections!");
                    best = SeedCollection.Create();
                }
                SeedData data = new SeedData();
                d.EnqueueNotification("Saved SeedData: " + data + " to: " + best.ReadFrom);
                best.Add(d.ShipName, d.Level, data);
                SeedCollection.WriteAll();
                mod.Log("Wrote SeedCollection to: " + best.ReadFrom);
            }
            if (Input.GetKeyUp((KeyCode)Enum.Parse(typeof(KeyCode), createNewSeedKeyWrapper.Value)))
            {
                mod.Log("Created new SeedCollection!");
                SeedCollection best = SeedCollection.Create();
                SeedData       data = new SeedData();
                best.Add(d.ShipName, d.Level, data);
                SeedCollection.WriteAll();
                d.EnqueueNotification("Saved SeedData: " + data + " to new: " + best.ReadFrom);
                mod.Log("Wrote SeedCollection to: " + best.ReadFrom);
            }
        }