Jippie! Finally got the Sub Statemachine declaration understandable for end-users.

Reworked the hierarchical state machine processing in terms of sub
processing.
Now, the declaration and usage of subs is completely understandable and
easy to implement.
I am excited to see how end-users will see the possibilities.
This commit is contained in:
FlightControl
2016-11-22 08:45:38 +01:00
parent 07f6760039
commit 2f4eb39156
13 changed files with 296 additions and 179 deletions

View File

@@ -116,9 +116,18 @@ function BASE:New()
self.__index = self
_ClassID = _ClassID + 1
self.ClassID = _ClassID
return self
end
function BASE:_Destructor()
--self:E("_Destructor")
self:EventRemoveAll()
end
--- This is the worker method to inherit from a parent class.
-- @param #BASE self
-- @param Child is the Child class that inherits.
@@ -131,6 +140,22 @@ function BASE:Inherit( Child, Parent )
if Child ~= nil then
setmetatable( Child, Parent )
Child.__index = Child
local proxy = newproxy(true)
local proxyMeta = getmetatable(proxy)
proxyMeta.__gc = function ()
-- env.info("In __gc for " .. Child:GetClassNameAndID() )
if Child._Destructor then
Child:_Destructor()
end
end
-- keep the userdata from newproxy reachable until the object
-- table is about to be garbage-collected - then the __gc hook
-- will be invoked and the destructor called
rawset(Child, '__proxy', proxy)
end
--self:T( 'Inherited from ' .. Parent.ClassName )
return Child