Browse Source

Return descriptions with command names, selected block/color fix

tags/v2.0.0
NorbiPeti 3 years ago
parent
commit
220eb02a19
Signed by: NorbiPeti <szatmari.norbert.peter@gmail.com> GPG Key ID: DBA4C4549A927E56
4 changed files with 33 additions and 11 deletions
  1. +6
    -9
      TechbloxModdingAPI/Commands/ExistingCommands.cs
  2. +13
    -0
      TechbloxModdingAPI/FlyCam.cs
  3. +2
    -2
      TechbloxModdingAPI/Player.cs
  4. +12
    -0
      TechbloxModdingAPI/Players/FlyCamEngine.cs

+ 6
- 9
TechbloxModdingAPI/Commands/ExistingCommands.cs View File

@@ -1,4 +1,4 @@
using System;
using System.Linq;

using uREPL;

@@ -27,16 +27,13 @@ namespace TechbloxModdingAPI.Commands
}

public static bool Exists(string commandName)
{
{
return RuntimeCommands.HasRegistered(commandName);
}

public static string[] GetCommandNames()
{
var keys = RuntimeCommands.table.Keys;
string[] res = new string[keys.Count];
keys.CopyTo(res, 0);
return res;
}
public static (string Name, string Description)[] GetCommandNamesAndDescriptions()
{
return RuntimeCommands.table.Values.Select(command => (command.name, command.description)).ToArray();
}
}
}

+ 13
- 0
TechbloxModdingAPI/FlyCam.cs 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);


+ 2
- 2
TechbloxModdingAPI/Player.cs 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;
}
}



+ 12
- 0
TechbloxModdingAPI/Players/FlyCamEngine.cs 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;
}
}
}

Loading…
Cancel
Save