mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-02 20:33:54 -04:00
Finish system optimization
This commit is contained in:
parent
424f27ed8a
commit
451b88cdea
3 changed files with 11 additions and 4 deletions
|
@ -199,7 +199,7 @@ print(positionComponent.x, positionComponent.y) -- 100, 50
|
|||
|
||||
```lua
|
||||
-- Remove a Component
|
||||
myEntity:remove(Concord.compoennts.positionComponent)
|
||||
myEntity:remove(Concord.components.positionComponent)
|
||||
```
|
||||
|
||||
```lua
|
||||
|
@ -209,7 +209,7 @@ print(hasPositionComponent) -- false
|
|||
```
|
||||
|
||||
```lua
|
||||
-- Entity:give will override a Component if the Entity already had it
|
||||
-- Entity:give will override a Component if the Entity already has it
|
||||
-- Entity:ensure will only put the Component if the Entity does not already have it
|
||||
|
||||
Entity:ensure(Concord.components.positionComponents, 0, 0) -- Will give
|
||||
|
|
|
@ -29,7 +29,7 @@ System.mt = {
|
|||
-- This grants slightly faster access times at the cost of memory.
|
||||
-- Since there (generally) won't be many instances of worlds this is a worthwhile tradeoff
|
||||
if (System.ENABLE_OPTIMIZATION) then
|
||||
Utils.shallowCopy(System, system)
|
||||
Utils.shallowCopy(systemClass, system)
|
||||
end
|
||||
|
||||
for _, filter in pairs(systemClass.__filter) do
|
||||
|
@ -58,6 +58,13 @@ function System.new(...)
|
|||
}, System.mt)
|
||||
systemClass.__index = systemClass
|
||||
|
||||
-- Optimization: We deep copy the World class into our instance of a world.
|
||||
-- This grants slightly faster access times at the cost of memory.
|
||||
-- Since there (generally) won't be many instances of worlds this is a worthwhile tradeoff
|
||||
if (System.ENABLE_OPTIMIZATION) then
|
||||
Utils.shallowCopy(System, systemClass)
|
||||
end
|
||||
|
||||
return systemClass
|
||||
end
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ function World:emit(functionName, ...)
|
|||
error("bad argument #1 to 'World:emit' (String expected, got "..type(functionName)..")")
|
||||
end
|
||||
|
||||
local listeners = self.events[functionName]
|
||||
local listeners = self.events[functionName]
|
||||
|
||||
if listeners then
|
||||
for i = 1, #listeners do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue