2020-05-24 17:29:02 +00:00
|
|
|
|
using Gamecraft.Wires;
|
2020-07-10 22:30:58 +00:00
|
|
|
|
using RobocraftX.Common;
|
2020-05-24 17:29:02 +00:00
|
|
|
|
using Svelto.ECS;
|
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Blocks
|
|
|
|
|
{
|
|
|
|
|
public class ObjectIdentifier : Block
|
|
|
|
|
{
|
|
|
|
|
public ObjectIdentifier(EGID id) : base(id)
|
|
|
|
|
{
|
|
|
|
|
if (!BlockEngine.GetBlockInfoExists<ObjectIdEntityStruct>(Id))
|
|
|
|
|
{
|
|
|
|
|
throw new BlockTypeException($"Block is not a {GetType().Name} block");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-10 22:30:58 +00:00
|
|
|
|
public ObjectIdentifier(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP))
|
2020-05-24 17:29:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (!BlockEngine.GetBlockInfoExists<ObjectIdEntityStruct>(Id))
|
|
|
|
|
{
|
|
|
|
|
throw new BlockTypeException($"Block is not a {GetType().Name} block");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public char Identifier
|
|
|
|
|
{
|
|
|
|
|
get => (char) (BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(Id).objectId + 'A');
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(Id).objectId = (byte) (value - 'A');
|
|
|
|
|
Label = value + ""; //The label isn't updated automatically
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-04 22:57:22 +00:00
|
|
|
|
/// Simulation-time ID. Assigned by the game starting from 0.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte SimID
|
|
|
|
|
{
|
|
|
|
|
get => BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(Id).simObjectId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finds the identifier blocks with the given ID.
|
2020-05-24 17:29:02 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">The ID to look for</param>
|
|
|
|
|
/// <returns>An array that may be empty</returns>
|
2020-06-04 22:57:22 +00:00
|
|
|
|
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);
|
2020-05-24 17:29:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|