Add AI script code to provide a cleaner API around the engine interface.

Handle AIProxy entirely through scripts.
Support structured clones of script values.
Improve performance.
Support multiple script contexts sharing a runtime.
Use a separate context per AI player.

This was SVN commit r8866.
This commit is contained in:
Ykkrosh
2011-01-15 23:35:20 +00:00
parent dd501b2a5a
commit f39f279132
31 changed files with 834 additions and 434 deletions
@@ -192,3 +192,18 @@ template<> bool ScriptInterface::FromJSVal<CFixedVector2D>(JSContext* cx, jsval
return true;
}
template<> jsval ScriptInterface::ToJSVal<CFixedVector2D>(JSContext* cx, const CFixedVector2D& val)
{
JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
if (!obj)
return JSVAL_VOID;
jsval x = ToJSVal(cx, val.X);
jsval y = ToJSVal(cx, val.Y);
JS_SetProperty(cx, obj, "x", &x);
JS_SetProperty(cx, obj, "y", &y);
return OBJECT_TO_JSVAL(obj);
}