0ad/binaries/data/mods/public/simulation/components/tests/setup.js
Ykkrosh 7c2e9027c2 # Rewrite of the game's simulation system
Giant merge from
http://svn.wildfiregames.com/hg-source/file/5fb522019d5e
Infrastructure is largely complete, gameplay is largely missing
Disabled by default; use command-line flag "-sim2"
(Second attempt at commit...)

This was SVN commit r7259.
2010-01-09 19:20:14 +00:00

39 lines
778 B
JavaScript

var g_ComponentTypes = {};
var g_Components = {};
// Emulate some engine functions:
Engine.RegisterComponentType = function(iid, name, ctor)
{
TS_ASSERT(!g_ComponentTypes[name]);
g_ComponentTypes[name] = { iid: iid, ctor: ctor };
}
Engine.QueryInterface = function(ent, iid)
{
if (g_Components[ent] && g_Components[ent][iid])
return g_Components[ent][iid];
return null;
}
// TODO:
// Engine.RegisterGlobal
// Engine.PostMessage
// Engine.BroadcastMessage
global.AddMock = function(ent, iid, mock)
{
if (!g_Components[ent])
g_Components[ent] = {};
g_Components[ent][iid] = mock;
}
global.ConstructComponent = function(ent, name, template)
{
var cmp = new g_ComponentTypes[name].ctor();
cmp.entity = ent;
cmp.template = template;
cmp.Init();
return cmp;
}