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.

56 lines
1.3KB

  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. using RobocraftX.Blocks;
  13. using Techblox.FlyCam;
  14. namespace GamecraftModdingAPI.Inventory
  15. {
  16. public class HotbarEngine : IApiEngine
  17. {
  18. public string Name { get; } = "GamecraftModdingAPIHotbarGameEngine";
  19. public EntitiesDB entitiesDB { set; private get; }
  20. public bool isRemovable => false;
  21. public bool IsInGame = false;
  22. public void Dispose()
  23. {
  24. IsInGame = false;
  25. }
  26. public void Ready()
  27. {
  28. IsInGame = true;
  29. }
  30. public bool SelectBlock(int block, uint playerID, bool cubeSelectedByPick = false)
  31. {
  32. if (!entitiesDB.TryQueryEntitiesAndIndex<EquippedPartStruct>(playerID, Techblox.FlyCam.FlyCam.Group,
  33. out var index, out var inputs))
  34. return false;
  35. inputs[index].CubeSelectedByPick = cubeSelectedByPick;
  36. inputs[index].SelectedDBPartID = block;
  37. // TODO: expose the rest of the input functionality
  38. return true;
  39. }
  40. public uint GetLocalPlayerID()
  41. {
  42. return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB);
  43. }
  44. }
  45. }