using System; using Entitas; using Proto; using ProtoCSClass; using UnityEngine; namespace CoreGame.Render.System { public class InputSystem : IExecuteSystem { private CombatContext m_Contexts; private Vector2 m_CacheCombinePosition = Vector2.zero; private bool m_isMoving; public InputSystem(CombatContext contexts) { m_Contexts = contexts; } private static int s_InputSeq = 1; public void Execute(float deltaTime) { var joyStickEnt = m_Contexts.joystickProxyEntity; if (joyStickEnt == null) return; joyStickEnt.joystickProxy.Sync(); var combinePos = joyStickEnt.joystickProxy.input; if (combinePos.magnitude > 0.01) { var atan2 = Math.Atan2(combinePos.y, combinePos.x); var angle = atan2 * 180 / Math.PI; // ClientCmd.CreateCommand(CommandType.JoyStickDrag, out var battleCommand); // battleCommand.m_joysticDirection = (int)angle; // m_Contexts.cmdRecv.PushRenderCmd(battleCommand); // var csPlayerOpInfo = new CSPlayerOpInfo(); // csPlayerOpInfo.Eid = m_Contexts.localCtrlEid; // csPlayerOpInfo.Move = new MoveDirectionCommand(); // csPlayerOpInfo.Move.Degree = (int)angle; // csPlayerOpInfo.Move.Seq = s_InputSeq++; // FrameCmdSvc.GetRenderCommand(FrameCmdDef.MoveDir, out CMD_MoveDirection cmd); // cmd.eid = m_Contexts.localCtrlEid; // cmd.degree = (int)angle; // cmd.seq = s_InputSeq++; // // FrameCmdSvc.SendRenderCommand(cmd); m_isMoving = true; } else { if (m_isMoving) { // ClientCmd.CreateCommand(CommandType.JoyStickEnd, out var battleCommand); // battleCommand.m_joysticDirection = 0; // m_Contexts.cmdRecv.PushRenderCmd(battleCommand); // FrameCmdSvc.GetRenderCommand(FrameCmdDef.MoveStop, out CMD_MoveStop cmd); // cmd.eid = m_Contexts.localCtrlEid; // cmd.seq = s_InputSeq++; // FrameCmdSvc.SendRenderCommand(cmd); // var csPlayerOpInfo = new CSPlayerOpInfo(); // csPlayerOpInfo.Type = FrameCmdDef.MoveDir; // csPlayerOpInfo.Eid = m_Contexts.localCtrlEid; // csPlayerOpInfo.Move = new MoveDirectionCommand(); // csPlayerOpInfo.Move.Degree = int.MaxValue; // csPlayerOpInfo.Move.Seq = s_InputSeq++; // // NetMsgGateway.Instance.SendMsgReq(ClientMsgId.CS_GAMEMSGID_PlayerOpInfoReq, csPlayerOpInfo, false); } m_isMoving = false; } m_CacheCombinePosition = combinePos; } } }