mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
light removing
This commit is contained in:
parent
ec7ee84470
commit
fa75eb2a8f
4 changed files with 33 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(){
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public:
|
|||
void clearDynamicLightSources();
|
||||
void addStaticLightSource(LightSource source);
|
||||
void addDynamicLightSource(LightSource source);
|
||||
void removeStaticLightSource(float x, float y);
|
||||
void initDynAttribs();
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Reference in a new issue