Return descriptions with command names, selected block/color fix

This commit is contained in:
Norbi Peti 2021-05-25 01:20:46 +02:00
parent e8515ef42b
commit 220eb02a19
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 33 additions and 11 deletions

View file

@ -1,4 +1,4 @@
using System;
using System.Linq;
using uREPL;
@ -31,12 +31,9 @@ namespace TechbloxModdingAPI.Commands
return RuntimeCommands.HasRegistered(commandName);
}
public static string[] GetCommandNames()
public static (string Name, string Description)[] GetCommandNamesAndDescriptions()
{
var keys = RuntimeCommands.table.Keys;
string[] res = new string[keys.Count];
keys.CopyTo(res, 0);
return res;
return RuntimeCommands.table.Values.Select(command => (command.name, command.description)).ToArray();
}
}
}

View file

@ -2,6 +2,7 @@ using RobocraftX.Physics;
using Svelto.ECS;
using Svelto.ECS.EntityStructs;
using Techblox.FlyCam;
using TechbloxModdingAPI.Blocks;
using TechbloxModdingAPI.Players;
using TechbloxModdingAPI.Utility;
using Unity.Mathematics;
@ -111,6 +112,18 @@ namespace TechbloxModdingAPI
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()
{
GameEngineManager.AddGameEngine(Engine);

View file

@ -313,7 +313,7 @@ namespace TechbloxModdingAPI
{
get
{
return (BlockIDs)playerEngine.GetSelectedBlock(Id);
return BuildCamera.SelectedBlock;
}
}
@ -325,7 +325,7 @@ namespace TechbloxModdingAPI
{
get
{
return new BlockColor(playerEngine.GetSelectedColor(Id));
return BuildCamera.SelectedColor;
}
}

View file

@ -23,5 +23,17 @@ namespace TechbloxModdingAPI.Players
{
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;
}
}
}