NETManaged.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include <ThirdParty/SDL/include/SDL.h>
  2. #include <Atomic/IO/FileSystem.h>
  3. #include <Atomic/IO/Log.h>
  4. #include <Atomic/Core/StringUtils.h>
  5. #include "NETCore.h"
  6. #include "NETManaged.h"
  7. #include "CSEventHelper.h"
  8. #include "CSComponent.h"
  9. namespace Atomic
  10. {
  11. NETManaged::NETManaged(Context* context) :
  12. Object(context),
  13. CSComponentCreate_(0),
  14. CSComponentApplyFields_(0),
  15. CSComponentCallMethod_(0),
  16. CSBeginSendEvent_(0),
  17. NETUpdate_(0)
  18. {
  19. }
  20. NETManaged::~NETManaged()
  21. {
  22. }
  23. bool NETManaged::Initialize()
  24. {
  25. NETCore* core = GetSubsystem<NETCore>();
  26. core->CreateDelegate("AtomicNETEngine", "AtomicEngine.ComponentCore", "CSComponentCreate", (void**) &CSComponentCreate_);
  27. core->CreateDelegate("AtomicNETEngine", "AtomicEngine.ComponentCore", "CSComponentApplyFields", (void**) &CSComponentApplyFields_);
  28. core->CreateDelegate("AtomicNETEngine", "AtomicEngine.NativeCore", "NETUpdate", (void**) &NETUpdate_);
  29. return true;
  30. }
  31. void NETManaged::NETUpdate(float timeStep)
  32. {
  33. if (!NETUpdate_)
  34. return;
  35. NETUpdate_(timeStep);
  36. }
  37. CSComponent* NETManaged::CSComponentCreate(const String& assemblyName, const String& componentName)
  38. {
  39. if (!CSComponentCreate_)
  40. return 0;
  41. return CSComponentCreate_(assemblyName.CString(), componentName.CString());
  42. }
  43. void NETManaged::CSComponentApplyFields(CSComponent* component, NETVariantMap* fieldMapPtr)
  44. {
  45. if (!CSComponentApplyFields_ || !component || !fieldMapPtr)
  46. return;
  47. CSComponentApplyFields_(component, fieldMapPtr);
  48. }
  49. void NETManaged::CSComponentCallMethod(unsigned id, CSComponentMethod methodID, float value)
  50. {
  51. if (!CSComponentCallMethod_)
  52. return;
  53. CSComponentCallMethod_(id, methodID, value);
  54. }
  55. void NETManaged::CSBeginSendEvent(unsigned senderRefID, unsigned eventType, VariantMap* eventData)
  56. {
  57. if (!CSBeginSendEvent_)
  58. return;
  59. CSBeginSendEvent_(senderRefID, eventType, eventData);
  60. }
  61. }