light removing

This commit is contained in:
Issac332 2026-07-02 16:08:13 +03:00
parent ec7ee84470
commit fa75eb2a8f
4 changed files with 33 additions and 1 deletions

View file

@ -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<LightMap>(self);
k->removeStaticLightSource(NUM2DBL(rb_x), NUM2DBL(rb_y));
return Qnil;
}
static VALUE setAmbient(VALUE self, VALUE var){
LightMap *k = getPrivateData<LightMap>(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);
}

View file

@ -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

View file

@ -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(){

View file

@ -33,6 +33,7 @@ public:
void clearDynamicLightSources();
void addStaticLightSource(LightSource source);
void addDynamicLightSource(LightSource source);
void removeStaticLightSource(float x, float y);
void initDynAttribs();
private: