mirror of
https://github.com/Relintai/rtile_map.git
synced 2024-11-09 05:12:10 +01:00
Added noise params to the tileset.
This commit is contained in:
parent
0e48188025
commit
6969ef8f00
@ -185,6 +185,7 @@ void RTileMap::set_tileset(const Ref<RTileSet> &p_tileset) {
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->connect("changed", this, "_recreate_quadrants");
|
||||
tile_set->add_change_receptor(this);
|
||||
tile_set->setup_noise(noise);
|
||||
} else {
|
||||
clear();
|
||||
}
|
||||
@ -1900,8 +1901,6 @@ void RTileMap::_changed_callback(Object *p_changed, const char *p_prop) {
|
||||
|
||||
RTileMap::RTileMap() {
|
||||
noise.instance();
|
||||
//noise->set_seed(Math::rand());
|
||||
noise->set_noise_type(FastNoise::TYPE_PERLIN);
|
||||
|
||||
rect_cache_dirty = true;
|
||||
used_size_cache_dirty = true;
|
||||
|
18
tile_set.cpp
18
tile_set.cpp
@ -1087,6 +1087,18 @@ int RTileSet::get_last_unused_tile_id() const {
|
||||
}
|
||||
}
|
||||
|
||||
void RTileSet::set_noise_params(const Ref<FastnoiseNoiseParams> &noise) {
|
||||
_noise_params = noise;
|
||||
}
|
||||
Ref<FastnoiseNoiseParams> RTileSet::get_noise_params() {
|
||||
return _noise_params;
|
||||
}
|
||||
void RTileSet::setup_noise(Ref<FastNoise> noise) {
|
||||
if (_noise_params.is_valid()) {
|
||||
_noise_params->setup_noise(noise);
|
||||
}
|
||||
}
|
||||
|
||||
int RTileSet::find_tile_by_name(const String &p_name) const {
|
||||
for (Map<int, TileData>::Element *E = tile_map.front(); E; E = E->next()) {
|
||||
if (p_name == E->get().name) {
|
||||
@ -1170,6 +1182,12 @@ void RTileSet::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("find_tile_by_name", "name"), &RTileSet::find_tile_by_name);
|
||||
ClassDB::bind_method(D_METHOD("get_tiles_ids"), &RTileSet::_get_tiles_ids);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_noise_params", "noise"), &RTileSet::set_noise_params);
|
||||
ClassDB::bind_method(D_METHOD("get_noise_params"), &RTileSet::get_noise_params);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, "FastnoiseNoiseParams"), "set_noise_params", "get_noise_params");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("setup_noise", "noise"), &RTileSet::setup_noise);
|
||||
|
||||
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_tile_bound", PropertyInfo(Variant::INT, "drawn_id"), PropertyInfo(Variant::INT, "neighbor_id")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::VECTOR2, "_forward_subtile_selection", PropertyInfo(Variant::INT, "autotile_id"), PropertyInfo(Variant::INT, "bitmask"), PropertyInfo(Variant::OBJECT, "tilemap", PROPERTY_HINT_NONE, "RTileMap"), PropertyInfo(Variant::VECTOR2, "tile_location")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::VECTOR2, "_forward_atlas_subtile_selection", PropertyInfo(Variant::INT, "atlastile_id"), PropertyInfo(Variant::OBJECT, "tilemap", PROPERTY_HINT_NONE, "RTileMap"), PropertyInfo(Variant::VECTOR2, "tile_location")));
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "scene/resources/convex_polygon_shape_2d.h"
|
||||
#include "scene/resources/shape_2d.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "../fastnoise/noise.h"
|
||||
#include "../fastnoise/fastnoise_noise_params.h"
|
||||
|
||||
class RTileSet : public Resource {
|
||||
GDCLASS(RTileSet, Resource);
|
||||
@ -136,6 +138,8 @@ private:
|
||||
|
||||
Map<int, TileData> tile_map;
|
||||
|
||||
Ref<FastnoiseNoiseParams> _noise_params;
|
||||
|
||||
protected:
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
@ -259,6 +263,10 @@ public:
|
||||
|
||||
int get_last_unused_tile_id() const;
|
||||
|
||||
void set_noise_params(const Ref<FastnoiseNoiseParams> &noise);
|
||||
Ref<FastnoiseNoiseParams> get_noise_params();
|
||||
void setup_noise(Ref<FastNoise> noise);
|
||||
|
||||
RTileSet();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user