summaryrefslogtreecommitdiffstats
path: root/src/Generating/Prefab.h
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-03-25 22:10:53 +0100
committermadmaxoft <github@xoft.cz>2014-03-25 22:10:53 +0100
commit37778e5f82f02eb417642390a36587a970e5479c (patch)
tree13e92d4ce434899451ec939e01ba728a50cfe10f /src/Generating/Prefab.h
parentBlockArea: Create() can take the size as Vector3i, too. (diff)
downloadcuberite-37778e5f82f02eb417642390a36587a970e5479c.tar
cuberite-37778e5f82f02eb417642390a36587a970e5479c.tar.gz
cuberite-37778e5f82f02eb417642390a36587a970e5479c.tar.bz2
cuberite-37778e5f82f02eb417642390a36587a970e5479c.tar.lz
cuberite-37778e5f82f02eb417642390a36587a970e5479c.tar.xz
cuberite-37778e5f82f02eb417642390a36587a970e5479c.tar.zst
cuberite-37778e5f82f02eb417642390a36587a970e5479c.zip
Diffstat (limited to 'src/Generating/Prefab.h')
-rw-r--r--src/Generating/Prefab.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h
new file mode 100644
index 000000000..6596b906b
--- /dev/null
+++ b/src/Generating/Prefab.h
@@ -0,0 +1,83 @@
+
+// Prefab.h
+
+/*
+Declares the cPrefab class, representing a cPiece descendant for the cPieceGenerator that
+uses a prefabricate in a cBlockArea for drawing itself.
+The class can be constructed from data that is stored directly in the executable, in a sPrefabDef structure
+declared in this file as well; the Gallery server exports areas in this format.
+*/
+
+
+
+
+
+#pragma once
+
+#include "PieceGenerator.h"
+#include "../BlockArea.h"
+
+
+
+
+
+
+class cPrefab :
+ public cPiece
+{
+public:
+ struct sDef
+ {
+ int m_SizeX;
+ int m_SizeY;
+ int m_SizeZ;
+ const char * m_CharMap;
+ const char * m_Image;
+ // TODO: Connectors
+ };
+
+ cPrefab(const sDef & a_Def);
+
+ /** Draws the prefab into the specified block area, according to the placement stored in the PlacedPiece. */
+ void Draw(cBlockArea & a_Dest, const cPlacedPiece * a_Placement);
+
+protected:
+ /** Maps letters in the sDef::m_Image onto a number, BlockType * 16 | BlockMeta */
+ typedef int CharMap[256];
+
+
+ /** The cBlockArea that contains the block definitions for the prefab */
+ cBlockArea m_BlockArea;
+
+ /** The size of the prefab */
+ Vector3i m_Size;
+
+ /** The hitbox of the prefab. In first version is the same as the m_BlockArea dimensions */
+ cCuboid m_HitBox;
+
+ /** The connectors through which the piece connects to other pieces */
+ cConnectors m_Connectors;
+
+ /** Bitmask, bit N set -> N rotations CCW supported */
+ int m_AllowedRotations;
+
+ /** The merge strategy to use when drawing the prefab into a block area */
+ cBlockArea::eMergeStrategy m_MergeStrategy;
+
+
+ // cPiece overrides:
+ virtual cConnectors GetConnectors(void) const override;
+ virtual Vector3i GetSize(void) const override;
+ virtual cCuboid GetHitBox(void) const override;
+ virtual bool CanRotateCCW(int a_NumRotations) const override;
+
+ /** Parses the CharMap in the definition into a CharMap binary data used for translating the definition into BlockArea. */
+ void ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef);
+
+ /** Parses the Image in the definition into m_BlockArea's block types and metas, using the specified CharMap. */
+ void ParseBlockImage(const CharMap & a_CharMap, const char * a_BlockImage);
+};
+
+
+
+