20 #ifndef BLOCKMANAGER_H
21 #define BLOCKMANAGER_H
55 static bool KindSubFromFile(QDataStream &, quint8 * kind, quint8 * sub);
72 constexpr
static int MakeId(
const int kind,
const int sub) {
73 return (kind << 6) | sub;
79 static bool IsValid(
int kind,
int sub);
86 static const QByteArray
kinds[];
87 static const QByteArray
subs[];
92 #endif // BLOCKMANAGER_H
static int StringToSub(QString)
If string is not convertible to substance, returns LAST_SUB.
void DeleteBlock(Block *) const
Does not actually delete normal blocks.
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".
This class is used for creating and deleting blocks, also for loading them from file.
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)
static bool IsValid(int kind, int sub)
BlockManager block_manager
static Block * NewBlock(int kind, int sub)
Use this to receive a pointer to new not-normal block.
static QString KindToString(int kind)
If kind is unknown, returns "unknown_kind".
BlockManager & operator=(const BlockManager &)=delete
static Block * BlockFromFile(QDataStream &, int kind, int sub)
Use this to load block from file.
Block without special physics and attributes.
static constexpr int MakeId(const int kind, const int sub)
static bool KindSubFromFile(QDataStream &, quint8 *kind, quint8 *sub)
Returns true if block is normal.