2019-08-24 17:39:35 -07:00
|
|
|
#pragma once
|
2019-06-12 00:15:47 -07:00
|
|
|
|
|
|
|
#include <string>
|
2020-03-03 21:45:22 -08:00
|
|
|
|
2020-08-13 00:55:18 -07:00
|
|
|
#include "ItemDef.h"
|
2020-03-03 21:45:22 -08:00
|
|
|
|
2020-08-13 00:55:18 -07:00
|
|
|
#include "lua/Lua.h"
|
|
|
|
#include "util/Util.h"
|
|
|
|
#include "game/def/mesh/BlockModel.h"
|
|
|
|
#include "game/def/mesh/SelectionBox.h"
|
2019-06-12 00:15:47 -07:00
|
|
|
|
2020-12-05 21:17:46 -08:00
|
|
|
/**
|
|
|
|
* Represents a block definition, defined by Lua.
|
|
|
|
* Contains all the necessary information about a block.
|
|
|
|
*/
|
|
|
|
|
2019-08-13 01:38:57 -07:00
|
|
|
class BlockDef : public ItemDef {
|
2020-12-05 21:17:46 -08:00
|
|
|
public:
|
|
|
|
enum class Callback {
|
|
|
|
CONSTRUCT, AFTER_CONSTRUCT,
|
|
|
|
DESTRUCT, AFTER_DESTRUCT,
|
|
|
|
|
|
|
|
PLACE, PLACE_CLIENT,
|
|
|
|
AFTER_PLACE, AFTER_PLACE_CLIENT,
|
|
|
|
|
|
|
|
BREAK, BREAK_CLIENT,
|
|
|
|
AFTER_BREAK, AFTER_BREAK_CLIENT,
|
|
|
|
|
|
|
|
INTERACT, INTERACT_CLIENT,
|
|
|
|
HIT, HIT_CLIENT
|
|
|
|
};
|
|
|
|
|
2021-09-03 14:22:58 -07:00
|
|
|
BlockDef() : ItemDef(ItemDef::Type::BLOCK) {};
|
2020-11-08 22:57:34 -08:00
|
|
|
|
|
|
|
void createModel();
|
|
|
|
|
|
|
|
bool hasInteraction();
|
|
|
|
|
|
|
|
BlockModel model;
|
|
|
|
BlockModel farModel;
|
|
|
|
|
|
|
|
bool culls = true;
|
|
|
|
bool solid = true;
|
|
|
|
bool lightPropagates = false;
|
|
|
|
|
|
|
|
int health = 0;
|
|
|
|
int defense = 0;
|
|
|
|
|
|
|
|
glm::ivec3 lightSource{};
|
|
|
|
|
|
|
|
std::vector<SelectionBox> sBoxes{};
|
|
|
|
std::vector<SelectionBox> cBoxes{};
|
|
|
|
|
2020-12-05 21:17:46 -08:00
|
|
|
std::unordered_map<Callback, sol::protected_function, Util::EnumClassHash> callbacks {};
|
2019-06-12 00:15:47 -07:00
|
|
|
};
|