A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.6KB

  1. using System;
  2. using RobocraftX.Common.Input;
  3. using RobocraftX.Players;
  4. using Svelto.ECS;
  5. using GamecraftModdingAPI.Utility;
  6. namespace GamecraftModdingAPI.Input
  7. {
  8. public class FakeInputEngine : IApiEngine
  9. {
  10. public string Name { get; } = "GamecraftModdingAPIFakeInputEngine";
  11. public EntitiesDB entitiesDB { set; private get; }
  12. public bool IsReady = false;
  13. public void Dispose()
  14. {
  15. IsReady = false;
  16. }
  17. public void Ready()
  18. {
  19. IsReady = true;
  20. }
  21. public bool SendCustomInput(InputEntityStruct input, uint playerID, bool remote = false)
  22. {
  23. EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
  24. if (entitiesDB.Exists<InputEntityStruct>(egid))
  25. {
  26. ref InputEntityStruct ies = ref entitiesDB.QueryEntity<InputEntityStruct>(egid);
  27. ies = input;
  28. return true;
  29. }
  30. else return false;
  31. }
  32. public InputEntityStruct GetInput(uint playerID, bool remote = false)
  33. {
  34. EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
  35. if (entitiesDB.Exists<InputEntityStruct>(egid))
  36. {
  37. return entitiesDB.QueryEntity<InputEntityStruct>(egid);
  38. }
  39. else return default(InputEntityStruct);
  40. }
  41. public ref InputEntityStruct GetInputRef(uint playerID, bool remote = false)
  42. {
  43. EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
  44. return ref entitiesDB.QueryEntity<InputEntityStruct>(egid);
  45. }
  46. public uint GetLocalPlayerID()
  47. {
  48. return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB);
  49. }
  50. }
  51. }