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,19 +126,18 @@ 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)
|
||||
}
|
||||
|
|
@ -138,6 +149,7 @@ class HumanSystem is ModifierSystem {
|
|||
pos.x = pos.x + size.x
|
||||
}
|
||||
}
|
||||
}
|
||||
} //HumanSystem
|
||||
|
||||
var Modifier = HumanSystem //required
|
||||
|
|
|
|||
Loading…
Reference in a new issue