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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. namespace GamecraftModdingAPI.Inventory
  12. {
  13. public class HotbarEngine : IApiEngine
  14. {
  15. public string Name { get; } = "GamecraftModdingAPIHotbarGameEngine";
  16. public EntitiesDB entitiesDB { set; private get; }
  17. public bool IsInGame = false;
  18. public void Dispose()
  19. {
  20. IsInGame = false;
  21. }
  22. public void Ready()
  23. {
  24. IsInGame = true;
  25. }
  26. public bool SelectBlock(int block, uint playerID, bool cubeSelectedByPick = false)
  27. {
  28. InputEntityStruct[] inputs = entitiesDB.QueryEntities<InputEntityStruct>(InputExclusiveGroups.LocalPlayers).ToFastAccess(out uint count);
  29. if (count == 0) return false;
  30. for (int i = 0; i < count; i++)
  31. {
  32. if (inputs[i].ID.entityID == playerID) {
  33. inputs[i].cubeSelectedByPick = cubeSelectedByPick;
  34. inputs[i].selectedCube = block;
  35. return true;
  36. }
  37. }
  38. // TODO: expose the rest of the input functionality
  39. return false;
  40. }
  41. public uint GetLocalPlayerID()
  42. {
  43. return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB);
  44. }
  45. }
  46. }