A stable modding interface between Techblox and mods https://mod.exmods.org/
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.

49 lines
1.6KB

  1. using Gamecraft.Wires;
  2. using RobocraftX.Common;
  3. using Svelto.ECS;
  4. namespace TechbloxModdingAPI.Blocks
  5. {
  6. public class ObjectIdentifier : Block
  7. {
  8. public ObjectIdentifier(EGID id) : base(id)
  9. {
  10. }
  11. public ObjectIdentifier(uint id) : base(new EGID(id, CommonExclusiveGroups.OBJID_BLOCK_GROUP))
  12. {
  13. }
  14. public char Identifier
  15. {
  16. get => (char) (BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(this).objectId + 'A');
  17. set
  18. {
  19. BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(this).objectId = (byte) (value - 'A');
  20. Label = value + ""; //The label isn't updated automatically
  21. }
  22. }
  23. /// <summary>
  24. /// Simulation-time ID. Assigned by the game starting from 0.
  25. /// </summary>
  26. public byte SimID
  27. {
  28. get => BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(this).simObjectId;
  29. }
  30. /// <summary>
  31. /// Finds the identifier blocks with the given ID.
  32. /// </summary>
  33. /// <param name="id">The ID to look for</param>
  34. /// <returns>An array that may be empty</returns>
  35. public static ObjectIdentifier[] GetByID(char id) => BlockEngine.GetObjectIDsFromID((byte) (id - 'A'), false);
  36. /// <summary>
  37. /// Finds the identifier blocks with the given simulation-time ID. This ID is assigned by the game starting from 0.
  38. /// </summary>
  39. /// <param name="id"></param>
  40. /// <returns></returns>
  41. public static ObjectIdentifier[] GetBySimID(byte id) => BlockEngine.GetObjectIDsFromID(id, true);
  42. }
  43. }