StaticInitializerOrder.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. #include "BlockType.h"
  2. #include "ItemType.h"
  3. #include "StaticRegistry.h"
  4. // block types
  5. #include "BasicBlocks.h"
  6. #include "NoBlock.h"
  7. #include "TreeSeblingBlock.h"
  8. // dimensions
  9. #include "OverworldDimension.h"
  10. // entities
  11. #include "ItemEntity.h"
  12. #include "Player.h"
  13. // item skills
  14. #include "BasicItems.h"
  15. #include "PlayerHand.h"
  16. #include "StoneTool.h"
  17. // world updates
  18. #include "AddEntityUpdate.h"
  19. #include "EntityRemovedUpdate.h"
  20. // Multiblocks
  21. #include "LightSources.h"
  22. #include "MultiblockTree.h"
  23. using namespace Framework;
  24. void initializeBlockTypes()
  25. {
  26. new NoBlockBlockType(BlockTypeEnum::NO_BLOCK, &NoBlock::INSTANCE);
  27. new NoBlockBlockType(BlockTypeEnum::AIR, &AirBlock::INSTANCE);
  28. (new BasicBlockType(BlockTypeEnum::DIRT,
  29. ItemTypeEnum::DIRT,
  30. ModelInfo("cube",
  31. {"blocks.ltdb/dirt.png",
  32. "blocks.ltdb/dirt.png",
  33. "blocks.ltdb/dirt.png",
  34. "blocks.ltdb/dirt.png",
  35. "blocks.ltdb/lawn.png",
  36. "blocks.ltdb/dirt.png"}),
  37. "Dirt"))
  38. ->initializeDefault();
  39. (new BasicBlockType(BlockTypeEnum::STONE,
  40. ItemTypeEnum::STONE,
  41. ModelInfo("cube", "blocks.ltdb/stone.png", 6),
  42. "Stone"))
  43. ->setHardness(2.f)
  44. ->initializeDefault();
  45. (new BasicBlockType(BlockTypeEnum::SAND,
  46. ItemTypeEnum::SAND,
  47. ModelInfo("cube", "blocks.ltdb/sand.png", 6),
  48. "Sand"))
  49. ->setHardness(0.5f)
  50. ->initializeDefault();
  51. (new BasicBlockType(BlockTypeEnum::WOOD_OAK,
  52. ItemTypeEnum::WOOD_OAK,
  53. ModelInfo("cube", "blocks.ltdb/oak.png", 6),
  54. "Oak Wood"))
  55. ->setHardness(1.5f)
  56. ->initializeDefault();
  57. (new BasicBlockType(BlockTypeEnum::LEAVES_WOOD_OAK,
  58. ItemTypeEnum::LEAVES_WOOD_OAK,
  59. ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
  60. [](Vec3<int> pos) {
  61. AdditionalItemSpawningBlock* block
  62. = new AdditionalItemSpawningBlock(
  63. BlockTypeEnum::LEAVES_WOOD_OAK, 0, pos);
  64. block->addSpawn({1, 1, 0.015, ItemTypeEnum::SEBLING_WOOD_OAK});
  65. return (Block*)block;
  66. },
  67. "Oak Wood Leaves"))
  68. ->setHardness(0.1f)
  69. ->initializeDefault();
  70. (new BasicBlockType(BlockTypeEnum::GRAVEL,
  71. ItemTypeEnum::GRAVEL,
  72. ModelInfo("cube", "blocks.ltdb/gravel.png", 6),
  73. "Gravel"))
  74. ->setHardness(0.75f)
  75. ->initializeDefault();
  76. (new BasicBlockType(BlockTypeEnum::STONE_GRANITE,
  77. ItemTypeEnum::STONE_GRANITE,
  78. ModelInfo("cube", "blocks.ltdb/granite.png", 6),
  79. "Granite Stone"))
  80. ->setHardness(3.f)
  81. ->initializeDefault();
  82. (new BasicBlockType(BlockTypeEnum::STONE_COBBLE,
  83. ItemTypeEnum::STONE_COBBLE,
  84. ModelInfo("cube", "blocks.ltdb/cobble.png", 6),
  85. "Cobble Stone"))
  86. ->setHardness(1.f)
  87. ->initializeDefault();
  88. (new BasicBlockType(BlockTypeEnum::WOOD_BIRCH,
  89. ItemTypeEnum::WOOD_BIRCH,
  90. ModelInfo("cube", "blocks.ltdb/birch.png", 6),
  91. "Birch Wood"))
  92. ->setHardness(1.5f)
  93. ->initializeDefault();
  94. (new BasicBlockType(BlockTypeEnum::LEAVES_WOOD_BIRCH,
  95. ItemTypeEnum::LEAVES_WOOD_BIRCH,
  96. ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
  97. [](Vec3<int> pos) {
  98. AdditionalItemSpawningBlock* block
  99. = new AdditionalItemSpawningBlock(
  100. BlockTypeEnum::LEAVES_WOOD_BIRCH, 0, pos);
  101. block->addSpawn({1, 1, 0.03, ItemTypeEnum::SEBLING_WOOD_BIRCH});
  102. return (Block*)block;
  103. },
  104. "Birch Wood Leaves"))
  105. ->setHardness(0.1f)
  106. ->initializeDefault();
  107. (new BasicBlockType(BlockTypeEnum::WOOD_BEECH,
  108. ItemTypeEnum::WOOD_BEECH,
  109. ModelInfo("cube", "blocks.ltdb/beech.png", 6),
  110. "Beech Wood"))
  111. ->setHardness(1.5f)
  112. ->initializeDefault();
  113. (new BasicBlockType(BlockTypeEnum::LEAVES_WOOD_BEECH,
  114. ItemTypeEnum::LEAVES_WOOD_BEECH,
  115. ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
  116. [](Vec3<int> pos) {
  117. AdditionalItemSpawningBlock* block
  118. = new AdditionalItemSpawningBlock(
  119. BlockTypeEnum::LEAVES_WOOD_BEECH, 0, pos);
  120. block->addSpawn({1, 1, 0.02, ItemTypeEnum::SEBLING_WOOD_BEECH});
  121. return (Block*)block;
  122. },
  123. "Beech Wood Leaves"))
  124. ->setHardness(0.1f)
  125. ->initializeDefault();
  126. (new BasicBlockType(BlockTypeEnum::STONE_BASALT,
  127. ItemTypeEnum::STONE_BASALT,
  128. ModelInfo("cube", "blocks.ltdb/basalt.png", 6),
  129. "Basalt Stone"))
  130. ->setHardness(2.f)
  131. ->initializeDefault();
  132. (new BasicBlockType(BlockTypeEnum::WOOD_PINE,
  133. ItemTypeEnum::WOOD_PINE,
  134. ModelInfo("cube", "blocks.ltdb/pine.png", 6),
  135. "Pine Wood"))
  136. ->setHardness(1.4f)
  137. ->initializeDefault();
  138. (new BasicBlockType(BlockTypeEnum::LEAVES_WOOD_PINE,
  139. ItemTypeEnum::LEAVES_WOOD_PINE,
  140. ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
  141. [](Vec3<int> pos) {
  142. AdditionalItemSpawningBlock* block
  143. = new AdditionalItemSpawningBlock(
  144. BlockTypeEnum::LEAVES_WOOD_PINE, 0, pos);
  145. block->addSpawn({1, 1, 0.025, ItemTypeEnum::SEBLING_WOOD_PINE});
  146. return (Block*)block;
  147. },
  148. "Pine Wood Leaves"))
  149. ->setHardness(0.1f)
  150. ->initializeDefault();
  151. (new BasicLightSourceBlockType(BlockTypeEnum::TORCH,
  152. ItemTypeEnum::TORCH,
  153. ModelInfo("blocks.m3/torch", "blocks.ltdb/torch.png", 6),
  154. "Torch"))
  155. ->setHardness(0.f)
  156. ->setColor(0x00F69A54)
  157. ->initializeDefault();
  158. (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_OAK,
  159. ItemTypeEnum::SEBLING_WOOD_OAK,
  160. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  161. BlockTypeEnum::WOOD_OAK,
  162. BlockTypeEnum::LEAVES_WOOD_OAK,
  163. "Oak Wood Sebling"))
  164. ->setHardness(0.1f)
  165. ->initializeDefault();
  166. (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_BIRCH,
  167. ItemTypeEnum::SEBLING_WOOD_BIRCH,
  168. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  169. BlockTypeEnum::WOOD_BIRCH,
  170. BlockTypeEnum::LEAVES_WOOD_BIRCH,
  171. "Birch Wood Sebling"))
  172. ->setHardness(0.1f)
  173. ->initializeDefault();
  174. (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_BEECH,
  175. ItemTypeEnum::SEBLING_WOOD_BEECH,
  176. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  177. BlockTypeEnum::WOOD_BEECH,
  178. BlockTypeEnum::LEAVES_WOOD_BEECH,
  179. "Beech Wood Sebling"))
  180. ->setHardness(0.1f)
  181. ->initializeDefault();
  182. (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_PINE,
  183. ItemTypeEnum::SEBLING_WOOD_PINE,
  184. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  185. BlockTypeEnum::WOOD_PINE,
  186. BlockTypeEnum::LEAVES_WOOD_PINE, "Pine Wood Sebling"))
  187. ->setHardness(0.1f)
  188. ->initializeDefault();
  189. }
  190. void initializeItemTypes()
  191. {
  192. (new BasicBlockItemType(ItemTypeEnum::DIRT,
  193. "Dirt",
  194. 0,
  195. 0,
  196. ModelInfo("itemCube", "blocks.ltdb/dirt.png", 6),
  197. BlockTypeEnum::DIRT));
  198. (new BasicBlockItemType(ItemTypeEnum::STONE,
  199. "Stone",
  200. 0,
  201. 0,
  202. ModelInfo("itemCube", "blocks.ltdb/stone.png", 6),
  203. BlockTypeEnum::STONE))
  204. ->setHardness(2.f);
  205. (new BasicBlockItemType(ItemTypeEnum::SAND,
  206. "Sand",
  207. 0,
  208. 0,
  209. ModelInfo("itemCube", "blocks.ltdb/sand.png", 6),
  210. BlockTypeEnum::SAND))
  211. ->setHardness(0.5f);
  212. (new BasicBlockItemType(ItemTypeEnum::WOOD_OAK,
  213. "Oak",
  214. 0,
  215. 0,
  216. ModelInfo("itemCube", "blocks.ltdb/oak.png", 6),
  217. BlockTypeEnum::WOOD_OAK))
  218. ->setHardness(1.5f);
  219. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_OAK,
  220. "Oak Leaves",
  221. 0,
  222. 0,
  223. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  224. BlockTypeEnum::LEAVES_WOOD_OAK))
  225. ->setHardness(0.1f);
  226. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_OAK,
  227. "Oak Sebling",
  228. 0,
  229. 0,
  230. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  231. BlockTypeEnum::SEBLING_WOOD_OAK))
  232. ->setHardness(0.1f);
  233. (new BasicBlockItemType(ItemTypeEnum::GRAVEL,
  234. "Gravel",
  235. 0,
  236. 0,
  237. ModelInfo("itemCube", "blocks.ltdb/gravel.png", 6),
  238. BlockTypeEnum::GRAVEL))
  239. ->setHardness(0.75f);
  240. (new BasicBlockItemType(ItemTypeEnum::STONE_GRANITE,
  241. "Granite",
  242. 0,
  243. 0,
  244. ModelInfo("itemCube", "blocks.ltdb/granite.png", 6),
  245. BlockTypeEnum::STONE_GRANITE))
  246. ->setHardness(3.f);
  247. (new BasicBlockItemType(ItemTypeEnum::STONE_COBBLE,
  248. "Cobble",
  249. 0,
  250. 0,
  251. ModelInfo("itemCube", "blocks.ltdb/cobble.png", 6),
  252. BlockTypeEnum::STONE_COBBLE))
  253. ->setHardness(1.f);
  254. (new BasicBlockItemType(ItemTypeEnum::WOOD_BIRCH,
  255. "Birch",
  256. 0,
  257. 0,
  258. ModelInfo("itemCube", "blocks.ltdb/birch.png", 6),
  259. BlockTypeEnum::WOOD_BIRCH))
  260. ->setHardness(1.5f);
  261. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_BIRCH,
  262. "Birch Leaves",
  263. 0,
  264. 0,
  265. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  266. BlockTypeEnum::LEAVES_WOOD_BIRCH))
  267. ->setHardness(0.1f);
  268. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_BIRCH,
  269. "Birch Sebling",
  270. 0,
  271. 0,
  272. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  273. BlockTypeEnum::SEBLING_WOOD_BIRCH))
  274. ->setHardness(0.1f);
  275. (new BasicBlockItemType(ItemTypeEnum::WOOD_BEECH,
  276. "Beech",
  277. 0,
  278. 0,
  279. ModelInfo("itemCube", "blocks.ltdb/beech.png", 6),
  280. BlockTypeEnum::WOOD_BEECH))
  281. ->setHardness(1.5f);
  282. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_BEECH,
  283. "Beech Leaves",
  284. 0,
  285. 0,
  286. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  287. BlockTypeEnum::LEAVES_WOOD_BEECH))
  288. ->setHardness(0.1f);
  289. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_BEECH,
  290. "Beech Sebling",
  291. 0,
  292. 0,
  293. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  294. BlockTypeEnum::SEBLING_WOOD_BEECH))
  295. ->setHardness(0.1f);
  296. (new BasicBlockItemType(ItemTypeEnum::STONE_BASALT,
  297. "Basalt",
  298. 0,
  299. 0,
  300. ModelInfo("itemCube", "blocks.ltdb/basalt.png", 6),
  301. BlockTypeEnum::STONE_BASALT))
  302. ->setHardness(2.f);
  303. (new BasicBlockItemType(ItemTypeEnum::WOOD_PINE,
  304. "Pine",
  305. 0,
  306. 0,
  307. ModelInfo("itemCube", "blocks.ltdb/pine.png", 6),
  308. BlockTypeEnum::WOOD_PINE))
  309. ->setHardness(1.4f);
  310. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_PINE,
  311. "Pine Leaves",
  312. 0,
  313. 0,
  314. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  315. BlockTypeEnum::LEAVES_WOOD_PINE))
  316. ->setHardness(0.1f);
  317. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_PINE,
  318. "Pine Sebling",
  319. 0,
  320. 0,
  321. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  322. BlockTypeEnum::SEBLING_WOOD_PINE))
  323. ->setHardness(0.1f);
  324. (new LightSourceItemType(ItemTypeEnum::TORCH,
  325. "Torch",
  326. ModelInfo("items.m3/stick", "blocks.ltdb/torch.png", 6),
  327. BlockTypeEnum::TORCH))
  328. ->setColor(0x00F69A54);
  329. new PlayerHandItemType();
  330. new StoneToolItemType();
  331. (new NoBlockItemType(ItemTypeEnum::WOOD_STICK,
  332. "WoodenStick",
  333. 0,
  334. 0,
  335. ModelInfo("items.m3/stick", "items.ltdb/stick.png", 1),
  336. []() {
  337. return ItemType::createBasicItem(ItemTypeEnum::WOOD_STICK,
  338. "Wooden Stick",
  339. 1.f,
  340. 1.f,
  341. 10.f,
  342. 10.f,
  343. 0,
  344. 0,
  345. 0,
  346. 1,
  347. 0,
  348. 50);
  349. }));
  350. (new NoBlockItemType(ItemTypeEnum::RESIN,
  351. "Resin",
  352. 0,
  353. 0,
  354. ModelInfo("itemCube", "items.ltdb/resin.png", 6),
  355. []() {
  356. return ItemType::createBasicItem(ItemTypeEnum::RESIN,
  357. "Resin",
  358. 1.f,
  359. 1.f,
  360. 10.f,
  361. 10.f,
  362. 0,
  363. 0,
  364. 0,
  365. 1,
  366. 0,
  367. 50);
  368. }));
  369. (new NoBlockItemType(ItemTypeEnum::STONE_TOOL_BROKEN,
  370. "BrokenStoneTool",
  371. 0,
  372. 0,
  373. ModelInfo("itemCube", "blocks.ltdb/stone.png", 6),
  374. []() {
  375. return ItemType::createBasicItem(ItemTypeEnum::STONE_TOOL_BROKEN,
  376. "Stone Tool",
  377. 100.f,
  378. 100.f,
  379. 100.f,
  380. 100.f,
  381. 0,
  382. 0,
  383. 0,
  384. 1,
  385. 0,
  386. 10);
  387. }));
  388. }
  389. void initializeEntityTypes()
  390. {
  391. new PlayerEntityType();
  392. new ItemEntityType();
  393. }
  394. void initializeDimensions()
  395. {
  396. new OverworldDimension();
  397. }
  398. void initializeMultiblockTypes()
  399. {
  400. new MultiblockTreeStructureType();
  401. }