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.

97 lines
2.4KB

  1. using System;
  2. using RobocraftX.Blocks;
  3. using Svelto.ECS;
  4. using Unity.Mathematics;
  5. using GamecraftModdingAPI;
  6. using GamecraftModdingAPI.Utility;
  7. namespace GamecraftModdingAPI.Blocks
  8. {
  9. public class ConsoleBlock : Block
  10. {
  11. public static ConsoleBlock PlaceNew(float3 position,
  12. float3 rotation = default, BlockColors color = BlockColors.Default, byte darkness = 0,
  13. int uscale = 1, float3 scale = default, Player player = null)
  14. {
  15. if (PlacementEngine.IsInGame && GameState.IsBuildMode())
  16. {
  17. try
  18. {
  19. EGID id = PlacementEngine.PlaceBlock(BlockIDs.ConsoleBlock, color, darkness,
  20. position, uscale, scale, player, rotation);
  21. return new ConsoleBlock(id);
  22. }
  23. catch (Exception e)
  24. {
  25. Logging.MetaDebugLog(e);
  26. }
  27. }
  28. return null;
  29. }
  30. public ConsoleBlock(EGID id): base(id)
  31. {
  32. if (!BlockEngine.GetBlockInfoExists<ConsoleBlockEntityStruct>(this.Id))
  33. {
  34. throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
  35. }
  36. }
  37. public ConsoleBlock(uint id): base(id)
  38. {
  39. if (!BlockEngine.GetBlockInfoExists<ConsoleBlockEntityStruct>(this.Id))
  40. {
  41. throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
  42. }
  43. }
  44. // custom console block properties
  45. public string Command
  46. {
  47. get
  48. {
  49. return BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).commandName;
  50. }
  51. set
  52. {
  53. BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).commandName.Set(value);
  54. }
  55. }
  56. public string Arg1
  57. {
  58. get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg1;
  59. set
  60. {
  61. BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg1.Set(value);
  62. }
  63. }
  64. public string Arg2
  65. {
  66. get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg2;
  67. set
  68. {
  69. BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg2.Set(value);
  70. }
  71. }
  72. public string Arg3
  73. {
  74. get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg3;
  75. set
  76. {
  77. BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg3.Set(value);
  78. }
  79. }
  80. }
  81. }