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.

52 lines
1.7KB

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