OperaComponentSystem.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using UnityEngine;
  3. namespace ET.Client
  4. {
  5. [FriendOf(typeof(OperaComponent))]
  6. public static class OperaComponentSystem
  7. {
  8. [ObjectSystem]
  9. public class OperaComponentAwakeSystem : AwakeSystem<OperaComponent>
  10. {
  11. public override void Awake(OperaComponent self)
  12. {
  13. self.mapMask = LayerMask.GetMask("Map");
  14. }
  15. }
  16. [ObjectSystem]
  17. public class OperaComponentUpdateSystem : UpdateSystem<OperaComponent>
  18. {
  19. public override void Update(OperaComponent self)
  20. {
  21. self.Update();
  22. }
  23. }
  24. public static void Update(this OperaComponent self)
  25. {
  26. if (Input.GetMouseButtonDown(1))
  27. {
  28. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  29. RaycastHit hit;
  30. if (Physics.Raycast(ray, out hit, 1000, self.mapMask))
  31. {
  32. self.ClickPoint = hit.point;
  33. self.frameClickMap.X = self.ClickPoint.x;
  34. self.frameClickMap.Y = self.ClickPoint.y;
  35. self.frameClickMap.Z = self.ClickPoint.z;
  36. self.ClientScene().GetComponent<SessionComponent>().Session.Send(self.frameClickMap);
  37. }
  38. }
  39. if (Input.GetKeyDown(KeyCode.R))
  40. {
  41. CodeLoader.Instance.LoadLogic();
  42. Game.EventSystem.Load();
  43. Log.Debug("hot reload success!");
  44. }
  45. if (Input.GetKeyDown(KeyCode.T))
  46. {
  47. C2M_TransferMap c2MTransferMap = new C2M_TransferMap();
  48. self.ClientScene().GetComponent<SessionComponent>().Session.Call(c2MTransferMap).Coroutine();
  49. }
  50. }
  51. }
  52. }