fix cyclic dependency
This commit is contained in:
parent
d5147eb33a
commit
a167c92d2c
2 changed files with 15 additions and 16 deletions
|
|
@ -5,9 +5,6 @@ import "math/util" for Util
|
||||||
import "globals" for Globals
|
import "globals" for Globals
|
||||||
import "luxe: assets" for Strings
|
import "luxe: assets" for Strings
|
||||||
import "luxe: input" for Input, MouseButton
|
import "luxe: input" for Input, MouseButton
|
||||||
import "blocks/ui" for Ui
|
|
||||||
|
|
||||||
System.print("ui is: %(Ui)")
|
|
||||||
|
|
||||||
//User facing API
|
//User facing API
|
||||||
//This is what the user of your modifier will interact with
|
//This is what the user of your modifier will interact with
|
||||||
|
|
@ -50,12 +47,12 @@ class Human {
|
||||||
//to do the actual work. You'll get notified when things change
|
//to do the actual work. You'll get notified when things change
|
||||||
//in the world and respond to them here.
|
//in the world and respond to them here.
|
||||||
class HumanSystem is ModifierSystem {
|
class HumanSystem is ModifierSystem {
|
||||||
|
|
||||||
player_start{[26, 89]}
|
player_start{[26, 89]}
|
||||||
player_size{[10, 12]}
|
player_size{[10, 12]}
|
||||||
|
|
||||||
construct new() {
|
construct new() {
|
||||||
//called when your system is first created.
|
//called when your system is first created.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(world) {
|
init(world) {
|
||||||
|
|
@ -80,8 +77,8 @@ class HumanSystem is ModifierSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
tick(delta) {
|
tick(delta) {
|
||||||
//called usually once every frame.
|
//called usually once every frame.
|
||||||
//called when the world that this modifier lives in, is ticked
|
//called when the world that this modifier lives in, is ticked
|
||||||
each {|entity, data|
|
each {|entity, data|
|
||||||
if(!data.active) return
|
if(!data.active) return
|
||||||
|
|
||||||
|
|
@ -92,21 +89,19 @@ class HumanSystem is ModifierSystem {
|
||||||
_hoverEnt = entity
|
_hoverEnt = entity
|
||||||
Globals["Tooltip"].set(Strings.get(data.name), entity)
|
Globals["Tooltip"].set(Strings.get(data.name), entity)
|
||||||
}
|
}
|
||||||
if(Input.mouse_state_pressed(MouseButton.left)){
|
|
||||||
|
|
||||||
var game = Globals["Game"]
|
|
||||||
System.print(Ui)
|
|
||||||
import "blocks/ui" for Ui
|
|
||||||
if(game.ui.ui_mode == Ui.Info){
|
|
||||||
game.Focus.value = entity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(!over && _hoverEnt == entity){
|
if(!over && _hoverEnt == entity){
|
||||||
_hoverEnt = null
|
_hoverEnt = null
|
||||||
Globals["Tooltip"].clear(entity)
|
Globals["Tooltip"].clear(entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Input.mouse_state_pressed(MouseButton.left)){
|
||||||
|
var game = Globals["Game"]
|
||||||
|
if(game.ui.ui_mode == Ui.Info && _hoverEnt){ //remove &&hoverEnt to allow unfocussing
|
||||||
|
game.Focus.value = _hoverEnt
|
||||||
|
}
|
||||||
|
}
|
||||||
} //tick
|
} //tick
|
||||||
|
|
||||||
update(){
|
update(){
|
||||||
|
|
@ -132,3 +127,5 @@ class HumanSystem is ModifierSystem {
|
||||||
} //HumanSystem
|
} //HumanSystem
|
||||||
|
|
||||||
var Modifier = HumanSystem //required
|
var Modifier = HumanSystem //required
|
||||||
|
|
||||||
|
import "blocks/ui" for Ui //import at the end in case of cyclic dependency
|
||||||
|
|
@ -197,4 +197,6 @@ class Ui{
|
||||||
test(){
|
test(){
|
||||||
ImageButton.get_data(_test)
|
ImageButton.get_data(_test)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//this is behind the class def to make cyclic dependency happy lol
|
||||||
|
import "blocks/human/human" for Human
|
||||||
Loading…
Reference in a new issue