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.

HotbarEngine.cs 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using RobocraftX.Character;
  3. using RobocraftX.GUI.Hotbar;
  4. using RobocraftX.Players;
  5. using RobocraftX.Common;
  6. using RobocraftX.Common.Input;
  7. using RobocraftX.Common.Players;
  8. using Svelto.ECS;
  9. using GamecraftModdingAPI.Blocks;
  10. using GamecraftModdingAPI.Utility;
  11. using GamecraftModdingAPI.Engines;
  12. namespace GamecraftModdingAPI.Inventory
  13. {
  14. public class HotbarEngine : IApiEngine
  15. {
  16. public string Name { get; } = "GamecraftModdingAPIHotbarGameEngine";
  17. public EntitiesDB entitiesDB { set; private get; }
  18. public bool isRemovable => false;
  19. public bool IsInGame = false;
  20. public void Dispose()
  21. {
  22. IsInGame = false;
  23. }
  24. public void Ready()
  25. {
  26. IsInGame = true;
  27. }
  28. public bool SelectBlock(int block, uint playerID, bool cubeSelectedByPick = false)
  29. {
  30. var inputs = entitiesDB.QueryEntities<LocalInputEntityStruct>(InputExclusiveGroups.LocalPlayers);
  31. if (inputs.count == 0) return false;
  32. for (int i = 0; i < inputs.count; i++)
  33. {
  34. if (inputs[i].ID.entityID == playerID) {
  35. inputs[i].cubeSelectedByPick = cubeSelectedByPick;
  36. inputs[i].selectedCube = block;
  37. return true;
  38. }
  39. }
  40. // TODO: expose the rest of the input functionality
  41. return false;
  42. }
  43. public uint GetLocalPlayerID()
  44. {
  45. return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB);
  46. }
  47. }
  48. }