示例#1
0
        public void Run_Update(On.RoR2.Run.orig_Update orig, Run self)
        {
            orig.Invoke(self);

            //Check if player is moving in any Axis
            float vert = inputPlayer.GetAxis("MoveVertical");
            float horz = inputPlayer.GetAxis("MoveHorizontal");

            //Rework so it works better with controller
            float move = vert != 0 ? .5f : horz != 0 ? .5f : 0;

            float sprint = move == 0 ? 0f : characterBody.isSprinting ? .4f : 0;

            //Check if player is litteraly pressing moving button (Jumping, Skills)
            float skill = inputPlayer.GetButton("PrimarySkill") ? .75f :
                          inputPlayer.GetButton("SecondarySkill") ? .75f :
                          inputPlayer.GetButton("UtilitySkill") ? .75f :
                          inputPlayer.GetButton("SpecialSkill") ? .75f :
                          inputPlayer.GetButton("Jump") ? .75f :
                          inputPlayer.GetButton("Equipment") ? .75f : 0;

            float onGround = characterMotor.isGrounded ? 0f : .25f;

            //Calculate Time
            //Gotta rework this sheit
            float time = onGround + skill + move + sprint;

            if (time > 1f)
            {
                time = 1f;
            }

            ExampleCommandHostCustom.Invoke(x => { x.Write("Time"); x.Write((double)time); });
        }
示例#2
0
        public async void Update()
        {
            // If we hit PageUp on a client, execute ExampleCommandHost on the server with the parameter "C2S!"
            if (Input.GetKeyDown(KeyCode.PageUp))
            {
                ExampleCommandHost.Invoke("C2S!");
            }

            // If we hit PageUp on the server, execute ExampleCommandClient on all clients (including ourselves) with the parameter "S2C!"
            if (Input.GetKeyDown(KeyCode.PageDown))
            {
                ExampleCommandClient.Invoke("S2C!");
            }

            // If we hit Home on the client, execute ExampleCommandHostCustom on the server, which writes a custom message as "parameter"
            if (Input.GetKeyDown(KeyCode.Home))
            {
                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("Test C2S");
                    x.Write(2);
                });
            }

            // If we hit End on the server, execute ExampleCommandHostCustom on all clients, which writes a custom message as "parameter"
            if (Input.GetKeyDown(KeyCode.End))
            {
                ExampleCommandClientCustom.Invoke(x =>
                {
                    x.Write("Test S2C");
                    x.Write(4);
                });
            }

            if (Input.GetKeyDown(KeyCode.Insert))
            {
                Debug.Log("[MiniRpcDemo] Sending request ExampleFuncHost.");
                ExampleFuncHost.Invoke(true, result =>
                {
                    Debug.Log($"[MiniRpcDemo] Received response ExampleFuncHost: {result}");
                });
            }

            if (Input.GetKeyDown(KeyCode.Delete))
            {
                Debug.Log("[MiniRpcDemo] Sending request ExampleFuncClient.");
                ExampleFuncClient.Invoke(true, result =>
                {
                    Debug.Log($"[MiniRpcDemo] Received response ExampleFuncClient: {result}");
                });
            }

            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                Debug.Log("[MiniRpcDemo] Sending request ExampleFuncClientObject.");
                ExampleFuncClientObject.Invoke(new ExampleObject(true, 28, "Pure"), result =>
                {
                    Debug.Log($"[MiniRpcDemo] Received response ExampleFuncClientObject: {result}");
                });
            }
        }