R=R or {}
require("./3d/model")(R)
require("./3d/scene")(R)

local GLOBAL=require("./global")

local SCENE=nil
local MODEL_GMAN=nil
local ACTOR_GMAN=nil
local MAT_GMAN=nil

return {
    bdr=function(y,t,unitT)
        vbank(0)
        R.setRGB(1,GLOBAL.rgbGMan)
    end,
    musicTic=function(isFirstRun,t,unitT)
        if isFirstRun then            
            vbank(1)
            cls(0)

            SCENE=R.Scene:new()

            MODEL_GMAN=R.Model:new()
            MODEL_GMAN:load(require("./data/model/greenman"))

            ACTOR_GMAN=R.Actor:new(MODEL_GMAN)
            ACTOR_GMAN:setDrawFn(R.poly.Draw1Colour(1),0)
            MAT_GMAN=ACTOR_GMAN:getMat()
            MAT_GMAN:mulM44(R.M44:newTrans(0,0,1.5))
            
            SCENE:registerActor(ACTOR_GMAN)
        end

        vbank(0)
        cls(0)
    
--        ACTOR_GMAN:setAnim("walk",unitT*8)
        SCENE:draw()
    end,
}
