StaticInitializerOrder.cpp 15 KB

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