1- atomic = {
1+ atomic = atomic or {
22 meta = {
33 author = " smokingplaya" ,
44 versionName = " Cherry" ,
5- version = " 1.0.0-alpha.5 " ,
5+ version = " 1.0.0-rc.1 " ,
66 },
7- _config = {}
7+ _config = {},
8+ _isGamemodeLoaded = false
89}
910
1011file .CreateDir (" atomic" )
1112
12- local start = SysTime ()
13-
1413local function includeSh (path )
1514 if (SERVER ) then
1615 AddCSLuaFile (path )
@@ -50,11 +49,44 @@ shared("atomic/libraries/package/common.lua")
5049server (" atomic/libraries/mysql.lua" )
5150shared (" atomic/utils/aliases.lua" )
5251
53- local packageLoadingStart = SysTime ()
54-
5552local package = atomic .package
5653local packages = package .find (" atomic/packages" )
54+ --- @type Atomic.Time.Instant
55+ local packageLoadingTime
56+
57+ local function loadPackages ()
58+ package .loadMany (packages )
59+ atomic .log :info (" Atomic Framework %s %s has loaded %s packages for %sms" , atomic .meta .version , atomic .meta .versionName , # packages , packageLoadingTime :elapsed ():as_millis ())
60+ end
61+
62+ local function appendGamemodePackages ()
63+ local gamemode = gmod .GetGamemode ()
64+ local dir = gamemode and gamemode .packageDir
65+ local gamemodePackages = dir and package .find (dir )
66+
67+ if (not gamemodePackages ) then
68+ return
69+ end
5770
58- package .loadMany (packages )
71+ for _ , gamemodePackage in ipairs (gamemodePackages ) do
72+ packages [# packages + 1 ] = gamemodePackage
73+ end
74+ end
75+
76+ local function onGamemodeLoaded ()
77+ atomic ._isGamemodeLoaded = true
78+ packageLoadingTime = Instant ()
79+
80+ appendGamemodePackages ()
81+ loadPackages ()
82+ end
83+
84+ local function init ()
85+ if (atomic ._isGamemodeLoaded ) then
86+ onGamemodeLoaded ()
87+ else
88+ hook .Add (" OnGamemodeLoaded" , " atomic:" .. atomic .meta .version , onGamemodeLoaded )
89+ end
90+ end
5991
60- atomic . log : info ( " Atomic Framework %s %s has been loaded for %sms (%s packages loaded for %sms) " , atomic . meta . version , atomic . meta . versionName , math.floor (( SysTime () - start ) * 1000 + 0.5 ), # atomic . package . _list , math.floor (( SysTime () - packageLoadingStart ) * 1000 + 0.5 ) )
92+ init ( )
0 commit comments