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.

91 lines
2.3KB

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