Files
UnrealLuaDemo/Script/lua/main.lua
T

39 lines
1.8 KiB
Lua
Raw Normal View History

local ____exports = __module.env
local M__share_base_logger = __MODULE__.Import("share.base.logger", __module)
local Logger = M__share_base_logger.Logger
local M__framework_context_game_context = __MODULE__.Import("framework.context.game_context", __module)
local CreateGameInstanceContext = M__framework_context_game_context.CreateGameInstanceContext
local DestroyGameInstanceContext = M__framework_context_game_context.DestroyGameInstanceContext
local GetGameInstanceContext = M__framework_context_game_context.GetGameInstanceContext
local M__game_startup = __MODULE__.Import("game.startup", __module)
local AssembleGameInstanceServices = M__game_startup.AssembleGameInstanceServices
local logger = Logger("Main")
function ____exports.OnInit(gameInstance)
local ctx = CreateGameInstanceContext(gameInstance)
AssembleGameInstanceServices(ctx)
logger:Info("GameInstance initialized", {contextId = ctx.contextId, luaVersion = _VERSION})
return ctx
end
function ____exports.OnTick(gameInstance, deltaSeconds)
local ctx = GetGameInstanceContext(gameInstance)
if ctx ~= nil then
ctx:Tick(deltaSeconds)
end
end
function ____exports.OnWorldCleanup(gameInstance)
local ctx = GetGameInstanceContext(gameInstance)
if ctx ~= nil then
ctx:OnWorldCleanup()
end
end
function ____exports.OnShutdown(gameInstance)
logger:Info("GameInstance shutting down")
DestroyGameInstanceContext(gameInstance)
end
function __module.UpdateImports()
Logger = M__share_base_logger.Logger
CreateGameInstanceContext = M__framework_context_game_context.CreateGameInstanceContext
DestroyGameInstanceContext = M__framework_context_game_context.DestroyGameInstanceContext
GetGameInstanceContext = M__framework_context_game_context.GetGameInstanceContext
AssembleGameInstanceServices = M__game_startup.AssembleGameInstanceServices
end