Regex is great GetBlockInfo\(this, \((\w+) (\w+)\) ?=> ?\2(.+)\); GetBlockInfo<$1>(this)$3; SetBlockInfo\(this, \(ref (\w+) (\w+), \w+ (\w+)\) ?=> \2(.*) = \3,\s*value\); GetBlockInfo<$1>(this)$4 = value;
52 lines
No EOL
1.7 KiB
C#
52 lines
No EOL
1.7 KiB
C#
using Gamecraft.Wires;
|
|
using RobocraftX.Common;
|
|
using Svelto.ECS;
|
|
|
|
namespace TechbloxModdingAPI.Blocks
|
|
{
|
|
public class ObjectIdentifier : Block
|
|
{
|
|
public ObjectIdentifier(EGID id) : base(id)
|
|
{
|
|
}
|
|
|
|
public ObjectIdentifier(uint id) : base(new EGID(id, CommonExclusiveGroups.OBJID_BLOCK_GROUP))
|
|
{
|
|
}
|
|
|
|
public char Identifier
|
|
{
|
|
get => (char) BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(this).objectId + 'A';
|
|
set
|
|
{
|
|
BlockEngine.SetBlockInfo(this, (ref ObjectIdEntityStruct st, char val) =>
|
|
{
|
|
st.objectId = (byte) (val - 'A');
|
|
Label = val + ""; //The label isn't updated automatically
|
|
}, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Simulation-time ID. Assigned by the game starting from 0.
|
|
/// </summary>
|
|
public byte SimID
|
|
{
|
|
get => BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(this).simObjectId;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds the identifier blocks with the given ID.
|
|
/// </summary>
|
|
/// <param name="id">The ID to look for</param>
|
|
/// <returns>An array that may be empty</returns>
|
|
public static ObjectIdentifier[] GetByID(char id) => BlockEngine.GetObjectIDsFromID((byte) (id - 'A'), false);
|
|
|
|
/// <summary>
|
|
/// Finds the identifier blocks with the given simulation-time ID. This ID is assigned by the game starting from 0.
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public static ObjectIdentifier[] GetBySimID(byte id) => BlockEngine.GetObjectIDsFromID(id, true);
|
|
}
|
|
} |