correctly hide humans
This commit is contained in:
parent
2f31e7a55f
commit
a3e2210195
1 changed files with 26 additions and 14 deletions
|
|
@ -50,6 +50,18 @@ class Human {
|
|||
data.adventure_count = data.adventure_count + 1
|
||||
}
|
||||
|
||||
static get_active(entity){
|
||||
if(entity == 0 || !entity) return null
|
||||
var data = Modifiers.get(This, entity)
|
||||
return data.active
|
||||
}
|
||||
|
||||
static set_active(entity, active){
|
||||
if(entity == 0 || !entity) return null
|
||||
var data = Modifiers.get(This, entity)
|
||||
data.active = active
|
||||
}
|
||||
|
||||
} //Human
|
||||
|
||||
//Your modifier system implementation.
|
||||
|
|
@ -114,28 +126,28 @@ class HumanSystem is ModifierSystem {
|
|||
game.focus.value = _hoverEnt
|
||||
}
|
||||
}
|
||||
|
||||
update() //optimisation: consider running this less often
|
||||
} //tick
|
||||
|
||||
update(){
|
||||
if(World.tag_has(_world, "edit")) return
|
||||
|
||||
var size = Vector.new(player_size)
|
||||
var pos = Vector.new(player_start) + size / 2
|
||||
each {|entity, data|
|
||||
if(!data.active){
|
||||
Transform.destroy(entity)
|
||||
Sprite.destroy(entity)
|
||||
return
|
||||
if(Transform.has(entity))Transform.destroy(entity)
|
||||
if(Sprite.has(entity))Sprite.destroy(entity)
|
||||
} else {
|
||||
if(!Transform.has(entity)){
|
||||
Transform.create(entity)
|
||||
}
|
||||
if(!Sprite.has(entity)){
|
||||
Sprite.create(entity, _material, 10, 12)
|
||||
Sprite.set_color(entity, data.color.r, data.color.g, data.color.b, data.color.a)
|
||||
}
|
||||
Transform.set_pos(entity, pos.x, pos.y)
|
||||
pos.x = pos.x + size.x
|
||||
}
|
||||
if(!Transform.has(entity)){
|
||||
Transform.create(entity)
|
||||
}
|
||||
if(!Sprite.has(entity)){
|
||||
Sprite.create(entity, _material, 10, 12)
|
||||
Sprite.set_color(entity, data.color.r, data.color.g, data.color.b, data.color.a)
|
||||
}
|
||||
Transform.set_pos(entity, pos.x, pos.y)
|
||||
pos.x = pos.x + size.x
|
||||
}
|
||||
}
|
||||
} //HumanSystem
|
||||
|
|
|
|||
Loading…
Reference in a new issue