summaryrefslogtreecommitdiff
path: root/scene/resources/tile_set.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/tile_set.cpp')
-rw-r--r--scene/resources/tile_set.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 894388e890..b9d2c503e1 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -45,6 +45,8 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
tile_set_name(id, p_value);
else if (what == "texture")
tile_set_texture(id, p_value);
+ else if (what == "normal_map")
+ tile_set_normal_map(id, p_value);
else if (what == "tex_offset")
tile_set_texture_offset(id, p_value);
else if (what == "material")
@@ -91,6 +93,8 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = tile_get_name(id);
else if (what == "texture")
r_ret = tile_get_texture(id);
+ else if (what == "normal_map")
+ r_ret = tile_get_normal_map(id);
else if (what == "tex_offset")
r_ret = tile_get_texture_offset(id);
else if (what == "material")
@@ -129,6 +133,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
String pre = itos(id) + "/";
p_list->push_back(PropertyInfo(Variant::STRING, pre + "name"));
p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "tex_offset"));
p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial"));
p_list->push_back(PropertyInfo(Variant::COLOR, pre + "modulate"));
@@ -165,6 +170,19 @@ Ref<Texture> TileSet::tile_get_texture(int p_id) const {
return tile_map[p_id].texture;
}
+void TileSet::tile_set_normal_map(int p_id, const Ref<Texture> &p_normal_map) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].normal_map = p_normal_map;
+ emit_changed();
+}
+
+Ref<Texture> TileSet::tile_get_normal_map(int p_id) const {
+
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture>());
+ return tile_map[p_id].normal_map;
+}
+
void TileSet::tile_set_material(int p_id, const Ref<ShaderMaterial> &p_material) {
ERR_FAIL_COND(!tile_map.has(p_id));
@@ -492,6 +510,8 @@ void TileSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("tile_get_name", "id"), &TileSet::tile_get_name);
ClassDB::bind_method(D_METHOD("tile_set_texture", "id", "texture:Texture"), &TileSet::tile_set_texture);
ClassDB::bind_method(D_METHOD("tile_get_texture:Texture", "id"), &TileSet::tile_get_texture);
+ ClassDB::bind_method(D_METHOD("tile_set_normal_map", "id", "normal_map:Texture"), &TileSet::tile_set_normal_map);
+ ClassDB::bind_method(D_METHOD("tile_get_normal_map:Texture", "id"), &TileSet::tile_get_normal_map);
ClassDB::bind_method(D_METHOD("tile_set_material", "id", "material:ShaderMaterial"), &TileSet::tile_set_material);
ClassDB::bind_method(D_METHOD("tile_get_material:ShaderMaterial", "id"), &TileSet::tile_get_material);
ClassDB::bind_method(D_METHOD("tile_set_texture_offset", "id", "texture_offset"), &TileSet::tile_set_texture_offset);