summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dgn-proclayouts.h
diff options
context:
space:
mode:
authorBrendan Hickey <brendan@bhickey.net>2012-09-15 23:54:09 -0700
committerBrendan Hickey <brendan@bhickey.net>2012-12-30 19:06:12 -0800
commit6783c3696236768d6d505bca012d4bb84294abd2 (patch)
tree342d09e378ed02e7d5866169f28472db0c7b0a63 /crawl-ref/source/dgn-proclayouts.h
parent2dc0ae06c2b423aac053e8c8afa5f4eecbe066d1 (diff)
downloadcrawl-ref-6783c3696236768d6d505bca012d4bb84294abd2.tar.gz
crawl-ref-6783c3696236768d6d505bca012d4bb84294abd2.zip
Abyss Layout: River
An endless river cutting through the abyss. Needs a bit of turbulent perlin noise and some large scale rotations to improve its look. An example of how to blend and chain procedural dungeon generators to get something interesting.
Diffstat (limited to 'crawl-ref/source/dgn-proclayouts.h')
-rw-r--r--crawl-ref/source/dgn-proclayouts.h117
1 files changed, 77 insertions, 40 deletions
diff --git a/crawl-ref/source/dgn-proclayouts.h b/crawl-ref/source/dgn-proclayouts.h
index fa0b85c6bf..1d79217dd2 100644
--- a/crawl-ref/source/dgn-proclayouts.h
+++ b/crawl-ref/source/dgn-proclayouts.h
@@ -1,7 +1,7 @@
/**
* @file
* @brief Procedurally generated dungeon layouts.
-**/
+ **/
#ifndef PROC_LAYOUTS_H
#define PROC_LAYOUTS_H
@@ -11,62 +11,99 @@
#include <vector>
#include "cellular.h"
+#include "dungeon.h"
#include "enum.h"
#include "externs.h"
-#include "perlin.h"
+
+bool less_dense_than(const dungeon_feature_type &a, const dungeon_feature_type &b);
class ProceduralSample
{
- public:
- ProceduralSample(const coord_def c, const dungeon_feature_type f, const uint32_t cp) :
- _coord(c), _feat(f), _changepoint(cp) {}
- coord_def coord() const { return _coord; }
- dungeon_feature_type feat() const { return _feat; }
- uint32_t changepoint() const { return _changepoint; }
- bool operator< (const ProceduralSample &rhs) const
- {
- // This is for priority_queue, which is a max heap, so reverse the comparison.
- return _changepoint > rhs._changepoint && _coord < rhs._coord && _feat < rhs._feat;
- }
- private:
- coord_def _coord;
- dungeon_feature_type _feat;
- uint32_t _changepoint;
+ public:
+ ProceduralSample(const coord_def _c, const dungeon_feature_type _ft, const uint32_t _cp, map_mask_type _m = MMT_NONE) :
+ c(_c), ft(_ft), cp(_cp), m(_m) {}
+ coord_def coord() const { return c; }
+ dungeon_feature_type feat() const { return ft; }
+ uint32_t changepoint() const { return cp; }
+ map_mask_type mask() const { return m; }
+ private:
+ coord_def c;
+ dungeon_feature_type ft;
+ uint32_t cp;
+ map_mask_type m;
+};
+
+class ProceduralSamplePQCompare
+{
+ public:
+ bool operator() (const ProceduralSample &lhs, const ProceduralSample &rhs)
+ {
+ return lhs.changepoint() > rhs.changepoint();
+ }
};
class ProceduralLayout
{
- public:
- virtual ProceduralSample operator()(const coord_def &p, const uint32_t offset = 0) const = 0;
+ public:
+ virtual ProceduralSample operator()(const coord_def &p, const uint32_t offset = 0) const = 0;
};
class ColumnLayout : public ProceduralLayout
{
- public:
- ColumnLayout(int cw, int cs = -1, int rw = -1, int rs = -1)
- {
- cs = (cs < 0 ? cw : cs);
- _col_width = cw;
- _col_space = cs;
- _row_width = (rw < 0 ? cw : rw);
- _row_space = (rs < 0 ? cs : rs);
- }
-
- ProceduralSample operator()(const coord_def &p, const uint32_t offset = 0) const;
- private:
- int _col_width, _col_space, _row_width, _row_space;
+ public:
+ ColumnLayout(int cw, int cs = -1, int rw = -1, int rs = -1)
+ {
+ cs = (cs < 0 ? cw : cs);
+ _col_width = cw;
+ _col_space = cs;
+ _row_width = (rw < 0 ? cw : rw);
+ _row_space = (rs < 0 ? cs : rs);
+ }
+
+ ProceduralSample operator()(const coord_def &p, const uint32_t offset = 0) const;
+ private:
+ int _col_width, _col_space, _row_width, _row_space;
};
class WorleyLayout : public ProceduralLayout
{
- public:
- WorleyLayout(uint32_t _seed,
- const ProceduralLayout &_a,
- const ProceduralLayout &_b) : seed(_seed), a(_a), b(_b) {}
- ProceduralSample operator()(const coord_def &p, const uint32_t offset = 0) const;
- private:
- const uint32_t seed;
- const ProceduralLayout &a, &b;
+ public:
+ WorleyLayout(uint32_t _seed,
+ const ProceduralLayout &_a,
+ const ProceduralLayout &_b) : seed(_seed), a(_a), b(_b) {}
+ ProceduralSample operator()(const coord_def &p, const uint32_t offset = 0) const;
+ private:
+ const uint32_t seed;
+ const ProceduralLayout &a, &b;
+};
+
+class ChaosLayout : public ProceduralLayout
+{
+ public:
+ ChaosLayout(uint32_t _seed) : seed(_seed) {}
+ ProceduralSample operator()(const coord_def &p, const uint32_t offset = 0) const;
+ private:
+ const uint32_t seed;
+};
+
+class RoilingChaosLayout : public ProceduralLayout
+{
+ public:
+ RoilingChaosLayout(uint32_t _seed) : seed(_seed) {}
+ ProceduralSample operator()(const coord_def &p, const uint32_t offset = 0) const;
+ private:
+ const uint32_t seed;
+
+};
+
+class TheRiver : public ProceduralLayout
+{
+ public:
+ TheRiver(uint32_t _seed, const ProceduralLayout &_layout) : seed(_seed), layout(_layout) {}
+ ProceduralSample operator()(const coord_def &p, const uint32_t offset = 0) const;
+ private:
+ const uint32_t seed;
+ const ProceduralLayout &layout;
};
#endif /* PROC_LAYOUTS_H */