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.8KB

  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(LocalInputEntityStruct input, uint playerID, bool remote = false)
  24. {
  25. EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
  26. if (entitiesDB.Exists<LocalInputEntityStruct>(egid))
  27. {
  28. ref LocalInputEntityStruct ies = ref entitiesDB.QueryEntity<LocalInputEntityStruct>(egid);
  29. ies = input;
  30. return true;
  31. }
  32. else return false;
  33. }
  34. public LocalInputEntityStruct GetInput(uint playerID, bool remote = false)
  35. {
  36. EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
  37. if (entitiesDB.Exists<LocalInputEntityStruct>(egid))
  38. {
  39. return entitiesDB.QueryEntity<LocalInputEntityStruct>(egid);
  40. }
  41. else return default(LocalInputEntityStruct);
  42. }
  43. public ref LocalInputEntityStruct GetInputRef(uint playerID, bool remote = false)
  44. {
  45. EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
  46. return ref entitiesDB.QueryEntity<LocalInputEntityStruct>(egid);
  47. }
  48. public uint GetLocalPlayerID()
  49. {
  50. return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB);
  51. }
  52. }
  53. }