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.

90 lines
2.2KB

  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. EGID id = PlacementEngine.PlaceBlock(BlockIDs.ConsoleBlock, color, darkness,
  18. position, uscale, scale, player, rotation);
  19. return new ConsoleBlock(id);
  20. }
  21. return null;
  22. }
  23. public ConsoleBlock(EGID id): base(id)
  24. {
  25. if (!BlockEngine.GetBlockInfoExists<ConsoleBlockEntityStruct>(this.Id))
  26. {
  27. throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
  28. }
  29. }
  30. public ConsoleBlock(uint 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. // custom console block properties
  38. public string Command
  39. {
  40. get
  41. {
  42. return BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).commandName;
  43. }
  44. set
  45. {
  46. BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).commandName.Set(value);
  47. }
  48. }
  49. public string Arg1
  50. {
  51. get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg1;
  52. set
  53. {
  54. BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg1.Set(value);
  55. }
  56. }
  57. public string Arg2
  58. {
  59. get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg2;
  60. set
  61. {
  62. BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg2.Set(value);
  63. }
  64. }
  65. public string Arg3
  66. {
  67. get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg3;
  68. set
  69. {
  70. BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg3.Set(value);
  71. }
  72. }
  73. }
  74. }