Exit-9B / CustomSkills

MIT License
5 stars 6 forks source link

Plugin API #11

Closed Exit-9B closed 7 months ago

Exit-9B commented 8 months ago

Usage:

class PluginAPIStorage
{
public:
    static PluginAPIStorage& get()
    {
        static PluginAPIStorage singleton{};
        return singleton;
    }

    CustomSkills::CustomSkillsInterface* customSkills;
};

inline CustomSkills::CustomSkillsInterface* GetCustomSkillsInterface()
{
    return PluginAPIStorage::get().customSkills;
}

extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Load(const SKSE::LoadInterface* a_skse)
{
    InitializeLog();
    logger::info("{} v{}"sv, Plugin::NAME, Plugin::VERSION.string());

    SKSE::Init(a_skse);

    SKSE::GetMessagingInterface()->RegisterListener("CustomSkills", [](auto msg)
    {
        CustomSkills::QueryCustomSkillsInterface(msg, PluginAPIStorage::get().customSkills);
    });

    return true;
}