TechbloxModdingAPI/GamecraftModdingAPI/Inventory/HotbarEngine.cs

59 lines
1.3 KiB
C#
Raw Normal View History

2020-04-02 13:50:30 +00:00
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;
2020-05-12 00:28:26 +00:00
using GamecraftModdingAPI.Engines;
2020-04-02 13:50:30 +00:00
namespace GamecraftModdingAPI.Inventory
{
public class HotbarEngine : IApiEngine
{
public string Name { get; } = "GamecraftModdingAPIHotbarGameEngine";
public EntitiesDB entitiesDB { set; private get; }
2020-05-12 00:28:26 +00:00
public bool isRemovable => false;
2020-04-02 13:50:30 +00:00
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++)
2020-04-02 13:50:30 +00:00
{
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);
}
}
}