/******************************************************************************
*	File		-	world_api.h
*	Author		-	Joey Pollack
*	Date		-	2022/11/21 (y/m/d)
*	Mod Date	-	2022/11/21 (y/m/d)
*	Description	-	The scripting api for the world interface
******************************************************************************/

#ifndef LUNARIUM_WORLD_API_H_
#define LUNARIUM_WORLD_API_H_

#include <core/common_defs.h>
#include <scripting/wren_state.h>
#include <scripting/wren_script.h>
#include <utils/op_res.h>

namespace lunarium
{
    class WorldAPI
    {
        friend class World;

    public:
        struct ScriptEventHandles
        {
            WrenHandle* mWIHandle;

            WrenHandle* mWIInitMethod;
            WrenHandle* mWIDoOnLoadMethod;
            WrenHandle* mWIDoOnUnloadMethod;
            WrenHandle* mWIUpdateMethod;
        };

        enum class Event
        {
            ON_LOAD,
            ON_UNLOAD,
            ON_UPDATE,
        };

    public:
        static OpRes Initialize(World* pWorld);
        static void Shutdown();

        static void RunScript(WrenScript& script);
        static void InvokeEvent(Event e, ...);

    private: // SCRIPTING API
        static void GetVelocityComponent(WrenVM* vm);

        // Foreign classes
        

    private:
        static WrenState mScriptState;
        static World* mpWorld;
        static ScriptEventHandles mEventHandles;
    };
}

#endif	// LUNARIUM_WORLD_API_H_