LSInputComponentSystem.cs 814 B

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