Пример #1
0
 // When they enter the level to load into
 bool OnEnterTeleportLevel(string level)
 {
     if (Dicts.tpDict == null)
     {
         Dicts.InitTpDict();
     }
     level = level.Replace(" ", "");
     if (Dicts.tpDict.ContainsKey(level))
     {
         TextEntryPopup locationPopup = InitTextEntryPopup(tpButton.addedTo, Manager <LocalizationManager> .Instance.GetText(TP_LOCATION_ENTRY_LOC_ID), (entry) => OnEnterTeleportLocation(level, entry), 2, null, CharsetFlags.Number | CharsetFlags.Dash);
         locationPopup.onBack += () => {
             locationPopup.gameObject.SetActive(false);
             tpButton.textEntryPopup.gameObject.SetActive(true);
             tpButton.textEntryPopup.StartCoroutine(tpButton.textEntryPopup.BackWhenBackButtonReleased());
         };
         tpButton.textEntryPopup.gameObject.SetActive(false);
         locationPopup.Init(string.Empty);
         locationPopup.gameObject.SetActive(true);
         locationPopup.transform.SetParent(tpButton.addedTo.transform.parent);
         tpButton.addedTo.gameObject.SetActive(false);
         Canvas.ForceUpdateCanvases();
         locationPopup.initialSelection.GetComponent <UIObjectAudioHandler>().playAudio = false;
         EventSystem.current.SetSelectedGameObject(locationPopup.initialSelection);
         locationPopup.initialSelection.GetComponent <UIObjectAudioHandler>().playAudio = true;
         return(false);
     }
     Console.WriteLine("Teleport Level set to an invalid value");
     return(false);
 }
Пример #2
0
 static string GetLevelNameFromEnum(ELevel levelEnum)
 {
     if (Dicts.levelDict == null)
     {
         Dicts.InitLevelDict();
     }
     foreach (KeyValuePair <string, string> kvp in Dicts.levelDict)
     {
         if (levelEnum.ToString().Equals(kvp.Value))
         {
             return(kvp.Key);
         }
     }
     return("");
 }
Пример #3
0
        public override void Load()
        {
            On.InGameHud.OnGUI             += InGameHud_OnGUI;
            On.PlayerController.CanJump    += PlayerController_CanJump;
            On.PlayerController.Awake      += PlayerController_Awake;
            On.PlayerController.ReceiveHit += PlayerController_ReceiveHit;
            On.Hittable.Awake          += Hittable_Awake;
            On.PlayerController.Update += PlayerController_Update;
#pragma warning disable RECS0026 // Possible unassigned object created by 'new'
            new Hook(get_PlayerShurikensInfo, get_PlayerShurikensHookInfo, this);
            // Stuff that doesn't always call orig(self)
            using (new DetourContext("TrainerRebornLast")
            {
                Before = { "*" }
            }) {
                On.PlayerController.Damage += PlayerController_Damage;
                On.RetroCamera.SnapPositionToCameraBounds += RetroCamera_SnapPositionToCameraBounds;
            }

            // Stuff that should always go first
            using (new DetourContext("TrainerRebornFirst")
            {
                After = { "*" }
            }) {
                On.PlayerController.CancelGraplou       += PlayerController_CancelGraplou;
                On.PlayerController.CancelJumpCoroutine += PlayerController_CancelJumpCoroutine;
                On.PlayerKnockbackState.StateEnter      += PlayerKnockbackState_StateEnter;
                On.PlayerKnockbackState.StateExecute    += PlayerKnockbackState_StateExecute;
                On.PlayerKnockbackState.StateExit       += PlayerKnockbackState_StateExit;
            }

            infHealthButton        = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(INF_HEALTH_BUTTON_LOC_ID), OnInfHealth, (b) => infHealth);
            infShurikenButton      = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(INF_SHURIKEN_BUTTON_LOC_ID), OnInfShuriken, (b) => infShuriken);
            infJumpButton          = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(INF_JUMP_BUTTON_LOC_ID), OnInfJump, (b) => infJump);
            noKnockbackButton      = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(NO_KNOCKBACK_BUTTON_LOC_ID), OnNoKnockback, (b) => noKnockback);
            noBoundsButton         = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(NO_BOUNDS_BUTTON_LOC_ID), OnNoBounds, (b) => noBounds);
            debugPosButton         = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(DEBUG_POS_BUTTON_LOC_ID), OnDebugPos, (b) => debugPos);
            debugBossButton        = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(DEBUG_BOSS_BUTTON_LOC_ID), OnDebugBoss, (b) => debugBoss);
            toggleCollisionsButton = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(TOGGLE_COLLISIONS_BUTTON_LOC_ID), OnToggleCollisions, (b) => !collisionsDisabled);
            secondQuestButton      = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(SECOND_QUEST_BUTTON_LOC_ID), OnSecondQuest, (b) => Manager <ProgressionManager> .Instance.secondQuest);
            showHitboxesButton     = Courier.UI.RegisterToggleModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(SHOW_HITBOXES_BUTTON_LOC_ID), OnShowHitboxes, (b) => hitboxesShown);
            speedMultButton        = Courier.UI.RegisterTextEntryModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(SPEED_MULT_BUTTON_LOC_ID), OnEnterSpeed, 4, null, () => Manager <PlayerManager> .Instance?.Player?.RunSpeedMultiplier.ToString() ?? "" + speedMult, CharsetFlags.Number | CharsetFlags.Dot);
            debugTextColorButton   = Courier.UI.RegisterTextEntryModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(DEBUG_TEXT_COLOR_BUTTON_LOC_ID), OnEnterDebugTextColor, 7, null, () => "", CharsetFlags.Letter);
            tpButton              = Courier.UI.RegisterTextEntryModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(TP_BUTTON_LOC_ID), OnEnterTeleportLevel, 17, () => Manager <LocalizationManager> .Instance.GetText(TP_LEVEL_ENTRY_LOC_ID), () => GetLevelNameFromEnum(Manager <LevelManager> .Instance?.GetCurrentLevelEnum() ?? ELevel.NONE), CharsetFlags.Letter);
            getItemButton         = Courier.UI.RegisterTextEntryModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(GET_ITEM_BUTTON_LOC_ID), OnEnterItemToGive, 16, () => Manager <LocalizationManager> .Instance.GetText(ITEM_NAME_ENTRY_LOC_ID), () => "", CharsetFlags.Letter);
            reloadButton          = Courier.UI.RegisterSubMenuModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(RELOAD_BUTTON_LOC_ID), OnReloadButton);
            saveButton            = Courier.UI.RegisterSubMenuModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(SAVE_BUTTON_LOC_ID), OnSaveButton);
            switchDimensionButton = Courier.UI.RegisterSubMenuModOptionButton(() => Manager <LocalizationManager> .Instance.GetText(Manager <DimensionManager> .Instance?.CurrentDimension == EBits.BITS_8 ? SWITCH_DIMENSION_TO_16_LOC_ID : SWITCH_DIMENSION_TO_8_LOC_ID), OnSwitchDimensionButton);

            // Disable certain features until we enter the level
            secondQuestButton.IsEnabled = () => Manager <LevelManager> .Instance.GetCurrentLevelEnum() != ELevel.NONE;

            tpButton.IsEnabled = () => Manager <LevelManager> .Instance.GetCurrentLevelEnum() != ELevel.NONE;

            getItemButton.IsEnabled = () => Manager <LevelManager> .Instance.GetCurrentLevelEnum() != ELevel.NONE;

            reloadButton.IsEnabled = () => Manager <LevelManager> .Instance.GetCurrentLevelEnum() != ELevel.NONE;

            saveButton.IsEnabled = () => Manager <LevelManager> .Instance.GetCurrentLevelEnum() != ELevel.NONE;

            switchDimensionButton.IsEnabled = () => Manager <LevelManager> .Instance.GetCurrentLevelEnum() != ELevel.NONE;

            // Save keybindings for save and reload to the save file
            Courier.ModOptionSaveData.Add(new CharacterOptionSaveMethod("BrokemiaTrainerRebornReloadBinding", () => reloadKeyBinding, (val) => reloadKeyBinding = char.ToLower(val)));
            Courier.ModOptionSaveData.Add(new CharacterOptionSaveMethod("BrokemiaTrainerRebornSaveBinding", () => saveKeyBinding, (val) => saveKeyBinding       = char.ToLower(val)));

            if (Dicts.tpDict == null)
            {
                Dicts.InitTpDict();
            }
            if (Dicts.itemDict == null)
            {
                Dicts.InitItemDict();
            }
            if (Dicts.levelDict == null)
            {
                Dicts.InitLevelDict();
            }
        }