import "luxe: world" for Entity, Transform, Sprite import "globals" for Globals import "luxe: containers" for Lists import "math/observable" for Observable import "math/vector" for Vector import "math/util" for Util class Human{ active{_active} active=(value){ _active = value if(!__activeHumans) __activeHumans = Observable.new([]) if(value){ show() _changeToken = __activeHumans.on_change{|x| update()} __activeHumans.value.add(this) __activeHumans.emit() } else { hide() _changeToken.discard() Lists.remove(__activeHumans.value, this) __activeHumans.emit() } } name{_name} name=(value){ _name = value } adventure_count{_adventure_count} entity{_entity} color=(value){ _color = value } construct new(){ _active = false _name = "unnamed" _adventure_count = 0 color = [1, 1, 1, 1] _material = Util.material_from_image_path("assets/wip/Human") } show(){ _entity = Entity.create(Globals["Game"].app.world, name) Transform.create(_entity) Sprite.create(_entity, _material, 10, 12) Sprite.set_color(_entity, _color.r, _color.g, _color.b, _color.a) } hide(){ Entity.destroy(_entity) } update(){ var index = __activeHumans.value.indexOf(this) var pos = PlayerStart + PlayerSize.y0() / 2 + PlayerSize.y0() * index Transform.set_pos(_entity, pos.x, pos.y) } dispose(){ active = false } } var PlayerStart:Vector = Vector.new(26, 89) var PlayerSize:Vector = Vector.new(10, 12)