diff --git a/modules/terraman/data/terrain_light.cpp b/modules/terraman/data/terrain_light.cpp index 302f4b14d..c9e56f067 100644 --- a/modules/terraman/data/terrain_light.cpp +++ b/modules/terraman/data/terrain_light.cpp @@ -114,6 +114,43 @@ void TerrainLight::set_specular(const real_t value) { _specular = value; } +Dictionary TerrainLight::to_dict() { + Dictionary data; + + data["owner_type"] = _owner_type; + + data["has_owner_chunk"] = _has_owner_chunk; + data["owner_chunk_position"] = _owner_chunk_position; + + data["world_data_position"] = _world_data_position; + + data["range"] = _range; + data["attenuation"] = _attenuation; + data["color"] = _color; + data["energy"] = _energy; + data["indirect_energy"] = _indirect_energy; + data["negative"] = _negative; + data["specular"] = _specular; + + return data; +} +void TerrainLight::from_dict(const Dictionary &p_data) { + _owner_type = (OwnerType)((int)p_data["owner_type"]); + + _has_owner_chunk = p_data["has_owner_chunk"]; + _owner_chunk_position = p_data["owner_chunk_position"]; + + _world_data_position = p_data["world_data_position"]; + + _range = p_data["range"]; + _attenuation = p_data["attenuation"]; + _color = p_data["color"]; + _energy = p_data["energy"]; + _indirect_energy = p_data["indirect_energy"]; + _negative = p_data["negative"]; + _specular = p_data["specular"]; +} + TerrainLight::TerrainLight() { _owner_type = OWNER_TYPE_NONE; _has_owner_chunk = false; @@ -184,6 +221,9 @@ void TerrainLight::_bind_methods() { ClassDB::bind_method(D_METHOD("set_specular", "value"), &TerrainLight::set_specular); ADD_PROPERTY(PropertyInfo(Variant::REAL, "light_specular"), "set_specular", "get_specular"); + ClassDB::bind_method(D_METHOD("to_dict"), &TerrainLight::to_dict); + ClassDB::bind_method(D_METHOD("from_dict", "data"), &TerrainLight::from_dict); + BIND_ENUM_CONSTANT(OWNER_TYPE_NONE); #ifdef MODULE_PROPS_ENABLED BIND_ENUM_CONSTANT(OWNER_TYPE_PROP); diff --git a/modules/terraman/data/terrain_light.h b/modules/terraman/data/terrain_light.h index 4eba3a3e2..0201fa7d9 100644 --- a/modules/terraman/data/terrain_light.h +++ b/modules/terraman/data/terrain_light.h @@ -85,6 +85,9 @@ public: real_t get_specular() const; void set_specular(const real_t value); + Dictionary to_dict(); + void from_dict(const Dictionary &p_data); + TerrainLight(); ~TerrainLight();