diff --git a/binding-mri/lightmap-binding.cpp b/binding-mri/lightmap-binding.cpp index 0c81757..3ff74c6 100644 --- a/binding-mri/lightmap-binding.cpp +++ b/binding-mri/lightmap-binding.cpp @@ -65,6 +65,12 @@ static VALUE addDynamicSource(VALUE self, VALUE rb_x, VALUE rb_y, VALUE rb_power return Qnil; } +static VALUE removeStaticSource(VALUE self, VALUE rb_x, VALUE rb_y) { + LightMap *k = getPrivateData(self); + k->removeStaticLightSource(NUM2DBL(rb_x), NUM2DBL(rb_y)); + return Qnil; +} + static VALUE setAmbient(VALUE self, VALUE var){ LightMap *k = getPrivateData(self); k->setAmbient(NUM2DBL(var)); @@ -91,5 +97,6 @@ void lightmapBindingInit(){ rb_define_method(klass, "clear_dynamic_sources", clearDynamicSources, 0); rb_define_method(klass, "add_static_source", addStaticSource, 5); rb_define_method(klass, "add_dynamic_source", addDynamicSource, 5); + rb_define_method(klass, "remove_static_source", removeStaticSource, 2); rb_define_method(klass, "ambient=", setAmbient, 1); } diff --git a/scripts/DynamicLight.rb b/scripts/DynamicLight.rb index 7ddc252..1d436f1 100644 --- a/scripts/DynamicLight.rb +++ b/scripts/DynamicLight.rb @@ -86,6 +86,11 @@ class DynamicLight } end + def clear_lights + @light_sprite.clear_static_sources() + @light_sprite.clear_dynamic_sources() + end + def light_passable(tile_id) $game_map.passages[tile_id] & 15 == 0 end @@ -104,6 +109,18 @@ class DynamicLight @light_npc << [$game_map.events[npc_id], power, radius, color] end + def remove(x, y) + @light_sprite.remove_static_source(x, y) + end + + def remove_npc(npc_id) + @light_npc.each do |npc| + if npc[0] == $game_map.events[npc_id] + @light_npc.delete(npc) + end + end + end + def has_effect(source) source[2] != 0 && source[3] > 0 && source[4].alpha >= 0 && (source[4].red != 0 || source[4].green != 0 || source[4].blue != 0) end @@ -166,4 +183,4 @@ class DynamicLight @plr_light_table[14] = val&.[](14) || 1 @plr_light_table[15] = val&.[](15) || 1 end -end \ No newline at end of file +end diff --git a/src/lightmap.cpp b/src/lightmap.cpp index 0571519..18bb927 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -202,6 +202,13 @@ void LightMap::addStaticLightSource(LightSource source){ void LightMap::addDynamicLightSource(LightSource source){ p->dynamicLightSources.push_back(source); } +void LightMap::removeStaticLightSource(float x, float y){ + for (int i = 0; i < p->staticLightSources.size(); i++) + if (p->staticLightSources[i].x == x && p->staticLightSources[i].y == y){ + p->staticLightSources.erase(p->staticLightSources.begin() + i); + return; + } +} /* SceneElement */ void LightMap::draw(){ diff --git a/src/lightmap.h b/src/lightmap.h index 0071542..ccee2c4 100644 --- a/src/lightmap.h +++ b/src/lightmap.h @@ -33,6 +33,7 @@ public: void clearDynamicLightSources(); void addStaticLightSource(LightSource source); void addDynamicLightSource(LightSource source); + void removeStaticLightSource(float x, float y); void initDynAttribs(); private: