|
- using System;
- using Techblox.ObjectIDBlockServer;
-
- namespace TechbloxModdingAPI.Blocks
- {
- using Svelto.ECS;
-
-
- public class ObjectID : SignalingBlock
- {
-
- /// <summary>
- /// Constructs a(n) ObjectID object representing an existing block.
- /// </summary>
- public ObjectID(EGID egid) :
- base(egid)
- {
- }
-
- /// <summary>
- /// Constructs a(n) ObjectID object representing an existing block.
- /// </summary>
- public ObjectID(uint id) :
- base(new EGID(id, ObjectIDBlockExclusiveGroups.OBJECT_ID_BLOCK_GROUP))
- {
- }
-
- /// <summary>
- /// Gets or sets the ObjectID's Identifier property. Tweakable stat.
- /// </summary>
- public char Identifier
- {
- get => (char) (BlockEngine.GetBlockInfo<ObjectIDTweakableComponent>(this).objectIDToTrigger + 'A');
- set
- {
- if(value is < 'A' or > 'Z')
- throw new ArgumentOutOfRangeException(nameof(value), "ObjectIdentifier must be set to a letter between A and Z.");
- BlockEngine.GetBlockInfo<ObjectIDTweakableComponent>(this).objectIDToTrigger = (byte) (value - 'A');
- Label = value + ""; //The label isn't updated automatically
- }
- }
-
- /// <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 ObjectID[] GetByID(char id) => BlockEngine.GetObjectIDsFromID((byte) (id - 'A'));
- }
- }
|