Jump to content

Identifying self within Flip() [resolved]


Rekindled Phoenix
 Share

Recommended Posts

My goal is to cycle all of the entities, and exclude the object that is invoking the event. The problem is that the function attached to AddHook() doesn't have a reference to the object that attached the hook. Seems the AddHook() function can only be passed a delegate (.Net reference) without parameters.

 

(Since the objects I will be adding are not sorted in order, indexes aren't an option)

 

function class:CreateObject(model)
       local object=self.super:CreateObject(model)

AddHook("Flip", UpdateCycleThru(object)) --fails 

function object:Free(model)
	RemoveHook("Flip", UpdateCycleThru(object)) --fails
	self.super:Free()
       end
end

function UpdateCycleThru(object)
       -- Cycle through nodes applying a draw method, except for self
end

 

So my question is, how does an object identify itself from the rest of the objects within the scene, when the function is called outside of the Class overrides?

 

Looking further into this issue, I may have to cycle through these objects using an external script marshaller...

Link to comment
Share on other sites

Looks like the issue is resolved. Instead of trying to access the within each object, I create a 'marshaller' that does the drawing for the necessary objects.

 

function UpdateCablesCycleThru()
--model,object
for k1,v1 in pairs(objecttable) do
	if v1.type ~= nil then
		if v1.type == NavTypeName then
			local Pos2 = CameraUnproject(fw.main.camera, k1.position)
			DrawPath(Pos2)
		end
	end
end
end

function DrawPath(Pos2) --Used for each object

for k,v in pairs(objecttable) do
	if v.type ~= nil then
		if v.type == NavTypeName then --inherited from 'PhoenixPath'
                               -- Draw elements using both positions
                               local Pos = CameraUnproject(fw.main.camera, k.position)
			DrawLine(Pos2.x, Pos2.y, Pos.x, Pos.y)
		end
	end
end
end

post-214-0-07632800-1308890212_thumb.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...