From c046bde701480f4ba0fbf87ac170aac8541674c7 Mon Sep 17 00:00:00 2001 From: bakpakin Date: Sat, 28 Mar 2015 22:54:34 +0800 Subject: [PATCH] Remove dependency on IDs in Systems and Entities. This allows Systems to be reused in multiple worlds. Fix a few bugs. Remove World:change(...) --- jojo.lua | 117 ++++++++++++++++++++++----------------------------- jojotest.lua | 2 +- 2 files changed, 51 insertions(+), 68 deletions(-) diff --git a/jojo.lua b/jojo.lua index b0becf9..9486495 100644 --- a/jojo.lua +++ b/jojo.lua @@ -1,15 +1,17 @@ local jojo = { - _VERSION = "0.0.2", - _URL = "https://github.com/bakpakin/Jojo" + _VERSION = "0.0.3", + _URL = "https://github.com/bakpakin/Jojo", + _DESCRIPTION = "Entity Component System for lua." } -- Simplified class implementation with no inheritance or polymorphism. local setmetatable = setmetatable -local function class() +local function class(name) local c = {} local mt = {} setmetatable(c, mt) c.__index = c + c.name = name function mt.__call(_, ...) local newobj = {} setmetatable(newobj, c) @@ -21,9 +23,9 @@ local function class() return c end -local World = class() -local Aspect = class() -local System = class() +local World = class("World") +local Aspect = class("Aspect") +local System = class("System") jojo.World = World jojo.Aspect = Aspect @@ -168,8 +170,6 @@ end ----- System ----- -System.nextID = 0 - -- System(preupdate, update, [aspect, addCallback, removeCallback]) -- Creates a new System with the given aspect and update callback. The update @@ -186,15 +186,10 @@ function System:init(preupdate, update, aspect, add, remove) self.active = true self.add = add self.remove = remove - local id = System.nextID - self.id = id - System.nextID = id + 1 end function System:__tostring() - return "JojoSystem