From a167c92d2c7236c645c4b21073f0349706671716 Mon Sep 17 00:00:00 2001 From: Ronja Date: Sun, 6 Sep 2020 17:04:34 +0200 Subject: [PATCH] fix cyclic dependency --- Luxe/blocks/human/human.wren | 27 ++++++++++++--------------- Luxe/blocks/ui.wren | 4 +++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Luxe/blocks/human/human.wren b/Luxe/blocks/human/human.wren index 23b1448..d9af71a 100644 --- a/Luxe/blocks/human/human.wren +++ b/Luxe/blocks/human/human.wren @@ -5,9 +5,6 @@ import "math/util" for Util import "globals" for Globals import "luxe: assets" for Strings import "luxe: input" for Input, MouseButton -import "blocks/ui" for Ui - -System.print("ui is: %(Ui)") //User facing API //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 //in the world and respond to them here. class HumanSystem is ModifierSystem { - player_start{[26, 89]} player_size{[10, 12]} construct new() { //called when your system is first created. + } init(world) { @@ -80,8 +77,8 @@ class HumanSystem is ModifierSystem { } tick(delta) { - //called usually once every frame. - //called when the world that this modifier lives in, is ticked + //called usually once every frame. + //called when the world that this modifier lives in, is ticked each {|entity, data| if(!data.active) return @@ -92,21 +89,19 @@ class HumanSystem is ModifierSystem { _hoverEnt = 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){ _hoverEnt = null 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 update(){ @@ -132,3 +127,5 @@ class HumanSystem is ModifierSystem { } //HumanSystem var Modifier = HumanSystem //required + +import "blocks/ui" for Ui //import at the end in case of cyclic dependency \ No newline at end of file diff --git a/Luxe/blocks/ui.wren b/Luxe/blocks/ui.wren index ede4812..8dc54f4 100644 --- a/Luxe/blocks/ui.wren +++ b/Luxe/blocks/ui.wren @@ -197,4 +197,6 @@ class Ui{ test(){ ImageButton.get_data(_test) } -} \ No newline at end of file +} +//this is behind the class def to make cyclic dependency happy lol +import "blocks/human/human" for Human \ No newline at end of file