|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
-
- using RobocraftX.Character;
- using RobocraftX.GUI.Hotbar;
- using RobocraftX.Players;
- using RobocraftX.Common;
- using RobocraftX.Common.Input;
- using RobocraftX.Common.Players;
- using Svelto.ECS;
-
- using GamecraftModdingAPI.Blocks;
- using GamecraftModdingAPI.Utility;
- using GamecraftModdingAPI.Engines;
-
- namespace GamecraftModdingAPI.Inventory
- {
- public class HotbarEngine : IApiEngine
- {
- public string Name { get; } = "GamecraftModdingAPIHotbarGameEngine";
-
- public EntitiesDB entitiesDB { set; private get; }
-
- public bool isRemovable => false;
-
- public bool IsInGame = false;
-
- public void Dispose()
- {
- IsInGame = false;
- }
-
- public void Ready()
- {
- IsInGame = true;
- }
-
- public bool SelectBlock(int block, uint playerID, bool cubeSelectedByPick = false)
- {
- var inputs = entitiesDB.QueryEntities<LocalInputEntityStruct>(InputExclusiveGroups.LocalPlayers);
- if (inputs.count == 0) return false;
- for (int i = 0; i < inputs.count; i++)
- {
- if (inputs[i].ID.entityID == playerID) {
- inputs[i].cubeSelectedByPick = cubeSelectedByPick;
- inputs[i].selectedCube = block;
- return true;
- }
- }
- // TODO: expose the rest of the input functionality
- return false;
- }
-
- public uint GetLocalPlayerID()
- {
- return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB);
- }
- }
- }
|