Purpose of Templates
by Patrick Li · in Torque X 2D · 05/01/2008 (10:25 pm) · 1 replies
Hi,
I just downloaded and read the introduction to Torque X. I'm very impressed with the Component structure that Torque X has set up. However I'm confused about the purpose of the Template system.
To create a whole bunch of the same sort of objects, why can't I just use a static factory method?
ie. Monster createMonster()
-Create BaseActor
-set actor type to Monster
-add components
-return actor
Is there any advantage to using templates?
I just downloaded and read the introduction to Torque X. I'm very impressed with the Component structure that Torque X has set up. However I'm confused about the purpose of the Template system.
To create a whole bunch of the same sort of objects, why can't I just use a static factory method?
ie. Monster createMonster()
-Create BaseActor
-set actor type to Monster
-add components
-return actor
Is there any advantage to using templates?
Torque Owner D. Robert Duke
Secondly, you need to separate your data from your code. Even a small game is going to contain hundreds of data values. Collision poly vectors, linkpoints, materials, names, physics values, etc. The list gets large very quickly. Given the slick XML deserialization TorqueX does there's just no reason not to separate your data. Load your templates from XML, then clone the templates.