using Gamecraft.Wires;
using RobocraftX.Common;
using Svelto.ECS;
namespace GamecraftModdingAPI.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(this, (ObjectIdEntityStruct st) => st.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);
}
}
///
/// Simulation-time ID. Assigned by the game starting from 0.
///
public byte SimID
{
get => BlockEngine.GetBlockInfo(this, (ObjectIdEntityStruct st) => st.simObjectId);
}
///
/// Finds the identifier blocks with the given ID.
///
/// The ID to look for
/// An array that may be empty
public static ObjectIdentifier[] GetByID(char id) => BlockEngine.GetObjectIDsFromID((byte) (id - 'A'), false);
///
/// Finds the identifier blocks with the given simulation-time ID. This ID is assigned by the game starting from 0.
///
///
///
public static ObjectIdentifier[] GetBySimID(byte id) => BlockEngine.GetObjectIDsFromID(id, true);
}
}