Skip to content

Commit 82f52a1

Browse files
authored
merge 1.0.0-rc.1
Merge pull request #22 from TeamMeadows/develop
2 parents c397d59 + 303dbe6 commit 82f52a1

2 files changed

Lines changed: 52 additions & 9 deletions

File tree

lua/atomic/libraries/package/class.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ function Package:include(side, files)
169169
end
170170

171171
local include = atomic.loader[side]
172+
local gamemode = gmod.GetGamemode()
173+
local isGamemodePackage = self._metadata._path:Split("/")[1] == gamemode.FolderName
172174

173175
if (not include) then
174176
return self.logger:err("unknown include side `%s`", side)
@@ -177,10 +179,19 @@ function Package:include(side, files)
177179
local dir = self._metadata.files.dir
178180
dir = dir and dir .. "/" or ""
179181

182+
if (isGamemodePackage) then
183+
GM = gamemode -- -\(3_3)/-
184+
end
185+
180186
for _, filename in ipairs(files) do
181187
filename = (filename:sub(-4) == ".lua" and filename or filename .. ".lua")
182188
include(self._metadata._path .. "/" .. dir .. filename)
183189
end
190+
191+
if (isGamemodePackage) then
192+
---@diagnostic disable-next-line
193+
GM = nil
194+
end
184195
end
185196

186197
---@private

lua/autorun/atomic_autorun.lua

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
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

1011
file.CreateDir("atomic")
1112

12-
local start = SysTime()
13-
1413
local function includeSh(path)
1514
if (SERVER) then
1615
AddCSLuaFile(path)
@@ -50,11 +49,44 @@ shared("atomic/libraries/package/common.lua")
5049
server("atomic/libraries/mysql.lua")
5150
shared("atomic/utils/aliases.lua")
5251

53-
local packageLoadingStart = SysTime()
54-
5552
local package = atomic.package
5653
local 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

Comments
 (0)