/******************************************************************************
*	File		-	world_interface.wren
*	Author		-	Joey Pollack
*	Date		-	2022/11/16 (y/m/d)
*	Mod Date	-	2022/11/16 (y/m/d)
*	Description	-	The main interface for scripts to interact with the game world
******************************************************************************/

import "Components" for VelocityComponent, BlockOutComponent

// Manages all of the EntityBehaviors
class WorldInterface {

     static Init() {
        __Behaviors = []
        System.print("WorldInterface initialized")
    }

    /////////////////////////////////////////////////////////////////////
    //				EVENTS
    /////////////////////////////////////////////////////////////////////

    static RegisterBehavior(behavior) {
        __Behaviors.add(behavior)
        // behavior.OnLoad()
    }

    static DoOnLoad() {
        for (behavior in __Behaviors) {
            behavior.OnLoad()
        }
    }

    static DoOnUnload() {
        for (behavior in __Behaviors) {
            behavior.OnUnload()
        }
    }

    static Update(dt) {
        //System.print("Updating %(__Behaviors.count) behaviors...")
        for (behavior in __Behaviors) {
            behavior.Update(dt)
        }
    }

    /////////////////////////////////////////////////////////////////////
    //				API
    /////////////////////////////////////////////////////////////////////

    static GetVelocityComponent(entity_id) {
        return VelocityComponent.new(entity_id)
    }

    static GetBlockOutComponent(entity_id) {
        return BlockOutComponent.new(entity_id)
    }
}



class EntityBehavior {

    EntityID { _EntityID }
    EntityID=(value) {
        _EntityID = value
    }

    OnLoad() {

    }

    OnUnload() {

    }

    Update(dt) {

    }
}

//WorldInterface.Init()