Exemple #1
0
        void ResetValues()
        {
            started             = false;
            startGame           = false;
            randoChangesApplied = false;
            singleRaceStarted   = false;

            randoGame = null;
        }
Exemple #2
0
        internal static void OnModeStarted(RandoGame randoGame)
        {
            foreach (var obj in GameObject.FindObjectsOfType <WingCorruptionZone>())
            {
                GameObject.Destroy(obj.gameObject);
            }

            // Set map subtitle
            var titleObj = GameObject.FindObjectOfType <LevelIntroTitleLogic>();

            int curMap = G.Sys.GameManager_.GetCurrentPlaylistIndex();

            if (titleObj)
            {
                titleObj.subtitleText_.text = $"-  MAP {curMap}/16  -";
            }
            else
            {
                MonoBehaviour.print("[RANDOMIZER] title obj null");
            }
        }
Exemple #3
0
        internal static void OnGo(RandoGame randoGame)
        {
            if (Game.LevelName == "Enemy" || Game.LevelName == "Credits")
            {
                return;
            }

            RandoMap map = randoGame.maps[Game.LevelName];

            G.Sys.GameManager_.Level_.Settings_.disableBoosting_    = !map.boostEnabled;
            G.Sys.GameManager_.Level_.Settings_.disableJumping_     = !map.jumpEnabled;
            G.Sys.GameManager_.Level_.Settings_.disableFlying_      = !map.wingsEnabled;
            G.Sys.GameManager_.Level_.Settings_.disableJetRotating_ = !map.jetsEnabled;

            CarLogic car = G.Sys.PlayerManager_.Current_.playerData_.CarLogic_;

            /*car.Boost_.AbilityEnabled_ = map.boostEnabled;
             * car.Jump_.AbilityEnabled_ = map.jumpEnabled;
             * car.Wings_.AbilityEnabled_ = map.wingsEnabled;
             * car.Jets_.AbilityEnabled_ = map.jetsEnabled;*/

            randoGame.abilityState.jumpShouldBeEnabled  = map.jumpEnabled;
            randoGame.abilityState.wingsShouldBeEnabled = map.wingsEnabled;
            randoGame.abilityState.jetsShouldBeEnabled  = map.jetsEnabled;
            //car.GetComponent<HornGadget>().enabled = true;

            foreach (var obj in UnityEngine.Object.FindObjectsOfType <InfoDisplayLogic>())
            {
                if (obj.gameObject.name == "InfoDisplayBox" || obj.gameObject.name == "InfoAndIndicatorDisplayBox")
                {
                    GameObject.Destroy(obj.gameObject);
                }
                else
                {
                    obj.gameObject.RemoveComponent <InfoDisplayLogic>();
                }
            }

            foreach (var obj in UnityEngine.Object.FindObjectsOfType <WingCorruptionZone>())
            {
                GameObject.Destroy(obj.gameObject);
            }

            foreach (var obj in UnityEngine.Object.FindObjectsOfType <AdventureAbilitySettings>())
            {
                GameObject.Destroy(obj.gameObject);
            }

            if (map.abilityEnabled != Ability.None)
            {
                Console.WriteLine($"enables {map.abilityEnabled.ToString()}");
                SetAbilitiesTrigger[] triggers = GameObject.FindObjectsOfType <SetAbilitiesTrigger>();

                foreach (var trigger in triggers)
                {
                    if (!(trigger.visualsOnly_ || !trigger.showAbilityAlert_))
                    {
                        // replace default triggers with a custom solution
                        // (this is an attempt to fix shockingly inconsistent behaviour with the default triggers)
                        // (also it lets us have progressive ability icons!! cool!!)
                        var newTrigger = trigger.gameObject.AddComponent <RandomizerAbilityTrigger>();

                        if (map.abilityEnabled == Ability.Jump)
                        {
                            newTrigger.enableJumping     = true;
                            newTrigger.enableFlying      = randoGame.abilityState.wingsShouldBeEnabled;
                            newTrigger.enableBoosting    = true;
                            newTrigger.enableJetRotating = randoGame.abilityState.jetsShouldBeEnabled;
                        }
                        else if (map.abilityEnabled == Ability.Wings)
                        {
                            newTrigger.enableJumping     = randoGame.abilityState.jumpShouldBeEnabled;
                            newTrigger.enableFlying      = true;
                            newTrigger.enableBoosting    = true;
                            newTrigger.enableJetRotating = randoGame.abilityState.jetsShouldBeEnabled;
                        }
                        else if (map.abilityEnabled == Ability.Jets)
                        {
                            newTrigger.enableJumping     = randoGame.abilityState.jumpShouldBeEnabled;
                            newTrigger.enableFlying      = randoGame.abilityState.wingsShouldBeEnabled;
                            newTrigger.enableBoosting    = true;
                            newTrigger.enableJetRotating = true;
                        }
                        else if (map.abilityEnabled == Ability.Boost)
                        {
                            newTrigger.enableJumping     = randoGame.abilityState.jumpShouldBeEnabled;
                            newTrigger.enableFlying      = randoGame.abilityState.wingsShouldBeEnabled;
                            newTrigger.enableBoosting    = true;
                            newTrigger.enableJetRotating = randoGame.abilityState.jetsShouldBeEnabled;
                        }

                        trigger.gameObject.RemoveComponent <SetAbilitiesTrigger>();
                    }
                    else
                    {
                        GameObject.Destroy(trigger.gameObject);
                    }
                }
            }
            else
            {
                SetAbilitiesTrigger[] triggers = GameObject.FindObjectsOfType <SetAbilitiesTrigger>();

                foreach (var trigger in triggers)
                {
                    GameObject.Destroy(trigger.gameObject);
                }
            }
        }
Exemple #4
0
        internal static void OnPostLoad(RandoGame randoGame)
        {
            foreach (var obj in GameObject.FindObjectsOfType <AdventureSpecialIntro>())
            {
                GameObject.Destroy(obj.gameObject);
            }

            if (!(Game.LevelName == "Enemy" || Game.LevelName == "Credits"))
            {
                // remove warpanchor cutscenes but keep all warpanchors present in arcade mode
                // (this could allow for abyss to unlock an ability)
                foreach (var obj in MonoBehaviour.FindObjectsOfType <WarpAnchor>())
                {
                    if (obj.ignoreInArcade_)
                    {
                        obj.ignoreInAdventure_ = true;
                    }
                    else if (obj.ignoreInAdventure_)
                    {
                        obj.ignoreInAdventure_ = false;
                    }
                }

                foreach (var obj in GameObject.FindObjectsOfType <GlitchFieldLogic>())
                {
                    if (obj.ignoreInArcade_)
                    {
                        GameObject.Destroy(obj.gameObject);
                    }
                }
            }
            else if (Game.LevelName == "Enemy")
            {
                // Enemy specific changes

                // Shorten the warp to earth cutscene by grabbing the relevant warp anchor
                // (in this case, the one just before the waterfall area) and altering its properties a bit
                foreach (var obj in GameObject.FindObjectsOfType <WarpAnchor>())
                {
                    if (obj.myID_ == 0 && obj.otherID_ == 51)
                    {
                        obj.otherID_          = 53;
                        obj.slowmoSpeed_      = 1.0f;
                        obj.time_             = 0.2f;
                        obj.transitionEffect_ = WarpAnchor.TransitionEffect.Teleport;
                        obj.audioEventAfter_  = "Stop_DU_ending_sequence";
                    }
                }

                // Remove the SetAbilitiesTrigger that disables all your abilties at the end
                foreach (var obj in GameObject.FindObjectsOfType <SetAbilitiesTrigger>())
                {
                    if (obj.enableBoosting_ == false &&
                        obj.enableJumping_ == false &&
                        obj.enableFlying_ == false &&
                        obj.enableJetRotating_ == false)
                    {
                        obj.Destroy();
                    }
                }
            }
        }
Exemple #5
0
        public void LateInitialize(IManager manager)
        {
            Console.WriteLine("Late Initialize!");

            // Randomizer plugin control events

            Events.MainMenu.Initialized.Subscribe((data) =>
            {
                if (firstMainMenuLoad)
                {
                    firstMainMenuLoad = false;
                    manager.Hotkeys.Bind("R", () => {
                        if (Game.SceneName == "MainMenu" && G.Sys.GameManager_.SoloAndNotOnline_)
                        {
                            // if prepped to start, show randomizer settings
                            if (startGame)
                            {
                                G.Sys.MenuPanelManager_.ShowError($"Adventure Randomizer {Metadata.RandomizerVersion}\n\n" +
                                                                  $"Seed hash: [FF0000]{randoGame.friendlyHash}[-]\n" +
                                                                  $"({randoGame.truncSeedHash})\n\nStart the [FF0000]Instantiation[-] map in Adventure mode to begin, or any other map to cancel.",
                                                                  "Randomizer Config");
                                return;
                            }

                            if (!G.Sys.MenuPanelManager_.TrackmogrifyMenuLogic_.trackmogrifyInput_.isSelected)
                            {
                                G.Sys.MenuPanelManager_.TrackmogrifyMenuLogic_.Display((inputSeed, isRandom) =>
                                {
                                    var usedSeed = inputSeed;

                                    G.Sys.MenuPanelManager_.Pop();

                                    // Generate randomizer settings
                                    randoGame = new RandoGame(usedSeed, Metadata.LogicVersion);

                                    G.Sys.MenuPanelManager_.ShowError($"Rando seed has been set to:\n[FF0000]{inputSeed.Trim()}[-]\n\n" +
                                                                      $"Hash: [FF0000]{randoGame.friendlyHash}[-]\n({randoGame.truncSeedHash})\n\n" +
                                                                      "Start the [FF0000]Instantiation[-] map in Adventure mode to begin, or any other map to cancel.", "Rando enabled");

                                    startGame          = true;
                                    Game.WatermarkText =
                                        $"ADVENTURE RANDOMIZER {Metadata.RandomizerVersion}\n{randoGame.friendlyHash}\n({randoGame.truncSeedHash})\n";
                                });
                            }
                        }
                    });
                }
                else
                {
                    if (started)
                    {
                        print($"[RANDOMIZER] End randomizer game! - Seed: {randoGame.seed} - Friendly hash: {randoGame.friendlyHash} - SHA256: {randoGame.truncSeedHash}");
                    }

                    ResetValues();
                }
            });

            Events.Scene.BeginSceneSwitchFadeOut.Subscribe((data) => {
                // Yes. We are intercepting a map load. I know it's bad, but this is the only way to get this to work I could find :P
                if (startGame)
                {
                    Console.WriteLine(G.Sys.GameManager_.NextLevelPathRelative_);
                    if (G.Sys.GameManager_.NextLevelPathRelative_ == "OfficialLevels/Instantiation.bytes")
                    {
                        StartRandoGame();
                    }
                    else
                    {
                        Console.WriteLine("rando game cancelled");
                        startGame = false;
                        ResetValues();
                    }
                }
            });

            // Events to handle the map changes required for the rando

            Events.GameMode.ModeStarted.Subscribe((data) =>
            {
                // pre start stuff
                if (started)
                {
                    ApplyRandoChanges.OnModeStarted(randoGame);
                }
            });

            Events.Level.PostLoad.Subscribe((data) =>
            {
                if (started)
                {
                    ApplyRandoChanges.OnPostLoad(randoGame);
                }
            });

            Events.GameMode.Go.Subscribe((data) =>
            {
                Console.WriteLine("Start/Load event fired");
                Console.WriteLine($"Rando game started? {started}");
                if (started)
                {
                    if (Game.LevelName == "Instantiation")
                    {
                        return;
                    }

                    Console.WriteLine($"Rando changes applied? {randoChangesApplied}");
                    if (!randoChangesApplied)
                    {
                        Console.WriteLine(randoChangesApplied);
                        Console.WriteLine("should only be called once");

                        ApplyRandoChanges.OnGo(randoGame);

                        randoChangesApplied = true;
                    }
                    singleRaceStarted = true;
                    CarLogic car      = G.Sys.PlayerManager_.Current_.playerData_.CarLogic_;
                    Console.WriteLine("Start event fired 2");
                    Console.WriteLine($"Jump {car.Jump_.AbilityEnabled_} - Wings {car.Wings_.AbilityEnabled_} - Jets {car.Jets_.AbilityEnabled_}");
                }
            });

            Events.ServerToClient.ModeFinished.Subscribe((data) =>
            {
                Console.WriteLine("Finish event fired");
                if (started)
                {
                    singleRaceStarted   = false;
                    randoChangesApplied = false;
                }
            });

            // Events to update the abiliyState object, and set the car's abiities to what they should be

            Events.Car.Explode.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    if (started)
                    {
                        randoGame.abilityState.UpdateAbilityState();
                    }
                }
            }
                                            );

            Events.Player.CarRespawn.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    if (started)
                    {
                        Console.WriteLine("Respawn event fired");
                        randoGame.abilityState.SetCarAbilities(singleRaceStarted);
                    }
                }
            });
        }
 public RandoCarAbilityState(RandoGame randoGame)
 {
     this.randoGame = randoGame;
 }