Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "AGSDelegate.h"
- #include <string>
- AGSDelegate::AGSDelegate(IAGSEngine *engine)
- {
- _engine = engine;
- }
- AGSDelegate::AGSDelegate(IAGSEngine *engine, const char* name)
- {
- _engine = engine;
- _functionName = name;
- }
- AGSDelegate::~AGSDelegate(void)
- {
- if (_functionName) delete _functionName;
- }
- void AGSDelegate::Run()
- {
- if (_functionName != 0)_engine->QueueGameScriptFunction(_functionName, 1, 0);
- }
- int AGSDelegate::Serialize(char *buffer)
- {
- size_t length = strlen(_functionName) + 1;
- memcpy(buffer, _functionName, length);
- return length;
- }
- ManagedAGSDelegateInterface::ManagedAGSDelegateInterface(void)
- {
- }
- int ManagedAGSDelegateInterface::Dispose(const char *address, bool force)
- {
- delete address; // free the memory and return 1 to tell AGS we did.
- return 1;
- }
- const char *ManagedAGSDelegateInterface::GetType()
- {
- return typeName;
- }
- int ManagedAGSDelegateInterface::Serialize(const char *address, char *buffer, int bufsize)
- {
- AGSDelegate *del = (AGSDelegate *)address;
- return del->Serialize(buffer);
- }
- const char* ManagedAGSDelegateInterface::typeName = "Delegate";
- ManagedAGSDelegateReader::ManagedAGSDelegateReader(IAGSEngine *engine, ManagedAGSDelegateInterface *theInterface)
- {
- _engine = engine;
- _interface = theInterface;
- }
- void ManagedAGSDelegateReader::Unserialize(int key, const char *serializedData, int dataSize)
- {
- AGSDelegate *del = new AGSDelegate(_engine, serializedData);
- _engine->RegisterUnserializedObject(key, del, _interface);
- }
Add Comment
Please, Sign In to add comment