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.

66 lines
1.7KB

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