BasicBlocks.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. #pragma once
  2. #include "Block.h"
  3. #include "BlockType.h"
  4. #include "Item.h"
  5. class BlockType;
  6. class ItemType;
  7. class BasicBlockType;
  8. class BasicBlock : public Block
  9. {
  10. public:
  11. BasicBlock(const BlockType* zType, ItemType* zTool, Framework::Vec3<int> pos);
  12. virtual bool onTick(TickQueue* zQueue, int numTicks, bool& blocked) override;
  13. virtual void onPostTick() override;
  14. friend BasicBlockType;
  15. };
  16. struct SpawnConfig
  17. {
  18. int min;
  19. int max;
  20. double chance;
  21. int itemType;
  22. };
  23. class AdditionalItemSpawningBlock : public BasicBlock
  24. {
  25. private:
  26. Framework::Array< SpawnConfig> spawns;
  27. public:
  28. AdditionalItemSpawningBlock(const BlockType* zType, ItemType* zTool, Framework::Vec3<int> pos);
  29. void addSpawn(SpawnConfig config);
  30. virtual void onDestroy() override;
  31. };
  32. class BasicBlockType : public BlockType
  33. {
  34. private:
  35. int itemType;
  36. protected:
  37. bool transparent;
  38. bool passable;
  39. float hardness;
  40. ItemType* zTool;
  41. float speedModifier;
  42. bool interactable;
  43. BasicBlockType(int typeId, int itemTypeId, ModelInfo model);
  44. virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
  45. public:
  46. virtual Block* createBlock(Framework::Vec3<int> position) const override;
  47. virtual Item* createItem() const override;
  48. };
  49. // Dirt
  50. class DirtBlockItemType : public BasicBlockItemType
  51. {
  52. REGISTRABLE(DirtBlockItemType)
  53. protected:
  54. DirtBlockItemType();
  55. public:
  56. virtual Item* createItem() const override;
  57. };
  58. REGISTER(DirtBlockItemType, ItemType)
  59. class DirtBlockType : public BasicBlockType
  60. {
  61. REGISTRABLE(DirtBlockType)
  62. protected:
  63. DirtBlockType();
  64. };
  65. REGISTER(DirtBlockType, BlockType)
  66. // Stone
  67. class StoneBlockItemType : public BasicBlockItemType
  68. {
  69. REGISTRABLE(StoneBlockItemType)
  70. protected:
  71. StoneBlockItemType();
  72. public:
  73. virtual Item* createItem() const override;
  74. };
  75. REGISTER(StoneBlockItemType, ItemType)
  76. class StoneBlockType : public BasicBlockType
  77. {
  78. REGISTRABLE(StoneBlockType)
  79. protected:
  80. StoneBlockType();
  81. };
  82. REGISTER(StoneBlockType, BlockType)
  83. // Sand
  84. class SandBlockItemType : public BasicBlockItemType
  85. {
  86. REGISTRABLE(SandBlockItemType)
  87. protected:
  88. SandBlockItemType();
  89. public:
  90. virtual Item* createItem() const override;
  91. };
  92. REGISTER(SandBlockItemType, ItemType)
  93. class SandBlockType : public BasicBlockType
  94. {
  95. REGISTRABLE(SandBlockType)
  96. protected:
  97. SandBlockType();
  98. };
  99. REGISTER(SandBlockType, BlockType)
  100. // Oak Wood
  101. class OakBlockItemType : public BasicBlockItemType
  102. {
  103. REGISTRABLE(OakBlockItemType)
  104. protected:
  105. OakBlockItemType();
  106. public:
  107. virtual Item* createItem() const override;
  108. };
  109. REGISTER(OakBlockItemType, ItemType)
  110. class OakBlockType : public BasicBlockType
  111. {
  112. REGISTRABLE(OakBlockType)
  113. protected:
  114. OakBlockType();
  115. };
  116. REGISTER(OakBlockType, BlockType)
  117. // Oak Leaves
  118. class OakLeavesBlockItemType : public BasicBlockItemType
  119. {
  120. REGISTRABLE(OakLeavesBlockItemType)
  121. protected:
  122. OakLeavesBlockItemType();
  123. public:
  124. virtual Item* createItem() const override;
  125. };
  126. REGISTER(OakLeavesBlockItemType, ItemType)
  127. class OakLeavesBlockType : public BasicBlockType
  128. {
  129. REGISTRABLE(OakLeavesBlockType)
  130. protected:
  131. OakLeavesBlockType();
  132. public:
  133. virtual Block* createBlock(Framework::Vec3<int> position) const override;
  134. };
  135. REGISTER(OakLeavesBlockType, BlockType)
  136. // Oak Sebling
  137. class OakSeblingBlockItemType : public BasicBlockItemType
  138. {
  139. REGISTRABLE(OakSeblingBlockItemType)
  140. protected:
  141. OakSeblingBlockItemType();
  142. public:
  143. virtual Item* createItem() const override;
  144. };
  145. REGISTER(OakSeblingBlockItemType, ItemType)
  146. // Gravel
  147. class GravelBlockItemType : public BasicBlockItemType
  148. {
  149. REGISTRABLE(GravelBlockItemType)
  150. protected:
  151. GravelBlockItemType();
  152. public:
  153. virtual Item* createItem() const override;
  154. };
  155. REGISTER(GravelBlockItemType, ItemType)
  156. class GravelBlockType : public BasicBlockType
  157. {
  158. REGISTRABLE(GravelBlockType)
  159. protected:
  160. GravelBlockType();
  161. };
  162. REGISTER(GravelBlockType, BlockType)
  163. // Granite
  164. class GraniteBlockItemType : public BasicBlockItemType
  165. {
  166. REGISTRABLE(GraniteBlockItemType)
  167. protected:
  168. GraniteBlockItemType();
  169. public:
  170. virtual Item* createItem() const override;
  171. };
  172. REGISTER(GraniteBlockItemType, ItemType)
  173. class GraniteBlockType : public BasicBlockType
  174. {
  175. REGISTRABLE(GraniteBlockType)
  176. protected:
  177. GraniteBlockType();
  178. };
  179. REGISTER(GraniteBlockType, BlockType)
  180. // Cobble
  181. class CobbleBlockItemType : public BasicBlockItemType
  182. {
  183. REGISTRABLE(CobbleBlockItemType)
  184. protected:
  185. CobbleBlockItemType();
  186. public:
  187. virtual Item* createItem() const override;
  188. };
  189. REGISTER(CobbleBlockItemType, ItemType)
  190. class CobbleBlockType : public BasicBlockType
  191. {
  192. REGISTRABLE(CobbleBlockType)
  193. protected:
  194. CobbleBlockType();
  195. };
  196. REGISTER(CobbleBlockType, BlockType)
  197. // Birch Wood
  198. class BirchBlockItemType : public BasicBlockItemType
  199. {
  200. REGISTRABLE(BirchBlockItemType)
  201. protected:
  202. BirchBlockItemType();
  203. public:
  204. virtual Item* createItem() const override;
  205. };
  206. REGISTER(BirchBlockItemType, ItemType)
  207. class BirchBlockType : public BasicBlockType
  208. {
  209. REGISTRABLE(BirchBlockType)
  210. protected:
  211. BirchBlockType();
  212. };
  213. REGISTER(BirchBlockType, BlockType)
  214. // Birch Leaves
  215. class BirchLeavesBlockItemType : public BasicBlockItemType
  216. {
  217. REGISTRABLE(BirchLeavesBlockItemType)
  218. protected:
  219. BirchLeavesBlockItemType();
  220. public:
  221. virtual Item* createItem() const override;
  222. };
  223. REGISTER(BirchLeavesBlockItemType, ItemType)
  224. class BirchLeavesBlockType : public BasicBlockType
  225. {
  226. REGISTRABLE(BirchLeavesBlockType)
  227. protected:
  228. BirchLeavesBlockType();
  229. public:
  230. virtual Block* createBlock(Framework::Vec3<int> position) const override;
  231. };
  232. REGISTER(BirchLeavesBlockType, BlockType)
  233. // Birch Sebling
  234. class BirchSeblingBlockItemType : public BasicBlockItemType
  235. {
  236. REGISTRABLE(BirchSeblingBlockItemType)
  237. protected:
  238. BirchSeblingBlockItemType();
  239. public:
  240. virtual Item* createItem() const override;
  241. };
  242. REGISTER(BirchSeblingBlockItemType, ItemType)
  243. // Beech Wood
  244. class BeechBlockItemType : public BasicBlockItemType
  245. {
  246. REGISTRABLE(BeechBlockItemType)
  247. protected:
  248. BeechBlockItemType();
  249. public:
  250. virtual Item* createItem() const override;
  251. };
  252. REGISTER(BeechBlockItemType, ItemType)
  253. class BeechBlockType : public BasicBlockType
  254. {
  255. REGISTRABLE(BeechBlockType)
  256. protected:
  257. BeechBlockType();
  258. };
  259. REGISTER(BeechBlockType, BlockType)
  260. // Beech Leaves
  261. class BeechLeavesBlockItemType : public BasicBlockItemType
  262. {
  263. REGISTRABLE(BeechLeavesBlockItemType)
  264. protected:
  265. BeechLeavesBlockItemType();
  266. public:
  267. virtual Item* createItem() const override;
  268. };
  269. REGISTER(BeechLeavesBlockItemType, ItemType)
  270. class BeechLeavesBlockType : public BasicBlockType
  271. {
  272. REGISTRABLE(BeechLeavesBlockType)
  273. protected:
  274. BeechLeavesBlockType();
  275. public:
  276. virtual Block* createBlock(Framework::Vec3<int> position) const override;
  277. };
  278. REGISTER(BeechLeavesBlockType, BlockType)
  279. // Beech Sebling
  280. class BeechSeblingBlockItemType : public BasicBlockItemType
  281. {
  282. REGISTRABLE(BeechSeblingBlockItemType)
  283. protected:
  284. BeechSeblingBlockItemType();
  285. public:
  286. virtual Item* createItem() const override;
  287. };
  288. REGISTER(BeechSeblingBlockItemType, ItemType)
  289. // Basalt
  290. class BasaltBlockItemType : public BasicBlockItemType
  291. {
  292. REGISTRABLE(BasaltBlockItemType)
  293. protected:
  294. BasaltBlockItemType();
  295. public:
  296. virtual Item* createItem() const override;
  297. };
  298. REGISTER(BasaltBlockItemType, ItemType)
  299. class BasaltBlockType : public BasicBlockType
  300. {
  301. REGISTRABLE(BasaltBlockType)
  302. protected:
  303. BasaltBlockType();
  304. };
  305. REGISTER(BasaltBlockType, BlockType)
  306. // Pine
  307. class PineBlockItemType : public BasicBlockItemType
  308. {
  309. REGISTRABLE(PineBlockItemType)
  310. protected:
  311. PineBlockItemType();
  312. public:
  313. virtual Item* createItem() const override;
  314. };
  315. REGISTER(PineBlockItemType, ItemType)
  316. class PineBlockType : public BasicBlockType
  317. {
  318. REGISTRABLE(PineBlockType)
  319. protected:
  320. PineBlockType();
  321. };
  322. REGISTER(PineBlockType, BlockType)
  323. // Pine Leaves
  324. class PineLeavesBlockItemType : public BasicBlockItemType
  325. {
  326. REGISTRABLE(PineLeavesBlockItemType)
  327. protected:
  328. PineLeavesBlockItemType();
  329. public:
  330. virtual Item* createItem() const override;
  331. };
  332. REGISTER(PineLeavesBlockItemType, ItemType)
  333. class PineLeavesBlockType : public BasicBlockType
  334. {
  335. REGISTRABLE(PineLeavesBlockType)
  336. protected:
  337. PineLeavesBlockType();
  338. public:
  339. virtual Block* createBlock(Framework::Vec3<int> position) const override;
  340. };
  341. REGISTER(PineLeavesBlockType, BlockType)
  342. // Pine Sebling
  343. class PineSeblingBlockItemType : public BasicBlockItemType
  344. {
  345. REGISTRABLE(PineSeblingBlockItemType)
  346. protected:
  347. PineSeblingBlockItemType();
  348. public:
  349. virtual Item* createItem() const override;
  350. };
  351. REGISTER(PineSeblingBlockItemType, ItemType)