2014-11-01 13:16:23 -04:00
|
|
|
/*
|
|
|
|
Minetest
|
|
|
|
Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MG_DECORATION_HEADER
|
|
|
|
#define MG_DECORATION_HEADER
|
|
|
|
|
|
|
|
#include <set>
|
2014-11-12 23:01:13 -05:00
|
|
|
#include "mapgen.h"
|
2014-11-01 13:16:23 -04:00
|
|
|
|
2014-12-08 03:06:31 -05:00
|
|
|
struct NoiseParams;
|
2014-11-01 13:16:23 -04:00
|
|
|
class Mapgen;
|
2015-01-05 02:42:27 -05:00
|
|
|
class MMVManip;
|
2014-11-01 13:16:23 -04:00
|
|
|
class PseudoRandom;
|
2014-11-12 23:01:13 -05:00
|
|
|
class Schematic;
|
2014-11-01 13:16:23 -04:00
|
|
|
|
|
|
|
enum DecorationType {
|
|
|
|
DECO_SIMPLE,
|
|
|
|
DECO_SCHEMATIC,
|
|
|
|
DECO_LSYSTEM
|
|
|
|
};
|
|
|
|
|
2015-03-04 20:53:11 -05:00
|
|
|
#define DECO_PLACE_CENTER_X 0x01
|
|
|
|
#define DECO_PLACE_CENTER_Y 0x02
|
|
|
|
#define DECO_PLACE_CENTER_Z 0x04
|
|
|
|
#define DECO_USE_NOISE 0x08
|
|
|
|
#define DECO_FORCE_PLACEMENT 0x10
|
2014-11-12 23:01:13 -05:00
|
|
|
|
2014-12-10 00:56:44 -05:00
|
|
|
extern FlagDesc flagdesc_deco[];
|
2014-11-12 23:01:13 -05:00
|
|
|
|
|
|
|
|
2014-11-01 13:16:23 -04:00
|
|
|
#if 0
|
|
|
|
struct CutoffData {
|
|
|
|
VoxelArea a;
|
|
|
|
Decoration *deco;
|
|
|
|
//v3s16 p;
|
|
|
|
//v3s16 size;
|
|
|
|
//s16 height;
|
|
|
|
|
|
|
|
CutoffData(s16 x, s16 y, s16 z, s16 h) {
|
|
|
|
p = v3s16(x, y, z);
|
|
|
|
height = h;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2015-03-30 23:40:35 -04:00
|
|
|
class Decoration : public ObjDef, public NodeResolver {
|
2014-11-01 13:16:23 -04:00
|
|
|
public:
|
2015-04-17 00:52:48 -04:00
|
|
|
Decoration();
|
|
|
|
virtual ~Decoration();
|
|
|
|
|
|
|
|
virtual void resolveNodeNames();
|
|
|
|
|
|
|
|
size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
|
|
|
|
//size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
|
|
|
|
|
|
|
|
virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p) = 0;
|
|
|
|
virtual int getHeight() = 0;
|
2014-11-01 13:16:23 -04:00
|
|
|
|
2014-12-10 00:56:44 -05:00
|
|
|
u32 flags;
|
2014-11-01 13:16:23 -04:00
|
|
|
int mapseed;
|
|
|
|
std::vector<content_t> c_place_on;
|
|
|
|
s16 sidelen;
|
2014-12-30 01:48:20 -05:00
|
|
|
s16 y_min;
|
|
|
|
s16 y_max;
|
2014-11-01 13:16:23 -04:00
|
|
|
float fill_ratio;
|
2014-12-10 00:56:44 -05:00
|
|
|
NoiseParams np;
|
2014-11-01 13:16:23 -04:00
|
|
|
|
|
|
|
std::set<u8> biomes;
|
|
|
|
//std::list<CutoffData> cutoffs;
|
|
|
|
//JMutex cutoff_mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DecoSimple : public Decoration {
|
|
|
|
public:
|
2015-04-17 00:52:48 -04:00
|
|
|
virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p);
|
|
|
|
bool canPlaceDecoration(MMVManip *vm, v3s16 p);
|
|
|
|
virtual int getHeight();
|
|
|
|
|
|
|
|
virtual void resolveNodeNames();
|
|
|
|
|
2014-11-01 13:16:23 -04:00
|
|
|
std::vector<content_t> c_decos;
|
|
|
|
std::vector<content_t> c_spawnby;
|
|
|
|
s16 deco_height;
|
|
|
|
s16 deco_height_max;
|
|
|
|
s16 nspawnby;
|
|
|
|
};
|
|
|
|
|
2014-11-12 23:01:13 -05:00
|
|
|
class DecoSchematic : public Decoration {
|
|
|
|
public:
|
2015-04-17 00:52:48 -04:00
|
|
|
DecoSchematic();
|
2014-11-12 23:01:13 -05:00
|
|
|
|
2015-03-14 00:26:04 -04:00
|
|
|
virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p);
|
2014-11-12 23:01:13 -05:00
|
|
|
virtual int getHeight();
|
2015-04-17 00:52:48 -04:00
|
|
|
|
|
|
|
Rotation rotation;
|
|
|
|
Schematic *schematic;
|
2014-11-12 23:01:13 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-11-01 13:16:23 -04:00
|
|
|
/*
|
|
|
|
class DecoLSystem : public Decoration {
|
|
|
|
public:
|
|
|
|
virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
2015-03-30 23:40:35 -04:00
|
|
|
class DecorationManager : public ObjDefManager {
|
2014-11-12 23:01:13 -05:00
|
|
|
public:
|
2014-12-12 14:07:49 -05:00
|
|
|
DecorationManager(IGameDef *gamedef);
|
2015-04-17 00:52:48 -04:00
|
|
|
virtual ~DecorationManager() {}
|
2014-11-12 23:01:13 -05:00
|
|
|
|
2015-03-30 23:40:35 -04:00
|
|
|
const char *getObjectTitle() const
|
|
|
|
{
|
|
|
|
return "decoration";
|
|
|
|
}
|
|
|
|
|
2015-03-31 23:27:19 -04:00
|
|
|
static Decoration *create(DecorationType type)
|
2014-11-12 23:01:13 -05:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case DECO_SIMPLE:
|
|
|
|
return new DecoSimple;
|
|
|
|
case DECO_SCHEMATIC:
|
|
|
|
return new DecoSchematic;
|
|
|
|
//case DECO_LSYSTEM:
|
|
|
|
// return new DecoLSystem;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-04 22:37:20 -05:00
|
|
|
size_t placeAllDecos(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
|
2014-11-12 23:01:13 -05:00
|
|
|
};
|
2014-11-01 13:16:23 -04:00
|
|
|
|
|
|
|
#endif
|