示例#1
0
    public void Start()
    {
        if (instance != null)
        {
            throw new Exception("MoreSailsMoreSpeed singleton was already set");
        }
        instance = this;

        harmony = HarmonyInstance.Create(harmonyID);
        harmony.PatchAll(Assembly.GetExecutingAssembly());

        RConsole.registerCommand(typeof(MoreSailsMoreSpeed), "Lower all sails", "sailsOpen", SailsOpen);
        RConsole.registerCommand(typeof(MoreSailsMoreSpeed), "Raise all sails", "sailsClose", SailsClose);
        RConsole.registerCommand(typeof(MoreSailsMoreSpeed), "Rotate sails by a certain number", "sailsRotate", SailsRotate);
        RConsole.registerCommand(typeof(MoreSailsMoreSpeed), "Toggle all engines at once", "toggleEngines", ToggleAllEngines);
        RConsole.registerCommand(typeof(MoreSailsMoreSpeed), "Toggle all engines's direction at once", "toggleEnginesDir", ToggleAllEnginesDir);
        RConsole.registerCommand(typeof(MoreSailsMoreSpeed), "Tells you your current speed, 1.5 = default drift speed", "raftSpeed", PrintSpeed);

        if (SceneManager.GetActiveScene().isLoaded&& SceneManager.GetActiveScene().name == network.gameSceneName)
        {
            WorldEvent_WorldLoaded();
        }

        RConsole.Log(modPrefix + "loaded!");
    }
示例#2
0
 private static bool Prefix(ref BlockButton ___button_ChangeDirection)
 {
     if (MyInput.GetButton("Sprint"))
     {
         MoreSailsMoreSpeed.ToggleAllEnginesDir();
         return(false);
     }
     return(true);
 }
示例#3
0
 private static bool Prefix(ref InteractionMotorWheelPowerButton ___button_EngineOnOff)
 {
     if (MyInput.GetButton("Sprint"))
     {
         MoreSailsMoreSpeed.ToggleAllEngines();
         return(false);
     }
     return(true);
 }
示例#4
0
    private static bool Prefix
    (
        SteeringWheel __instance,
        ref bool ___hasBeenPlaced,
        ref bool ___isDisplayingText,
        DisplayTextManager ___displayText,
        ref Network_Player ___localPlayer,
        ref Semih_Network ___network
    )
    {
        if (!___hasBeenPlaced)
        {
            return(true);
        }
        if (MyInput.GetButton("Sprint"))
        {
            ___isDisplayingText = true;
            ___displayText.ShowText("Toggle Engines", MyInput.Keybinds["Interact"].MainKey, 1, "Toggle Engine Direction", MyInput.Keybinds["Rotate"].MainKey, 2);

            if (MyInput.GetButtonDown("Interact"))
            {
                MoreSailsMoreSpeed.ToggleAllEngines();
            }
            if (MyInput.GetButtonDown("Rotate"))
            {
                MoreSailsMoreSpeed.ToggleAllEnginesDir();
            }
        }
        else
        {
            ___isDisplayingText = true;
            ___displayText.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, Helper.GetTerm("Game/RotateSmooth2", false), MyInput.Keybinds["Rotate"].MainKey, 2);
            if (MyInput.GetButtonDown("Rotate"))
            {
                ___localPlayer.PlayerScript.SetMouseLookScripts(false);
            }
            if (MyInput.GetButtonUp("Rotate"))
            {
                ___localPlayer.PlayerScript.SetMouseLookScripts(true);
            }
            if (MyInput.GetButton("Rotate"))
            {
                float axis = Input.GetAxis("Mouse X");
                Message_SteeringWheel_Rotate message = new Message_SteeringWheel_Rotate(Messages.SteeringWheelRotate, ___network.NetworkIDManager, __instance.ObjectIndex, axis);
                if (Semih_Network.IsHost)
                {
                    AccessTools.Method("SteeringWheel:Rotate").Invoke(__instance, new object[] { axis });
                    return(false);
                }
                ___network.SendP2P(___network.HostID, message, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
            }
        }
        return(false);
    }
示例#5
0
    private static bool Prefix
    (
        Sail __instance,
        ref bool ___blockPlaced,
        ref Network_Player ___localPlayer,
        ref CanvasHelper ___canvas,
        ref bool ___isRotating,
        ref GameObject ___paintCollider,
        ref Semih_Network ___network
    )
    {
        if (!___blockPlaced)
        {
            return(false);
        }
        if (___canvas == null || ___canvas.displayTextManager == null || ___localPlayer == null)
        {
            return(false);
        }
        if (Helper.LocalPlayerIsWithinDistance(__instance.transform.position, Player.UseDistance) && CanvasHelper.ActiveMenu == MenuType.None)
        {
            bool mod = MyInput.GetButton("Sprint");
            if (!__instance.open)
            {
                if (mod)
                {
                    ___canvas.displayTextManager.ShowText("Open Sails", MyInput.Keybinds["Interact"].MainKey, 1, "Rotate Sails", MyInput.Keybinds["Rotate"].MainKey, 2);
                }
                else
                {
                    ___canvas.displayTextManager.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, "Open", MyInput.Keybinds["Interact"].MainKey, 2, 0, true);
                    ___canvas.displayTextManager.ShowText("Rotate", MyInput.Keybinds["Rotate"].MainKey, 3, 0, false);
                }
            }
            else
            {
                if (mod)
                {
                    ___canvas.displayTextManager.ShowText("Close Sails", MyInput.Keybinds["Interact"].MainKey, 1, "Rotate Sails", MyInput.Keybinds["Rotate"].MainKey, 2);
                }
                else
                {
                    ___canvas.displayTextManager.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, "Close", MyInput.Keybinds["Interact"].MainKey, 2, 0, true);
                    ___canvas.displayTextManager.ShowText("Rotate", MyInput.Keybinds["Rotate"].MainKey, 3, 0, false);
                }
            }

            if (MyInput.GetButtonDown("Interact"))
            {
                Message_NetworkBehaviour message = new Message_NetworkBehaviour(__instance.open ? Messages.Sail_Close : Messages.Sail_Open, __instance);
                if (Semih_Network.IsHost)
                {
                    if (__instance.open)
                    {
                        if (mod)
                        {
                            MoreSailsMoreSpeed.SailsClose();
                        }
                        else
                        {
                            AccessTools.Method("Sail:Close").Invoke(__instance, null);
                        }
                    }
                    else
                    {
                        if (mod)
                        {
                            MoreSailsMoreSpeed.SailsOpen();
                        }
                        else
                        {
                            AccessTools.Method("Sail:Open").Invoke(__instance, null);
                        }
                    }
                    ___network.RPC(message, Target.Other, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                }
                else
                {
                    ___network.SendP2P(___network.HostID, message, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                }
            }

            if (MyInput.GetButton("Rotate"))
            {
                ___localPlayer.PlayerScript.SetMouseLookScripts(false);
                ___isRotating = true;
            }
            else if (MyInput.GetButtonUp("Rotate"))
            {
                if (mod)
                {
                    MoreSailsMoreSpeed.RotateSailsTo(__instance);
                }
                ___localPlayer.PlayerScript.SetMouseLookScripts(true);
                ___isRotating = false;
            }
            if (MyInput.GetButtonUp("Sprint") && ___isRotating)
            {
                MoreSailsMoreSpeed.RotateSailsTo(__instance);
                ___localPlayer.PlayerScript.SetMouseLookScripts(true);
                ___isRotating = false;
                return(false);
            }

            bool button = MyInput.GetButton("Rotate");
            if (button)
            {
                float axis = Input.GetAxis("Mouse X");
                if (Semih_Network.IsHost)
                {
                    AccessTools.Method("Sail:Rotate").Invoke(__instance, new object[] { axis });
                }
                else
                {
                    Message_Sail_Rotate message2 = new Message_Sail_Rotate(Messages.Sail_Rotate, __instance, axis);
                    ___network.SendP2P(___network.HostID, message2, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                }
            }
            ___paintCollider.SetActiveSafe(!button);
            return(false);
        }
        if (___isRotating)
        {
            ___isRotating = false;
            ___localPlayer.PlayerScript.SetMouseLookScripts(true);
        }
        ___canvas.displayTextManager.HideDisplayTexts();
        return(false);
    }