afxScriptEvent.cpp 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #include "afx/arcaneFX.h"
  25. #include "console/consoleTypes.h"
  26. #include "core/stream/bitStream.h"
  27. #include "afx/ce/afxScriptEvent.h"
  28. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  29. // afxScriptEventData
  30. IMPLEMENT_CO_DATABLOCK_V1(afxScriptEventData);
  31. ConsoleDocClass( afxScriptEventData,
  32. "@brief A datablock that specifies a Script Event effect.\n\n"
  33. "Arbitrary script functions can be called as an AFX effect using afxScriptEventData. They are useful for implementing "
  34. "high-level scripted side-effects such as character resurrection or teleportation."
  35. "\n\n"
  36. "@ingroup afxEffects\n"
  37. "@ingroup AFX\n"
  38. "@ingroup Datablocks\n"
  39. );
  40. afxScriptEventData::afxScriptEventData()
  41. {
  42. method_name = ST_NULLSTRING;
  43. script_data = ST_NULLSTRING;
  44. }
  45. afxScriptEventData::afxScriptEventData(const afxScriptEventData& other, bool temp_clone) : GameBaseData(other, temp_clone)
  46. {
  47. method_name = other.method_name;
  48. script_data = other.script_data;
  49. }
  50. #define myOffset(field) Offset(field, afxScriptEventData)
  51. void afxScriptEventData::initPersistFields()
  52. {
  53. addField("methodName", TypeString, myOffset(method_name),
  54. "The name of a script method defined for the instance class of an effects "
  55. "choreographer. The arguments used to call this method are determined by the type "
  56. "of choreographer.");
  57. addField("scriptData", TypeString, myOffset(script_data),
  58. "An arbitrary blind data value which is passed in as an argument of the script event "
  59. "method. The value of scriptData can be used to differentiate uses when handling "
  60. "different script event effects with a single method.");
  61. Parent::initPersistFields();
  62. }
  63. void afxScriptEventData::packData(BitStream* stream)
  64. {
  65. Parent::packData(stream);
  66. stream->writeString(method_name);
  67. stream->writeString(script_data);
  68. }
  69. void afxScriptEventData::unpackData(BitStream* stream)
  70. {
  71. Parent::unpackData(stream);
  72. method_name = stream->readSTString();
  73. script_data = stream->readSTString();
  74. }
  75. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//