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.

103 lines
2.7KB

  1. using System;
  2. using RobocraftX.Blocks;
  3. using RobocraftX.Common;
  4. using Gamecraft.CharacterVulnerability;
  5. using Svelto.ECS;
  6. using Unity.Mathematics;
  7. using GamecraftModdingAPI;
  8. using GamecraftModdingAPI.Utility;
  9. namespace GamecraftModdingAPI.Blocks
  10. {
  11. public class SpawnPoint : Block
  12. {
  13. public SpawnPoint(EGID id) : base(id)
  14. {
  15. if (!BlockEngine.GetBlockInfoExists<SpawnPointStatsEntityStruct>(this.Id))
  16. {
  17. throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
  18. }
  19. }
  20. public SpawnPoint(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SPAWNPOINT_BLOCK_GROUP))
  21. {
  22. if (!BlockEngine.GetBlockInfoExists<SpawnPointStatsEntityStruct>(this.Id))
  23. {
  24. throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
  25. }
  26. }
  27. // custom spawn point properties
  28. /// <summary>
  29. /// The lives the player spawns in with.
  30. /// </summary>
  31. public uint Lives
  32. {
  33. get
  34. {
  35. return BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(Id).lives;
  36. }
  37. set
  38. {
  39. ref SpawnPointStatsEntityStruct spses = ref BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(Id);
  40. spses.lives = value;
  41. }
  42. }
  43. /// <summary>
  44. /// Whether the spawned player can take damage.
  45. /// </summary>
  46. public bool Damageable
  47. {
  48. get
  49. {
  50. return BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(Id).canTakeDamage;
  51. }
  52. set
  53. {
  54. ref SpawnPointStatsEntityStruct spses = ref BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(Id);
  55. spses.canTakeDamage = value;
  56. }
  57. }
  58. /// <summary>
  59. /// Whether the game over screen will be displayed
  60. /// </summary>
  61. public bool GameOverEnabled
  62. {
  63. get
  64. {
  65. return BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(Id).gameOverScreen;
  66. }
  67. set
  68. {
  69. ref SpawnPointStatsEntityStruct spses = ref BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(Id);
  70. spses.gameOverScreen = value;
  71. }
  72. }
  73. /// <summary>
  74. /// The team id for players who spawn here.
  75. /// </summary>
  76. public byte Team
  77. {
  78. get
  79. {
  80. return BlockEngine.GetBlockInfo<SpawnPointIdsEntityStruct>(Id).teamId;
  81. }
  82. set
  83. {
  84. ref SpawnPointIdsEntityStruct spses = ref BlockEngine.GetBlockInfo<SpawnPointIdsEntityStruct>(Id);
  85. spses.teamId = value;
  86. }
  87. }
  88. }
  89. }