StaticInitializerOrder.cpp 13 KB

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