diff --git a/library/terrain_2d_library.cpp b/library/terrain_2d_library.cpp index 0d34790..3cb441d 100644 --- a/library/terrain_2d_library.cpp +++ b/library/terrain_2d_library.cpp @@ -159,6 +159,29 @@ bool Terrain2DLibrary::_supports_caching() { return false; } +//Textures + +Ref Terrain2DLibrary::texture_get() { + return _texture; +} +void Terrain2DLibrary::texture_set(const Ref &value) { + _texture = value; +} + +Ref Terrain2DLibrary::liquid_texture_get() { + return _liquid_texture; +} +void Terrain2DLibrary::liquid_texture_set(const Ref &value) { + _liquid_texture = value; +} + +Ref Terrain2DLibrary::prop_texture_get() { + return _prop_texture; +} +void Terrain2DLibrary::prop_texture_set(const Ref &value) { + _prop_texture = value; +} + //Materials void Terrain2DLibrary::material_cache_get_key(Ref chunk) { @@ -355,6 +378,18 @@ void Terrain2DLibrary::_bind_methods() { ClassDB::bind_method(D_METHOD("_supports_caching"), &Terrain2DLibrary::_supports_caching); ClassDB::bind_method(D_METHOD("supports_caching"), &Terrain2DLibrary::supports_caching); + ClassDB::bind_method(D_METHOD("texture_get"), &Terrain2DLibrary::texture_get); + ClassDB::bind_method(D_METHOD("texture_set", "value"), &Terrain2DLibrary::texture_set); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "texture_set", "texture_get"); + + ClassDB::bind_method(D_METHOD("liquid_texture_get"), &Terrain2DLibrary::liquid_texture_get); + ClassDB::bind_method(D_METHOD("liquid_texture_set", "value"), &Terrain2DLibrary::liquid_texture_set); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "liquid_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "liquid_texture_set", "liquid_texture_get"); + + ClassDB::bind_method(D_METHOD("prop_texture_get"), &Terrain2DLibrary::prop_texture_get); + ClassDB::bind_method(D_METHOD("prop_texture_set", "value"), &Terrain2DLibrary::prop_texture_set); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "prop_texture_set", "prop_texture_get"); + #if VERSION_MAJOR < 4 BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::INT, "material_index"), PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"))); #else @@ -421,7 +456,9 @@ void Terrain2DLibrary::_bind_methods() { ClassDB::bind_method(D_METHOD("_prop_material_cache_unref", "key"), &Terrain2DLibrary::_prop_material_cache_unref); ClassDB::bind_method(D_METHOD("prop_material_get"), &Terrain2DLibrary::prop_material_get); - ClassDB::bind_method(D_METHOD("prop_material_set" "value"), &Terrain2DLibrary::prop_material_set); + ClassDB::bind_method(D_METHOD("prop_material_set" + "value"), + &Terrain2DLibrary::prop_material_set); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "prop_material_set", "prop_material_get"); ClassDB::bind_method(D_METHOD("terra_surface_get", "index"), &Terrain2DLibrary::terra_surface_get); diff --git a/library/terrain_2d_library.h b/library/terrain_2d_library.h index 8a753af..7428942 100644 --- a/library/terrain_2d_library.h +++ b/library/terrain_2d_library.h @@ -88,6 +88,15 @@ public: bool supports_caching(); virtual bool _supports_caching(); + Ref texture_get(); + void texture_set(const Ref &value); + + Ref liquid_texture_get(); + void liquid_texture_set(const Ref &value); + + Ref prop_texture_get(); + void prop_texture_set(const Ref &value); + void material_cache_get_key(Ref chunk); virtual void _material_cache_get_key(Ref chunk); Ref material_cache_get(const int key); @@ -173,6 +182,11 @@ protected: static void _bind_methods(); bool _initialized; + + Ref _texture; + Ref _liquid_texture; + Ref _prop_texture; + Ref _material; Ref _liquid_material; Ref _prop_material; diff --git a/library/terrain_2d_library_merger.cpp b/library/terrain_2d_library_merger.cpp index f9417b1..f22829f 100644 --- a/library/terrain_2d_library_merger.cpp +++ b/library/terrain_2d_library_merger.cpp @@ -256,6 +256,9 @@ void Terrain2DLibraryMerger::refresh_rects() { Ref tex = _packer->get_generated_texture(0); + texture_set(tex); + liquid_texture_set(tex); + setup_material_albedo(MATERIAL_INDEX_TERRAIN, tex); setup_material_albedo(MATERIAL_INDEX_LIQUID, tex); } @@ -280,6 +283,8 @@ void Terrain2DLibraryMerger::refresh_rects() { Ref tex = _prop_packer->get_generated_texture(0); + prop_texture_set(tex); + setup_material_albedo(MATERIAL_INDEX_PROP, tex); } #endif