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
|
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
|
} //Human
|
||||||
|
|
||||||
//Your modifier system implementation.
|
//Your modifier system implementation.
|
||||||
|
|
@ -114,19 +126,18 @@ class HumanSystem is ModifierSystem {
|
||||||
game.focus.value = _hoverEnt
|
game.focus.value = _hoverEnt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update() //optimisation: consider running this less often
|
||||||
} //tick
|
} //tick
|
||||||
|
|
||||||
update(){
|
update(){
|
||||||
if(World.tag_has(_world, "edit")) return
|
|
||||||
|
|
||||||
var size = Vector.new(player_size)
|
var size = Vector.new(player_size)
|
||||||
var pos = Vector.new(player_start) + size / 2
|
var pos = Vector.new(player_start) + size / 2
|
||||||
each {|entity, data|
|
each {|entity, data|
|
||||||
if(!data.active){
|
if(!data.active){
|
||||||
Transform.destroy(entity)
|
if(Transform.has(entity))Transform.destroy(entity)
|
||||||
Sprite.destroy(entity)
|
if(Sprite.has(entity))Sprite.destroy(entity)
|
||||||
return
|
} else {
|
||||||
}
|
|
||||||
if(!Transform.has(entity)){
|
if(!Transform.has(entity)){
|
||||||
Transform.create(entity)
|
Transform.create(entity)
|
||||||
}
|
}
|
||||||
|
|
@ -138,6 +149,7 @@ class HumanSystem is ModifierSystem {
|
||||||
pos.x = pos.x + size.x
|
pos.x = pos.x + size.x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} //HumanSystem
|
} //HumanSystem
|
||||||
|
|
||||||
var Modifier = HumanSystem //required
|
var Modifier = HumanSystem //required
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue