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)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public char Identifier
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
get => (char) BlockEngine.GetBlockInfo(this, (ObjectIdEntityStruct st) => st.objectId + 'A');
|
2020-05-24 17:29:02 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref ObjectIdEntityStruct st, char val) =>
|
|
|
|
|
{
|
|
|
|
|
st.objectId = (byte) (val - 'A');
|
|
|
|
|
Label = val + ""; //The label isn't updated automatically
|
|
|
|
|
}, value);
|
2020-05-24 17:29:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-04 22:57:22 +00:00
|
|
|
|
/// Simulation-time ID. Assigned by the game starting from 0.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte SimID
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo(this, (ObjectIdEntityStruct st) => st.simObjectId);
|
2020-06-04 22:57:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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
|
|
|
|
}
|
|
|
|
|
}
|