You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using Gamecraft.Wires;
- 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");
- }
- }
-
- public ObjectIdentifier(uint id) : base(id)
- {
- 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>
- /// Finds the identfier 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'));
- }
- }
|