Return descriptions with command names, selected block/color fix
This commit is contained in:
parent
e8515ef42b
commit
220eb02a19
4 changed files with 33 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System.Linq;
|
||||||
|
|
||||||
using uREPL;
|
using uREPL;
|
||||||
|
|
||||||
|
@ -31,12 +31,9 @@ namespace TechbloxModdingAPI.Commands
|
||||||
return RuntimeCommands.HasRegistered(commandName);
|
return RuntimeCommands.HasRegistered(commandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string[] GetCommandNames()
|
public static (string Name, string Description)[] GetCommandNamesAndDescriptions()
|
||||||
{
|
{
|
||||||
var keys = RuntimeCommands.table.Keys;
|
return RuntimeCommands.table.Values.Select(command => (command.name, command.description)).ToArray();
|
||||||
string[] res = new string[keys.Count];
|
|
||||||
keys.CopyTo(res, 0);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ using RobocraftX.Physics;
|
||||||
using Svelto.ECS;
|
using Svelto.ECS;
|
||||||
using Svelto.ECS.EntityStructs;
|
using Svelto.ECS.EntityStructs;
|
||||||
using Techblox.FlyCam;
|
using Techblox.FlyCam;
|
||||||
|
using TechbloxModdingAPI.Blocks;
|
||||||
using TechbloxModdingAPI.Players;
|
using TechbloxModdingAPI.Players;
|
||||||
using TechbloxModdingAPI.Utility;
|
using TechbloxModdingAPI.Utility;
|
||||||
using Unity.Mathematics;
|
using Unity.Mathematics;
|
||||||
|
@ -111,6 +112,18 @@ namespace TechbloxModdingAPI
|
||||||
set => Engine.GetComponent<RigidBodyEntityStruct>(this).angularVelocity = value;
|
set => Engine.GetComponent<RigidBodyEntityStruct>(this).angularVelocity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's selected block ID in their hand.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The selected block.</value>
|
||||||
|
public BlockIDs SelectedBlock => (BlockIDs)Engine.GetSelectedBlock(this);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's selected block color in their hand.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The selected block's color.</value>
|
||||||
|
public BlockColor SelectedColor => new BlockColor(Engine.GetSelectedColor(this));
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
GameEngineManager.AddGameEngine(Engine);
|
GameEngineManager.AddGameEngine(Engine);
|
||||||
|
|
|
@ -313,7 +313,7 @@ namespace TechbloxModdingAPI
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return (BlockIDs)playerEngine.GetSelectedBlock(Id);
|
return BuildCamera.SelectedBlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ namespace TechbloxModdingAPI
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return new BlockColor(playerEngine.GetSelectedColor(Id));
|
return BuildCamera.SelectedColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,5 +23,17 @@ namespace TechbloxModdingAPI.Players
|
||||||
{
|
{
|
||||||
return ref entitiesDB.QueryEntityOrDefault<T>(cam);
|
return ref entitiesDB.QueryEntityOrDefault<T>(cam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ushort GetSelectedBlock(FlyCam cam)
|
||||||
|
{
|
||||||
|
var oc = entitiesDB.QueryEntityOptional<EquippedPartStruct>(cam);
|
||||||
|
return oc ? (ushort) oc.Get().SelectedDBPartID : ushort.MaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte GetSelectedColor(FlyCam cam)
|
||||||
|
{
|
||||||
|
var oc = entitiesDB.QueryEntityOptional<EquippedColourStruct>(cam);
|
||||||
|
return oc ? oc.Get().indexInPalette : (byte) 255;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue