|
@@ -62,127 +62,91 @@ public:
|
|
|
/// Register object factory.
|
|
/// Register object factory.
|
|
|
static void RegisterObject(Context* context);
|
|
static void RegisterObject(Context* context);
|
|
|
|
|
|
|
|
- ///// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
|
|
|
|
|
|
|
+ /// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
|
|
|
virtual void ApplyAttributes();
|
|
virtual void ApplyAttributes();
|
|
|
|
|
|
|
|
- /// Create script object.
|
|
|
|
|
|
|
+ /// Create script object. Return true if successful.
|
|
|
bool CreateObject(const String& scriptObjectType);
|
|
bool CreateObject(const String& scriptObjectType);
|
|
|
-
|
|
|
|
|
- /// Create script object.
|
|
|
|
|
|
|
+ /// Create script object. Return true if successful.
|
|
|
bool CreateObject(const String& scriptFileName, const String& scriptObjectType);
|
|
bool CreateObject(const String& scriptFileName, const String& scriptObjectType);
|
|
|
-
|
|
|
|
|
/// Set script file name.
|
|
/// Set script file name.
|
|
|
void SetScriptFileName(const String& scriptFileName);
|
|
void SetScriptFileName(const String& scriptFileName);
|
|
|
-
|
|
|
|
|
/// Set script object type.
|
|
/// Set script object type.
|
|
|
void SetScriptObjectType(const String& scriptObjectType);
|
|
void SetScriptObjectType(const String& scriptObjectType);
|
|
|
-
|
|
|
|
|
/// Set script file serialization attribute by calling a script function.
|
|
/// Set script file serialization attribute by calling a script function.
|
|
|
void SetScriptDataAttr(PODVector<unsigned char> data);
|
|
void SetScriptDataAttr(PODVector<unsigned char> data);
|
|
|
-
|
|
|
|
|
/// Set script network serialization attribute by calling a script function.
|
|
/// Set script network serialization attribute by calling a script function.
|
|
|
void SetScriptNetworkDataAttr(PODVector<unsigned char> data);
|
|
void SetScriptNetworkDataAttr(PODVector<unsigned char> data);
|
|
|
-
|
|
|
|
|
/// Script subscribe to an event that can by send by any sender.
|
|
/// Script subscribe to an event that can by send by any sender.
|
|
|
void ScriptSubscribeToEvent(const String& eventName, const String& functionName);
|
|
void ScriptSubscribeToEvent(const String& eventName, const String& functionName);
|
|
|
-
|
|
|
|
|
/// Script unsubscribe from an event.
|
|
/// Script unsubscribe from an event.
|
|
|
void ScriptUnsubscribeFromEvent(const String& eventName);
|
|
void ScriptUnsubscribeFromEvent(const String& eventName);
|
|
|
-
|
|
|
|
|
/// Script unsubscribe from all events.
|
|
/// Script unsubscribe from all events.
|
|
|
void ScriptUnsubscribeFromAllEvents();
|
|
void ScriptUnsubscribeFromAllEvents();
|
|
|
-
|
|
|
|
|
/// Script subscribe to a specific sender's event.
|
|
/// Script subscribe to a specific sender's event.
|
|
|
void ScriptSubscribeToEvent(void* sender, const String& eventName, const String& functionName);
|
|
void ScriptSubscribeToEvent(void* sender, const String& eventName, const String& functionName);
|
|
|
-
|
|
|
|
|
/// Script unsubscribe from a specific sender's event.
|
|
/// Script unsubscribe from a specific sender's event.
|
|
|
void ScriptUnsubscribeFromEvent(void* sender, const String& eventName);
|
|
void ScriptUnsubscribeFromEvent(void* sender, const String& eventName);
|
|
|
-
|
|
|
|
|
/// Script unsubscribe from a specific sender's all events.
|
|
/// Script unsubscribe from a specific sender's all events.
|
|
|
void ScriptUnsubscribeFromEvents(void* sender);
|
|
void ScriptUnsubscribeFromEvents(void* sender);
|
|
|
-
|
|
|
|
|
- /// Execute a script object function with parameters. Return true if successful.
|
|
|
|
|
- bool Execute(const String& functionName, const VariantVector& parameters);
|
|
|
|
|
|
|
+ /// Execute a script object function. Parameters can be supplied in a VariantVector. Return true if successful.
|
|
|
|
|
+ bool ExecuteFunction(const String& functionName, const VariantVector& parameters = Variant::emptyVariantVector);
|
|
|
|
|
|
|
|
/// Return script file name.
|
|
/// Return script file name.
|
|
|
const String& GetScriptFileName() const { return scriptFileName_; }
|
|
const String& GetScriptFileName() const { return scriptFileName_; }
|
|
|
-
|
|
|
|
|
/// Return script object type.
|
|
/// Return script object type.
|
|
|
const String& GetScriptObjectType() const { return scriptObjectType_; }
|
|
const String& GetScriptObjectType() const { return scriptObjectType_; }
|
|
|
-
|
|
|
|
|
/// Return script object ref.
|
|
/// Return script object ref.
|
|
|
int GetScriptObjectRef() const { return scriptObjectRef_; }
|
|
int GetScriptObjectRef() const { return scriptObjectRef_; }
|
|
|
-
|
|
|
|
|
/// Get script file serialization attribute by calling a script function.
|
|
/// Get script file serialization attribute by calling a script function.
|
|
|
PODVector<unsigned char> GetScriptDataAttr() const;
|
|
PODVector<unsigned char> GetScriptDataAttr() const;
|
|
|
-
|
|
|
|
|
/// Get script network serialization attribute by calling a script function.
|
|
/// Get script network serialization attribute by calling a script function.
|
|
|
PODVector<unsigned char> GetScriptNetworkDataAttr() const;
|
|
PODVector<unsigned char> GetScriptNetworkDataAttr() const;
|
|
|
|
|
|
|
|
private:
|
|
private:
|
|
|
/// Find script object method refs.
|
|
/// Find script object method refs.
|
|
|
void FindScriptObjectMethodRefs();
|
|
void FindScriptObjectMethodRefs();
|
|
|
-
|
|
|
|
|
/// Handle the logic update event.
|
|
/// Handle the logic update event.
|
|
|
void HandleUpdate(StringHash eventType, VariantMap& eventData);
|
|
void HandleUpdate(StringHash eventType, VariantMap& eventData);
|
|
|
-
|
|
|
|
|
/// Handle the logic post update event.
|
|
/// Handle the logic post update event.
|
|
|
void HandlePostUpdate(StringHash eventType, VariantMap& eventData);
|
|
void HandlePostUpdate(StringHash eventType, VariantMap& eventData);
|
|
|
-
|
|
|
|
|
/// Handle the physics update event.
|
|
/// Handle the physics update event.
|
|
|
void HandleFixedUpdate(StringHash eventType, VariantMap& eventData);
|
|
void HandleFixedUpdate(StringHash eventType, VariantMap& eventData);
|
|
|
-
|
|
|
|
|
/// Handle the physics post update event.
|
|
/// Handle the physics post update event.
|
|
|
void HandlePostFixedUpdate(StringHash eventType, VariantMap& eventData);
|
|
void HandlePostFixedUpdate(StringHash eventType, VariantMap& eventData);
|
|
|
-
|
|
|
|
|
/// Handle event.
|
|
/// Handle event.
|
|
|
void HandleEvent(StringHash eventType, VariantMap& eventData);
|
|
void HandleEvent(StringHash eventType, VariantMap& eventData);
|
|
|
-
|
|
|
|
|
/// Handle a specific sender's event.
|
|
/// Handle a specific sender's event.
|
|
|
void HandleObjectEvent(StringHash eventType, VariantMap& eventData);
|
|
void HandleObjectEvent(StringHash eventType, VariantMap& eventData);
|
|
|
-
|
|
|
|
|
/// Release the script object.
|
|
/// Release the script object.
|
|
|
void ReleaseObject();
|
|
void ReleaseObject();
|
|
|
-
|
|
|
|
|
/// Call script object function.
|
|
/// Call script object function.
|
|
|
void CallScriptObjectFunction(int functionRef);
|
|
void CallScriptObjectFunction(int functionRef);
|
|
|
-
|
|
|
|
|
/// Call script object function.
|
|
/// Call script object function.
|
|
|
void CallScriptObjectFunction(int functionRef, float timeStep);
|
|
void CallScriptObjectFunction(int functionRef, float timeStep);
|
|
|
-
|
|
|
|
|
/// Call script object function.
|
|
/// Call script object function.
|
|
|
void CallScriptObjectFunction(int functionRef, Deserializer& deserializer);
|
|
void CallScriptObjectFunction(int functionRef, Deserializer& deserializer);
|
|
|
-
|
|
|
|
|
/// Call script object function.
|
|
/// Call script object function.
|
|
|
void CallScriptObjectFunction(int functionRef, Serializer& serializer) const;
|
|
void CallScriptObjectFunction(int functionRef, Serializer& serializer) const;
|
|
|
-
|
|
|
|
|
/// Call script object function.
|
|
/// Call script object function.
|
|
|
void CallScriptObjectFunction(int functionRef, StringHash eventType, VariantMap& eventData);
|
|
void CallScriptObjectFunction(int functionRef, StringHash eventType, VariantMap& eventData);
|
|
|
-
|
|
|
|
|
/// Call script object function with arbitrary parameters.
|
|
/// Call script object function with arbitrary parameters.
|
|
|
bool CallScriptObjectFunction(int functionRef, const VariantVector& parameters);
|
|
bool CallScriptObjectFunction(int functionRef, const VariantVector& parameters);
|
|
|
-
|
|
|
|
|
- // Lua Script.
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Lua Script subsystem.
|
|
|
LuaScript* luaScript_;
|
|
LuaScript* luaScript_;
|
|
|
-
|
|
|
|
|
/// Lua state.
|
|
/// Lua state.
|
|
|
lua_State* luaState_;
|
|
lua_State* luaState_;
|
|
|
-
|
|
|
|
|
/// Script file name.
|
|
/// Script file name.
|
|
|
String scriptFileName_;
|
|
String scriptFileName_;
|
|
|
-
|
|
|
|
|
/// Script object type.
|
|
/// Script object type.
|
|
|
String scriptObjectType_;
|
|
String scriptObjectType_;
|
|
|
-
|
|
|
|
|
/// Script object ref.
|
|
/// Script object ref.
|
|
|
int scriptObjectRef_;
|
|
int scriptObjectRef_;
|
|
|
-
|
|
|
|
|
/// Script object method refs.
|
|
/// Script object method refs.
|
|
|
int scriptObjectMethodRefs_[MAX_LUA_SCRIPT_OBJECT_METHODS];
|
|
int scriptObjectMethodRefs_[MAX_LUA_SCRIPT_OBJECT_METHODS];
|
|
|
-
|
|
|
|
|
/// Event type to function ref map.
|
|
/// Event type to function ref map.
|
|
|
HashMap<StringHash, int> eventTypeToFunctionRefMap_;
|
|
HashMap<StringHash, int> eventTypeToFunctionRefMap_;
|
|
|
-
|
|
|
|
|
/// Object to event type to function ref map.
|
|
/// Object to event type to function ref map.
|
|
|
HashMap<Object*, HashMap<StringHash, int> > objectToEventTypeToFunctionRefMap_;
|
|
HashMap<Object*, HashMap<StringHash, int> > objectToEventTypeToFunctionRefMap_;
|
|
|
};
|
|
};
|