mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-03 04:43:56 -04:00
Add resources to world
- setResource(name, resource) to set a resource - getResource(name) to retrieve it
This commit is contained in:
parent
9bccd05019
commit
429a448ab6
1 changed files with 18 additions and 0 deletions
|
@ -36,6 +36,8 @@ function World.new()
|
||||||
__events = {},
|
__events = {},
|
||||||
__emitSDepth = 0,
|
__emitSDepth = 0,
|
||||||
|
|
||||||
|
__resources = {},
|
||||||
|
|
||||||
__hash = {
|
__hash = {
|
||||||
state = -2^53,
|
state = -2^53,
|
||||||
generator = defaultGenerator,
|
generator = defaultGenerator,
|
||||||
|
@ -474,6 +476,22 @@ end
|
||||||
function World:onEntityRemoved(e) -- luacheck: ignore
|
function World:onEntityRemoved(e) -- luacheck: ignore
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets a named resource in the world
|
||||||
|
-- @string name Name of the resource
|
||||||
|
-- @tparam Any resource Resource to set
|
||||||
|
-- @treturn World self
|
||||||
|
function World:setResource(name, resource)
|
||||||
|
self.__resources[name] = resource
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets a named resource from the world
|
||||||
|
-- @string name Name of the resource
|
||||||
|
-- @treturn Any resource
|
||||||
|
function World:getResource(name)
|
||||||
|
return self.__resources[name]
|
||||||
|
end
|
||||||
|
|
||||||
return setmetatable(World, {
|
return setmetatable(World, {
|
||||||
__call = function(_, ...)
|
__call = function(_, ...)
|
||||||
---@diagnostic disable-next-line: redundant-parameter
|
---@diagnostic disable-next-line: redundant-parameter
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue