LSInputComponentSystem.cs 816 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using ET.Client;
  3. using TrueSync;
  4. namespace ET
  5. {
  6. [EntitySystemOf(typeof(LSInputComponent))]
  7. [LSEntitySystemOf(typeof(LSInputComponent))]
  8. public static partial class LSInputComponentSystem
  9. {
  10. [EntitySystem]
  11. private static void Awake(this LSInputComponent self)
  12. {
  13. }
  14. [LSEntitySystem]
  15. private static void LSUpdate(this LSInputComponent self)
  16. {
  17. LSUnit unit = self.GetParent<LSUnit>();
  18. TSVector2 v2 = self.LSInput.V * 6 * 50 / 1000;
  19. if (v2.LengthSquared() < 0.0001f)
  20. {
  21. return;
  22. }
  23. TSVector oldPos = unit.Position;
  24. unit.Position += new TSVector(v2.x, 0, v2.y);
  25. unit.Forward = unit.Position - oldPos;
  26. }
  27. }
  28. }