mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-22 01:05:29 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user