20 #include <QDataStream>
89 "meat_of_intellectual",
120 for (
int sub=0; sub<
LAST_SUB; ++sub) {
124 "invalid number of strings in BlockManager::kinds[]");
126 "invalid number of strings in BlockManager::subs[]");
127 static_assert((LAST_SUB <= 64 ),
"too many substances, should be < 64.");
128 static_assert((
LAST_KIND <= 128),
"too many kinds, should be < 128.");
138 for(
int sub=0; sub<
LAST_SUB; ++sub) {
147 switch ( static_cast<enum kinds>(kind) ) {
149 case BELL:
return new Bell (kind, sub);
152 case PICK:
return new Pick (kind, sub);
155 case BUSH:
return new Bush (kind, sub);
163 case DOOR:
return new Door (kind, sub);
164 case BOX:
return new Box (kind, sub);
166 case MAP:
return new Map (kind, sub);
170 case AXE:
return new Axe (kind, sub);
189 const int kind,
const int sub)
192 switch ( static_cast<enum kinds>(kind) ) {
193 case BLOCK:
return new Block (str, kind, sub);
194 case BELL:
return new Bell (str, kind, sub);
196 case DWARF:
return new Dwarf (str, kind, sub);
197 case PICK:
return new Pick (str, kind, sub);
199 case GRASS:
return new Grass (str, kind, sub);
200 case BUSH:
return new Bush (str, kind, sub);
203 case CLOCK:
return new Clock (str, kind, sub);
204 case PLATE:
return new Plate (str, kind, sub);
208 case DOOR:
return new Door (str, kind, sub);
209 case BOX:
return new Box (str, kind, sub);
211 case MAP:
return new Map (str, kind, sub);
215 case AXE:
return new Axe (str, kind, sub);
222 case BOOTS:
return new Boots (str, kind, sub);
234 quint8 * kind, quint8 * sub)
250 if ( active !=
nullptr ) {
274 if ( block!=normal && *block==*normal ) {
287 switch ( static_cast<enum kinds>(kind) ) {
288 case BLOCK:
return true;
static int StringToSub(QString)
If string is not convertible to substance, returns LAST_SUB.
void DeleteBlock(Block *) const
Does not actually delete normal blocks.
Container is multi-purpose container for blocks.
BlockManager block_manager
static int KindFromId(int id)
Block * normals[LAST_SUB]
Block * Normal(int sub) const
Use this to receive a pointer to normal block.
static QString SubToString(int sub)
If substance is unknown, returns "unknown_sub".
static sub_groups GetSubGroup(int sub)
This class is used for creating and deleting blocks, also for loading them from file.
static const QByteArray kinds[]
Block * ReplaceWithNormal(Block *block) const
For memory economy.
static int StringToKind(QString)
If string is not convertible to kind, returns LAST_KIND.
static int SubFromId(int id)
Workbench allows craft from multiple sources. There can be up to 2 products. Also can be used as cont...
static bool IsValid(int kind, int sub)
static Block * NewBlock(int kind, int sub)
Use this to receive a pointer to new not-normal block.
Box represents falling inventory.
static QString KindToString(int kind)
If kind is unknown, returns "unknown_kind".
virtual Active * ActiveBlock()
static const QByteArray subs[]
Weapon class represents simple weapons as sticks, pebbles and so on. Also is used as base class for m...
static Block * BlockFromFile(QDataStream &, int kind, int sub)
Use this to load block from file.
Block without special physics and attributes.
static bool KindSubFromFile(QDataStream &, quint8 *kind, quint8 *sub)
Returns true if block is normal.