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.

TextBlock.cs 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using Gamecraft.Blocks.GUI;
  3. using RobocraftX.Common;
  4. using Svelto.ECS;
  5. using Unity.Mathematics;
  6. using GamecraftModdingAPI;
  7. using GamecraftModdingAPI.Utility;
  8. namespace GamecraftModdingAPI.Blocks
  9. {
  10. public class TextBlock : SignalingBlock
  11. {
  12. public TextBlock(EGID id) : base(id)
  13. {
  14. }
  15. public TextBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TEXT_BLOCK_GROUP))
  16. {
  17. }
  18. // custom text block properties
  19. /// <summary>
  20. /// The text block's current text.
  21. /// </summary>
  22. public string Text
  23. {
  24. get => BlockEngine.GetBlockInfo(this, (TextBlockDataStruct st) => st.textCurrent);
  25. set
  26. {
  27. BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
  28. {
  29. if (val == null) val = "";
  30. tbds.textCurrent.Set(val);
  31. tbds.textStored.Set(val);
  32. }, value);
  33. BlockEngine.SetBlockInfo(this,
  34. (ref TextBlockNetworkDataStruct st, string val) => st.newTextBlockStringContent.Set(val), value);
  35. }
  36. }
  37. /// <summary>
  38. /// The text block's current text block ID (used in ChangeTextBlockCommand).
  39. /// </summary>
  40. public string TextBlockId
  41. {
  42. get => BlockEngine.GetBlockInfo(this, (TextBlockDataStruct st) => st.textBlockID);
  43. set
  44. {
  45. BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
  46. tbds.textBlockID.Set(val), value);
  47. BlockEngine.SetBlockInfo(this,
  48. (ref TextBlockNetworkDataStruct st, string val) => st.newTextBlockID.Set(val), value);
  49. }
  50. }
  51. }
  52. }