Jelajahi Sumber

Merge with next

seanpaultaylor 11 tahun lalu
induk
melakukan
2ea76bc191
100 mengubah file dengan 2970 tambahan dan 3084 penghapusan
  1. 1 0
      .gitignore
  2. 9 104
      gameplay/CMakeLists.txt
  3. 4 52
      gameplay/android/jni/Android.mk
  4. 13 104
      gameplay/gameplay.vcxproj
  5. 20 296
      gameplay/gameplay.vcxproj.filters
  6. 28 342
      gameplay/gameplay.xcodeproj/project.pbxproj
  7. 13 0
      gameplay/res/shaders/terrain.frag
  8. 3 5
      gameplay/src/AIAgent.cpp
  9. 2 2
      gameplay/src/AIAgent.h
  10. 11 6
      gameplay/src/AIState.cpp
  11. 1 2
      gameplay/src/AIState.h
  12. 1 0
      gameplay/src/AIStateMachine.h
  13. 19 104
      gameplay/src/AnimationClip.cpp
  14. 17 77
      gameplay/src/AnimationClip.h
  15. 1 1
      gameplay/src/Base.h
  16. 2 2
      gameplay/src/Button.cpp
  17. 7 2
      gameplay/src/Button.h
  18. 5 5
      gameplay/src/CheckBox.cpp
  19. 10 5
      gameplay/src/CheckBox.h
  20. 5 5
      gameplay/src/Container.cpp
  21. 10 5
      gameplay/src/Container.h
  22. 9 9
      gameplay/src/Control.cpp
  23. 14 7
      gameplay/src/Control.h
  24. 4 2
      gameplay/src/ControlFactory.cpp
  25. 10 2
      gameplay/src/DebugNew.cpp
  26. 34 8
      gameplay/src/FileSystem.cpp
  27. 17 0
      gameplay/src/FileSystem.h
  28. 5 6
      gameplay/src/Form.cpp
  29. 10 5
      gameplay/src/Form.h
  30. 213 51
      gameplay/src/Game.cpp
  31. 28 33
      gameplay/src/Game.h
  32. 6 6
      gameplay/src/Gamepad.cpp
  33. 5 5
      gameplay/src/ImageControl.cpp
  34. 10 2
      gameplay/src/ImageControl.h
  35. 5 5
      gameplay/src/JoystickControl.cpp
  36. 10 5
      gameplay/src/JoystickControl.h
  37. 7 6
      gameplay/src/Label.cpp
  38. 10 5
      gameplay/src/Label.h
  39. 6 5
      gameplay/src/Logger.cpp
  40. 28 0
      gameplay/src/Node.cpp
  41. 30 1
      gameplay/src/Node.h
  42. 3 0
      gameplay/src/PhysicsCharacter.cpp
  43. 45 7
      gameplay/src/PhysicsCollisionObject.cpp
  44. 28 6
      gameplay/src/PhysicsCollisionObject.h
  45. 9 4
      gameplay/src/PhysicsController.cpp
  46. 12 0
      gameplay/src/PhysicsController.h
  47. 11 34
      gameplay/src/Platform.cpp
  48. 8 3
      gameplay/src/PlatformAndroid.cpp
  49. 5 5
      gameplay/src/RadioButton.cpp
  50. 10 5
      gameplay/src/RadioButton.h
  51. 10 1
      gameplay/src/Scene.cpp
  52. 11 0
      gameplay/src/Scene.h
  53. 25 13
      gameplay/src/SceneLoader.cpp
  54. 4 3
      gameplay/src/SceneLoader.h
  55. 42 0
      gameplay/src/Script.cpp
  56. 119 0
      gameplay/src/Script.h
  57. 395 506
      gameplay/src/ScriptController.cpp
  58. 219 526
      gameplay/src/ScriptController.h
  59. 21 24
      gameplay/src/ScriptController.inl
  60. 401 74
      gameplay/src/ScriptTarget.cpp
  61. 357 36
      gameplay/src/ScriptTarget.h
  62. 5 5
      gameplay/src/Slider.cpp
  63. 10 5
      gameplay/src/Slider.h
  64. 15 15
      gameplay/src/TextBox.cpp
  65. 10 5
      gameplay/src/TextBox.h
  66. 14 5
      gameplay/src/Transform.cpp
  67. 13 2
      gameplay/src/Transform.h
  68. 4 87
      gameplay/src/lua/lua_AIAgent.cpp
  69. 1 2
      gameplay/src/lua/lua_AIAgent.h
  70. 1 2
      gameplay/src/lua/lua_AIAgentListener.cpp
  71. 1 0
      gameplay/src/lua/lua_AIAgentListener.h
  72. 2 1
      gameplay/src/lua/lua_AIController.cpp
  73. 1 0
      gameplay/src/lua/lua_AIController.h
  74. 3 3
      gameplay/src/lua/lua_AIMessage.cpp
  75. 1 0
      gameplay/src/lua/lua_AIMessage.h
  76. 0 56
      gameplay/src/lua/lua_AIMessageParameterType.cpp
  77. 0 15
      gameplay/src/lua/lua_AIMessageParameterType.h
  78. 4 85
      gameplay/src/lua/lua_AIState.cpp
  79. 1 2
      gameplay/src/lua/lua_AIState.h
  80. 4 3
      gameplay/src/lua/lua_AIStateListener.cpp
  81. 1 0
      gameplay/src/lua/lua_AIStateListener.h
  82. 6 5
      gameplay/src/lua/lua_AIStateMachine.cpp
  83. 1 0
      gameplay/src/lua/lua_AIStateMachine.h
  84. 2 2
      gameplay/src/lua/lua_AbsoluteLayout.cpp
  85. 1 0
      gameplay/src/lua/lua_AbsoluteLayout.h
  86. 5 4
      gameplay/src/lua/lua_Animation.cpp
  87. 1 0
      gameplay/src/lua/lua_Animation.h
  88. 448 180
      gameplay/src/lua/lua_AnimationClip.cpp
  89. 9 0
      gameplay/src/lua/lua_AnimationClip.h
  90. 4 3
      gameplay/src/lua/lua_AnimationClipListener.cpp
  91. 1 0
      gameplay/src/lua/lua_AnimationClipListener.h
  92. 0 36
      gameplay/src/lua/lua_AnimationClipListenerEventType.cpp
  93. 0 15
      gameplay/src/lua/lua_AnimationClipListenerEventType.h
  94. 1 0
      gameplay/src/lua/lua_AnimationController.cpp
  95. 1 0
      gameplay/src/lua/lua_AnimationController.h
  96. 17 17
      gameplay/src/lua/lua_AnimationTarget.cpp
  97. 1 0
      gameplay/src/lua/lua_AnimationTarget.h
  98. 1 0
      gameplay/src/lua/lua_AnimationValue.cpp
  99. 1 0
      gameplay/src/lua/lua_AnimationValue.h
  100. 1 0
      gameplay/src/lua/lua_AudioBuffer.cpp

+ 1 - 0
.gitignore

@@ -181,3 +181,4 @@ gameplay.xcworkspace/xcshareddata/gameplay.xccheckout
 
 /tools/encoder/windows
 /tools/luagen/windows
+/tools/encoder/gameplay-encoder.xcodeproj/project.xcworkspace/

+ 9 - 104
gameplay/CMakeLists.txt

@@ -187,6 +187,8 @@ set(GAMEPLAY_SRC
     src/SceneLoader.h
     src/ScreenDisplayer.cpp
     src/ScreenDisplayer.h
+    src/Script.cpp
+    src/Script.h
     src/ScriptController.cpp
     src/ScriptController.h
     src/ScriptController.inl
@@ -242,8 +244,6 @@ set(GAMEPLAY_LUA
     src/lua/lua_AIController.h
     src/lua/lua_AIMessage.cpp
     src/lua/lua_AIMessage.h
-    src/lua/lua_AIMessageParameterType.cpp
-    src/lua/lua_AIMessageParameterType.h
     src/lua/lua_AIState.cpp
     src/lua/lua_AIState.h
     src/lua/lua_AIStateListener.cpp
@@ -256,8 +256,6 @@ set(GAMEPLAY_LUA
     src/lua/lua_AnimationClip.h
     src/lua/lua_AnimationClipListener.cpp
     src/lua/lua_AnimationClipListener.h
-    src/lua/lua_AnimationClipListenerEventType.cpp
-    src/lua/lua_AnimationClipListenerEventType.h
     src/lua/lua_AnimationController.cpp
     src/lua/lua_AnimationController.h
     src/lua/lua_AnimationTarget.cpp
@@ -272,8 +270,6 @@ set(GAMEPLAY_LUA
     src/lua/lua_AudioListener.h
     src/lua/lua_AudioSource.cpp
     src/lua/lua_AudioSource.h
-    src/lua/lua_AudioSourceState.cpp
-    src/lua/lua_AudioSourceState.h
     src/lua/lua_BoundingBox.cpp
     src/lua/lua_BoundingBox.h
     src/lua/lua_BoundingSphere.cpp
@@ -286,36 +282,18 @@ set(GAMEPLAY_LUA
     src/lua/lua_Camera.h
     src/lua/lua_CameraListener.h
     src/lua/lua_CameraListener.cpp
-    src/lua/lua_CameraType.cpp
-    src/lua/lua_CameraType.h
     src/lua/lua_CheckBox.cpp
     src/lua/lua_CheckBox.h
     src/lua/lua_Container.cpp
     src/lua/lua_Container.h
-    src/lua/lua_ContainerDirection.cpp
-    src/lua/lua_ContainerDirection.h
-    src/lua/lua_ContainerScroll.cpp
-    src/lua/lua_ContainerScroll.h
     src/lua/lua_Control.cpp
     src/lua/lua_Control.h
-    src/lua/lua_ControlAlignment.cpp
-    src/lua/lua_ControlAlignment.h
-    src/lua/lua_ControlAutoSize.cpp
-    src/lua/lua_ControlAutoSize.h
     src/lua/lua_ControlListener.cpp
     src/lua/lua_ControlListener.h
-    src/lua/lua_ControlListenerEventType.cpp
-    src/lua/lua_ControlListenerEventType.h
-    src/lua/lua_ControlState.cpp
-    src/lua/lua_ControlState.h
     src/lua/lua_Curve.cpp
     src/lua/lua_Curve.h
-    src/lua/lua_CurveInterpolationType.cpp
-    src/lua/lua_CurveInterpolationType.h
     src/lua/lua_DepthStencilTarget.cpp
     src/lua/lua_DepthStencilTarget.h
-    src/lua/lua_DepthStencilTargetFormat.cpp
-    src/lua/lua_DepthStencilTargetFormat.h
     src/lua/lua_Effect.cpp
     src/lua/lua_Effect.h
     src/lua/lua_FileSystem.cpp
@@ -324,12 +302,6 @@ set(GAMEPLAY_LUA
     src/lua/lua_FlowLayout.h
     src/lua/lua_Font.cpp
     src/lua/lua_Font.h
-    src/lua/lua_FontFormat.cpp
-    src/lua/lua_FontFormat.h
-    src/lua/lua_FontJustify.cpp
-    src/lua/lua_FontJustify.h
-    src/lua/lua_FontStyle.cpp
-    src/lua/lua_FontStyle.h
     src/lua/lua_FontText.cpp
     src/lua/lua_FontText.h
     src/lua/lua_Form.cpp
@@ -340,20 +312,10 @@ set(GAMEPLAY_LUA
     src/lua/lua_Frustum.h
     src/lua/lua_Game.cpp
     src/lua/lua_Game.h
-    src/lua/lua_GameClearFlags.cpp
-    src/lua/lua_GameClearFlags.h
     src/lua/lua_Gamepad.cpp
     src/lua/lua_Gamepad.h
-    src/lua/lua_GamepadButtonMapping.cpp
-    src/lua/lua_GamepadButtonMapping.h
-    src/lua/lua_GamepadGamepadEvent.cpp
-    src/lua/lua_GamepadGamepadEvent.h
-    src/lua/lua_GameState.cpp
-    src/lua/lua_GameState.h
     src/lua/lua_Gesture.cpp
     src/lua/lua_Gesture.h
-    src/lua/lua_GestureGestureEvent.cpp
-    src/lua/lua_GestureGestureEvent.h
     src/lua/lua_Global.cpp
     src/lua/lua_Global.h
     src/lua/lua_HeightField.cpp
@@ -362,32 +324,20 @@ set(GAMEPLAY_LUA
     src/lua/lua_Image.h
     src/lua/lua_ImageControl.cpp
     src/lua/lua_ImageControl.h
-    src/lua/lua_ImageFormat.cpp
-    src/lua/lua_ImageFormat.h
     src/lua/lua_Joint.cpp
     src/lua/lua_Joint.h
     src/lua/lua_JoystickControl.cpp
     src/lua/lua_JoystickControl.h
     src/lua/lua_Keyboard.cpp
     src/lua/lua_Keyboard.h
-    src/lua/lua_KeyboardKey.cpp
-    src/lua/lua_KeyboardKey.h
-    src/lua/lua_KeyboardKeyEvent.cpp
-    src/lua/lua_KeyboardKeyEvent.h
     src/lua/lua_Label.cpp
     src/lua/lua_Label.h
     src/lua/lua_Layout.cpp
     src/lua/lua_Layout.h
-    src/lua/lua_LayoutType.cpp
-    src/lua/lua_LayoutType.h
     src/lua/lua_Light.cpp
     src/lua/lua_Light.h
-    src/lua/lua_LightType.cpp
-    src/lua/lua_LightType.h
     src/lua/lua_Logger.cpp
     src/lua/lua_Logger.h
-    src/lua/lua_LoggerLevel.cpp
-    src/lua/lua_LoggerLevel.h
     src/lua/lua_Material.cpp
     src/lua/lua_Material.h
     src/lua/lua_MaterialParameter.cpp
@@ -400,30 +350,20 @@ set(GAMEPLAY_LUA
     src/lua/lua_Mesh.h
     src/lua/lua_MeshBatch.cpp
     src/lua/lua_MeshBatch.h
-    src/lua/lua_MeshIndexFormat.cpp
-    src/lua/lua_MeshIndexFormat.h
     src/lua/lua_MeshPart.cpp
     src/lua/lua_MeshPart.h
-    src/lua/lua_MeshPrimitiveType.cpp
-    src/lua/lua_MeshPrimitiveType.h
     src/lua/lua_MeshSkin.cpp
     src/lua/lua_MeshSkin.h
     src/lua/lua_Model.cpp
     src/lua/lua_Model.h
     src/lua/lua_Mouse.cpp
     src/lua/lua_Mouse.h
-    src/lua/lua_MouseMouseEvent.cpp
-    src/lua/lua_MouseMouseEvent.h
     src/lua/lua_Node.cpp
     src/lua/lua_Node.h
     src/lua/lua_NodeCloneContext.cpp
     src/lua/lua_NodeCloneContext.h
-    src/lua/lua_NodeType.cpp
-    src/lua/lua_NodeType.h
     src/lua/lua_ParticleEmitter.cpp
     src/lua/lua_ParticleEmitter.h
-    src/lua/lua_ParticleEmitterBlendMode.cpp
-    src/lua/lua_ParticleEmitterBlendMode.h
     src/lua/lua_Pass.cpp
     src/lua/lua_Pass.h
     src/lua/lua_PhysicsCharacter.cpp
@@ -432,18 +372,12 @@ set(GAMEPLAY_LUA
     src/lua/lua_PhysicsCollisionObject.h
     src/lua/lua_PhysicsCollisionObjectCollisionListener.cpp
     src/lua/lua_PhysicsCollisionObjectCollisionListener.h
-    src/lua/lua_PhysicsCollisionObjectCollisionListenerEventType.cpp
-    src/lua/lua_PhysicsCollisionObjectCollisionListenerEventType.h
     src/lua/lua_PhysicsCollisionObjectCollisionPair.cpp
     src/lua/lua_PhysicsCollisionObjectCollisionPair.h
-    src/lua/lua_PhysicsCollisionObjectType.cpp
-    src/lua/lua_PhysicsCollisionObjectType.h
     src/lua/lua_PhysicsCollisionShape.cpp
     src/lua/lua_PhysicsCollisionShape.h
     src/lua/lua_PhysicsCollisionShapeDefinition.cpp
     src/lua/lua_PhysicsCollisionShapeDefinition.h
-    src/lua/lua_PhysicsCollisionShapeType.cpp
-    src/lua/lua_PhysicsCollisionShapeType.h
     src/lua/lua_PhysicsConstraint.cpp
     src/lua/lua_PhysicsConstraint.h
     src/lua/lua_PhysicsController.cpp
@@ -454,8 +388,6 @@ set(GAMEPLAY_LUA
     src/lua/lua_PhysicsControllerHitResult.h
     src/lua/lua_PhysicsControllerListener.cpp
     src/lua/lua_PhysicsControllerListener.h
-    src/lua/lua_PhysicsControllerListenerEventType.cpp
-    src/lua/lua_PhysicsControllerListenerEventType.h
     src/lua/lua_PhysicsFixedConstraint.cpp
     src/lua/lua_PhysicsFixedConstraint.h
     src/lua/lua_PhysicsGenericConstraint.cpp
@@ -482,8 +414,6 @@ set(GAMEPLAY_LUA
     src/lua/lua_Platform.h
     src/lua/lua_Properties.cpp
     src/lua/lua_Properties.h
-    src/lua/lua_PropertiesType.cpp
-    src/lua/lua_PropertiesType.h
     src/lua/lua_Quaternion.cpp
     src/lua/lua_Quaternion.h
     src/lua/lua_RadioButton.cpp
@@ -496,31 +426,24 @@ set(GAMEPLAY_LUA
     src/lua/lua_Ref.h
     src/lua/lua_RenderState.cpp
     src/lua/lua_RenderState.h
-    src/lua/lua_RenderStateAutoBinding.cpp
-    src/lua/lua_RenderStateAutoBinding.h
-    src/lua/lua_RenderStateBlend.cpp
-    src/lua/lua_RenderStateBlend.h
-    src/lua/lua_RenderStateCullFaceSide.cpp
-    src/lua/lua_RenderStateDepthFunction.cpp
-    src/lua/lua_RenderStateDepthFunction.h
-    src/lua/lua_RenderStateFrontFace.cpp
-    src/lua/lua_RenderStateFrontFace.h
     src/lua/lua_RenderStateStateBlock.cpp
     src/lua/lua_RenderStateStateBlock.h
-    src/lua/lua_RenderStateStencilFunction.cpp
-    src/lua/lua_RenderStateStencilFunction.h
-    src/lua/lua_RenderStateStencilOperation.cpp
-    src/lua/lua_RenderStateStencilOperation.h
     src/lua/lua_RenderTarget.cpp
     src/lua/lua_RenderTarget.h
     src/lua/lua_Scene.cpp
     src/lua/lua_Scene.h
     src/lua/lua_ScreenDisplayer.cpp
     src/lua/lua_ScreenDisplayer.h
+    src/lua/lua_Script.cpp
+    src/lua/lua_Script.h
     src/lua/lua_ScriptController.cpp
     src/lua/lua_ScriptController.h
     src/lua/lua_ScriptTarget.cpp
     src/lua/lua_ScriptTarget.h
+    src/lua/lua_ScriptTargetEvent.cpp
+    src/lua/lua_ScriptTargetEvent.h
+    src/lua/lua_ScriptTargetEventRegistry.cpp
+    src/lua/lua_ScriptTargetEventRegistry.h
     src/lua/lua_Slider.cpp
     src/lua/lua_Slider.h
     src/lua/lua_SpriteBatch.cpp
@@ -529,28 +452,14 @@ set(GAMEPLAY_LUA
     src/lua/lua_Technique.h
     src/lua/lua_Terrain.cpp
     src/lua/lua_Terrain.h
-    src/lua/lua_TerrainFlags.cpp
-    src/lua/lua_TerrainFlags.h
     src/lua/lua_TerrainPatch.cpp
     src/lua/lua_TerrainPatch.h
     src/lua/lua_TextBox.cpp
     src/lua/lua_TextBox.h
-    src/lua/lua_TextBoxInputMode.cpp
-    src/lua/lua_TextBoxInputMode.h
     src/lua/lua_Texture.cpp
     src/lua/lua_Texture.h
-    src/lua/lua_TextureCubeFace.cpp
-    src/lua/lua_TextureCubeFace.h
-    src/lua/lua_TextureFilter.cpp
-    src/lua/lua_TextureFilter.h
-    src/lua/lua_TextureFormat.cpp
-    src/lua/lua_TextureFormat.h
     src/lua/lua_TextureSampler.cpp
     src/lua/lua_TextureSampler.h
-    src/lua/lua_TextureType.cpp
-    src/lua/lua_TextureType.h
-    src/lua/lua_TextureWrap.cpp
-    src/lua/lua_TextureWrap.h
     src/lua/lua_Theme.cpp
     src/lua/lua_Theme.h
     src/lua/lua_ThemeSideRegions.cpp
@@ -563,8 +472,6 @@ set(GAMEPLAY_LUA
     src/lua/lua_ThemeUVs.h
     src/lua/lua_Touch.cpp
     src/lua/lua_Touch.h
-    src/lua/lua_TouchTouchEvent.cpp
-    src/lua/lua_TouchTouchEvent.h
     src/lua/lua_Transform.cpp
     src/lua/lua_Transform.h
     src/lua/lua_TransformListener.cpp
@@ -583,8 +490,6 @@ set(GAMEPLAY_LUA
     src/lua/lua_VertexFormat.h
     src/lua/lua_VertexFormatElement.cpp
     src/lua/lua_VertexFormatElement.h
-    src/lua/lua_VertexFormatUsage.cpp
-    src/lua/lua_VertexFormatUsage.h
     src/lua/lua_VerticalLayout.cpp
     src/lua/lua_VerticalLayout.h
 )
@@ -621,7 +526,7 @@ set(GAMEPLAY_RES_SHADERS
     res/ui/default.theme
 )
 
-include_directories( 
+include_directories(
     src
     ../external-deps/lua/include
     ../external-deps/bullet/include

+ 4 - 52
gameplay/android/jni/Android.mk

@@ -162,6 +162,7 @@ LOCAL_SRC_FILES := \
     Scene.cpp \
     SceneLoader.cpp \
     ScreenDisplayer.cpp \
+    Script.cpp \
     ScriptController.cpp \
     ScriptTarget.cpp \
     Slider.cpp \
@@ -185,7 +186,6 @@ LOCAL_SRC_FILES := \
     lua/lua_AIAgentListener.cpp \
     lua/lua_AIController.cpp \
     lua/lua_AIMessage.cpp \
-    lua/lua_AIMessageParameterType.cpp \
     lua/lua_AIState.cpp \
     lua/lua_AIStateListener.cpp \
     lua/lua_AIStateMachine.cpp \
@@ -193,7 +193,6 @@ LOCAL_SRC_FILES := \
     lua/lua_Animation.cpp \
     lua/lua_AnimationClip.cpp \
     lua/lua_AnimationClipListener.cpp \
-    lua/lua_AnimationClipListenerEventType.cpp \
     lua/lua_AnimationController.cpp \
     lua/lua_AnimationTarget.cpp \
     lua/lua_AnimationValue.cpp \
@@ -201,98 +200,65 @@ LOCAL_SRC_FILES := \
     lua/lua_AudioController.cpp \
     lua/lua_AudioListener.cpp \
     lua/lua_AudioSource.cpp \
-    lua/lua_AudioSourceState.cpp \
     lua/lua_BoundingBox.cpp \
     lua/lua_BoundingSphere.cpp \
     lua/lua_Bundle.cpp \
     lua/lua_Button.cpp \
     lua/lua_Camera.cpp \
     lua/lua_CameraListener.cpp \
-    lua/lua_CameraType.cpp \
     lua/lua_CheckBox.cpp \
     lua/lua_Container.cpp \
-    lua/lua_ContainerDirection.cpp \
-    lua/lua_ContainerScroll.cpp \
     lua/lua_Control.cpp \
-    lua/lua_ControlAlignment.cpp \
-    lua/lua_ControlAutoSize.cpp \
     lua/lua_ControlListener.cpp \
-    lua/lua_ControlListenerEventType.cpp \
-    lua/lua_ControlState.cpp \
     lua/lua_Curve.cpp \
-    lua/lua_CurveInterpolationType.cpp \
     lua/lua_DepthStencilTarget.cpp \
-    lua/lua_DepthStencilTargetFormat.cpp \
     lua/lua_Effect.cpp \
     lua/lua_FileSystem.cpp \
     lua/lua_FlowLayout.cpp \
     lua/lua_Font.cpp \
-    lua/lua_FontFormat.cpp \
-    lua/lua_FontJustify.cpp \
-    lua/lua_FontStyle.cpp \
     lua/lua_FontText.cpp \
     lua/lua_Form.cpp \
     lua/lua_FrameBuffer.cpp \
     lua/lua_Frustum.cpp \
     lua/lua_Game.cpp \
-    lua/lua_GameClearFlags.cpp \
     lua/lua_Gamepad.cpp \
-    lua/lua_GamepadButtonMapping.cpp \
-    lua/lua_GamepadGamepadEvent.cpp \
-    lua/lua_GameState.cpp \
     lua/lua_Gesture.cpp \
-    lua/lua_GestureGestureEvent.cpp \
     lua/lua_Global.cpp \
     lua/lua_HeightField.cpp \
     lua/lua_Image.cpp \
     lua/lua_ImageControl.cpp \
-    lua/lua_ImageFormat.cpp \
     lua/lua_Joint.cpp \
     lua/lua_JoystickControl.cpp \
     lua/lua_Keyboard.cpp \
-    lua/lua_KeyboardKey.cpp \
-    lua/lua_KeyboardKeyEvent.cpp \
     lua/lua_Label.cpp \
     lua/lua_Layout.cpp \
-    lua/lua_LayoutType.cpp \
     lua/lua_Light.cpp \
-    lua/lua_LightType.cpp \
     lua/lua_Logger.cpp \
-    lua/lua_LoggerLevel.cpp \
     lua/lua_Material.cpp \
     lua/lua_MaterialParameter.cpp \
     lua/lua_MathUtil.cpp \
     lua/lua_Matrix.cpp \
     lua/lua_Mesh.cpp \
     lua/lua_MeshBatch.cpp \
-    lua/lua_MeshIndexFormat.cpp \
     lua/lua_MeshPart.cpp \
-    lua/lua_MeshPrimitiveType.cpp \
     lua/lua_MeshSkin.cpp \
     lua/lua_Model.cpp \
     lua/lua_Mouse.cpp \
-    lua/lua_MouseMouseEvent.cpp \
     lua/lua_Node.cpp \
     lua/lua_NodeCloneContext.cpp \
-    lua/lua_NodeType.cpp \
     lua/lua_ParticleEmitter.cpp \
-    lua/lua_ParticleEmitterBlendMode.cpp \
     lua/lua_Pass.cpp \
     lua/lua_PhysicsCharacter.cpp \
     lua/lua_PhysicsCollisionObject.cpp \
     lua/lua_PhysicsCollisionObjectCollisionListener.cpp \
-    lua/lua_PhysicsCollisionObjectCollisionListenerEventType.cpp \
     lua/lua_PhysicsCollisionObjectCollisionPair.cpp \
-    lua/lua_PhysicsCollisionObjectType.cpp \
     lua/lua_PhysicsCollisionShape.cpp \
     lua/lua_PhysicsCollisionShapeDefinition.cpp \
-    lua/lua_PhysicsCollisionShapeType.cpp \
     lua/lua_PhysicsConstraint.cpp \
     lua/lua_PhysicsController.cpp \
     lua/lua_PhysicsControllerHitFilter.cpp \
     lua/lua_PhysicsControllerHitResult.cpp \
     lua/lua_PhysicsControllerListener.cpp \
-    lua/lua_PhysicsControllerListenerEventType.cpp \
     lua/lua_PhysicsFixedConstraint.cpp \
     lua/lua_PhysicsGenericConstraint.cpp \
     lua/lua_PhysicsGhostObject.cpp \
@@ -306,48 +272,35 @@ LOCAL_SRC_FILES := \
     lua/lua_Plane.cpp \
     lua/lua_Platform.cpp \
     lua/lua_Properties.cpp \
-    lua/lua_PropertiesType.cpp \
     lua/lua_Quaternion.cpp \
     lua/lua_RadioButton.cpp \
     lua/lua_Ray.cpp \
     lua/lua_Rectangle.cpp \
     lua/lua_Ref.cpp \
     lua/lua_RenderState.cpp \
-    lua/lua_RenderStateAutoBinding.cpp \
-    lua/lua_RenderStateBlend.cpp \
-    lua/lua_RenderStateCullFaceSide.cpp \
-    lua/lua_RenderStateDepthFunction.cpp \
-    lua/lua_RenderStateFrontFace.cpp  \
     lua/lua_RenderStateStateBlock.cpp \
-    lua/lua_RenderStateStencilFunction.cpp \
-    lua/lua_RenderStateStencilOperation.cpp \
     lua/lua_RenderTarget.cpp \
     lua/lua_Scene.cpp \
     lua/lua_ScreenDisplayer.cpp \
+    lua/lua_Script.cpp \
     lua/lua_ScriptController.cpp \
     lua/lua_ScriptTarget.cpp \
+    lua/lua_ScriptTargetEvent.cpp \
+    lua/lua_ScriptTargetEventRegistry.cpp \
     lua/lua_Slider.cpp \
     lua/lua_SpriteBatch.cpp \
     lua/lua_Technique.cpp \
     lua/lua_Terrain.cpp \
-    lua/lua_TerrainFlags.cpp \
     lua/lua_TerrainPatch.cpp \
     lua/lua_TextBox.cpp \
-    lua/lua_TextBoxInputMode.cpp \
     lua/lua_Texture.cpp \
-    lua/lua_TextureCubeFace.cpp \
-    lua/lua_TextureFilter.cpp \
-    lua/lua_TextureFormat.cpp \
     lua/lua_TextureSampler.cpp \
-    lua/lua_TextureType.cpp \
-    lua/lua_TextureWrap.cpp \
     lua/lua_Theme.cpp \
     lua/lua_ThemeSideRegions.cpp \
     lua/lua_ThemeStyle.cpp \
     lua/lua_ThemeThemeImage.cpp \
     lua/lua_ThemeUVs.cpp \
     lua/lua_Touch.cpp \
-    lua/lua_TouchTouchEvent.cpp \
     lua/lua_Transform.cpp \
     lua/lua_TransformListener.cpp \
     lua/lua_Uniform.cpp \
@@ -357,7 +310,6 @@ LOCAL_SRC_FILES := \
     lua/lua_VertexAttributeBinding.cpp \
     lua/lua_VertexFormat.cpp \
     lua/lua_VertexFormatElement.cpp \
-    lua/lua_VertexFormatUsage.cpp \
     lua/lua_VerticalLayout.cpp
 
 LOCAL_CPPFLAGS += -std=c++11 -Wno-switch-enum -Wno-switch

+ 13 - 104
gameplay/gameplay.vcxproj

@@ -67,7 +67,6 @@
     <ClCompile Include="src\lua\lua_AIAgentListener.cpp" />
     <ClCompile Include="src\lua\lua_AIController.cpp" />
     <ClCompile Include="src\lua\lua_AIMessage.cpp" />
-    <ClCompile Include="src\lua\lua_AIMessageParameterType.cpp" />
     <ClCompile Include="src\lua\lua_AIState.cpp" />
     <ClCompile Include="src\lua\lua_AIStateListener.cpp" />
     <ClCompile Include="src\lua\lua_AIStateMachine.cpp" />
@@ -75,7 +74,6 @@
     <ClCompile Include="src\lua\lua_Animation.cpp" />
     <ClCompile Include="src\lua\lua_AnimationClip.cpp" />
     <ClCompile Include="src\lua\lua_AnimationClipListener.cpp" />
-    <ClCompile Include="src\lua\lua_AnimationClipListenerEventType.cpp" />
     <ClCompile Include="src\lua\lua_AnimationController.cpp" />
     <ClCompile Include="src\lua\lua_AnimationTarget.cpp" />
     <ClCompile Include="src\lua\lua_AnimationValue.cpp" />
@@ -83,98 +81,65 @@
     <ClCompile Include="src\lua\lua_AudioController.cpp" />
     <ClCompile Include="src\lua\lua_AudioListener.cpp" />
     <ClCompile Include="src\lua\lua_AudioSource.cpp" />
-    <ClCompile Include="src\lua\lua_AudioSourceState.cpp" />
     <ClCompile Include="src\lua\lua_BoundingBox.cpp" />
     <ClCompile Include="src\lua\lua_BoundingSphere.cpp" />
     <ClCompile Include="src\lua\lua_Bundle.cpp" />
     <ClCompile Include="src\lua\lua_Button.cpp" />
     <ClCompile Include="src\lua\lua_Camera.cpp" />
     <ClCompile Include="src\lua\lua_CameraListener.cpp" />
-    <ClCompile Include="src\lua\lua_CameraType.cpp" />
     <ClCompile Include="src\lua\lua_CheckBox.cpp" />
     <ClCompile Include="src\lua\lua_Container.cpp" />
-    <ClCompile Include="src\lua\lua_ContainerDirection.cpp" />
-    <ClCompile Include="src\lua\lua_ContainerScroll.cpp" />
     <ClCompile Include="src\lua\lua_Control.cpp" />
-    <ClCompile Include="src\lua\lua_ControlAlignment.cpp" />
-    <ClCompile Include="src\lua\lua_ControlAutoSize.cpp" />
     <ClCompile Include="src\lua\lua_ControlListener.cpp" />
-    <ClCompile Include="src\lua\lua_ControlListenerEventType.cpp" />
-    <ClCompile Include="src\lua\lua_ControlState.cpp" />
     <ClCompile Include="src\lua\lua_Curve.cpp" />
-    <ClCompile Include="src\lua\lua_CurveInterpolationType.cpp" />
     <ClCompile Include="src\lua\lua_DepthStencilTarget.cpp" />
-    <ClCompile Include="src\lua\lua_DepthStencilTargetFormat.cpp" />
     <ClCompile Include="src\lua\lua_Effect.cpp" />
     <ClCompile Include="src\lua\lua_FileSystem.cpp" />
     <ClCompile Include="src\lua\lua_FlowLayout.cpp" />
     <ClCompile Include="src\lua\lua_Font.cpp" />
-    <ClCompile Include="src\lua\lua_FontFormat.cpp" />
-    <ClCompile Include="src\lua\lua_FontJustify.cpp" />
-    <ClCompile Include="src\lua\lua_FontStyle.cpp" />
     <ClCompile Include="src\lua\lua_FontText.cpp" />
     <ClCompile Include="src\lua\lua_Form.cpp" />
     <ClCompile Include="src\lua\lua_FrameBuffer.cpp" />
     <ClCompile Include="src\lua\lua_Frustum.cpp" />
     <ClCompile Include="src\lua\lua_Game.cpp" />
-    <ClCompile Include="src\lua\lua_GameClearFlags.cpp" />
     <ClCompile Include="src\lua\lua_Gamepad.cpp" />
-    <ClCompile Include="src\lua\lua_GamepadButtonMapping.cpp" />
-    <ClCompile Include="src\lua\lua_GamepadGamepadEvent.cpp" />
-    <ClCompile Include="src\lua\lua_GameState.cpp" />
     <ClCompile Include="src\lua\lua_Gesture.cpp" />
-    <ClCompile Include="src\lua\lua_GestureGestureEvent.cpp" />
     <ClCompile Include="src\lua\lua_Global.cpp" />
     <ClCompile Include="src\lua\lua_HeightField.cpp" />
     <ClCompile Include="src\lua\lua_Image.cpp" />
     <ClCompile Include="src\lua\lua_ImageControl.cpp" />
-    <ClCompile Include="src\lua\lua_ImageFormat.cpp" />
     <ClCompile Include="src\lua\lua_Joint.cpp" />
     <ClCompile Include="src\lua\lua_JoystickControl.cpp" />
     <ClCompile Include="src\lua\lua_Keyboard.cpp" />
-    <ClCompile Include="src\lua\lua_KeyboardKey.cpp" />
-    <ClCompile Include="src\lua\lua_KeyboardKeyEvent.cpp" />
     <ClCompile Include="src\lua\lua_Label.cpp" />
     <ClCompile Include="src\lua\lua_Layout.cpp" />
-    <ClCompile Include="src\lua\lua_LayoutType.cpp" />
     <ClCompile Include="src\lua\lua_Light.cpp" />
-    <ClCompile Include="src\lua\lua_LightType.cpp" />
     <ClCompile Include="src\lua\lua_Logger.cpp" />
-    <ClCompile Include="src\lua\lua_LoggerLevel.cpp" />
     <ClCompile Include="src\lua\lua_Material.cpp" />
     <ClCompile Include="src\lua\lua_MaterialParameter.cpp" />
     <ClCompile Include="src\lua\lua_MathUtil.cpp" />
     <ClCompile Include="src\lua\lua_Matrix.cpp" />
     <ClCompile Include="src\lua\lua_Mesh.cpp" />
     <ClCompile Include="src\lua\lua_MeshBatch.cpp" />
-    <ClCompile Include="src\lua\lua_MeshIndexFormat.cpp" />
     <ClCompile Include="src\lua\lua_MeshPart.cpp" />
-    <ClCompile Include="src\lua\lua_MeshPrimitiveType.cpp" />
     <ClCompile Include="src\lua\lua_MeshSkin.cpp" />
     <ClCompile Include="src\lua\lua_Model.cpp" />
     <ClCompile Include="src\lua\lua_Mouse.cpp" />
-    <ClCompile Include="src\lua\lua_MouseMouseEvent.cpp" />
     <ClCompile Include="src\lua\lua_Node.cpp" />
     <ClCompile Include="src\lua\lua_NodeCloneContext.cpp" />
-    <ClCompile Include="src\lua\lua_NodeType.cpp" />
     <ClCompile Include="src\lua\lua_ParticleEmitter.cpp" />
-    <ClCompile Include="src\lua\lua_ParticleEmitterBlendMode.cpp" />
     <ClCompile Include="src\lua\lua_Pass.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsCharacter.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsCollisionObject.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsCollisionObjectCollisionListener.cpp" />
-    <ClCompile Include="src\lua\lua_PhysicsCollisionObjectCollisionListenerEventType.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsCollisionObjectCollisionPair.cpp" />
-    <ClCompile Include="src\lua\lua_PhysicsCollisionObjectType.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsCollisionShape.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsCollisionShapeDefinition.cpp" />
-    <ClCompile Include="src\lua\lua_PhysicsCollisionShapeType.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsConstraint.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsController.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsControllerHitFilter.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsControllerHitResult.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsControllerListener.cpp" />
-    <ClCompile Include="src\lua\lua_PhysicsControllerListenerEventType.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsFixedConstraint.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsGenericConstraint.cpp" />
     <ClCompile Include="src\lua\lua_PhysicsGhostObject.cpp" />
@@ -188,48 +153,35 @@
     <ClCompile Include="src\lua\lua_Plane.cpp" />
     <ClCompile Include="src\lua\lua_Platform.cpp" />
     <ClCompile Include="src\lua\lua_Properties.cpp" />
-    <ClCompile Include="src\lua\lua_PropertiesType.cpp" />
     <ClCompile Include="src\lua\lua_Quaternion.cpp" />
     <ClCompile Include="src\lua\lua_RadioButton.cpp" />
     <ClCompile Include="src\lua\lua_Ray.cpp" />
     <ClCompile Include="src\lua\lua_Rectangle.cpp" />
     <ClCompile Include="src\lua\lua_Ref.cpp" />
     <ClCompile Include="src\lua\lua_RenderState.cpp" />
-    <ClCompile Include="src\lua\lua_RenderStateAutoBinding.cpp" />
-    <ClCompile Include="src\lua\lua_RenderStateBlend.cpp" />
-    <ClCompile Include="src\lua\lua_RenderStateCullFaceSide.cpp" />
-    <ClCompile Include="src\lua\lua_RenderStateDepthFunction.cpp" />
-    <ClCompile Include="src\lua\lua_RenderStateFrontFace.cpp" />
     <ClCompile Include="src\lua\lua_RenderStateStateBlock.cpp" />
-    <ClCompile Include="src\lua\lua_RenderStateStencilFunction.cpp" />
-    <ClCompile Include="src\lua\lua_RenderStateStencilOperation.cpp" />
     <ClCompile Include="src\lua\lua_RenderTarget.cpp" />
     <ClCompile Include="src\lua\lua_Scene.cpp" />
     <ClCompile Include="src\lua\lua_ScreenDisplayer.cpp" />
+    <ClCompile Include="src\lua\lua_Script.cpp" />
     <ClCompile Include="src\lua\lua_ScriptController.cpp" />
     <ClCompile Include="src\lua\lua_ScriptTarget.cpp" />
+    <ClCompile Include="src\lua\lua_ScriptTargetEvent.cpp" />
+    <ClCompile Include="src\lua\lua_ScriptTargetEventRegistry.cpp" />
     <ClCompile Include="src\lua\lua_Slider.cpp" />
     <ClCompile Include="src\lua\lua_SpriteBatch.cpp" />
     <ClCompile Include="src\lua\lua_Technique.cpp" />
     <ClCompile Include="src\lua\lua_Terrain.cpp" />
-    <ClCompile Include="src\lua\lua_TerrainFlags.cpp" />
     <ClCompile Include="src\lua\lua_TerrainPatch.cpp" />
     <ClCompile Include="src\lua\lua_TextBox.cpp" />
-    <ClCompile Include="src\lua\lua_TextBoxInputMode.cpp" />
     <ClCompile Include="src\lua\lua_Texture.cpp" />
-    <ClCompile Include="src\lua\lua_TextureCubeFace.cpp" />
-    <ClCompile Include="src\lua\lua_TextureFilter.cpp" />
-    <ClCompile Include="src\lua\lua_TextureFormat.cpp" />
     <ClCompile Include="src\lua\lua_TextureSampler.cpp" />
-    <ClCompile Include="src\lua\lua_TextureType.cpp" />
-    <ClCompile Include="src\lua\lua_TextureWrap.cpp" />
     <ClCompile Include="src\lua\lua_Theme.cpp" />
     <ClCompile Include="src\lua\lua_ThemeSideRegions.cpp" />
     <ClCompile Include="src\lua\lua_ThemeStyle.cpp" />
     <ClCompile Include="src\lua\lua_ThemeThemeImage.cpp" />
     <ClCompile Include="src\lua\lua_ThemeUVs.cpp" />
     <ClCompile Include="src\lua\lua_Touch.cpp" />
-    <ClCompile Include="src\lua\lua_TouchTouchEvent.cpp" />
     <ClCompile Include="src\lua\lua_Transform.cpp" />
     <ClCompile Include="src\lua\lua_TransformListener.cpp" />
     <ClCompile Include="src\lua\lua_Uniform.cpp" />
@@ -239,7 +191,6 @@
     <ClCompile Include="src\lua\lua_VertexAttributeBinding.cpp" />
     <ClCompile Include="src\lua\lua_VertexFormat.cpp" />
     <ClCompile Include="src\lua\lua_VertexFormatElement.cpp" />
-    <ClCompile Include="src\lua\lua_VertexFormatUsage.cpp" />
     <ClCompile Include="src\lua\lua_VerticalLayout.cpp" />
     <ClCompile Include="src\Material.cpp" />
     <ClCompile Include="src\MathUtil.cpp" />
@@ -284,6 +235,7 @@
     <ClCompile Include="src\Scene.cpp" />
     <ClCompile Include="src\SceneLoader.cpp" />
     <ClCompile Include="src\ScreenDisplayer.cpp" />
+    <ClCompile Include="src\Script.cpp" />
     <ClCompile Include="src\ScriptController.cpp" />
     <ClCompile Include="src\ScriptTarget.cpp" />
     <ClCompile Include="src\Slider.cpp" />
@@ -357,7 +309,6 @@
     <ClInclude Include="src\lua\lua_AIAgentListener.h" />
     <ClInclude Include="src\lua\lua_AIController.h" />
     <ClInclude Include="src\lua\lua_AIMessage.h" />
-    <ClInclude Include="src\lua\lua_AIMessageParameterType.h" />
     <ClInclude Include="src\lua\lua_AIState.h" />
     <ClInclude Include="src\lua\lua_AIStateListener.h" />
     <ClInclude Include="src\lua\lua_AIStateMachine.h" />
@@ -365,7 +316,6 @@
     <ClInclude Include="src\lua\lua_Animation.h" />
     <ClInclude Include="src\lua\lua_AnimationClip.h" />
     <ClInclude Include="src\lua\lua_AnimationClipListener.h" />
-    <ClInclude Include="src\lua\lua_AnimationClipListenerEventType.h" />
     <ClInclude Include="src\lua\lua_AnimationController.h" />
     <ClInclude Include="src\lua\lua_AnimationTarget.h" />
     <ClInclude Include="src\lua\lua_AnimationValue.h" />
@@ -373,98 +323,65 @@
     <ClInclude Include="src\lua\lua_AudioController.h" />
     <ClInclude Include="src\lua\lua_AudioListener.h" />
     <ClInclude Include="src\lua\lua_AudioSource.h" />
-    <ClInclude Include="src\lua\lua_AudioSourceState.h" />
     <ClInclude Include="src\lua\lua_BoundingBox.h" />
     <ClInclude Include="src\lua\lua_BoundingSphere.h" />
     <ClInclude Include="src\lua\lua_Bundle.h" />
     <ClInclude Include="src\lua\lua_Button.h" />
     <ClInclude Include="src\lua\lua_Camera.h" />
     <ClInclude Include="src\lua\lua_CameraListener.h" />
-    <ClInclude Include="src\lua\lua_CameraType.h" />
     <ClInclude Include="src\lua\lua_CheckBox.h" />
     <ClInclude Include="src\lua\lua_Container.h" />
-    <ClInclude Include="src\lua\lua_ContainerDirection.h" />
-    <ClInclude Include="src\lua\lua_ContainerScroll.h" />
     <ClInclude Include="src\lua\lua_Control.h" />
-    <ClInclude Include="src\lua\lua_ControlAlignment.h" />
-    <ClInclude Include="src\lua\lua_ControlAutoSize.h" />
     <ClInclude Include="src\lua\lua_ControlListener.h" />
-    <ClInclude Include="src\lua\lua_ControlListenerEventType.h" />
-    <ClInclude Include="src\lua\lua_ControlState.h" />
     <ClInclude Include="src\lua\lua_Curve.h" />
-    <ClInclude Include="src\lua\lua_CurveInterpolationType.h" />
     <ClInclude Include="src\lua\lua_DepthStencilTarget.h" />
-    <ClInclude Include="src\lua\lua_DepthStencilTargetFormat.h" />
     <ClInclude Include="src\lua\lua_Effect.h" />
     <ClInclude Include="src\lua\lua_FileSystem.h" />
     <ClInclude Include="src\lua\lua_FlowLayout.h" />
     <ClInclude Include="src\lua\lua_Font.h" />
-    <ClInclude Include="src\lua\lua_FontFormat.h" />
-    <ClInclude Include="src\lua\lua_FontJustify.h" />
-    <ClInclude Include="src\lua\lua_FontStyle.h" />
     <ClInclude Include="src\lua\lua_FontText.h" />
     <ClInclude Include="src\lua\lua_Form.h" />
     <ClInclude Include="src\lua\lua_FrameBuffer.h" />
     <ClInclude Include="src\lua\lua_Frustum.h" />
     <ClInclude Include="src\lua\lua_Game.h" />
-    <ClInclude Include="src\lua\lua_GameClearFlags.h" />
     <ClInclude Include="src\lua\lua_Gamepad.h" />
-    <ClInclude Include="src\lua\lua_GamepadButtonMapping.h" />
-    <ClInclude Include="src\lua\lua_GamepadGamepadEvent.h" />
-    <ClInclude Include="src\lua\lua_GameState.h" />
     <ClInclude Include="src\lua\lua_Gesture.h" />
-    <ClInclude Include="src\lua\lua_GestureGestureEvent.h" />
     <ClInclude Include="src\lua\lua_Global.h" />
     <ClInclude Include="src\lua\lua_HeightField.h" />
     <ClInclude Include="src\lua\lua_Image.h" />
     <ClInclude Include="src\lua\lua_ImageControl.h" />
-    <ClInclude Include="src\lua\lua_ImageFormat.h" />
     <ClInclude Include="src\lua\lua_Joint.h" />
     <ClInclude Include="src\lua\lua_JoystickControl.h" />
     <ClInclude Include="src\lua\lua_Keyboard.h" />
-    <ClInclude Include="src\lua\lua_KeyboardKey.h" />
-    <ClInclude Include="src\lua\lua_KeyboardKeyEvent.h" />
     <ClInclude Include="src\lua\lua_Label.h" />
     <ClInclude Include="src\lua\lua_Layout.h" />
-    <ClInclude Include="src\lua\lua_LayoutType.h" />
     <ClInclude Include="src\lua\lua_Light.h" />
-    <ClInclude Include="src\lua\lua_LightType.h" />
     <ClInclude Include="src\lua\lua_Logger.h" />
-    <ClInclude Include="src\lua\lua_LoggerLevel.h" />
     <ClInclude Include="src\lua\lua_Material.h" />
     <ClInclude Include="src\lua\lua_MaterialParameter.h" />
     <ClInclude Include="src\lua\lua_MathUtil.h" />
     <ClInclude Include="src\lua\lua_Matrix.h" />
     <ClInclude Include="src\lua\lua_Mesh.h" />
     <ClInclude Include="src\lua\lua_MeshBatch.h" />
-    <ClInclude Include="src\lua\lua_MeshIndexFormat.h" />
     <ClInclude Include="src\lua\lua_MeshPart.h" />
-    <ClInclude Include="src\lua\lua_MeshPrimitiveType.h" />
     <ClInclude Include="src\lua\lua_MeshSkin.h" />
     <ClInclude Include="src\lua\lua_Model.h" />
     <ClInclude Include="src\lua\lua_Mouse.h" />
-    <ClInclude Include="src\lua\lua_MouseMouseEvent.h" />
     <ClInclude Include="src\lua\lua_Node.h" />
     <ClInclude Include="src\lua\lua_NodeCloneContext.h" />
-    <ClInclude Include="src\lua\lua_NodeType.h" />
     <ClInclude Include="src\lua\lua_ParticleEmitter.h" />
-    <ClInclude Include="src\lua\lua_ParticleEmitterBlendMode.h" />
     <ClInclude Include="src\lua\lua_Pass.h" />
     <ClInclude Include="src\lua\lua_PhysicsCharacter.h" />
     <ClInclude Include="src\lua\lua_PhysicsCollisionObject.h" />
     <ClInclude Include="src\lua\lua_PhysicsCollisionObjectCollisionListener.h" />
-    <ClInclude Include="src\lua\lua_PhysicsCollisionObjectCollisionListenerEventType.h" />
     <ClInclude Include="src\lua\lua_PhysicsCollisionObjectCollisionPair.h" />
-    <ClInclude Include="src\lua\lua_PhysicsCollisionObjectType.h" />
     <ClInclude Include="src\lua\lua_PhysicsCollisionShape.h" />
     <ClInclude Include="src\lua\lua_PhysicsCollisionShapeDefinition.h" />
-    <ClInclude Include="src\lua\lua_PhysicsCollisionShapeType.h" />
     <ClInclude Include="src\lua\lua_PhysicsConstraint.h" />
     <ClInclude Include="src\lua\lua_PhysicsController.h" />
     <ClInclude Include="src\lua\lua_PhysicsControllerHitFilter.h" />
     <ClInclude Include="src\lua\lua_PhysicsControllerHitResult.h" />
     <ClInclude Include="src\lua\lua_PhysicsControllerListener.h" />
-    <ClInclude Include="src\lua\lua_PhysicsControllerListenerEventType.h" />
     <ClInclude Include="src\lua\lua_PhysicsFixedConstraint.h" />
     <ClInclude Include="src\lua\lua_PhysicsGenericConstraint.h" />
     <ClInclude Include="src\lua\lua_PhysicsGhostObject.h" />
@@ -478,48 +395,35 @@
     <ClInclude Include="src\lua\lua_Plane.h" />
     <ClInclude Include="src\lua\lua_Platform.h" />
     <ClInclude Include="src\lua\lua_Properties.h" />
-    <ClInclude Include="src\lua\lua_PropertiesType.h" />
     <ClInclude Include="src\lua\lua_Quaternion.h" />
     <ClInclude Include="src\lua\lua_RadioButton.h" />
     <ClInclude Include="src\lua\lua_Ray.h" />
     <ClInclude Include="src\lua\lua_Rectangle.h" />
     <ClInclude Include="src\lua\lua_Ref.h" />
     <ClInclude Include="src\lua\lua_RenderState.h" />
-    <ClInclude Include="src\lua\lua_RenderStateAutoBinding.h" />
-    <ClInclude Include="src\lua\lua_RenderStateBlend.h" />
-    <ClInclude Include="src\lua\lua_RenderStateCullFaceSide.h" />
-    <ClInclude Include="src\lua\lua_RenderStateDepthFunction.h" />
-    <ClInclude Include="src\lua\lua_RenderStateFrontFace.h" />
     <ClInclude Include="src\lua\lua_RenderStateStateBlock.h" />
-    <ClInclude Include="src\lua\lua_RenderStateStencilFunction.h" />
-    <ClInclude Include="src\lua\lua_RenderStateStencilOperation.h" />
     <ClInclude Include="src\lua\lua_RenderTarget.h" />
     <ClInclude Include="src\lua\lua_Scene.h" />
     <ClInclude Include="src\lua\lua_ScreenDisplayer.h" />
+    <ClInclude Include="src\lua\lua_Script.h" />
     <ClInclude Include="src\lua\lua_ScriptController.h" />
     <ClInclude Include="src\lua\lua_ScriptTarget.h" />
+    <ClInclude Include="src\lua\lua_ScriptTargetEvent.h" />
+    <ClInclude Include="src\lua\lua_ScriptTargetEventRegistry.h" />
     <ClInclude Include="src\lua\lua_Slider.h" />
     <ClInclude Include="src\lua\lua_SpriteBatch.h" />
     <ClInclude Include="src\lua\lua_Technique.h" />
     <ClInclude Include="src\lua\lua_Terrain.h" />
-    <ClInclude Include="src\lua\lua_TerrainFlags.h" />
     <ClInclude Include="src\lua\lua_TerrainPatch.h" />
     <ClInclude Include="src\lua\lua_TextBox.h" />
-    <ClInclude Include="src\lua\lua_TextBoxInputMode.h" />
     <ClInclude Include="src\lua\lua_Texture.h" />
-    <ClInclude Include="src\lua\lua_TextureCubeFace.h" />
-    <ClInclude Include="src\lua\lua_TextureFilter.h" />
-    <ClInclude Include="src\lua\lua_TextureFormat.h" />
     <ClInclude Include="src\lua\lua_TextureSampler.h" />
-    <ClInclude Include="src\lua\lua_TextureType.h" />
-    <ClInclude Include="src\lua\lua_TextureWrap.h" />
     <ClInclude Include="src\lua\lua_Theme.h" />
     <ClInclude Include="src\lua\lua_ThemeSideRegions.h" />
     <ClInclude Include="src\lua\lua_ThemeStyle.h" />
     <ClInclude Include="src\lua\lua_ThemeThemeImage.h" />
     <ClInclude Include="src\lua\lua_ThemeUVs.h" />
     <ClInclude Include="src\lua\lua_Touch.h" />
-    <ClInclude Include="src\lua\lua_TouchTouchEvent.h" />
     <ClInclude Include="src\lua\lua_Transform.h" />
     <ClInclude Include="src\lua\lua_TransformListener.h" />
     <ClInclude Include="src\lua\lua_Uniform.h" />
@@ -529,7 +433,6 @@
     <ClInclude Include="src\lua\lua_VertexAttributeBinding.h" />
     <ClInclude Include="src\lua\lua_VertexFormat.h" />
     <ClInclude Include="src\lua\lua_VertexFormatElement.h" />
-    <ClInclude Include="src\lua\lua_VertexFormatUsage.h" />
     <ClInclude Include="src\lua\lua_VerticalLayout.h" />
     <ClInclude Include="src\Material.h" />
     <ClInclude Include="src\MathUtil.h" />
@@ -572,6 +475,7 @@
     <ClInclude Include="src\Scene.h" />
     <ClInclude Include="src\SceneLoader.h" />
     <ClInclude Include="src\ScreenDisplayer.h" />
+    <ClInclude Include="src\Script.h" />
     <ClInclude Include="src\ScriptController.h" />
     <ClInclude Include="src\ScriptTarget.h" />
     <ClInclude Include="src\Slider.h" />
@@ -724,6 +628,8 @@
       <RuntimeTypeInfo>
       </RuntimeTypeInfo>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <MultiProcessorCompilation>true</MultiProcessorCompilation>
+      <MinimalRebuild>false</MinimalRebuild>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
@@ -743,6 +649,8 @@
       <AdditionalIncludeDirectories>$(ProjectDir)src;..\external-deps\lua\include;..\external-deps\bullet\include;..\external-deps\openal\include\AL;..\external-deps\alut\include\AL;..\external-deps\ogg\include;..\external-deps\vorbis\include;..\external-deps\glew\include;..\external-deps\png\include;..\external-deps\zlib\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <RuntimeTypeInfo>true</RuntimeTypeInfo>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <MultiProcessorCompilation>true</MultiProcessorCompilation>
+      <MinimalRebuild>false</MinimalRebuild>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
@@ -765,6 +673,7 @@
       <AdditionalIncludeDirectories>$(ProjectDir)src;..\external-deps\lua\include;..\external-deps\bullet\include;..\external-deps\openal\include\AL;..\external-deps\alut\include\AL;..\external-deps\ogg\include;..\external-deps\vorbis\include;..\external-deps\glew\include;..\external-deps\png\include;..\external-deps\zlib\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <DebugInformationFormat>
       </DebugInformationFormat>
+      <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>

+ 20 - 296
gameplay/gameplay.vcxproj.filters

@@ -357,9 +357,6 @@
     <ClCompile Include="src\lua\lua_AIMessage.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_AIMessageParameterType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_AIState.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -381,9 +378,6 @@
     <ClCompile Include="src\lua\lua_AnimationClipListener.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_AnimationClipListenerEventType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_AnimationController.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -405,9 +399,6 @@
     <ClCompile Include="src\lua\lua_AudioSource.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_AudioSourceState.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_BoundingBox.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -423,48 +414,24 @@
     <ClCompile Include="src\lua\lua_Camera.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_CameraType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_CheckBox.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
     <ClCompile Include="src\lua\lua_Container.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_ContainerScroll.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Control.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_ControlAlignment.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_ControlAutoSize.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_ControlListener.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_ControlListenerEventType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_ControlState.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Curve.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_CurveInterpolationType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_DepthStencilTarget.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_DepthStencilTargetFormat.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Effect.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -477,15 +444,6 @@
     <ClCompile Include="src\lua\lua_Font.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_FontFormat.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_FontJustify.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_FontStyle.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_FontText.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -501,27 +459,12 @@
     <ClCompile Include="src\lua\lua_Game.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_GameClearFlags.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Gamepad.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_GamepadButtonMapping.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_GamepadGamepadEvent.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_GameState.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Gesture.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_GestureGestureEvent.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Global.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -534,42 +477,24 @@
     <ClCompile Include="src\lua\lua_ImageControl.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_ImageFormat.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Joint.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
     <ClCompile Include="src\lua\lua_Keyboard.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_KeyboardKey.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_KeyboardKeyEvent.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Label.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
     <ClCompile Include="src\lua\lua_Layout.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_LayoutType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Light.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_LightType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Logger.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_LoggerLevel.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Material.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -588,15 +513,9 @@
     <ClCompile Include="src\lua\lua_MeshBatch.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_MeshIndexFormat.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_MeshPart.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_MeshPrimitiveType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_MeshSkin.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -606,24 +525,15 @@
     <ClCompile Include="src\lua\lua_Mouse.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_MouseMouseEvent.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Node.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
     <ClCompile Include="src\lua\lua_NodeCloneContext.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_NodeType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_ParticleEmitter.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_ParticleEmitterTextureBlending.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Pass.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -636,24 +546,15 @@
     <ClCompile Include="src\lua\lua_PhysicsCollisionObjectCollisionListener.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_PhysicsCollisionObjectCollisionListenerEventType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_PhysicsCollisionObjectCollisionPair.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_PhysicsCollisionObjectType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_PhysicsCollisionShape.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
     <ClCompile Include="src\lua\lua_PhysicsCollisionShapeDefinition.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_PhysicsCollisionShapeType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_PhysicsConstraint.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -669,9 +570,6 @@
     <ClCompile Include="src\lua\lua_PhysicsControllerListener.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_PhysicsControllerListenerEventType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_PhysicsFixedConstraint.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -711,9 +609,6 @@
     <ClCompile Include="src\lua\lua_Properties.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_PropertiesType.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Quaternion.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -732,30 +627,9 @@
     <ClCompile Include="src\lua\lua_RenderState.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_RenderStateAutoBinding.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_RenderStateBlend.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_RenderStateCullFaceSide.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_RenderStateDepthFunction.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_RenderStateFrontFace.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_RenderStateStateBlock.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_RenderStateStencilFunction.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_RenderStateStencilOperation.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_RenderTarget.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -783,30 +657,15 @@
     <ClCompile Include="src\lua\lua_Terrain.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_TerrainFlags.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_TextBox.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_TextBoxInputMode.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Texture.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_TextureFilter.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
-    <ClCompile Include="src\lua\lua_TextureFormat.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_TextureSampler.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_TextureWrap.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Theme.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -825,9 +684,6 @@
     <ClCompile Include="src\lua\lua_Touch.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_TouchTouchEvent.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_Transform.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -855,9 +711,6 @@
     <ClCompile Include="src\lua\lua_VertexFormatElement.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_VertexFormatUsage.cpp">
-      <Filter>src\lua</Filter>
-    </ClCompile>
     <ClCompile Include="src\lua\lua_VerticalLayout.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
@@ -873,7 +726,16 @@
     <ClCompile Include="src\lua\lua_JoystickControl.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
-    <ClCompile Include="src\lua\lua_ContainerDirection.cpp">
+    <ClCompile Include="src\Script.cpp">
+      <Filter>src</Filter>
+    </ClCompile>
+    <ClCompile Include="src\lua\lua_Script.cpp">
+      <Filter>src\lua</Filter>
+    </ClCompile>
+    <ClCompile Include="src\lua\lua_ScriptTargetEvent.cpp">
+      <Filter>src\lua</Filter>
+    </ClCompile>
+    <ClCompile Include="src\lua\lua_ScriptTargetEventRegistry.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
     <ClCompile Include="src\lua\lua_TextureCubeFace.cpp">
@@ -1226,9 +1088,6 @@
     <ClInclude Include="src\lua\lua_AIMessage.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_AIMessageParameterType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_AIState.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1250,9 +1109,6 @@
     <ClInclude Include="src\lua\lua_AnimationClipListener.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_AnimationClipListenerEventType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_AnimationController.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1274,9 +1130,6 @@
     <ClInclude Include="src\lua\lua_AudioSource.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_AudioSourceState.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_BoundingBox.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1292,48 +1145,24 @@
     <ClInclude Include="src\lua\lua_Camera.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_CameraType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_CheckBox.h">
       <Filter>src\lua</Filter>
     </ClInclude>
     <ClInclude Include="src\lua\lua_Container.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_ContainerScroll.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Control.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_ControlAlignment.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_ControlAutoSize.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_ControlListener.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_ControlListenerEventType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_ControlState.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Curve.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_CurveInterpolationType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_DepthStencilTarget.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_DepthStencilTargetFormat.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Effect.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1346,15 +1175,6 @@
     <ClInclude Include="src\lua\lua_Font.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_FontFormat.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_FontJustify.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_FontStyle.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_FontText.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1370,27 +1190,12 @@
     <ClInclude Include="src\lua\lua_Game.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_GameClearFlags.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Gamepad.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_GamepadButtonMapping.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_GamepadGamepadEvent.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_GameState.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Gesture.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_GestureGestureEvent.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Global.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1403,42 +1208,24 @@
     <ClInclude Include="src\lua\lua_ImageControl.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_ImageFormat.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Joint.h">
       <Filter>src\lua</Filter>
     </ClInclude>
     <ClInclude Include="src\lua\lua_Keyboard.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_KeyboardKey.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_KeyboardKeyEvent.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Label.h">
       <Filter>src\lua</Filter>
     </ClInclude>
     <ClInclude Include="src\lua\lua_Layout.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_LayoutType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Light.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_LightType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Logger.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_LoggerLevel.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Material.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1457,15 +1244,9 @@
     <ClInclude Include="src\lua\lua_MeshBatch.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_MeshIndexFormat.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_MeshPart.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_MeshPrimitiveType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_MeshSkin.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1475,24 +1256,15 @@
     <ClInclude Include="src\lua\lua_Mouse.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_MouseMouseEvent.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Node.h">
       <Filter>src\lua</Filter>
     </ClInclude>
     <ClInclude Include="src\lua\lua_NodeCloneContext.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_NodeType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_ParticleEmitter.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_ParticleEmitterTextureBlending.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Pass.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1505,24 +1277,15 @@
     <ClInclude Include="src\lua\lua_PhysicsCollisionObjectCollisionListener.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_PhysicsCollisionObjectCollisionListenerEventType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_PhysicsCollisionObjectCollisionPair.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_PhysicsCollisionObjectType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_PhysicsCollisionShape.h">
       <Filter>src\lua</Filter>
     </ClInclude>
     <ClInclude Include="src\lua\lua_PhysicsCollisionShapeDefinition.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_PhysicsCollisionShapeType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_PhysicsConstraint.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1538,9 +1301,6 @@
     <ClInclude Include="src\lua\lua_PhysicsControllerListener.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_PhysicsControllerListenerEventType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_PhysicsFixedConstraint.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1580,9 +1340,6 @@
     <ClInclude Include="src\lua\lua_Properties.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_PropertiesType.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Quaternion.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1601,30 +1358,9 @@
     <ClInclude Include="src\lua\lua_RenderState.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_RenderStateAutoBinding.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_RenderStateBlend.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_RenderStateCullFaceSide.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_RenderStateDepthFunction.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_RenderStateFrontFace.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_RenderStateStateBlock.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_RenderStateStencilFunction.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_RenderStateStencilOperation.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_RenderTarget.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1652,30 +1388,15 @@
     <ClInclude Include="src\lua\lua_Terrain.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_TerrainFlags.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_TextBox.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_TextBoxInputMode.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Texture.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_TextureFilter.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
-    <ClInclude Include="src\lua\lua_TextureFormat.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_TextureSampler.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_TextureWrap.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Theme.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1694,9 +1415,6 @@
     <ClInclude Include="src\lua\lua_Touch.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_TouchTouchEvent.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_Transform.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1724,9 +1442,6 @@
     <ClInclude Include="src\lua\lua_VertexFormatElement.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_VertexFormatUsage.h">
-      <Filter>src\lua</Filter>
-    </ClInclude>
     <ClInclude Include="src\lua\lua_VerticalLayout.h">
       <Filter>src\lua</Filter>
     </ClInclude>
@@ -1742,7 +1457,16 @@
     <ClInclude Include="src\lua\lua_JoystickControl.h">
       <Filter>src\lua</Filter>
     </ClInclude>
-    <ClInclude Include="src\lua\lua_ContainerDirection.h">
+    <ClInclude Include="src\Script.h">
+      <Filter>src</Filter>
+    </ClInclude>
+    <ClInclude Include="src\lua\lua_Script.h">
+      <Filter>src\lua</Filter>
+    </ClInclude>
+    <ClInclude Include="src\lua\lua_ScriptTargetEvent.h">
+      <Filter>src\lua</Filter>
+    </ClInclude>
+    <ClInclude Include="src\lua\lua_ScriptTargetEventRegistry.h">
       <Filter>src\lua</Filter>
     </ClInclude>
     <ClInclude Include="src\lua\lua_TextureCubeFace.h">

File diff ditekan karena terlalu besar
+ 28 - 342
gameplay/gameplay.xcodeproj/project.pbxproj


+ 13 - 0
gameplay/res/shaders/terrain.frag

@@ -71,6 +71,19 @@ vec4 _baseColor;
 varying vec3 v_normalVector;
 #else
 vec3 v_normalVector;
+
+#if (DIRECTIONAL_LIGHT_COUNT > 0)
+varying vec3 v_lightDirection[DIRECTIONAL_LIGHT_COUNT];
+#endif
+
+#if (POINT_LIGHT_COUNT > 0)
+varying vec3 v_vertexToPointLightDirection[POINT_LIGHT_COUNT];
+#endif
+
+#if (SPOT_LIGHT_COUNT > 0)
+varying vec3 v_vertexToSpotLightDirection[SPOT_LIGHT_COUNT];
+#endif
+
 #endif
 #endif
 

+ 3 - 5
gameplay/src/AIAgent.cpp

@@ -9,8 +9,6 @@ AIAgent::AIAgent()
     : _stateMachine(NULL), _node(NULL), _enabled(true), _listener(NULL), _next(NULL)
 {
     _stateMachine = new AIStateMachine(this);
-
-    addScriptEvent("message", "<AIMessage>");
 }
 
 AIAgent::~AIAgent()
@@ -90,10 +88,10 @@ bool AIAgent::processMessage(AIMessage* message)
     // Dispatch message to registered listener.
     if (_listener && _listener->messageReceived(message))
         return true;
-    
-    if (fireScriptEvent<bool>("message", message))
+
+    if (_node && _node->fireScriptEvent<bool>(GP_GET_SCRIPT_EVENT(Node, messageReceived), dynamic_cast<void*>(_node), message))
         return true;
-    
+
     return false;
 }
 

+ 2 - 2
gameplay/src/AIAgent.h

@@ -4,7 +4,6 @@
 #include "Ref.h"
 #include "AIStateMachine.h"
 #include "AIMessage.h"
-#include "ScriptTarget.h"
 
 namespace gameplay
 {
@@ -19,9 +18,10 @@ class Node;
  * such as state machines. By default, an AIAgent has an empty state 
  * machine.
  */
-class AIAgent : public Ref, public ScriptTarget
+class AIAgent : public Ref
 {
     friend class Node;
+    friend class AIState;
     friend class AIController;
 
 public:

+ 11 - 6
gameplay/src/AIState.cpp

@@ -1,6 +1,8 @@
 #include "Base.h"
 #include "AIState.h"
+#include "AIAgent.h"
 #include "AIStateMachine.h"
+#include "Node.h"
 
 namespace gameplay
 {
@@ -10,9 +12,6 @@ AIState* AIState::_empty = NULL;
 AIState::AIState(const char* id)
     : _id(id), _listener(NULL)
 {
-    addScriptEvent("enter", "<AIAgent><AIState>");
-    addScriptEvent("exit", "<AIAgent><AIState>");
-    addScriptEvent("update", "<AIAgent><AIState>f");
 }
 
 AIState::~AIState()
@@ -39,7 +38,9 @@ void AIState::enter(AIStateMachine* stateMachine)
     if (_listener)
         _listener->stateEnter(stateMachine->getAgent(), this);
 
-    fireScriptEvent<void>("enter", stateMachine->getAgent(), this);
+    Node* node = stateMachine->_agent->_node;
+    if (node)
+        node->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(Node, stateEnter), dynamic_cast<void*>(node), this);
 }
 
 void AIState::exit(AIStateMachine* stateMachine)
@@ -47,7 +48,9 @@ void AIState::exit(AIStateMachine* stateMachine)
     if (_listener)
         _listener->stateExit(stateMachine->getAgent(), this);
 
-    fireScriptEvent<void>("exit", stateMachine->getAgent(), this);
+    Node* node = stateMachine->_agent->_node;
+    if (node)
+        node->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(Node, stateExit), dynamic_cast<void*>(node), this);
 }
 
 void AIState::update(AIStateMachine* stateMachine, float elapsedTime)
@@ -55,7 +58,9 @@ void AIState::update(AIStateMachine* stateMachine, float elapsedTime)
     if (_listener)
         _listener->stateUpdate(stateMachine->getAgent(), this, elapsedTime);
 
-    fireScriptEvent<void>("update", stateMachine->getAgent(), this, elapsedTime);
+    Node* node = stateMachine->_agent->_node;
+    if (node)
+        node->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(Node, stateUpdate), dynamic_cast<void*>(node), this, elapsedTime);
 }
 
 AIState::Listener::~Listener()

+ 1 - 2
gameplay/src/AIState.h

@@ -2,7 +2,6 @@
 #define AISTATE_H_
 
 #include "Ref.h"
-#include "ScriptTarget.h"
 
 namespace gameplay
 {
@@ -17,7 +16,7 @@ class AIStateMachine;
  * state machine. Events can be programmed or scripted when the
  * state is entered, exited and each frame/tick in its update event.
  */
-class AIState : public Ref, public ScriptTarget
+class AIState : public Ref
 {
     friend class AIStateMachine;
 

+ 1 - 0
gameplay/src/AIStateMachine.h

@@ -30,6 +30,7 @@ class AIAgent;
 class AIStateMachine
 {
     friend class AIAgent;
+    friend class AIState;
 
 public:
 

+ 19 - 104
gameplay/src/AnimationClip.cpp

@@ -9,12 +9,16 @@
 namespace gameplay
 {
 
+extern void splitURL(const std::string& url, std::string* file, std::string* id);
+
 AnimationClip::AnimationClip(const char* id, Animation* animation, unsigned long startTime, unsigned long endTime)
     : _id(id), _animation(animation), _startTime(startTime), _endTime(endTime), _duration(_endTime - _startTime), 
       _stateBits(0x00), _repeatCount(1.0f), _loopBlendTime(0), _activeDuration(_duration * _repeatCount), _speed(1.0f), _timeStarted(0), 
       _elapsedTime(0), _crossFadeToClip(NULL), _crossFadeOutElapsed(0), _crossFadeOutDuration(0), _blendWeight(1.0f),
-      _beginListeners(NULL), _endListeners(NULL), _listeners(NULL), _listenerItr(NULL), _scriptListeners(NULL)
+      _beginListeners(NULL), _endListeners(NULL), _listeners(NULL), _listenerItr(NULL)
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     GP_ASSERT(_animation);
     GP_ASSERT(0 <= startTime && startTime <= _animation->_duration && 0 <= endTime && endTime <= _animation->_duration);
 
@@ -40,15 +44,6 @@ AnimationClip::~AnimationClip()
     SAFE_DELETE(_beginListeners);
     SAFE_DELETE(_endListeners);
 
-    if (_scriptListeners)
-    {
-        for (size_t i = 0; i < _scriptListeners->size(); i++)
-        {
-            SAFE_DELETE((*_scriptListeners)[i]);
-        }
-        SAFE_DELETE(_scriptListeners);
-    }
-
     if (_listeners)
     {
         *_listenerItr = _listeners->begin();
@@ -73,6 +68,11 @@ AnimationClip::ListenerEvent::~ListenerEvent()
 {
 }
 
+const char* AnimationClip::getTypeName() const
+{
+    return "AnimationClip";
+}
+
 const char* AnimationClip::getId() const
 {
     return _id.c_str();
@@ -392,88 +392,6 @@ void AnimationClip::removeEndListener(AnimationClip::Listener* listener)
     }
 }
 
-void AnimationClip::addBeginListener(const char* function)
-{
-    if (!_scriptListeners)
-        _scriptListeners = new std::vector<ScriptListener*>;
-
-    ScriptListener* listener = new ScriptListener(function);
-    _scriptListeners->push_back(listener);
-    addBeginListener(listener);
-}
-
-void AnimationClip::removeBeginListener(const char* function)
-{
-    if (_scriptListeners)
-    {
-        std::string functionRef = Game::getInstance()->getScriptController()->loadUrl(function);
-        std::vector<ScriptListener*>::iterator iter = std::find_if(_scriptListeners->begin(), _scriptListeners->end(), [&](ScriptListener* listener){ return listener->function == functionRef; });
-        if (iter != _scriptListeners->end())
-        {
-            ScriptListener* listener = *iter;
-
-            removeBeginListener(listener);
-            _scriptListeners->erase(iter);
-            SAFE_DELETE(listener);
-        }
-    }
-}
-
-void AnimationClip::addEndListener(const char* function)
-{
-    if (!_scriptListeners)
-        _scriptListeners = new std::vector<ScriptListener*>;
-
-    ScriptListener* listener = new ScriptListener(function);
-    _scriptListeners->push_back(listener);
-    addEndListener(listener);
-}
-
-void AnimationClip::removeEndListener(const char* function)
-{
-    if (_scriptListeners)
-    {
-        std::string functionRef = Game::getInstance()->getScriptController()->loadUrl(function);
-        std::vector<ScriptListener*>::iterator iter = std::find_if(_scriptListeners->begin(), _scriptListeners->end(), [&](ScriptListener* listener){ return listener->function == functionRef; });
-        if (iter != _scriptListeners->end())
-        {
-            ScriptListener* listener = *iter;
-
-            removeEndListener(listener);
-            _scriptListeners->erase(iter);
-            SAFE_DELETE(listener);
-        }
-    }
-}
-
-void AnimationClip::addListener(const char* function, unsigned long eventTime)
-{
-    if (!_scriptListeners)
-        _scriptListeners = new std::vector<ScriptListener*>;
-
-    ScriptListener* listener = new ScriptListener(function);
-    _scriptListeners->push_back(listener);
-    addListener(listener, eventTime);
-}
-
-void AnimationClip::removeListener(const char* function, unsigned long eventTime)
-{
-    if (_scriptListeners)
-    {
-        GP_ASSERT(eventTime < _activeDuration); // Do this check here, before we modify any state
-        std::string functionRef = Game::getInstance()->getScriptController()->loadUrl(function);
-        std::vector<ScriptListener*>::iterator iter = std::find_if(_scriptListeners->begin(), _scriptListeners->end(), [&](ScriptListener* listener){ return listener->function == functionRef; });
-        if (iter != _scriptListeners->end())
-        {
-            ScriptListener* listener = *iter;
-
-            removeListener(listener, eventTime);
-            _scriptListeners->erase(iter);
-            SAFE_DELETE(listener);
-        }
-    }
-}
-
 bool AnimationClip::update(float elapsedTime)
 {
     if (isClipStateBitSet(CLIP_IS_PAUSED_BIT))
@@ -566,6 +484,9 @@ bool AnimationClip::update(float elapsedTime)
         }
     }
 
+    // Fire script update event
+    fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(AnimationClip, clipUpdate), this, _elapsedTime);
+
     // Add back in start time, and divide by the total animation's duration to get the actual percentage complete
     GP_ASSERT(_animation);
 
@@ -693,6 +614,9 @@ void AnimationClip::onBegin()
         }
     }
 
+    // Fire script begin event
+    fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(AnimationClip, clipBegin), this);
+
     release();
 }
 
@@ -715,6 +639,9 @@ void AnimationClip::onEnd()
         }
     }
 
+    // Fire script end event
+    fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(AnimationClip, clipEnd), this);
+
     release();
 }
 
@@ -757,16 +684,4 @@ AnimationClip* AnimationClip::clone(Animation* animation) const
     return newClip;
 }
 
-AnimationClip::ScriptListener::ScriptListener(const std::string& function)
-{
-    // Store the function name.
-    this->function = Game::getInstance()->getScriptController()->loadUrl(function.c_str());
-}
-
-void AnimationClip::ScriptListener::animationEvent(AnimationClip* clip, EventType type)
-{
-    Game::getInstance()->getScriptController()->executeFunction<void>(function.c_str(), "<AnimationClip>[AnimationClip::Listener::EventType]", clip, type);
-}
-
-
 }

+ 17 - 77
gameplay/src/AnimationClip.h

@@ -1,26 +1,31 @@
 #ifndef ANIMATIONCLIP_H_
 #define ANIMATIONCLIP_H_
 
-#include "Base.h"
 #include "AnimationValue.h"
 #include "Curve.h"
 #include "Animation.h"
+#include "ScriptTarget.h"
 
 namespace gameplay
 {
 
 class Animation;
 class AnimationValue;
-class ScriptListener;
 
 /**
  * Defines the runtime session of an Animation to be played.
  */
-class AnimationClip : public Ref
+class AnimationClip : public Ref, public ScriptTarget
 {
     friend class AnimationController;
     friend class Animation;
 
+    GP_SCRIPT_EVENTS_START();
+    GP_SCRIPT_EVENT(clipBegin, "<AnimationClip>");
+    GP_SCRIPT_EVENT(clipEnd, "<AnimationClip>");
+    GP_SCRIPT_EVENT(clipUpdate, "<AnimationClip>f");
+    GP_SCRIPT_EVENTS_END();
+
 public:
 
     /**
@@ -37,7 +42,7 @@ public:
 
     public:
 
-        /*
+        /**
          * Constructor.
          */
         Listener() 
@@ -76,6 +81,14 @@ public:
         virtual void animationEvent(AnimationClip* clip, EventType type) = 0;
     };
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * @return The type name of this class: "AnimationClip"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Gets the AnimationClip's ID.
      *
@@ -271,59 +284,6 @@ public:
      */
     void removeListener(AnimationClip::Listener* listener, unsigned long eventTime);
 
-    /**
-     * Adds an animation begin listener.
-     * 
-     * Note: the given Lua function must have the same function signature as AnimationClip::Listener::animationEvent.
-     *
-     * @param function The Lua script function to be called when an AnimationClip begins.
-     */
-    void addBeginListener(const char* function);
-
-    /**
-     * Removes an animation begin listener.
-     *
-     * @param function The Lua script function to remove.
-     */
-    void removeBeginListener(const char* function);
-
-    /**
-     * Adds an animation end listener.
-     * 
-     * Note: the given Lua function must have the same function signature as AnimationClip::Listener::animationEvent.
-     *
-     * @param function The Lua script function to be called when an AnimationClip ends.
-     */
-    void addEndListener(const char* function);
-
-    /**
-     * Removes an animation end listener.
-     *
-     * @param function The Lua script function to remove.
-     */
-    void removeEndListener(const char* function);
-
-    /**
-     * Adds an animation listener to be called back at the specified eventTime during the playback 
-     * of the AnimationClip.
-     * 
-     * Note: the given Lua function must have the same function signature as AnimationClip::Listener::animationEvent.
-     * 
-     * @param function The Lua script function to be called when an AnimationClip reaches the 
-     *      specified time in its playback.
-     * @param eventTime The time the listener will be called during the playback of the AnimationClip. 
-     *      Must be between 0 and the duration of the AnimationClip.
-     */
-    void addListener(const char* function, unsigned long eventTime);
-
-    /**
-     * Removes an animation listener assigned to the specified eventTime.
-     *
-     * @param function The Lua script function to remove with the specified time.
-     * @param eventTime The time of the listener to be removed.
-     */
-    void removeListener(const char* function, unsigned long eventTime);
-
 private:
     
     static const unsigned char CLIP_IS_PLAYING_BIT = 0x01;             // Bit representing whether AnimationClip is a running clip in AnimationController
@@ -362,25 +322,6 @@ private:
         unsigned long _eventTime;   // The time at which the listener will be called back at during the playback of the AnimationClip.
     };
 
-    /**
-     * Listener implementation for script callbacks.
-     */
-    struct ScriptListener : public AnimationClip::Listener
-    {
-        /**
-         * Constructor.
-         */
-        ScriptListener(const std::string& function);
-
-        /**
-         * @see AnimationClip::Listener::animationEvent
-         */
-        void animationEvent(AnimationClip* clip, EventType type);
-
-        /** The function to call back when an animation event occurs. */
-        std::string function;
-    };
-
     /**
      * Constructor.
      */
@@ -466,7 +407,6 @@ private:
     std::vector<Listener*>* _endListeners;              // Collection of end listeners on the clip.
     std::list<ListenerEvent*>* _listeners;              // Ordered collection of listeners on the clip.
     std::list<ListenerEvent*>::iterator* _listenerItr;  // Iterator that points to the next listener event to be triggered.
-    std::vector<ScriptListener*>* _scriptListeners;     // Collection of listeners that are bound to Lua script functions.
 };
 
 }

+ 1 - 1
gameplay/src/Base.h

@@ -294,7 +294,7 @@ typedef unsigned long GamepadHandle;
  * mode and is therefore safe to use for realtime/per-frame GL
  * function calls.
  */
-#ifdef NDEBUG
+#if defined(NDEBUG) || (defined(__APPLE__) && !defined(DEBUG))
 #define GL_ASSERT( gl_code ) gl_code
 #else
 #define GL_ASSERT( gl_code ) do \

+ 2 - 2
gameplay/src/Button.cpp

@@ -45,9 +45,9 @@ void Button::initialize(const char* typeName, Theme::Style* style, Properties* p
     }
 }
 
-const char* Button::getType() const
+const char* Button::getTypeName() const
 {
-    return "button";
+    return "Button";
 }
 
 const unsigned int Button::getDataBinding() const

+ 7 - 2
gameplay/src/Button.h

@@ -62,9 +62,14 @@ protected:
     void initialize(const char* typeName, Theme::Style* style, Properties* properties);
 
     /**
-     * @see Control::getType
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "Button"
+     * @see ScriptTarget::getTypeName()
      */
-    const char* getType() const;
+    const char* getTypeName() const;
 
     /**
      * Gets the data binding index for this control.

+ 5 - 5
gameplay/src/CheckBox.cpp

@@ -39,6 +39,11 @@ void CheckBox::initialize(const char* typeName, Theme::Style* style, Properties*
     }
 }
 
+const char* CheckBox::getTypeName() const
+{
+    return "CheckBox";
+}
+
 bool CheckBox::isChecked()
 {
     return _checked;
@@ -155,9 +160,4 @@ unsigned int CheckBox::drawImages(Form* form, const Rectangle& clip)
     return 1;
 }
 
-const char* CheckBox::getType() const
-{
-    return "checkBox";
-}
-
 }

+ 10 - 5
gameplay/src/CheckBox.h

@@ -34,6 +34,16 @@ public:
      */
     static CheckBox* create(const char* id, Theme::Style* style = NULL);
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "CheckBox"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Gets whether this checkbox is checked.
      *
@@ -48,11 +58,6 @@ public:
      */
     void setChecked(bool checked);
 
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
-
     /**
      * Add a listener to be notified of specific events affecting
      * this control.  Event types can be OR'ed together.

+ 5 - 5
gameplay/src/Container.cpp

@@ -177,6 +177,11 @@ void Container::addControls(Properties* properties)
     sortControls();
 }
 
+const char* Container::getTypeName() const
+{
+    return "Container";
+}
+
 Layout* Container::getLayout()
 {
     return _layout;
@@ -444,11 +449,6 @@ Animation* Container::getAnimation(const char* id) const
     return NULL;
 }
 
-const char* Container::getType() const
-{
-    return "container";
-}
-
 bool Container::getScrollWheelRequiresFocus() const
 {
     return _scrollWheelRequiresFocus;

+ 10 - 5
gameplay/src/Container.h

@@ -62,6 +62,16 @@ public:
      */
     static Container* create(const char* id, Theme::Style* style = NULL, Layout::Type layout = Layout::LAYOUT_ABSOLUTE);
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "Container"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Get this container's layout.
      *
@@ -233,11 +243,6 @@ public:
      */
     bool isContainer() const;
 
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
-
     /**
      * Get whether this container requires focus in order to handle scroll-wheel events.
      */

+ 9 - 9
gameplay/src/Control.cpp

@@ -43,7 +43,7 @@ Control::Control()
     _autoSize(AUTO_SIZE_BOTH), _listeners(NULL), _style(NULL), _visible(true), _opacity(0.0f), _zIndex(-1),
     _contactIndex(INVALID_CONTACT_INDEX), _focusIndex(-1), _canFocus(false), _state(NORMAL), _parent(NULL), _styleOverridden(false), _skin(NULL)
 {
-    addScriptEvent("controlEvent", "<Control>[Control::Listener::EventType]");
+    GP_REGISTER_SCRIPT_EVENTS();
 }
 
 Control::~Control()
@@ -237,8 +237,8 @@ void Control::initialize(const char* typeName, Theme::Style* style, Properties*
 		}
 
 		// Register script listeners for control events
-		if (properties->exists("listener"))
-			addScriptCallback("controlEvent", properties->getString("listener"));
+		if (properties->exists("script"))
+			addScript(properties->getString("script"));
 
 		// Potentially override themed properties for all states.
 		overrideThemedProperties(properties, STATE_ALL);
@@ -285,6 +285,11 @@ void Control::initialize(const char* typeName, Theme::Style* style, Properties*
 	}
 }
 
+const char* Control::getTypeName() const
+{
+    return "Control";
+}
+
 const char* Control::getId() const
 {
     return _id.c_str();
@@ -1116,7 +1121,7 @@ void Control::notifyListeners(Control::Listener::EventType eventType)
         }
     }
 
-    fireScriptEvent<void>("controlEvent", this, eventType);
+    fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(Control, controlEvent), dynamic_cast<void*>(this), eventType);
 
     release();
 }
@@ -1497,11 +1502,6 @@ Theme::ThemeImage* Control::getImage(const char* id, State state)
     return image ? image : _style->getTheme()->_emptyImage;
 }
 
-const char* Control::getType() const
-{
-    return "control";
-}
-
 Control* Control::getParent() const
 {
     return _parent;

+ 14 - 7
gameplay/src/Control.h

@@ -28,6 +28,10 @@ class Control : public Ref, public AnimationTarget, public ScriptTarget
     friend class Form;
     friend class Container;
 
+    GP_SCRIPT_EVENTS_START();
+    GP_SCRIPT_EVENT(controlEvent, "<Control>[Control::Listener::EventType]");
+    GP_SCRIPT_EVENTS_END();
+
 public:
 
     /**
@@ -231,6 +235,16 @@ public:
      */
     static const int ANIMATE_OPACITY = 7;
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "Control"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Get this control's ID string.
      *
@@ -904,13 +918,6 @@ public:
      */
     virtual bool isContainer() const;
 
-    /**
-     * Gets the type of the Control and returns it as a string.
-     *
-     * @return The string of the Control type, all in lower-case.
-     */
-    virtual const char* getType() const;
-
     /**
      * Returns this control's parent, or NULL if this control does not have a parent.
      *

+ 4 - 2
gameplay/src/ControlFactory.cpp

@@ -85,8 +85,10 @@ void ControlFactory::registerStandardControls()
     registerCustomControl("CONTAINER", &Container::create);
     registerCustomControl("SLIDER", &Slider::create);
     registerCustomControl("TEXTBOX", &TextBox::create);
-    registerCustomControl("JOYSTICK", &JoystickControl::create);
-    registerCustomControl("IMAGE", &ImageControl::create);
+    registerCustomControl("JOYSTICK", &JoystickControl::create); // convenience alias
+    registerCustomControl("JOYSTICKCONTROL", &JoystickControl::create);
+    registerCustomControl("IMAGE", &ImageControl::create);  // convenience alias
+    registerCustomControl("IMAGECONTROL", &ImageControl::create);
 }
 
 }

+ 10 - 2
gameplay/src/DebugNew.cpp

@@ -114,7 +114,7 @@ void* debugAlloc(std::size_t size, const char* file, int line)
 
     // Capture the stack frame (up to MAX_STACK_FRAMES) if we 
     // are running on Windows and the user has enabled it.
-#if defined(WIN32) && defined(_M_IX86)
+#if defined(WIN32)
     rec->trackStackTrace = __trackStackTrace;
     if (rec->trackStackTrace)
     {
@@ -134,7 +134,7 @@ void* debugAlloc(std::size_t size, const char* file, int line)
         memset(&stackFrame, 0, sizeof(STACKFRAME64));
 
         // Initialize the stack frame based on the machine architecture.
-#ifdef _M_IX86
+#if defined(_M_IX86)
         static const DWORD machineType = IMAGE_FILE_MACHINE_I386;
         stackFrame.AddrPC.Offset = context.Eip;
         stackFrame.AddrPC.Mode = AddrModeFlat;
@@ -142,6 +142,14 @@ void* debugAlloc(std::size_t size, const char* file, int line)
         stackFrame.AddrFrame.Mode = AddrModeFlat;
         stackFrame.AddrStack.Offset = context.Esp;
         stackFrame.AddrStack.Mode = AddrModeFlat;
+#elif defined (_M_X64)
+        static const DWORD machineType = IMAGE_FILE_MACHINE_AMD64;
+        stackFrame.AddrPC.Offset = context.Rip;
+        stackFrame.AddrPC.Mode = AddrModeFlat;
+        stackFrame.AddrFrame.Offset = context.Rdi;
+        stackFrame.AddrFrame.Mode = AddrModeFlat;
+        stackFrame.AddrStack.Offset = context.Rsp;
+        stackFrame.AddrStack.Mode = AddrModeFlat;
 #else
 #error "Machine architecture not supported!"
 #endif

+ 34 - 8
gameplay/src/FileSystem.cpp

@@ -87,6 +87,7 @@ static bool androidFileExists(const char* filePath)
 
 /** @script{ignore} */
 static std::string __resourcePath("./");
+static std::string __assetPath("");
 static std::map<std::string, std::string> __aliases;
 
 /**
@@ -343,14 +344,18 @@ bool FileSystem::fileExists(const char* filePath)
 {
     GP_ASSERT(filePath);
 
+    std::string fullPath;
+
 #ifdef __ANDROID__
-    if (androidFileExists(resolvePath(filePath)))
+    fullPath = __assetPath;
+    fullPath += resolvePath(filePath);
+
+    if (androidFileExists(fullPath.c_str()))
     {
         return true;
     }
 #endif
 
-    std::string fullPath;
     getFullPath(filePath, fullPath);
 
     gp_stat_struct s;
@@ -364,17 +369,17 @@ Stream* FileSystem::open(const char* path, size_t streamMode)
     if ((streamMode & WRITE) != 0)
         modeStr[0] = 'w';
 #ifdef __ANDROID__
+    std::string fullPath(__resourcePath);
+    fullPath += resolvePath(path);
+
     if ((streamMode & WRITE) != 0)
     {
         // Open a file on the SD card
-        std::string fullPath(__resourcePath);
-        fullPath += resolvePath(path);
-
         size_t index = fullPath.rfind('/');
         if (index != std::string::npos)
         {
             std::string directoryPath = fullPath.substr(0, index);
-            struct stat s;
+            gp_stat_struct s;
             if (stat(directoryPath.c_str(), &s) != 0)
                 makepath(directoryPath, 0777);
         }
@@ -382,8 +387,19 @@ Stream* FileSystem::open(const char* path, size_t streamMode)
     }
     else
     {
-        // Open a file in the read-only asset directory
-        return FileStreamAndroid::create(resolvePath(path), modeStr);
+        // First try the SD card
+        Stream* stream = FileStream::create(fullPath.c_str(), modeStr);
+
+        if (!stream)
+        {
+            // Otherwise fall-back to assets loaded via the AssetManager
+            fullPath = __assetPath;
+            fullPath += resolvePath(path);
+
+            stream = FileStreamAndroid::create(fullPath.c_str(), modeStr);
+        }
+
+        return stream;
     }
 #else
     std::string fullPath;
@@ -456,6 +472,16 @@ bool FileSystem::isAbsolutePath(const char* filePath)
 #endif
 }
 
+void FileSystem::setAssetPath(const char* path)
+{
+    __assetPath = path;
+}
+
+const char* FileSystem::getAssetPath()
+{
+    return __assetPath.c_str();
+}
+
 void FileSystem::createFileFromAsset(const char* path)
 {
 #ifdef __ANDROID__

+ 17 - 0
gameplay/src/FileSystem.h

@@ -201,6 +201,23 @@ public:
      */
     static bool isAbsolutePath(const char* filePath);
 
+    /**
+    * Sets the asset root path for the game on platforms that have separate assets (currently just Android).
+    *
+    * Once set, all asset paths will be loaded relative to the given path.
+    * The default asset path is an empty string ("").
+    *
+    * @param path The asset root path.
+    */
+    static void setAssetPath(const char* path);
+
+    /**
+    * Returns the currently set asset root path.
+    *
+    * @return The currently set asset root path.
+    */
+    static const char* getAssetPath();
+
     /**
      * Creates a file on the file system from the specified asset (Android-specific).
      * 

+ 5 - 6
gameplay/src/Form.cpp

@@ -170,6 +170,11 @@ void Form::clearFocus()
     setFocusControl(NULL);
 }
 
+const char* Form::getTypeName() const
+{
+    return "Form";
+}
+
 bool Form::isForm() const
 {
     return true;
@@ -280,12 +285,6 @@ unsigned int Form::draw()
     return drawCalls;
 }
 
-const char* Form::getType() const
-{
-    return "form";
-}
-
-
 bool Form::isBatchingEnabled() const
 {
     return _batched;

+ 10 - 5
gameplay/src/Form.h

@@ -93,6 +93,16 @@ public:
      */
     static void clearFocus();
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "Form"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * @see Container#isForm()
      */
@@ -119,11 +129,6 @@ public:
      */
     unsigned int draw();
 
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
-
     /**
      * Determines whether batching is enabled for this form.
      *

+ 213 - 51
gameplay/src/Game.cpp

@@ -20,21 +20,61 @@ static Game* __gameInstance = NULL;
 double Game::_pausedTimeLast = 0.0;
 double Game::_pausedTimeTotal = 0.0;
 
+/**
+* @script{ignore}
+*/
+class GameScriptTarget : public ScriptTarget
+{
+    friend class Game;
+
+    GP_SCRIPT_EVENTS_START();
+    GP_SCRIPT_EVENT(initialize, "");
+    GP_SCRIPT_EVENT(finalize, "");
+    GP_SCRIPT_EVENT(update, "f");
+    GP_SCRIPT_EVENT(render, "f");
+    GP_SCRIPT_EVENT(resizeEvent, "ii");
+    GP_SCRIPT_EVENT(keyEvent, "[Keyboard::KeyEvent]i");
+    GP_SCRIPT_EVENT(touchEvent, "[Touch::TouchEvent]iiui");
+    GP_SCRIPT_EVENT(mouseEvent, "[Mouse::MouseEvent]iii");
+    GP_SCRIPT_EVENT(gestureSwipeEvent, "iii");
+    GP_SCRIPT_EVENT(gesturePinchEvent, "iif");
+    GP_SCRIPT_EVENT(gestureTapEvent, "ii");
+    GP_SCRIPT_EVENT(gestureLongTapevent, "iif");
+    GP_SCRIPT_EVENT(gestureDragEvent, "ii");
+    GP_SCRIPT_EVENT(gestureDropEvent, "ii");
+    GP_SCRIPT_EVENT(gamepadEvent, "[Gamepad::GamepadEvent]<Gamepad>");
+    GP_SCRIPT_EVENTS_END();
+
+public:
+
+    GameScriptTarget()
+    {
+        GP_REGISTER_SCRIPT_EVENTS();
+    }
+
+    const char* getTypeName() const
+    {
+        return "GameScriptTarget";
+    }
+};
+
 Game::Game()
     : _initialized(false), _state(UNINITIALIZED), _pausedCount(0),
       _frameLastFPS(0), _frameCount(0), _frameRate(0), _width(0), _height(0),
       _clearDepth(1.0f), _clearStencil(0), _properties(NULL),
       _animationController(NULL), _audioController(NULL),
       _physicsController(NULL), _aiController(NULL), _audioListener(NULL),
-      _timeEvents(NULL), _scriptController(NULL), _scriptListeners(NULL)
+      _timeEvents(NULL), _scriptController(NULL), _scriptTarget(NULL)
 {
     GP_ASSERT(__gameInstance == NULL);
+
     __gameInstance = this;
     _timeEvents = new std::priority_queue<TimeEvent, std::vector<TimeEvent>, std::less<TimeEvent> >();
 }
 
 Game::~Game()
 {
+    SAFE_DELETE(_scriptTarget);
 	SAFE_DELETE(_scriptController);
 
     // Do not call any virtual functions from the destructor.
@@ -44,6 +84,8 @@ Game::~Game()
     Ref::printLeaks();
     printMemoryLeaks();
 #endif
+
+    __gameInstance = NULL;
 }
 
 Game* Game::getInstance()
@@ -52,6 +94,26 @@ Game* Game::getInstance()
     return __gameInstance;
 }
 
+void Game::initialize()
+{
+    // stub
+}
+
+void Game::finalize()
+{
+    // stub
+}
+
+void Game::update(float elapsedTime)
+{
+    // stub
+}
+
+void Game::render(float elapsedTime)
+{
+    // stub
+}
+
 double Game::getAbsoluteTime()
 {
     return Platform::getAbsoluteTime();
@@ -119,29 +181,42 @@ bool Game::startup()
     // Load any gamepads, ui or physical.
     loadGamepads();
 
-    // Set the script callback functions.
+    // Set script handler
     if (_properties)
     {
-        Properties* scripts = _properties->getNamespace("scripts", true);
-        if (scripts)
+        const char* scriptPath = _properties->getString("script");
+        if (scriptPath)
         {
-            const char* callback;
-            while ((callback = scripts->getNextProperty()) != NULL)
+            _scriptTarget = new GameScriptTarget();
+            _scriptTarget->addScript(scriptPath);
+        }
+        else
+        {
+            // Use the older scripts namespace for loading individual global script callback functions.
+            Properties* sns = _properties->getNamespace("scripts", true);
+            if (sns)
             {
-                std::string url = scripts->getString();
-                std::string file;
-                std::string id;
-                splitURL(url, &file, &id);
-
-                if (file.size() <= 0 || id.size() <= 0)
-                {
-                    GP_ERROR("Invalid %s script callback function '%s'.", callback, url.c_str());
-                }
-                else
-                {
-                    _scriptController->loadScript(file.c_str());
-                    _scriptController->registerCallback(callback, id.c_str());
-                }
+                _scriptTarget = new GameScriptTarget();
+
+                // Define a macro to simplify defining the following script callback registrations
+                #define GP_REG_GAME_SCRIPT_CB(e) if (sns->exists(#e)) _scriptTarget->addScriptCallback(GP_GET_SCRIPT_EVENT(GameScriptTarget, e), sns->getString(#e))
+
+                // Register all supported script callbacks if they are defined
+                GP_REG_GAME_SCRIPT_CB(initialize);
+                GP_REG_GAME_SCRIPT_CB(finalize);
+                GP_REG_GAME_SCRIPT_CB(update);
+                GP_REG_GAME_SCRIPT_CB(render);
+                GP_REG_GAME_SCRIPT_CB(resizeEvent);
+                GP_REG_GAME_SCRIPT_CB(keyEvent);
+                GP_REG_GAME_SCRIPT_CB(touchEvent);
+                GP_REG_GAME_SCRIPT_CB(mouseEvent);
+                GP_REG_GAME_SCRIPT_CB(gestureSwipeEvent);
+                GP_REG_GAME_SCRIPT_CB(gesturePinchEvent);
+                GP_REG_GAME_SCRIPT_CB(gestureTapEvent);
+                GP_REG_GAME_SCRIPT_CB(gestureLongTapevent);
+                GP_REG_GAME_SCRIPT_CB(gestureDragEvent);
+                GP_REG_GAME_SCRIPT_CB(gestureDropEvent);
+                GP_REG_GAME_SCRIPT_CB(gamepadEvent);
             }
         }
     }
@@ -166,16 +241,14 @@ void Game::shutdown()
 		// Call user finalize
         finalize();
 
+        // Call script finalize
+        if (_scriptTarget)
+            _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, finalize));
+
+        // Destroy script target so no more script events are fired
+        SAFE_DELETE(_scriptTarget);
+
 		// Shutdown scripting system first so that any objects allocated in script are released before our subsystems are released
-		_scriptController->finalizeGame();
-		if (_scriptListeners)
-		{
-			for (size_t i = 0; i < _scriptListeners->size(); i++)
-			{
-				SAFE_DELETE((*_scriptListeners)[i]);
-			}
-			SAFE_DELETE(_scriptListeners);
-		}
 		_scriptController->finalize();
 
         unsigned int gamepadCount = Gamepad::getGamepadCount();
@@ -286,7 +359,8 @@ void Game::frame()
     {
         // Perform lazy first time initialization
         initialize();
-        _scriptController->initializeGame();
+        if (_scriptTarget)
+            _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, initialize));
         _initialized = true;
 
         // Fire first game resize event
@@ -329,7 +403,8 @@ void Game::frame()
         Form::updateInternal(elapsedTime);
 
         // Run script update.
-        _scriptController->update(elapsedTime);
+        if (_scriptTarget)
+            _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, update), elapsedTime);
 
         // Audio Rendering.
         _audioController->update(elapsedTime);
@@ -338,7 +413,8 @@ void Game::frame()
         render(elapsedTime);
 
         // Run script render.
-        _scriptController->render(elapsedTime);
+        if (_scriptTarget)
+            _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, render), elapsedTime);
 
         // Update FPS.
         ++_frameCount;
@@ -361,13 +437,15 @@ void Game::frame()
         Form::updateInternal(0);
 
         // Script update.
-        _scriptController->update(0);
+        if (_scriptTarget)
+            _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, update), 0);
 
         // Graphics Rendering.
         render(0);
 
         // Script render.
-        _scriptController->render(0);
+        if (_scriptTarget)
+            _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, render), 0);
     }
 }
 
@@ -395,7 +473,8 @@ void Game::updateOnce()
     _physicsController->update(elapsedTime);
     _aiController->update(elapsedTime);
     _audioController->update(elapsedTime);
-    _scriptController->update(elapsedTime);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, update), elapsedTime);
 }
 
 void Game::setViewport(const Rectangle& viewport)
@@ -463,19 +542,23 @@ AudioListener* Game::getAudioListener()
 
 void Game::keyEvent(Keyboard::KeyEvent evt, int key)
 {
+    // stub
 }
 
 void Game::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
+    // stub
 }
 
 bool Game::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 {
+    // stub
     return false;
 }
 
 void Game::resizeEvent(unsigned int width, unsigned int height)
 {
+    // stub
 }
 
 bool Game::isGestureSupported(Gesture::GestureEvent evt)
@@ -500,30 +583,124 @@ bool Game::isGestureRegistered(Gesture::GestureEvent evt)
 
 void Game::gestureSwipeEvent(int x, int y, int direction)
 {
+    // stub
 }
 
 void Game::gesturePinchEvent(int x, int y, float scale)
 {
+    // stub
 }
 
 void Game::gestureTapEvent(int x, int y)
 {
+    // stub
 }
 
 void Game::gestureLongTapEvent(int x, int y, float duration)
 {
+    // stub
 }
 
 void Game::gestureDragEvent(int x, int y)
 {
+    // stub
 }
 
 void Game::gestureDropEvent(int x, int y)
 {
+    // stub
 }
 
 void Game::gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad)
 {
+    // stub
+}
+
+void Game::keyEventInternal(Keyboard::KeyEvent evt, int key)
+{
+    keyEvent(evt, key);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, keyEvent), evt, key);
+}
+
+void Game::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
+{
+    touchEvent(evt, x, y, contactIndex);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, touchEvent), evt, x, y, contactIndex);
+}
+
+bool Game::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
+{
+    if (mouseEvent(evt, x, y, wheelDelta))
+        return true;
+
+    if (_scriptTarget)
+        return _scriptTarget->fireScriptEvent<bool>(GP_GET_SCRIPT_EVENT(GameScriptTarget, mouseEvent), evt, x, y, wheelDelta);
+
+    return false;
+}
+
+void Game::resizeEventInternal(unsigned int width, unsigned int height)
+{
+    // Update the width and height of the game
+    if (_width != width || _height != height)
+    {
+        _width = width;
+        _height = height;
+        resizeEvent(width, height);
+        if (_scriptTarget)
+            _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, resizeEvent), width, height);
+    }
+}
+
+void Game::gestureSwipeEventInternal(int x, int y, int direction)
+{
+    gestureSwipeEvent(x, y, direction);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, gestureSwipeEvent), x, y, direction);
+}
+
+void Game::gesturePinchEventInternal(int x, int y, float scale)
+{
+    gesturePinchEvent(x, y, scale);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, gesturePinchEvent), x, y, scale);
+}
+
+void Game::gestureTapEventInternal(int x, int y)
+{
+    gestureTapEvent(x, y);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, gestureTapEvent), x, y);
+}
+
+void Game::gestureLongTapEventInternal(int x, int y, float duration)
+{
+    gestureLongTapEvent(x, y, duration);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, gestureLongTapevent), x, y, duration);
+}
+
+void Game::gestureDragEventInternal(int x, int y)
+{
+    gestureDragEvent(x, y);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, gestureDragEvent), x, y);
+}
+
+void Game::gestureDropEventInternal(int x, int y)
+{
+    gestureDropEvent(x, y);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, gestureDropEvent), x, y);
+}
+
+void Game::gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad)
+{
+    gamepadEvent(evt, gamepad);
+    if (_scriptTarget)
+        _scriptTarget->fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(GameScriptTarget, gamepadEvent), evt, gamepad);
 }
 
 void Game::getArguments(int* argc, char*** argv) const
@@ -540,12 +717,7 @@ void Game::schedule(float timeOffset, TimeListener* timeListener, void* cookie)
 
 void Game::schedule(float timeOffset, const char* function)
 {
-    if (!_scriptListeners)
-        _scriptListeners = new std::vector<ScriptListener*>();
-
-    ScriptListener* listener = new ScriptListener(function);
-    _scriptListeners->push_back(listener);
-    schedule(timeOffset, listener, NULL);
+    getScriptController()->schedule(timeOffset, function);
 }
 
 void Game::clearSchedule()
@@ -571,16 +743,6 @@ void Game::fireTimeEvents(double frameTime)
     }
 }
 
-Game::ScriptListener::ScriptListener(const char* url)
-{
-    function = Game::getInstance()->getScriptController()->loadUrl(url);
-}
-
-void Game::ScriptListener::timeEvent(long timeDiff, void* cookie)
-{
-    Game::getInstance()->getScriptController()->executeFunction<void>(function.c_str(), "l", timeDiff);
-}
-
 Game::TimeEvent::TimeEvent(double time, TimeListener* timeListener, void* cookie)
     : time(time), listener(timeListener), cookie(cookie)
 {

+ 28 - 33
gameplay/src/Game.h

@@ -31,6 +31,7 @@ class ScriptController;
 class Game
 {
     friend class Platform;
+    friend class Gamepad;
     friend class ShutdownListener;
 
 public:
@@ -59,6 +60,11 @@ public:
         CLEAR_COLOR_DEPTH_STENCIL = CLEAR_COLOR | CLEAR_DEPTH | CLEAR_STENCIL
     };
 
+    /**
+     * Constructor.
+     */
+    Game();
+
     /**
      * Destructor.
      */
@@ -590,11 +596,12 @@ public:
      * Schedules a time event to be sent to the given TimeListener a given number of game milliseconds from now.
      * Game time stops while the game is paused. A time offset of zero will fire the time event in the next frame.
      * 
-     * Note: the given Lua function must take a single floating point number, which is the difference between the
-     * current game time and the target time (see TimeListener::timeEvent).
+     * The given script function must take a single floating point number, which is the difference between the
+     * current game time and the target time (see TimeListener::timeEvent). The function will be executed
+     * in the context of the script envionrment that the schedule function was called from.
      * 
      * @param timeOffset The number of game milliseconds in the future to schedule the event to be fired.
-     * @param function The Lua script function that will receive the event.
+     * @param function The script function that will receive the event.
      */
     void schedule(float timeOffset, const char* function);
 
@@ -614,20 +621,15 @@ public:
 
 protected:
 
-    /**
-     * Constructor.
-     */
-    Game();
-
     /**
      * Initialize callback that is called just before the first frame when the game starts.
      */
-    virtual void initialize() = 0;
+    virtual void initialize();
 
     /**
      * Finalize callback that is called when the game on exits.
      */
-    virtual void finalize() = 0;
+    virtual void finalize();
 
     /**
      * Update callback for handling update routines.
@@ -637,7 +639,7 @@ protected:
      *
      * @param elapsedTime The elapsed game time.
      */
-    virtual void update(float elapsedTime) = 0;
+    virtual void update(float elapsedTime);
 
     /**
      * Render callback for handling rendering routines.
@@ -647,7 +649,7 @@ protected:
      *
      * @param elapsedTime The elapsed game time.
      */
-    virtual void render(float elapsedTime) = 0;
+    virtual void render(float elapsedTime);
 
     /**
      * Renders a single frame once and then swaps it to the display.
@@ -659,7 +661,7 @@ protected:
 
     /**
      * Renders a single frame once and then swaps it to the display.
-     * This calls the given Lua function, which should take no parameters and return nothing (void).
+     * This calls the given script function, which should take no parameters and return nothing (void).
      *
      * This is useful for rendering splash screens.
      */
@@ -676,25 +678,6 @@ protected:
 
 private:
 
-    /**
-     * Allows time listener interaction from Lua scripts.
-     */
-    struct ScriptListener : public TimeListener
-    {
-        /**
-         * Constructor.
-         */
-        ScriptListener(const char* url);
-
-        /**
-         * @see TimeListener#timeEvent(long, void*)
-         */
-        void timeEvent(long timeDiff, void* cookie);
-
-        /** Holds the name of the Lua script function to call back. */
-        std::string function;
-    };
-
     struct ShutdownListener : public TimeListener
     {
         void timeEvent(long timeDiff, void* cookie);
@@ -748,6 +731,18 @@ private:
      */
     void loadGamepads();
 
+    void keyEventInternal(Keyboard::KeyEvent evt, int key);
+    void touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
+    bool mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta);
+    void resizeEventInternal(unsigned int width, unsigned int height);
+    void gestureSwipeEventInternal(int x, int y, int direction);
+    void gesturePinchEventInternal(int x, int y, float scale);
+    void gestureTapEventInternal(int x, int y);
+    void gestureLongTapEventInternal(int x, int y, float duration);
+    void gestureDragEventInternal(int x, int y);
+    void gestureDropEventInternal(int x, int y);
+    void gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad);
+
     bool _initialized;                          // If game has initialized yet.
     State _state;                               // The game state.
     unsigned int _pausedCount;                  // Number of times pause() has been called.
@@ -770,7 +765,7 @@ private:
     AudioListener* _audioListener;              // The audio listener in 3D space.
     std::priority_queue<TimeEvent, std::vector<TimeEvent>, std::less<TimeEvent> >* _timeEvents;     // Contains the scheduled time events.
     ScriptController* _scriptController;            // Controls the scripting engine.
-    std::vector<ScriptListener*>* _scriptListeners; // Lua script listeners.
+    ScriptTarget* _scriptTarget;                // Script target for the game
 
     // Note: Do not add STL object member variables on the stack; this will cause false memory leaks to be reported.
 

+ 6 - 6
gameplay/src/Gamepad.cpp

@@ -62,7 +62,7 @@ Gamepad* Gamepad::add(GamepadHandle handle, unsigned int buttonCount, unsigned i
     Gamepad* gamepad = new Gamepad(handle, buttonCount, joystickCount, triggerCount, name);
 
     __gamepads.push_back(gamepad);
-    Game::getInstance()->gamepadEvent(CONNECTED_EVENT, gamepad);
+    Game::getInstance()->gamepadEventInternal(CONNECTED_EVENT, gamepad);
     return gamepad;
 }
 
@@ -71,7 +71,7 @@ Gamepad* Gamepad::add(const char* formPath)
     Gamepad* gamepad = new Gamepad(formPath);
 
     __gamepads.push_back(gamepad);
-    Game::getInstance()->gamepadEvent(CONNECTED_EVENT, gamepad);
+    Game::getInstance()->gamepadEventInternal(CONNECTED_EVENT, gamepad);
     return gamepad;
 }
 
@@ -84,7 +84,7 @@ void Gamepad::remove(GamepadHandle handle)
         if (gamepad->_handle == handle)
         {
             it = __gamepads.erase(it);
-            Game::getInstance()->gamepadEvent(DISCONNECTED_EVENT, gamepad);
+            Game::getInstance()->gamepadEventInternal(DISCONNECTED_EVENT, gamepad);
             SAFE_DELETE(gamepad);
         }
         else
@@ -103,7 +103,7 @@ void Gamepad::remove(Gamepad* gamepad)
         if (g == gamepad)
         {
             it = __gamepads.erase(it);
-            Game::getInstance()->gamepadEvent(DISCONNECTED_EVENT, g);
+            Game::getInstance()->gamepadEventInternal(DISCONNECTED_EVENT, g);
             SAFE_DELETE(gamepad);
         }
         else
@@ -127,14 +127,14 @@ void Gamepad::bindGamepadControls(Container* container)
         {
             bindGamepadControls((Container*) control);
         }
-        else if (std::strcmp("joystick", control->getType()) == 0)
+        else if (std::strcmp("JoystickControl", control->getTypeName()) == 0)
         {
             JoystickControl* joystick = (JoystickControl*)control;
             joystick->setConsumeInputEvents(true);
             _uiJoysticks[joystick->getIndex()] = joystick;
             _joystickCount++;
         }
-        else if (std::strcmp("button", control->getType()) == 0)
+        else if (std::strcmp("Button", control->getTypeName()) == 0)
         {
             Button* button = (Button*)control;
             button->setConsumeInputEvents(true);

+ 5 - 5
gameplay/src/ImageControl.cpp

@@ -58,6 +58,11 @@ void ImageControl::initialize(const char* typeName, Theme::Style* style, Propert
 	}
 }
 
+const char* ImageControl::getTypeName() const
+{
+    return "ImageControl";
+}
+
 void ImageControl::setImage(const char* path)
 {
     SAFE_DELETE(_batch);
@@ -106,11 +111,6 @@ const Rectangle& ImageControl::getRegionDst() const
     return _dstRegion;
 }
 
-const char* ImageControl::getType() const
-{
-    return "image";
-}
-
 unsigned int ImageControl::drawImages(Form* form, const Rectangle& clip)
 {
     if (!_batch)

+ 10 - 2
gameplay/src/ImageControl.h

@@ -35,6 +35,16 @@ public:
      */
     static ImageControl* create(const char* id, Theme::Style* style = NULL);
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "ImageControl"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Set the path of the image for this ImageControl to display.
      *
@@ -94,8 +104,6 @@ public:
      */
     const Rectangle& getRegionDst() const;
 
-    const char* getType() const;
-
 protected:
 
     ImageControl();

+ 5 - 5
gameplay/src/JoystickControl.cpp

@@ -31,6 +31,11 @@ Control* JoystickControl::create(Theme::Style* style, Properties* properties)
     return joystickControl;
 }
 
+const char* JoystickControl::getTypeName() const
+{
+    return "JoystickControl";
+}
+
 const Vector2& JoystickControl::getValue() const
 {
     return _value;
@@ -344,9 +349,4 @@ unsigned int JoystickControl::drawImages(Form* form, const Rectangle& clip)
     return drawCalls;
 }
 
-const char* JoystickControl::getType() const
-{
-    return "joystick";
-}
-
 }

+ 10 - 5
gameplay/src/JoystickControl.h

@@ -32,6 +32,16 @@ public:
      */
     static JoystickControl* create(const char* id, Theme::Style* style = NULL);
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "JoystickControl"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Add a listener to be notified of specific events affecting
      * this control.  Event types can be OR'ed together.
@@ -107,11 +117,6 @@ public:
      * @return The index of this joystick on a form.
      */
     unsigned int getIndex() const;
-    
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
 
 protected:
     

+ 7 - 6
gameplay/src/Label.cpp

@@ -41,6 +41,12 @@ void Label::initialize(const char* typeName, Theme::Style* style, Properties* pr
 	}
 }
 
+const char* Label::getTypeName() const
+{
+    return "Label";
+}
+
+
 void Label::addListener(Control::Listener* listener, int eventFlags)
 {
     if ((eventFlags & Control::Listener::TEXT_CHANGED) == Control::Listener::TEXT_CHANGED)
@@ -54,7 +60,7 @@ void Label::addListener(Control::Listener* listener, int eventFlags)
 
     Control::addListener(listener, eventFlags);
 }
-    
+
 void Label::setText(const char* text)
 {
     if ((text == NULL && _text.length() > 0) || strcmp(text, _text.c_str()) != 0)
@@ -134,9 +140,4 @@ unsigned int Label::drawText(Form* form, const Rectangle& clip)
     return 0;
 }
 
-const char* Label::getType() const
-{
-    return "label";
-}
-
 }

+ 10 - 5
gameplay/src/Label.h

@@ -32,6 +32,16 @@ public:
      */
     static Label* create(const char* id, Theme::Style* style = NULL);
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "Label"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Set the text for this label to display.
      *
@@ -46,11 +56,6 @@ public:
      */
     const char* getText();
 
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
-
     /**
      * Add a listener to be notified of specific events affecting
      * this control.  Event types can be OR'ed together.

+ 6 - 5
gameplay/src/Logger.cpp

@@ -26,9 +26,6 @@ void Logger::log(Level level, const char* message, ...)
     if (!state.enabled)
         return;
 
-    va_list args;
-    va_start(args, message);
-
     // Declare a moderately sized buffer on the stack that should be
     // large enough to accommodate most log requests.
     int size = 1024;
@@ -37,6 +34,9 @@ void Logger::log(Level level, const char* message, ...)
     char* str = stackBuffer;
     for ( ; ; )
     {
+        va_list args;
+        va_start(args, message);
+
         // Pass one less than size to leave room for NULL terminator
         int needed = vsnprintf(str, size-1, message, args);
 
@@ -46,12 +46,15 @@ void Logger::log(Level level, const char* message, ...)
         {
             // Successfully wrote buffer. Added a NULL terminator in case it wasn't written.
             str[needed] = '\0';
+            va_end(args);
             break;
         }
 
         size = needed > 0 ? (needed + 1) : (size * 2);
         dynamicBuffer.resize(size);
         str = &dynamicBuffer[0];
+
+        va_end(args);
     }
 
     if (state.logFunctionC)
@@ -69,8 +72,6 @@ void Logger::log(Level level, const char* message, ...)
         // Log to the default output
         gameplay::print("%s", str);
     }
-
-    va_end(args);
 }
 
 bool Logger::isEnabled(Level level)

+ 28 - 0
gameplay/src/Node.cpp

@@ -25,6 +25,8 @@ Node::Node(const char* id)
         _form(NULL), _particleEmitter(NULL), _terrain(NULL), _audioSource(NULL), _collisionObject(NULL), _agent(NULL),
        _dirtyBits(NODE_DIRTY_ALL), _notifyHierarchyChanged(true), _userData(NULL)
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     if (id)
     {
         _id = id;
@@ -74,6 +76,11 @@ Node* Node::create(const char* id)
     return new Node(id);
 }
 
+const char* Node::getTypeName() const
+{
+    return "Node";
+}
+
 const char* Node::getId() const
 {
     return _id.c_str();
@@ -442,6 +449,17 @@ Node* Node::getRootNode() const
     return n;
 }
 
+void Node::update(float elapsedTime)
+{
+    for (Node* node = _firstChild; node != NULL; node = node->_nextSibling)
+    {
+        if (node->isEnabled())
+            node->update(elapsedTime);
+    }
+
+    fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(Node, update), dynamic_cast<void*>(this), elapsedTime);
+}
+
 bool Node::isStatic() const
 {
     return (_collisionObject && _collisionObject->isStatic());
@@ -1365,6 +1383,16 @@ PhysicsCollisionObject* Node::setCollisionObject(Properties* properties)
 
 AIAgent* Node::getAgent() const
 {
+    // Lazily create a new Agent for this Node if we don't have one yet.
+    // Basically, all Nodes by default can have an Agent, we just won't
+    // waste the memory unless they request one.
+    if (!_agent)
+    {
+        _agent = AIAgent::create();
+        _agent->_node = const_cast<Node*>(this);
+        Game::getInstance()->getAIController()->addAgent(_agent);
+    }
+
     return _agent;
 }
 

+ 30 - 1
gameplay/src/Node.h

@@ -2,6 +2,7 @@
 #define NODE_H_
 
 #include "Transform.h"
+#include "ScriptTarget.h"
 #include "Camera.h"
 #include "Light.h"
 #include "Model.h"
@@ -45,6 +46,14 @@ class Node : public Transform, public Ref
     friend class MeshSkin;
     friend class Light;
 
+    GP_SCRIPT_EVENTS_START();
+    GP_SCRIPT_EVENT(update, "<Node>f");
+    GP_SCRIPT_EVENT(messageReceived, "<Node><AIMessage>");
+    GP_SCRIPT_EVENT(stateEnter, "<Node><AIState>");
+    GP_SCRIPT_EVENT(stateExit, "<Node><AIState>");
+    GP_SCRIPT_EVENT(stateUpdate, "<Node><AIState>f");
+    GP_SCRIPT_EVENTS_END();
+
 public:
 
     /**
@@ -64,6 +73,14 @@ public:
      */
     static Node* create(const char* id = NULL);
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * @return The type name of this class: "Node"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Gets the identifier for the node.
      *
@@ -264,6 +281,18 @@ public:
      */
     Node* getRootNode() const;
 
+    /**
+     * Called to update the state of this Node.
+     *
+     * This method is called by Scene::update(float) to update the state of all active
+     * nodes in a scene. A Node is considered active if Node::isActive() returns true.
+     *
+     * If any scripts are attached to the node, their update event will be fired.
+     *
+     * @param elapsedTime Elapsed time in milliseconds.
+     */
+    void update(float elapsedTime);
+
     /**
      * Returns whether the transformation of this node is static.
      *
@@ -901,7 +930,7 @@ protected:
     /**
      * Pointer to the AI agent attached to the Node.
      */
-    AIAgent* _agent;
+    mutable AIAgent* _agent;
 
     /**
      * World Matrix representation of the Node.

+ 3 - 0
gameplay/src/PhysicsCharacter.cpp

@@ -650,6 +650,9 @@ void PhysicsCharacter::ActionInterface::debugDraw(btIDebugDraw* debugDrawer)
 
 void PhysicsCharacter::updateAction(btCollisionWorld* collisionWorld, btScalar deltaTimeStep)
 {
+    if (!isEnabled())
+        return;
+
     GP_ASSERT(_ghostObject);
     GP_ASSERT(_node);
 

+ 45 - 7
gameplay/src/PhysicsCollisionObject.cpp

@@ -13,6 +13,8 @@
 namespace gameplay
 {
 
+extern void splitURL(const std::string& url, std::string* file, std::string* id);
+
 /**
  * Internal class used to implement the collidesWith(PhysicsCollisionObject*) function.
  * @script{ignore}
@@ -45,7 +47,7 @@ PhysicsCollisionObject::~PhysicsCollisionObject()
 
     if (_scriptListeners)
     {
-        for (unsigned int i = 0; i < _scriptListeners->size(); i++)
+        for (size_t i = 0, count = _scriptListeners->size(); i < count; ++i)
         {
             SAFE_DELETE((*_scriptListeners)[i]);
         }
@@ -144,11 +146,14 @@ void PhysicsCollisionObject::removeCollisionListener(CollisionListener* listener
 
 void PhysicsCollisionObject::addCollisionListener(const char* function, PhysicsCollisionObject* object)
 {
+    ScriptListener* listener = ScriptListener::create(function);
+    if (!listener)
+        return; // falied to load
+
     if (!_scriptListeners)
         _scriptListeners = new std::vector<ScriptListener*>();
-
-    ScriptListener* listener = new ScriptListener(function);
     _scriptListeners->push_back(listener);
+
     addCollisionListener(listener, object);
 }
 
@@ -158,7 +163,7 @@ void PhysicsCollisionObject::removeCollisionListener(const char* function, Physi
         return;
 
     std::string url = function;
-    for (unsigned int i = 0; i < _scriptListeners->size(); i++)
+    for (size_t i = 0, count = _scriptListeners->size(); i < count; ++i)
     {
         if ((*_scriptListeners)[i]->url == url)
         {
@@ -301,10 +306,43 @@ void PhysicsCollisionObject::PhysicsMotionState::setCenterOfMassOffset(const Vec
     _centerOfMassOffset.setOrigin(BV(centerOfMassOffset));
 }
 
-PhysicsCollisionObject::ScriptListener::ScriptListener(const char* url)
-    : url(url)
+PhysicsCollisionObject::ScriptListener::ScriptListener()
+    : script(NULL)
+{
+}
+
+PhysicsCollisionObject::ScriptListener::~ScriptListener()
+{
+    SAFE_RELEASE(script);
+}
+
+PhysicsCollisionObject::ScriptListener* PhysicsCollisionObject::ScriptListener::create(const char* url)
 {
-    function = Game::getInstance()->getScriptController()->loadUrl(url);
+    std::string scriptPath, func;
+    splitURL(url, &scriptPath, &func);
+    if (func.empty())
+    {
+        // Only a function was specified
+        func = scriptPath;
+        scriptPath = "";
+    }
+
+    Script* script = NULL;
+    if (!scriptPath.empty())
+    {
+        script = Game::getInstance()->getScriptController()->loadScript(scriptPath.c_str(), Script::GLOBAL);
+        if (!script)
+        {
+            // Failed to load script
+            return NULL;
+        }
+    }
+
+    ScriptListener* listener = new ScriptListener();
+    listener->url = url;
+    listener->script = script;
+    listener->function = func;
+    return listener;
 }
 
 void PhysicsCollisionObject::ScriptListener::collisionEvent(PhysicsCollisionObject::CollisionListener::EventType type,

+ 28 - 6
gameplay/src/PhysicsCollisionObject.h

@@ -1,6 +1,7 @@
 #ifndef PHYSICSCOLLISIONOBJECT_H_
 #define PHYSICSCOLLISIONOBJECT_H_
 
+#include "Script.h"
 #include "Vector3.h"
 #include "PhysicsCollisionShape.h"
 
@@ -236,9 +237,10 @@ public:
     /**
      * Adds a collision listener for this collision object.
      * 
-     * Note: the given Lua function must match the function signature of PhysicsCollisionObject::CollisionListener::collisionEvent.
+     * Note: the given script function must be global and it must match the function 
+     * signature of PhysicsCollisionObject::CollisionListener::collisionEvent.
      * 
-     * @param function The Lua script function to add as a listener callback.
+     * @param function A valid global script function to add as a listener callback.
      * @param object Optional collision object used to filter the collision event.
      */
     void addCollisionListener(const char* function, PhysicsCollisionObject* object = NULL);
@@ -246,7 +248,7 @@ public:
     /**
      * Removes a collision listener.
      *
-     * @param function The Lua function (used as a listener callback) to remove.
+     * @param function The previously added script function to remove.
      * @param object Optional collision object used to filter the collision event.
      */
     void removeCollisionListener(const char* function, PhysicsCollisionObject* object = NULL);
@@ -310,12 +312,23 @@ protected:
     /**
      * Handles collision event callbacks to Lua script functions.
      */
-    struct ScriptListener : public CollisionListener
+    class ScriptListener : public CollisionListener
     {
+    public:
+
         /**
-         * Constructor.
+         * Destructor.
          */
-        ScriptListener(const char* url);
+        ~ScriptListener();
+
+        /**
+         * Creates a ScriptListener for the given script function url.
+         *
+         * @param url The global script function, or script#function.
+         *
+         * @return The ScriptListener, or NULL if the function could not be loaded.
+         */
+        static ScriptListener* create(const char* url);
 
         /**
          * @see PhysicsCollisionObject::CollisionListener
@@ -325,8 +338,17 @@ protected:
 
         /** The URL to the Lua script function to use as the callback. */
         std::string url;
+        /** The loaded script that contains the function. */
+        Script* script;
         /** The name of the Lua script function to use as the callback. */
         std::string function;
+
+    private:
+
+        /**
+         * Constructor.
+         */
+        ScriptListener();
     };
 
     /**

+ 9 - 4
gameplay/src/PhysicsController.cpp

@@ -33,10 +33,10 @@ PhysicsController::PhysicsController()
     _debugDrawer(NULL), _status(PhysicsController::Listener::DEACTIVATED), _listeners(NULL),
     _gravity(btScalar(0.0), btScalar(-9.8), btScalar(0.0)), _collisionCallback(NULL)
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     // Default gravity is 9.8 along the negative Y axis.
     _collisionCallback = new CollisionCallback(this);
-
-    addScriptEvent("statusEvent", "[PhysicsController::Listener::EventType]");
 }
 
 PhysicsController::~PhysicsController()
@@ -47,6 +47,11 @@ PhysicsController::~PhysicsController()
     SAFE_DELETE(_listeners);
 }
 
+const char* PhysicsController::getTypeName() const
+{
+    return "PhysicsController";
+}
+
 void PhysicsController::addStatusListener(Listener* listener)
 {
     GP_ASSERT(listener);
@@ -484,7 +489,7 @@ void PhysicsController::update(float elapsedTime)
     _world->stepSimulation(elapsedTime * 0.001f, 10);
 
     // If we have status listeners, then check if our status has changed.
-    if (_listeners || _callbacks["statusEvent"])
+    if (_listeners || hasScriptListener(GP_GET_SCRIPT_EVENT(PhysicsController, statusEvent)))
     {
         Listener::EventType oldStatus = _status;
 
@@ -529,7 +534,7 @@ void PhysicsController::update(float elapsedTime)
                 }
             }
 
-            fireScriptEvent<void>("statusEvent", _status);
+            fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(PhysicsController, statusEvent), _status);
         }
     }
 

+ 12 - 0
gameplay/src/PhysicsController.h

@@ -32,6 +32,10 @@ class PhysicsController : public ScriptTarget
     friend class PhysicsCollisionObject;
     friend class PhysicsGhostObject;
 
+    GP_SCRIPT_EVENTS_START();
+    GP_SCRIPT_EVENT(statusEvent, "[PhysicsController::Listener::EventType]");
+    GP_SCRIPT_EVENTS_END();
+
 public:
 
     /**
@@ -144,6 +148,14 @@ public:
         virtual bool hit(const HitResult& result);
     };
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * @return The type name of this class: "PhysicsController"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Adds a listener to the physics controller.
      * 

+ 11 - 34
gameplay/src/Platform.cpp

@@ -12,8 +12,7 @@ void Platform::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned
 {
     if (actuallyMouse || !Form::touchEventInternal(evt, x, y, contactIndex))
     {
-        Game::getInstance()->touchEvent(evt, x, y, contactIndex);
-        Game::getInstance()->getScriptController()->touchEvent(evt, x, y, contactIndex);
+        Game::getInstance()->touchEventInternal(evt, x, y, contactIndex);
     }
 }
 
@@ -21,73 +20,51 @@ void Platform::keyEventInternal(Keyboard::KeyEvent evt, int key)
 {
     if (!Form::keyEventInternal(evt, key))
     {
-        Game::getInstance()->keyEvent(evt, key);
-        Game::getInstance()->getScriptController()->keyEvent(evt, key);
+        Game::getInstance()->keyEventInternal(evt, key);
     }
 }
 
 bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 {
     if (Form::mouseEventInternal(evt, x, y, wheelDelta))
-    {
         return true;
-    }
-    else if (Game::getInstance()->mouseEvent(evt, x, y, wheelDelta))
-    {
-        return true;
-    }
-    else
-    {
-        return Game::getInstance()->getScriptController()->mouseEvent(evt, x, y, wheelDelta);
-    }
+
+    return Game::getInstance()->mouseEventInternal(evt, x, y, wheelDelta);
 }
 
 void Platform::gestureSwipeEventInternal(int x, int y, int direction)
 {
-    Game::getInstance()->gestureSwipeEvent(x, y, direction);
-    Game::getInstance()->getScriptController()->gestureSwipeEvent(x, y, direction);
+    Game::getInstance()->gestureSwipeEventInternal(x, y, direction);
 }
 
 void Platform::gesturePinchEventInternal(int x, int y, float scale)
 {
-    Game::getInstance()->gesturePinchEvent(x, y, scale);
-    Game::getInstance()->getScriptController()->gesturePinchEvent(x, y, scale);
+    Game::getInstance()->gesturePinchEventInternal(x, y, scale);
 }
 
 void Platform::gestureTapEventInternal(int x, int y)
 {
-    Game::getInstance()->gestureTapEvent(x, y);
-    Game::getInstance()->getScriptController()->gestureTapEvent(x, y);
+    Game::getInstance()->gestureTapEventInternal(x, y);
 }
 
 void Platform::gestureLongTapEventInternal(int x, int y, float duration)
 {
-	Game::getInstance()->gestureLongTapEvent(x, y, duration);
-	Game::getInstance()->getScriptController()->gestureLongTapEvent(x, y, duration);
+    Game::getInstance()->gestureLongTapEventInternal(x, y, duration);
 }
 
 void Platform::gestureDragEventInternal(int x, int y)
 {
-	Game::getInstance()->gestureDragEvent(x, y);
-	Game::getInstance()->getScriptController()->gestureDragEvent(x, y);
+    Game::getInstance()->gestureDragEventInternal(x, y);
 }
 
 void Platform::gestureDropEventInternal(int x, int y)
 {
-	Game::getInstance()->gestureDropEvent(x, y);
-	Game::getInstance()->getScriptController()->gestureDropEvent(x, y);
+    Game::getInstance()->gestureDropEventInternal(x, y);
 }
 
 void Platform::resizeEventInternal(unsigned int width, unsigned int height)
 {
-    Game* game = Game::getInstance();
-    if (game->_width != width || game->_height != height)
-    {
-        game->_width = width;
-        game->_height = height;
-        game->resizeEvent(width, height);
-        game->getScriptController()->resizeEvent(width, height);
-    }
+    Game::getInstance()->resizeEventInternal(width, height);
     Form::resizeEventInternal(width, height);
 }
 

+ 8 - 3
gameplay/src/PlatformAndroid.cpp

@@ -857,7 +857,7 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
                         
                         // Gestures
                         bool gestureDetected = false;
-					    if (__pointer0.pressed &&  __pointer0.pointerId == pointerId)
+					    if (__pointer0.pressed &&  __pointer0.pointerId == pointerId && !Form::getActiveControl())
                         {
                             int deltaX = x - __pointer0.x;
                             int deltaY = y - __pointer0.y;
@@ -966,7 +966,7 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
                         y = AMotionEvent_getY(event, pointerIndex);
 
                         bool gestureDetected = false;
-                        if (__pointer1.pressed &&  __pointer1.pointerId == pointerId)
+                        if (__pointer1.pressed &&  __pointer1.pointerId == pointerId && !Form::getActiveControl())
                         {
                             int deltaX = x - __pointer1.x;
                             int deltaY = y - __pointer1.y;
@@ -1032,7 +1032,7 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
                             y = AMotionEvent_getY(event, i);
                             
                             bool gestureDetected = false;
-						    if (__pointer0.pressed)
+						    if (__pointer0.pressed && !Form::getActiveControl())
 						    {
 							    //The two pointers are pressed and the event was done by one of it
 							    if (__pointer1.pressed && (pointerId == __pointer0.pointerId || pointerId == __pointer1.pointerId))
@@ -1779,6 +1779,11 @@ JNIEXPORT void JNICALL Java_org_gameplay3d_GamePlayNativeActivity_gamepadEventDi
 	gameplay::Platform::gamepadEventDisconnectedInternal(deviceId);
 }
 
+JNIEXPORT void JNICALL Java_org_gameplay3d_GamePlayNativeActivity_screenOrientationChanged(JNIEnv* env, jclass clazz, jint orientation)
+{
+    __orientationAngle = orientation * 90;
+}
+
 }
 
 #endif

+ 5 - 5
gameplay/src/RadioButton.cpp

@@ -60,6 +60,11 @@ void RadioButton::initialize(const char* typeName, Theme::Style* style, Properti
     }
 }
 
+const char* RadioButton::getTypeName() const
+{
+    return "RadioButton";
+}
+
 bool RadioButton::isSelected() const
 {
     return _selected;
@@ -198,11 +203,6 @@ unsigned int RadioButton::drawImages(Form* form, const Rectangle& clip)
     return 1;
 }
 
-const char* RadioButton::getType() const
-{
-    return "radioButton";
-}
-
 void RadioButton::setGroupId(const char* groupId)
 {
     _groupId = groupId;

+ 10 - 5
gameplay/src/RadioButton.h

@@ -35,6 +35,16 @@ public:
      */
     static RadioButton* create(const char* id, Theme::Style* style = NULL);
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "RadioButton"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Get whether this radio button is currently selected.
      *
@@ -47,11 +57,6 @@ public:
      */
     void setSelected(bool selected);
 
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
-
     /**
      * Add a listener to be notified of specific events affecting
      * this control.  Event types can be OR'ed together.

+ 10 - 1
gameplay/src/Scene.cpp

@@ -200,7 +200,7 @@ void Scene::visitNode(Node* node, const char* visitMethod)
     ScriptController* sc = Game::getInstance()->getScriptController();
 
     // Invoke the visit method for this node.
-    if (!sc->executeFunction<bool>(visitMethod, "<Node>", node))
+    if (!sc->executeFunction<bool>(visitMethod, "<Node>", dynamic_cast<void*>(node)))
         return;
 
     // If this node has a model with a mesh skin, visit the joint hierarchy within it
@@ -384,6 +384,15 @@ void Scene::setAmbientColor(float red, float green, float blue)
     _ambientColor.set(red, green, blue);
 }
 
+void Scene::update(float elapsedTime)
+{
+    for (Node* node = _firstNode; node != NULL; node = node->_nextSibling)
+    {
+        if (node->isEnabled())
+            node->update(elapsedTime);
+    }
+}
+
 void Scene::reset()
 {
     _nextItr = NULL;

+ 11 - 0
gameplay/src/Scene.h

@@ -176,6 +176,17 @@ public:
      */
     void setAmbientColor(float red, float green, float blue);
 
+    /**
+     * Updates all active nodes in the scene.
+     *
+     * This method is recursively calls the Node::update(float) method on all nodes that
+     * are active within the scene. A Node is considered active if Node::isActive()
+     * returns true.
+     *
+     * @param elapsedTime Elapsed time in milliseconds.
+     */
+    void update(float elapsedTime);
+
     /**
      * Visits each node in the scene and calls the specified method pointer.
      *

+ 25 - 13
gameplay/src/SceneLoader.cpp

@@ -92,6 +92,7 @@ Scene* SceneLoader::loadInternal(const char* url)
         SceneNodeProperty::ROTATE |
         SceneNodeProperty::SCALE |
         SceneNodeProperty::TRANSLATE |
+        SceneNodeProperty::SCRIPT |
         SceneNodeProperty::SPRITE |
         SceneNodeProperty::TILESET |
         SceneNodeProperty::TEXT);
@@ -406,7 +407,7 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
     }
     else
     {
-        // Handle scale, rotate and translate.
+        // Handle simple types (scale, rotate, translate, script, etc)
         switch (snp._type)
         {
         case SceneNodeProperty::TRANSLATE:
@@ -430,6 +431,9 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
                 node->scale(s);
             break;
         }
+        case SceneNodeProperty::SCRIPT:
+            node->addScript(snp._value.c_str());
+            break;
         default:
             GP_ERROR("Unsupported node property type (%d).", snp._type);
             break;
@@ -839,6 +843,10 @@ void SceneLoader::parseNode(Properties* ns, SceneNode* parent, const std::string
         {
             addSceneNodeProperty(sceneNode, SceneNodeProperty::SCALE, ns->getString());
         }
+        else if (strcmp(name, "script") == 0)
+        {
+            addSceneNodeProperty(sceneNode, SceneNodeProperty::SCRIPT, ns->getString());
+        }
         else
         {
             GP_ERROR("Unsupported node property: %s = %s", name, ns->getString());
@@ -1262,29 +1270,33 @@ void splitURL(const std::string& url, std::string* file, std::string* id)
         return;
     }
 
-    // Check if the url references a file (otherwise, it only references a node within the main GPB).
-    size_t loc = url.rfind(".");
+    // Check if the url references a file (otherwise, it only references some sort of ID)
+    size_t loc = url.rfind("#"); 
     if (loc != std::string::npos)
     {
-        // If the url references a specific namespace within the file,
-        // set the id out parameter appropriately. Otherwise, set the id out
-        // parameter to the empty string so we know to load the first namespace.
-        loc = url.rfind("#");
-        if (loc != std::string::npos)
+        *file = url.substr(0, loc);
+        if (FileSystem::fileExists(file->c_str()))
         {
-            *file = url.substr(0, loc);
             *id = url.substr(loc + 1);
         }
         else
         {
-            *file = url;
-            *id = std::string();
+            *file = std::string();
+            *id = url;
         }
     }
     else
     {
-        *file = std::string();
-        *id = url;
+        if (FileSystem::fileExists(url.c_str()))
+        {
+            *file = url;
+            *id = std::string();
+        }
+        else
+        {
+            *file = std::string();
+            *id = url;
+        }
     }
 }
 

+ 4 - 3
gameplay/src/SceneLoader.h

@@ -58,9 +58,10 @@ private:
             ROTATE = 256,
             SCALE = 512,
             URL = 1024,
-            SPRITE = 2048,
-            TILESET = 4096,
-            TEXT = 8192
+            SCRIPT = 2048,
+            SPRITE = 4096,
+            TILESET = 8192,
+            TEXT = 16384
         };
 
         SceneNodeProperty(Type type, const std::string& value, int index, bool isUrl);

+ 42 - 0
gameplay/src/Script.cpp

@@ -0,0 +1,42 @@
+#include "Script.h"
+#include "ScriptController.h"
+
+namespace gameplay
+{
+
+Script::Script() : _scope(GLOBAL), _env(0)
+{
+}
+
+Script::~Script()
+{
+    Game::getInstance()->getScriptController()->unloadScript(this);
+}
+
+const char* Script::getPath() const
+{
+    return _path.c_str();
+}
+
+Script::Scope Script::getScope() const
+{
+    return _scope;
+}
+
+bool Script::functionExists(const char* name) const
+{
+    return Game::getInstance()->getScriptController()->functionExists(name, this);
+}
+
+bool Script::reload()
+{
+    ScriptController* sc = Game::getInstance()->getScriptController();
+
+    // First unload our current script
+    sc->unloadScript(this);
+
+    // Now attempt to reload the script
+    return Game::getInstance()->getScriptController()->loadScript(this);
+}
+
+}

+ 119 - 0
gameplay/src/Script.h

@@ -0,0 +1,119 @@
+#ifndef SCRIPT_H_
+#define SCRIPT_H_
+
+#include "Base.h"
+#include "Ref.h"
+
+namespace gameplay
+{
+
+/**
+ * Represents a script that has been loaded by the scripting system.
+ */
+class Script : public Ref
+{
+    friend class ScriptController;
+
+public:
+
+    /**
+     * Defines the scope of a script environment.
+     */
+    enum Scope
+    {
+        /**
+         * Global scripts execute in a single shared environment that is accessible to
+         * all other scripts in the system. Global scripts can use code from other global
+         * scripts and other scripts can use code from a global script.
+         *
+         * Scripts that execute in the global environment must be careful to not override
+         * other variables or functions that already exist in the global environment (unless
+         * this is intended). Because of this, script naming conventions and the use of 
+         * unique namespaces is important to prevent naming collisions with other global code.
+         */
+        GLOBAL,
+
+        /**
+         * Protected scripts execute in a more limited sandbox environment that by default does
+         * not allow other scripts to see their variables or functions. Variables and functions
+         * in a protected script can be named the same as those in other scripts without 
+         * collision issues.
+         *
+         * Although global code cannot access protected scripts, protected scripts can acceess
+         * global code. Similarly, protected scripts can expose variables and functions to the
+         * global environment using explicit notation, although the same precautions noted
+         * for the GLOBAL scope should be used when doing this, to prevent naming collisions.
+         *
+         * Protected scripts are best used when associated with a single game object, since
+         * these scripts are not cached the same way global scripts are. Each time a protected
+         * script is loaded, a new instance of the script is loaded. This allows protected 
+         * scripts to store per-instance state, since it will not be shared by multiple instances.
+         *
+         * @see ScriptTarget
+         */
+        PROTECTED
+    };
+
+    /**
+     * Returns the path from which this Script was loaded.
+     *
+     * @return The script's path.
+     */
+    const char* getPath() const;
+
+    /**
+     * Returns the scope of this script.
+     *
+     * @return The scope of this script.
+     */
+    Scope getScope() const;
+
+    /**
+     * Determines if a function with the given name exists in the script.
+     *
+     * @param name Name of the function.
+     *
+     * @return True if the function exists, false otherwise.
+     */
+    bool functionExists(const char* name) const;
+
+    /** 
+     * Reloads this script.
+     *
+     * The code in the script will be reloaded and any functions and variables will be overwritten
+     * into the script's envrionment.
+     *
+     * If the script is GLOBAL in scope, it will simply be re-run, replacing any existing global 
+     * variables and functions. If the script has changed, any previous variables or functions that
+     * do not exist in the updated script will remain in the global environment.
+     *
+     * @return True if the script is successfully reloaded, false otherwise.
+     */
+    bool reload();
+
+private:
+
+    /**
+     * Constructor.
+     */
+    Script();
+
+    /**
+     * Copy constructor (hidden).
+     */
+    Script(const Script& copy);
+
+    /**
+     * Destructor.
+     */
+    ~Script();
+
+    std::string _path;
+    Scope _scope;
+    int _env;
+
+};
+
+}
+
+#endif

File diff ditekan karena terlalu besar
+ 395 - 506
gameplay/src/ScriptController.cpp


File diff ditekan karena terlalu besar
+ 219 - 526
gameplay/src/ScriptController.h


+ 21 - 24
gameplay/src/ScriptController.inl

@@ -21,7 +21,7 @@ ScriptUtil::LuaArray<T>::LuaArray(int count)
     // Allocate a chunk of memory to store 'count' number of T.
     // Use new instead of malloc since we track memory allocations
     // int DebugMem configurations.
-    _data->value = (T*)new unsigned char[sizeof(T) * count];
+    _data->value = (T*)new unsigned char[sizeof(T)* count];
 
     // Positive ref count means we automatically cleanup memory
     _data->refCount = 1;
@@ -272,7 +272,12 @@ ScriptUtil::LuaArray<T> ScriptUtil::getObjectPointer(int index, const char* type
 
 template<typename T> T ScriptController::executeFunction(const char* func)
 {
-    executeFunctionHelper(1, func, NULL, NULL);
+    return executeFunction<T>((Script*)NULL, func);
+}
+
+template<typename T> T ScriptController::executeFunction(Script* script, const char* func)
+{
+    executeFunctionHelper(1, func, NULL, NULL, script);
     T value = (T)((ScriptUtil::LuaObject*)lua_touserdata(_lua, -1))->instance;
     lua_pop(_lua, -1);
     return value;
@@ -282,40 +287,32 @@ template<typename T> T ScriptController::executeFunction(const char* func, const
 {
     va_list list;
     va_start(list, args);
-    executeFunctionHelper(1, func, args, &list);
-
-    T value = (T)((ScriptUtil::LuaObject*)lua_touserdata(_lua, -1))->instance;
-    lua_pop(_lua, -1);
+    T value = executeFunction<T>((Script*)NULL, func, args, list);
     va_end(list);
     return value;
 }
 
-template<typename T> T ScriptController::executeFunction(const char* func, const char* args, va_list* list)
+template<typename T> T ScriptController::executeFunction(Script* script, const char* func, const char* args, ...)
 {
-    executeFunctionHelper(1, func, args, list);
-
-    T value = (T)((ScriptUtil::LuaObject*)lua_touserdata(_lua, -1))->instance;
-    lua_pop(_lua, -1);
+    va_list list;
+    va_start(list, args);
+    T value = executeFunction<T>(script, func, args, list);
+    va_end(list);
     return value;
 }
 
-template<typename T>T* ScriptController::getObjectPointer(const char* type, const char* name)
+template<typename T> T ScriptController::executeFunction(const char* func, const char* args, va_list* list)
 {
-    lua_getglobal(_lua, name);
-    void* userdata = luaL_checkudata(_lua, -1, type);
-    std::string msg = std::string("'") + std::string(type) + std::string("' expected.");
-    luaL_argcheck(_lua, userdata != NULL, 1, msg.c_str());
-    return (T*)((ScriptUtil::LuaObject*)userdata)->instance;
+    return executeFunctionHelper(1, func, args, list, (Script*)NULL);
 }
 
-template<typename T>void ScriptController::setObjectPointer(const char* type, const char* name, T* v)
+template<typename T> T ScriptController::executeFunction(Script* script, const char* func, const char* args, va_list* list)
 {
-    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(_lua, sizeof(ScriptUtil::LuaObject));
-    object->instance = (void*)v;
-    object->owns = false;
-    luaL_getmetatable(_lua, type);
-    lua_setmetatable(_lua, -2);
-    lua_setglobal(_lua, name);
+    executeFunctionHelper(1, func, args, list, script);
+
+    T value = (T)((ScriptUtil::LuaObject*)lua_touserdata(_lua, -1))->instance;
+    lua_pop(_lua, -1);
+    return value;
 }
 
 }

+ 401 - 74
gameplay/src/ScriptTarget.cpp

@@ -5,146 +5,473 @@
 namespace gameplay
 {
 
+// TODO: Handle reloading scripts and then case where EventRegistries have events added AFTER a script has been loaded (i.e. need to reload callbacks for the script).
+
 extern void splitURL(const std::string& url, std::string* file, std::string* id);
 
-ScriptTarget::ScriptTarget()
+const char* ScriptTarget::Event::getName() const
+{
+    return name.c_str();
+}
+
+const char* ScriptTarget::Event::getArgs() const
+{
+    return args.c_str();
+}
+
+ScriptTarget::EventRegistry::EventRegistry()
+{
+}
+
+ScriptTarget::EventRegistry::~EventRegistry()
+{
+    for (size_t i = 0, count = _events.size(); i < count; ++i)
+    {
+        SAFE_DELETE(_events[i]);
+    }
+}
+
+const ScriptTarget::Event* ScriptTarget::EventRegistry::addEvent(const char* name, const char* args)
+{
+    GP_ASSERT(name);
+
+    Event* evt = new Event;
+    evt->name = name;
+    evt->args = args ? args : "";
+
+    _events.push_back(evt);
+
+    return evt;
+}
+
+unsigned int ScriptTarget::EventRegistry::getEventCount() const
+{
+    return _events.size();
+}
+
+const ScriptTarget::Event* ScriptTarget::EventRegistry::getEvent(unsigned int index) const
+{
+    GP_ASSERT(index < _events.size());
+
+    return _events[index];
+}
+
+const ScriptTarget::Event* ScriptTarget::EventRegistry::getEvent(const char* name) const
+{
+    GP_ASSERT(name);
+
+    for (size_t i = 0, count = _events.size(); i < count; ++i)
+    {
+        if (_events[i]->name == name)
+            return _events[i];
+    }
+
+    return NULL;
+}
+
+ScriptTarget::ScriptTarget() : _scriptRegistries(NULL), _scripts(NULL), _scriptCallbacks(NULL)
 {
 }
 
 ScriptTarget::~ScriptTarget()
 {
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.begin();
-    for (; iter != _callbacks.end(); iter++)
+    // Free callbacks
+    SAFE_DELETE(_scriptCallbacks);
+
+    // Free scripts
+    ScriptEntry* se = _scripts;
+    while (se)
+    {
+        ScriptEntry* tmp = se;
+        se = se->next;
+
+        SAFE_RELEASE(tmp->script);
+        SAFE_DELETE(tmp);
+    }
+
+    // Free registry entries
+    RegistryEntry* re = _scriptRegistries;
+    while (re)
     {
-        SAFE_DELETE(iter->second);
+        RegistryEntry* tmp = re;
+        re = re->next;
+
+        // Don't delete the actual EventRegistry, since it's shared by all
+        // ScriptTargets of the same type
+        SAFE_DELETE(tmp);
     }
 }
 
-template<> void ScriptTarget::fireScriptEvent<void>(const char* eventName, ...)
+void ScriptTarget::registerEvents(EventRegistry* registry)
 {
-    va_list list;
-    va_start(list, eventName);
+    GP_ASSERT(registry);
 
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.find(eventName);
-    if (iter != _callbacks.end() && iter->second != NULL)
+    // Attach the registry
+    RegistryEntry* re = new RegistryEntry(registry);
+    if (_scriptRegistries)
     {
-        ScriptController* sc = Game::getInstance()->getScriptController();
+        RegistryEntry* last = _scriptRegistries;
+        while (last->next)
+            last = last->next;
+        last->next = re;
+        re->prev = last;
+    }
+    else
+    {
+        _scriptRegistries = re;
+    }
+}
 
-        if (_events[eventName].size() > 0)
+Script* ScriptTarget::addScript(const char* path)
+{
+    ScriptController* sc = Game::getInstance()->getScriptController();
+
+    // Load the script
+    Script* script = sc->loadScript(path, Script::PROTECTED);
+    if (!script)
+        return NULL;
+
+    // Attach the script
+    ScriptEntry* se = new ScriptEntry(script);
+    if (_scripts)
+    {
+        ScriptEntry* last = _scripts;
+        while (last->next)
+            last = last->next;
+        last->next = se;
+        se->prev = last;
+    }
+    else
+    {
+        _scripts = se;
+    }
+
+    // Inspect the loaded script for event functions that are supported by this ScriptTarget.
+    // TODO: We'll need to re-load eventCallbacks when EventRegistries change for this ScriptObject.
+    RegistryEntry* re = _scriptRegistries;
+    while (re)
+    {
+        std::vector<Event*>& events = re->registry->_events;
+        for (size_t i = 0, count = events.size(); i < count; ++i)
         {
-            for (unsigned int i = 0; i < iter->second->size(); i++)
+            const Event* event = events[i];
+            if (sc->functionExists(event->name.c_str(), script))
             {
-                sc->executeFunction<void>((*iter->second)[i].function.c_str(), _events[eventName].c_str(), &list);
+                if (!_scriptCallbacks)
+                    _scriptCallbacks = new std::map<const Event*, std::vector<CallbackFunction>>();
+                (*_scriptCallbacks)[event].push_back(CallbackFunction(script, event->name.c_str()));
             }
         }
-        else
+        re = re->next;
+    }
+
+    // Automatically call the 'attached' event if it is defined within the script
+    if (sc->functionExists("attached", script))
+    {
+        char args[256];
+        sprintf(args, "<%s>", getTypeName());
+        sc->executeFunction<void>(script, "attached", args, dynamic_cast<void*>(this));
+    }
+
+    return script;
+}
+
+bool ScriptTarget::removeScript(const char* path)
+{
+    GP_ASSERT(path);
+
+    ScriptEntry* se = _scripts;
+    while (se)
+    {
+        if (strcmp(se->script->getPath(), path) == 0 && se->script->getScope() == Script::PROTECTED)
+        {
+            removeScript(se);
+            return true;
+        }
+        se = se->next;
+    }
+
+    return false;
+}
+
+void ScriptTarget::removeScript(ScriptEntry* se)
+{
+    GP_ASSERT(se);
+
+    // Link out this ScriptEntry
+    if (se->prev)
+        se->prev->next = se->next;
+    if (se->next)
+        se->next->prev = se->prev;
+    if (_scripts == se)
+        _scripts = se->next;
+
+    Script* script = se->script;
+
+    // Delete the ScriptEntry
+    SAFE_DELETE(se);
+
+    // Erase any callback functions registered for this script
+    if (_scriptCallbacks)
+    {
+        std::map<const Event*, std::vector<CallbackFunction>>::iterator itr = _scriptCallbacks->begin();
+        for ( ; itr != _scriptCallbacks->end(); ++itr)
         {
-            for (unsigned int i = 0; i < iter->second->size(); i++)
+            std::vector<CallbackFunction>& callbacks = itr->second;
+            std::vector<CallbackFunction>::iterator itr2 = callbacks.begin();
+            while (itr2 != callbacks.end())
             {
-                sc->executeFunction<void>((*iter->second)[i].function.c_str(), _events[eventName].c_str());
+                if (itr2->script == script)
+                    itr2 = callbacks.erase(itr2);
+                else
+                    ++itr2;
             }
         }
     }
 
-    va_end(list);
+    // Free the script
+    SAFE_RELEASE(script);
 }
 
-template<> bool ScriptTarget::fireScriptEvent<bool>(const char* eventName, ...)
+void ScriptTarget::addScriptCallback(const Event* event, const char* function)
 {
-    va_list list;
-    va_start(list, eventName);
+    GP_ASSERT(event);
+    GP_ASSERT(function);
 
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.find(eventName);
-    if (iter != _callbacks.end() && iter->second)
+    // Parse the script name (if it exists) and function out
+    std::string scriptPath, func;
+    splitURL(function, &scriptPath, &func);
+    if (func.length() == 0)
     {
-        ScriptController* sc = Game::getInstance()->getScriptController();
+        // The url doesn't reference a script, only a function
+        func = scriptPath;
+        scriptPath = "";
+    }
 
-        if (_events[eventName].size() > 0)
+    // Have we already loaded this global script?
+    bool loaded = true;
+    Script* script = NULL;
+    if (!scriptPath.empty())
+    {
+        loaded = false;
+        ScriptEntry* se = _scripts;
+        while (se)
         {
-            for (unsigned int i = 0; i < iter->second->size(); i++)
+            if (scriptPath == se->script->getPath() && se->script->getScope() == Script::GLOBAL)
             {
-                if (sc->executeFunction<bool>((*iter->second)[i].function.c_str(), _events[eventName].c_str(), &list))
-                {
-                    va_end(list);
-                    return true;
-                }
+                // Script is already loaded
+                script = se->script;
+                loaded = true;
+                break;
+            }
+            se = se->next;
+        }
+    }
+
+    if (!loaded)
+    {
+        // The specified global script is not yet loaded, so do so
+        script = Game::getInstance()->getScriptController()->loadScript(scriptPath.c_str(), Script::GLOBAL);
+        if (script)
+        {
+            loaded = true;
+            ScriptEntry* se = new ScriptEntry(script);
+            if (_scripts)
+            {
+                ScriptEntry* last = _scripts;
+                while (last->next)
+                    last = last->next;
+                last->next = se;
+                se->prev = last;
+            }
+            else
+            {
+                _scripts = se;
             }
         }
         else
         {
-            for (unsigned int i = 0; i < iter->second->size(); i++)
+            GP_WARN("Failed to load script '%s' for script target while registering for function: %s", scriptPath.c_str(), function);
+        }
+    }
+
+    if (loaded)
+    {
+        // Store the callback
+        if (!_scriptCallbacks)
+            _scriptCallbacks = new std::map<const Event*, std::vector<CallbackFunction>>();
+        (*_scriptCallbacks)[event].push_back(CallbackFunction(script, func.c_str()));
+    }
+}
+
+void ScriptTarget::removeScriptCallback(const Event* event, const char* function)
+{
+    // Parse the script name (if it exists) and function out
+    std::string scriptPath, func;
+    splitURL(function, &scriptPath, &func);
+    if (func.length() == 0)
+    {
+        // The url doesn't reference a script, only a function
+        func = scriptPath;
+        scriptPath = "";
+    }
+
+    // Find the script entry for this callback
+    ScriptEntry* scriptEntry = NULL;
+    if (!scriptPath.empty())
+    {
+        ScriptEntry* se = _scripts;
+        while (se)
+        {
+            if (scriptPath == se->script->getPath() && se->script->getScope() == Script::GLOBAL)
+            {
+                scriptEntry = se;
+                break;
+            }
+            se = se->next;
+        }
+    }
+    Script* script = scriptEntry ? scriptEntry->script : NULL;
+
+    // Remove any registered callback functions that match the specified one
+    int removedCallbacks = 0;
+    int totalCallbacks = 0;
+    if (_scriptCallbacks)
+    {
+        std::map<const Event*, std::vector<CallbackFunction>>::iterator itr = _scriptCallbacks->begin();
+        for (; itr != _scriptCallbacks->end(); ++itr)
+        {
+            // Erase matching callback functions for this event
+            bool forEvent = itr->first == event;
+            std::vector<CallbackFunction>& callbacks = itr->second;
+            std::vector<CallbackFunction>::iterator itr2 = callbacks.begin();
+            while (itr2 != callbacks.end())
             {
-                if (sc->executeFunction<bool>((*iter->second)[i].function.c_str(), _events[eventName].c_str()))
+                if (itr2->script == script)
                 {
-                    va_end(list);
-                    return true;
+                    ++totalCallbacks; // sum total number of callbacks found for this script
+                    if (forEvent && itr2->function == func)
+                    {
+                        itr2 = callbacks.erase(itr2);
+                        ++removedCallbacks; // sum number of callbacks removed
+                    }
+                    else
+                        ++itr2;
                 }
             }
         }
     }
 
-    va_end(list);
-    return false;
+    // Cleanup the script if there are no remaining callbacks for it
+    if (scriptEntry && (totalCallbacks - removedCallbacks) <= 0)
+    {
+        removeScript(scriptEntry);
+    }
 }
 
-void ScriptTarget::addScriptCallback(const std::string& eventName, const std::string& function)
+void ScriptTarget::clearScripts()
 {
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.find(eventName);
-    if (iter != _callbacks.end())
+    while (_scripts)
     {
-        if (!iter->second)
-            iter->second = new std::vector<Callback>();
+        removeScript(_scripts);
+    }
+}
 
-        // Add the function to the list of callbacks.
-        std::string functionName = Game::getInstance()->getScriptController()->loadUrl(function.c_str());
-        iter->second->push_back(Callback(functionName));
+bool ScriptTarget::hasScriptListener(const char* eventName) const
+{
+    const Event* event = getScriptEvent(eventName);
+    return event ? hasScriptListener(event) : false;
+}
+
+const ScriptTarget::Event* ScriptTarget::getScriptEvent(const char* eventName) const
+{
+    GP_ASSERT(eventName);
+
+    // Lookup the event for this name
+    const Event* event = NULL;
+    RegistryEntry* re = _scriptRegistries;
+    while (re)
+    {
+        if ((event = re->registry->getEvent(eventName)) != NULL)
+            break;
+        re = re->next;
     }
-    else
+
+    return event;
+}
+
+bool ScriptTarget::hasScriptListener(const Event* event) const
+{
+    GP_ASSERT(event);
+
+    if (_scriptCallbacks)
     {
-        GP_ERROR("Attempting to add a script callback for unsupported event '%s'.", eventName.c_str());
+        std::map<const Event*, std::vector<CallbackFunction>>::iterator itr = _scriptCallbacks->find(event);
+        if (itr != _scriptCallbacks->end())
+        {
+            return !itr->second.empty();
+        }
     }
+
+    return false;
 }
 
-void ScriptTarget::removeScriptCallback(const std::string& eventName, const std::string& function)
+template<> void ScriptTarget::fireScriptEvent<void>(const Event* event, ...)
 {
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.find(eventName);
-    if (iter != _callbacks.end())
+    GP_ASSERT(event);
+
+    if (!_scriptCallbacks)
+        return; // no registered callbacks
+
+    va_list list;
+    va_start(list, event);
+
+    // Lookup registered callbacks for this event and fire them
+    std::map<const Event*, std::vector<CallbackFunction>>::iterator itr = _scriptCallbacks->find(event);
+    if (itr != _scriptCallbacks->end())
     {
-        if (!iter->second)
-            return;
+        ScriptController* sc = Game::getInstance()->getScriptController();
+        std::vector<CallbackFunction>& callbacks = itr->second;
+        for (size_t i = 0, count = callbacks.size(); i < count; ++i)
+        {
+            CallbackFunction& cb = callbacks[i];
+            sc->executeFunction<void>(cb.script, cb.function.c_str(), event->args.c_str(), &list);
+        }
+    }
+
+    va_end(list);
+}
 
-        std::string file;
-        std::string id;
-        splitURL(function, &file, &id);
+template<> bool ScriptTarget::fireScriptEvent<bool>(const Event* event, ...)
+{
+    GP_ASSERT(event);
 
-        // Make sure the function isn't empty.
-        if (id.size() <= 0)
-            return;
+    if (!_scriptCallbacks)
+        return false; // no registered callbacks
 
-        // Remove the function from the list of callbacks.
-        for (unsigned int i = 0; i < iter->second->size(); i++)
+    va_list list;
+    va_start(list, event);
+
+    // Lookup registered callbacks for this event and fire them
+    std::map<const Event*, std::vector<CallbackFunction>>::iterator itr = _scriptCallbacks->find(event);
+    if (itr != _scriptCallbacks->end())
+    {
+        ScriptController* sc = Game::getInstance()->getScriptController();
+        std::vector<CallbackFunction>& callbacks = itr->second;
+        for (size_t i = 0, count = callbacks.size(); i < count; ++i)
         {
-            if ((*iter->second)[i].function == id)
+            CallbackFunction& cb = callbacks[i];
+            if (sc->executeFunction<bool>(cb.script, cb.function.c_str(), event->args.c_str(), &list))
             {
-                iter->second->erase(iter->second->begin() + i);
-                return;
+                va_end(list);
+                return true;
             }
         }
     }
-    else
-    {
-        GP_ERROR("Attempting to remove a script callback for unsupported event '%s'.", eventName.c_str());
-    }
-}
 
-void ScriptTarget::addScriptEvent(const std::string& eventName, const char* argsString)
-{
-    _events[eventName] = (argsString ? argsString : "");
-    _callbacks[eventName] = NULL;
-}
+    va_end(list);
 
-ScriptTarget::Callback::Callback(const std::string& function) : function(function)
-{
+    return false;
 }
 
 }

+ 357 - 36
gameplay/src/ScriptTarget.h

@@ -1,89 +1,410 @@
 #ifndef SCRIPTTARGET_H_
 #define SCRIPTTARGET_H_
 
-#include "Base.h"
+#include "Script.h"
 
 namespace gameplay
 {
 
+/**
+ * Macro to indidate the start of script event definitions for a class.
+ *
+ * This macro should be used at the top of a class declaration. The class
+ * should extend ScriptTarget and the lines immediately following this
+ * macro should be one or more GP_SCRIPT_EVENT macros, followed by
+ * exactly one GP_SCRIPT_EVENTS_END macro.
+ *
+ * @script{ignore}
+ */
+#define GP_SCRIPT_EVENTS_START() \
+public: \
+    class ScriptEvents { \
+    public: \
+        static ScriptEvents* getInstance() \
+        { \
+            static ScriptEvents instance; \
+            return &instance; \
+        } \
+        static ScriptTarget::EventRegistry* getRegistry() \
+        { \
+            static ScriptTarget::EventRegistry registry; \
+            return &registry; \
+        }
+
+/**
+ * Macro to define a single supported script event for a class.
+ *
+ * This macro should follow exactly one prior GP_SCRIPT_EVENTS_START macro
+ * and zero or more other GP_SCRIPT_EVENT macros.
+ *
+ * @param eventName The name of the script event.
+ * @param eventArgs A string of arguments to be passed to the script event, using
+ *      the format specified in ScriptController::executeFunction.
+ *
+ * @script{ignore}
+ */
+#define GP_SCRIPT_EVENT(eventName, eventArgs) \
+        struct SCRIPT_EVENT_ ## eventName \
+        { \
+            SCRIPT_EVENT_ ## eventName() \
+            { \
+                _event = ScriptEvents::getRegistry()->addEvent(#eventName, eventArgs); \
+            } \
+            const ScriptTarget::Event* getEvent() \
+            { \
+                return _event; \
+            } \
+        private: \
+            const ScriptTarget::Event* _event; \
+        }; \
+        SCRIPT_EVENT_ ## eventName eventName;
+
+/**
+ * Macro to indiate the end of a series of script event defintions.
+ *
+ * @script{ignore}
+ */
+#define GP_SCRIPT_EVENTS_END() \
+    private: \
+        ScriptEvents() { } \
+    };
+
+/**
+ * Macro used to retrieve a script event object the given class name.
+ *
+ * @param eventClass The C++ class that contains the specified script event.
+ * @param eventName The name of the registered script event to retrieve.
+ *
+ * @script{ignore}
+ */
+#define GP_GET_SCRIPT_EVENT(eventClass, eventName) \
+    eventClass::ScriptEvents::getInstance()->eventName.getEvent()
+
+
+/**
+ * Registers the defined script events for a ScriptTarget.
+ *
+ * This macro should be called at the beginning of all constructors of a
+ * ScriptTarget child class that contains one or more script event 
+ * declarations (via the GP_SCRIPT_EVENT macro).
+ *
+ * @script{ignore}
+ */
+#define GP_REGISTER_SCRIPT_EVENTS() \
+    ScriptTarget::registerEvents(ScriptEvents::getInstance()->getRegistry())
+
 /**
  * Defines an interface for supporting script callbacks.
+ *
+ * Classes that extend ScriptTarget can expose script events using the GP_SCRIPT_EVENT macros.
+ * Custom events should be registered using these macros at the top of the class definition.
+ * Events can be fired by calling the ScriptTarget::fireScriptEvent method, passing the 
+ * registered ScriptTarget::Event object and any required parameters.
+ *
+ * In addition to script events that are explicitly defined by a custom ScriptTarget class,
+ * all ScriptTarget scripts implicitly support an "attached" event. This event is called
+ * immediately after such a script is attached to a ScriptTarget and it takes a single
+ * parameter: the ScriptTarget object.
  */
 class ScriptTarget
 {
+    friend class Game;
+
 public:
 
     /**
-     * Adds the given Lua script function as a callback for the given event.
+     * Defines a single script event.
+     */
+    class Event
+    {
+        friend class ScriptTarget;
+
+    public:
+
+        /**
+         * Returns the name of this event.
+         *
+         * @return The event name.
+         */
+        const char* getName() const;
+
+        /**
+         * Returns the argument string for this event.
+         *
+         * @return The argument string.
+         */
+        const char* getArgs() const;
+
+    private:
+
+        /**
+         * The event name.
+         */
+        std::string name;
+
+        /**
+         * The event arguments.
+         *
+         * @see ScriptController::executeFunction
+         */
+        std::string args;
+
+    };
+
+    /**
+     * Script event registry that defines the supported script events
+     * for a ScriptTarget.
+     *
+     * This class should generally only be used via the GP_REGISTER_SCRIPT_EVENTS macro.
+     */
+    class EventRegistry
+    {
+        friend class ScriptTarget;
+
+    public:
+
+        /**
+         * Creates an empty event registry.
+         */
+        EventRegistry();
+
+        /**
+         * Destructor.
+         */
+        ~EventRegistry();
+
+        /**
+         * Adds a registered event to the registry.
+         *
+         * @param name The name of the script event.
+         * @param args The argument string for the event.
+         *
+         * @return The added event.
+         *
+         * @see ScriptController::executeFunction
+         */
+        const Event* addEvent(const char* name, const char* args = NULL);
+
+        /**
+         * Returns the number of registered script events.
+         *
+         * @return The number of script events registered.
+         */
+        unsigned int getEventCount() const;
+
+        /**
+         * Returns the event with the given index.
+         *
+         * @param index The index of the event to retrieve.
+         *
+         * @return The event for the given index.
+         */
+        const Event* getEvent(unsigned int index) const;
+
+        /**
+         * Returns the event that matches the given name.
+         *
+         * @param name The name of the event to search for.
+         *
+         * @return The matching event, or NULL if no such event exists.
+         */
+        const Event* getEvent(const char* name) const;
+
+    private:
+
+        std::vector<Event*> _events;
+    };
+
+    /**
+     * Implemented by child classes to return the type name identifier for
+     * the class that extends ScriptTarget.
+     *
+     * @return A string describing the type name of the ScriptTarget child
+     *      class, as it is defined in the lua bindings (i.e. "Node").
+     */
+    virtual const char* getTypeName() const = 0;
+
+    /**
+     * Attaches a script to this object.
+     *
+     * Scripts attached to a ScriptTarget are loaded using the PROTECTED scope,
+     * which loads scripts into their own protected script environment, allowing
+     * variables with the same name to be used without colliding with other scripts.
+     *
+     * @param path Path to the script.
+     *
+     * @return A pointer to the successfully loaded script, or NULL if unsuccessful.
+     */
+    Script* addScript(const char* path);
+
+    /**
+     * Removes a previously attached script from this object.
+     *
+     * @param path The same path that was used to load the script being removed.
+     *
+     * @return True if a script is successfully removed, false otherwise.
+     */
+    bool removeScript(const char* path);
+
+    /**
+     * Adds the given global script function as a callback for the given event.
+     *
+     * Individual script callback events registered via this method are expected
+     * to be global script functions. Registering individual callbacks in this
+     * manner is generally slower than registering a single script to handle script
+     * events for an object.
      * 
-     * @param eventName The name of the event.
-     * @param function The name of the Lua script function to call when the event is fired; can either be
+     * @param event The event to add the callback for.
+     * @param function The name of the script function to call when the event is fired; can either be
      *  just the name of a function (if the function's script file has already been loaded), or can be
      *  a URL of the form scriptFile.lua#functionName.
      */
-    virtual void addScriptCallback(const std::string& eventName, const std::string& function);
+    void addScriptCallback(const Event* event, const char* function);
 
     /**
-     * Removes the given Lua script function as a callback for the given event.
+     * Removes the given script function as a callback for the given event.
      * 
-     * @param eventName The name of the event.
-     * @param function The name of the Lua script function.
+     * @param event The event to remove the callback for.
+     * @param function The name of the script function.
      */
-    virtual void removeScriptCallback(const std::string& eventName, const std::string& function);
+    void removeScriptCallback(const Event* event, const char* function);
 
-protected:
+    /**
+     *  Removes all scripts and callbacks from this object.
+     */
+    void clearScripts();
 
     /**
-     * Hidden constructor.
+     * Determines if there is a script installed that is listening for the given script
+     * event (i.e. has a function callback defined for the given event).
+     *
+     * @param eventName The script event to check.
+     *
+     * @return True if there is a listener for the specified event, false otherwise.
      */
-    ScriptTarget();
+    bool hasScriptListener(const char* eventName) const;
 
     /**
-     * Destructor.
+     * Determines if there is a script installed that is listening for the given script
+     * event (i.e. has a function callback defined for the given event).
+     *
+     * @param event The script event to check.
+     *
+     * @return True if there is a listener for the specified event, false otherwise.
      */
-    virtual ~ScriptTarget();
+    bool hasScriptListener(const Event* event) const;
 
     /**
-     * Adds the given event with the given Lua script parameter string ({@link ScriptController::executeFunction})
-     * as a supported event for this script target.
-     * 
-     * @param eventName The name of the event.
-     * @param argsString The argument string for the event.
+     * Returns the event object for the given event name, if it exists.
+     *
+     * @param eventName Name of the event.
+     *
+     * @return The event object for the given name, or NULL if no such event exists.
      */
-    void addScriptEvent(const std::string& eventName, const char* argsString = NULL);
+    const Event* getScriptEvent(const char* eventName) const;
 
     /**
-     * Fires the event with the given event name and the given arguments.
+     * Fires the specified script event, passing the specified arguments.
+     *
+     * The only supported return types are void and boolean. When a boolean
+     * return type is used and there are multiple scripts registered for the
+     * given script event, event delegation will stop at the first script
+     * that returns a value of true.
      * 
-     * @param eventName The name of the event.
+     * @param event The script event to fire, which was returned from EventRegistry::addEvent.
+     * @param ... Optional list of arguments to pass to the script event (should match the
+     *      script event argument definition).
+     *
+     * @script{ignore}
      */
-    template<typename T> T fireScriptEvent(const char* eventName, ...);
+    template<typename T> T fireScriptEvent(const Event* event, ...);
+
+protected:
 
-    /** Used to store a script callbacks for given event. */
-    struct Callback
+    /**
+     * Stores an EventRegistry entry for a ScriptTarget.
+     */
+    struct RegistryEntry
     {
-        /** Constructor. */
-        Callback(const std::string& string);
+        EventRegistry* registry;
+        RegistryEntry* next;
+        RegistryEntry* prev;
 
-        /** Holds the Lua script callback function. */
+        RegistryEntry(EventRegistry* registry) : registry(registry), next(NULL), prev(NULL) { }
+    };
+
+    /**
+     * Stores a Script that is registered for a ScriptTarget.
+     */
+    struct ScriptEntry
+    {
+        Script* script;
+        ScriptEntry* next;
+        ScriptEntry* prev;
+        ScriptEntry(Script* script) : script(script), next(NULL), prev(NULL) { }
+    };
+
+    /**
+     * Stores a single registered script callback function.
+     */
+    struct CallbackFunction
+    {
+        // The script the callback belongs to (or NULL if the callback is a global function)
+        Script* script;
+
+        // The function within the script to call
         std::string function;
+
+        CallbackFunction(Script* script, const char* function) : script(script), function(function) { }
     };
 
-    /** Holds the supported events for this script target. */
-    std::map<std::string, std::string> _events;
-    /** Holds the callbacks for this script target's events. */
-    std::map<std::string, std::vector<Callback>*> _callbacks;
+    /**
+     * Constructor.
+     */
+    ScriptTarget();
+
+    /**
+     * Destructor.
+     */
+    virtual ~ScriptTarget();
+
+    /**
+     * Removes the specified script.
+     */
+    void removeScript(ScriptEntry* se);
+
+    /**
+     * Registers a set of supported script events and event arguments for this ScriptTarget. 
+     *
+     * The passed in EventRegistry object should contain a list of all script events to
+     * be supported by this ScriptTarget, along with their parameter definitions. This
+     * registry object will be held onto for the lifetime of the ScriptTarget and it is
+     * recommended that it be shared among all ScriptTargets of the same class/type.
+     *
+     * This should normally be set using the GP_REGISTER_SCRIPT_EVENTS macro in the
+     * constructor of the child class.
+     *
+     * @param registry The EventRegistry containing the list of supported script events.
+     */
+    void registerEvents(EventRegistry* registry);
+
+    /** Holds the event registries for this script target. */
+    RegistryEntry* _scriptRegistries;
+    /** Holds the list of scripts referenced by this ScriptTarget. */
+    ScriptEntry* _scripts;
+    /** Holds the list of callback functions registered for this ScriptTarget. */
+    std::map<const Event*, std::vector<CallbackFunction> >* _scriptCallbacks;
 };
 
-template<typename T> T ScriptTarget::fireScriptEvent(const char* eventName, ...)
+template<typename T> T ScriptTarget::fireScriptEvent(const Event* evt, ...)
 {
-    GP_ERROR("Unsupported return type!");
+    GP_ERROR("Unsupported return type for template function ScriptTarget::fireScriptEvent.");
 }
 
 /** Template specialization. */
-template<> void ScriptTarget::fireScriptEvent<void>(const char* eventName, ...);
+template<> void ScriptTarget::fireScriptEvent<void>(const Event* event, ...);
 /** Template specialization. */
-template<> bool ScriptTarget::fireScriptEvent<bool>(const char* eventName, ...);
+template<> bool ScriptTarget::fireScriptEvent<bool>(const Event* event, ...);
 
 }
 

+ 5 - 5
gameplay/src/Slider.cpp

@@ -59,6 +59,11 @@ void Slider::initialize(const char* typeName, Theme::Style* style, Properties* p
     setValue(_value);
 }
 
+const char* Slider::getTypeName() const
+{
+    return "Slider";
+}
+
 void Slider::setMin(float min)
 {
     _min = min;
@@ -486,9 +491,4 @@ unsigned int Slider::drawText(Form* form, const Rectangle& clip)
     return drawCalls;
 }
 
-const char* Slider::getType() const
-{
-    return "slider";
-}
-
 }

+ 10 - 5
gameplay/src/Slider.h

@@ -35,6 +35,16 @@ public:
      */
     static Slider* create(const char* id, Theme::Style* style = NULL);
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "Slider"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Set the minimum value that can be set on this slider.
      *
@@ -93,11 +103,6 @@ public:
      */
     float getValue() const;
 
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
-
     /**
      * Sets if the slider value text is rendered below the control.
      * 

+ 15 - 15
gameplay/src/TextBox.cpp

@@ -28,16 +28,6 @@ Control* TextBox::create(Theme::Style* style, Properties* properties)
     return textBox;
 }
 
-void TextBox::addListener(Control::Listener* listener, int eventFlags)
-{
-    if ((eventFlags & Control::Listener::VALUE_CHANGED) == Control::Listener::VALUE_CHANGED)
-    {
-        GP_ERROR("VALUE_CHANGED event is not applicable to this control.");
-    }
-
-    Control::addListener(listener, eventFlags);
-}
-
 void TextBox::initialize(const char* typeName, Theme::Style* style, Properties* properties)
 {
     Label::initialize(typeName, style, properties);
@@ -48,6 +38,21 @@ void TextBox::initialize(const char* typeName, Theme::Style* style, Properties*
 	}
 }
 
+const char* TextBox::getTypeName() const
+{
+    return "TextBox";
+}
+
+void TextBox::addListener(Control::Listener* listener, int eventFlags)
+{
+    if ((eventFlags & Control::Listener::VALUE_CHANGED) == Control::Listener::VALUE_CHANGED)
+    {
+        GP_ERROR("VALUE_CHANGED event is not applicable to this control.");
+    }
+
+    Control::addListener(listener, eventFlags);
+}
+
 int TextBox::getLastKeypress()
 {
     return _lastKeypress;
@@ -456,11 +461,6 @@ void TextBox::getCaretLocation(Vector2* p)
     getFont(state)->getLocationAtIndex(getDisplayedText().c_str(), _textBounds, getFontSize(state), p, _caretLocation, getTextAlignment(state), true, getTextRightToLeft(state));
 }
 
-const char* TextBox::getType() const
-{
-    return "textBox";
-}
-
 void TextBox::setPasswordChar(char character)
 {
     _passwordChar = character;

+ 10 - 5
gameplay/src/TextBox.h

@@ -52,6 +52,16 @@ public:
      */
     static TextBox* create(const char* id, Theme::Style* style = NULL);
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * Child controls should override this function to return the correct type name.
+     *
+     * @return The type name of this class: "TextBox"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Returns the current location of the caret with the text of this TextBox.
      *
@@ -73,11 +83,6 @@ public:
      */
     int getLastKeypress();
 
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
-
     /**
      * Set the character displayed in password mode.
      *

+ 14 - 5
gameplay/src/Transform.cpp

@@ -12,33 +12,37 @@ std::vector<Transform*> Transform::_transformsChanged;
 Transform::Transform()
     : _matrixDirtyBits(0), _listeners(NULL)
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     _targetType = AnimationTarget::TRANSFORM;
     _scale.set(Vector3::one());
-    addScriptEvent("transformChanged", "<Transform>");
 }
 
 Transform::Transform(const Vector3& scale, const Quaternion& rotation, const Vector3& translation)
     : _matrixDirtyBits(0), _listeners(NULL)
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     _targetType = AnimationTarget::TRANSFORM;
     set(scale, rotation, translation);
-    addScriptEvent("transformChanged", "<Transform>");
 }
 
 Transform::Transform(const Vector3& scale, const Matrix& rotation, const Vector3& translation)
     : _matrixDirtyBits(0), _listeners(NULL)
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     _targetType = AnimationTarget::TRANSFORM;
     set(scale, rotation, translation);
-    addScriptEvent("transformChanged", "<Transform>");
 }
 
 Transform::Transform(const Transform& copy)
     : _matrixDirtyBits(0), _listeners(NULL)
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     _targetType = AnimationTarget::TRANSFORM;
     set(copy);
-    addScriptEvent("transformChanged", "<Transform>");
 }
 
 Transform::~Transform()
@@ -88,6 +92,11 @@ bool Transform::isTransformChangedSuspended()
     return (_suspendTransformChanged > 0);
 }
 
+const char* Transform::getTypeName() const
+{
+    return "Transform";
+}
+
 const Matrix& Transform::getMatrix() const
 {
     if (_matrixDirtyBits)
@@ -991,7 +1000,7 @@ void Transform::transformChanged()
             l.listener->transformChanged(this, l.cookie);
         }
     }
-    fireScriptEvent<void>("transformChanged", this);
+    fireScriptEvent<void>(GP_GET_SCRIPT_EVENT(Transform, transformChanged), dynamic_cast<void*>(this));
 }
 
 void Transform::cloneInto(Transform* transform, NodeCloneContext &context) const

+ 13 - 2
gameplay/src/Transform.h

@@ -1,12 +1,11 @@
 #ifndef TRANSFORM_H_
 #define TRANSFORM_H_
 
-#include "Ref.h"
+#include "ScriptTarget.h"
 #include "Vector3.h"
 #include "Quaternion.h"
 #include "Matrix.h"
 #include "AnimationTarget.h"
-#include "ScriptTarget.h"
 
 namespace gameplay
 {
@@ -31,6 +30,10 @@ class ScriptListener;
  */
 class Transform : public AnimationTarget, public ScriptTarget
 {
+    GP_SCRIPT_EVENTS_START();
+    GP_SCRIPT_EVENT(transformChanged, "<Transform>");
+    GP_SCRIPT_EVENTS_END();
+
 public:
 
     /**
@@ -173,6 +176,14 @@ public:
      */
     virtual ~Transform();
 
+    /**
+     * Extends ScriptTarget::getTypeName() to return the type name of this class.
+     *
+     * @return The type name of this class: "Transform"
+     * @see ScriptTarget::getTypeName()
+     */
+    const char* getTypeName() const;
+
     /**
      * Gets the matrix corresponding to this transform.
      *

+ 4 - 87
gameplay/src/lua/lua_AIAgent.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AIAgent.h"
@@ -6,8 +7,6 @@
 #include "Game.h"
 #include "Node.h"
 #include "Ref.h"
-#include "ScriptController.h"
-#include "ScriptTarget.h"
 
 namespace gameplay
 {
@@ -17,14 +16,12 @@ void luaRegister_AIAgent()
     const luaL_Reg lua_members[] = 
     {
         {"addRef", lua_AIAgent_addRef},
-        {"addScriptCallback", lua_AIAgent_addScriptCallback},
         {"getId", lua_AIAgent_getId},
         {"getNode", lua_AIAgent_getNode},
         {"getRefCount", lua_AIAgent_getRefCount},
         {"getStateMachine", lua_AIAgent_getStateMachine},
         {"isEnabled", lua_AIAgent_isEnabled},
         {"release", lua_AIAgent_release},
-        {"removeScriptCallback", lua_AIAgent_removeScriptCallback},
         {"setEnabled", lua_AIAgent_setEnabled},
         {"setListener", lua_AIAgent_setListener},
         {NULL, NULL}
@@ -116,46 +113,6 @@ int lua_AIAgent_addRef(lua_State* state)
     return 0;
 }
 
-int lua_AIAgent_addScriptCallback(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
-
-                AIAgent* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_AIAgent_addScriptCallback - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_AIAgent_getId(lua_State* state)
 {
     // Get the number of parameters.
@@ -204,7 +161,7 @@ int lua_AIAgent_getNode(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 AIAgent* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getNode();
+                void* returnPtr = ((void*)instance->getNode());
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -283,7 +240,7 @@ int lua_AIAgent_getStateMachine(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 AIAgent* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getStateMachine();
+                void* returnPtr = ((void*)instance->getStateMachine());
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -381,46 +338,6 @@ int lua_AIAgent_release(lua_State* state)
     return 0;
 }
 
-int lua_AIAgent_removeScriptCallback(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
-
-                AIAgent* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_AIAgent_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_AIAgent_setEnabled(lua_State* state)
 {
     // Get the number of parameters.
@@ -509,7 +426,7 @@ int lua_AIAgent_static_create(lua_State* state)
     {
         case 0:
         {
-            void* returnPtr = (void*)AIAgent::create();
+            void* returnPtr = ((void*)AIAgent::create());
             if (returnPtr)
             {
                 gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));

+ 1 - 2
gameplay/src/lua/lua_AIAgent.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_AIAGENT_H_
 #define LUA_AIAGENT_H_
 
@@ -7,14 +8,12 @@ namespace gameplay
 // Lua bindings for AIAgent.
 int lua_AIAgent__gc(lua_State* state);
 int lua_AIAgent_addRef(lua_State* state);
-int lua_AIAgent_addScriptCallback(lua_State* state);
 int lua_AIAgent_getId(lua_State* state);
 int lua_AIAgent_getNode(lua_State* state);
 int lua_AIAgent_getRefCount(lua_State* state);
 int lua_AIAgent_getStateMachine(lua_State* state);
 int lua_AIAgent_isEnabled(lua_State* state);
 int lua_AIAgent_release(lua_State* state);
-int lua_AIAgent_removeScriptCallback(lua_State* state);
 int lua_AIAgent_setEnabled(lua_State* state);
 int lua_AIAgent_setListener(lua_State* state);
 int lua_AIAgent_static_create(lua_State* state);

+ 1 - 2
gameplay/src/lua/lua_AIAgentListener.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AIAgentListener.h"
@@ -6,8 +7,6 @@
 #include "Game.h"
 #include "Node.h"
 #include "Ref.h"
-#include "ScriptController.h"
-#include "ScriptTarget.h"
 
 namespace gameplay
 {

+ 1 - 0
gameplay/src/lua/lua_AIAgentListener.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_AIAGENTLISTENER_H_
 #define LUA_AIAGENTLISTENER_H_
 

+ 2 - 1
gameplay/src/lua/lua_AIController.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AIController.h"
@@ -46,7 +47,7 @@ int lua_AIController_findAgent(lua_State* state)
                 const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
                 AIController* instance = getInstance(state);
-                void* returnPtr = (void*)instance->findAgent(param1);
+                void* returnPtr = ((void*)instance->findAgent(param1));
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));

+ 1 - 0
gameplay/src/lua/lua_AIController.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_AICONTROLLER_H_
 #define LUA_AICONTROLLER_H_
 

+ 3 - 3
gameplay/src/lua/lua_AIMessage.cpp

@@ -1,9 +1,9 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AIMessage.h"
 #include "AIMessage.h"
 #include "Base.h"
-#include "lua_AIMessageParameterType.h"
 
 namespace gameplay
 {
@@ -334,7 +334,7 @@ int lua_AIMessage_getParameterType(lua_State* state)
                 AIMessage::ParameterType result = instance->getParameterType(param1);
 
                 // Push the return value onto the stack.
-                lua_pushstring(state, lua_stringFromEnum_AIMessageParameterType(result));
+                lua_pushnumber(state, (int)result);
 
                 return 1;
             }
@@ -729,7 +729,7 @@ int lua_AIMessage_static_create(lua_State* state)
                 // Get parameter 4 off the stack.
                 unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 4);
 
-                void* returnPtr = (void*)AIMessage::create(param1, param2, param3, param4);
+                void* returnPtr = ((void*)AIMessage::create(param1, param2, param3, param4));
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));

+ 1 - 0
gameplay/src/lua/lua_AIMessage.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_AIMESSAGE_H_
 #define LUA_AIMESSAGE_H_
 

+ 0 - 56
gameplay/src/lua/lua_AIMessageParameterType.cpp

@@ -1,56 +0,0 @@
-#include "Base.h"
-#include "lua_AIMessageParameterType.h"
-
-namespace gameplay
-{
-
-static const char* enumStringEmpty = "";
-
-static const char* luaEnumString_AIMessageParameterType_UNDEFINED = "UNDEFINED";
-static const char* luaEnumString_AIMessageParameterType_INTEGER = "INTEGER";
-static const char* luaEnumString_AIMessageParameterType_LONG = "LONG";
-static const char* luaEnumString_AIMessageParameterType_FLOAT = "FLOAT";
-static const char* luaEnumString_AIMessageParameterType_DOUBLE = "DOUBLE";
-static const char* luaEnumString_AIMessageParameterType_BOOLEAN = "BOOLEAN";
-static const char* luaEnumString_AIMessageParameterType_STRING = "STRING";
-
-AIMessage::ParameterType lua_enumFromString_AIMessageParameterType(const char* s)
-{
-    if (strcmp(s, luaEnumString_AIMessageParameterType_UNDEFINED) == 0)
-        return AIMessage::UNDEFINED;
-    if (strcmp(s, luaEnumString_AIMessageParameterType_INTEGER) == 0)
-        return AIMessage::INTEGER;
-    if (strcmp(s, luaEnumString_AIMessageParameterType_LONG) == 0)
-        return AIMessage::LONG;
-    if (strcmp(s, luaEnumString_AIMessageParameterType_FLOAT) == 0)
-        return AIMessage::FLOAT;
-    if (strcmp(s, luaEnumString_AIMessageParameterType_DOUBLE) == 0)
-        return AIMessage::DOUBLE;
-    if (strcmp(s, luaEnumString_AIMessageParameterType_BOOLEAN) == 0)
-        return AIMessage::BOOLEAN;
-    if (strcmp(s, luaEnumString_AIMessageParameterType_STRING) == 0)
-        return AIMessage::STRING;
-    return AIMessage::UNDEFINED;
-}
-
-const char* lua_stringFromEnum_AIMessageParameterType(AIMessage::ParameterType e)
-{
-    if (e == AIMessage::UNDEFINED)
-        return luaEnumString_AIMessageParameterType_UNDEFINED;
-    if (e == AIMessage::INTEGER)
-        return luaEnumString_AIMessageParameterType_INTEGER;
-    if (e == AIMessage::LONG)
-        return luaEnumString_AIMessageParameterType_LONG;
-    if (e == AIMessage::FLOAT)
-        return luaEnumString_AIMessageParameterType_FLOAT;
-    if (e == AIMessage::DOUBLE)
-        return luaEnumString_AIMessageParameterType_DOUBLE;
-    if (e == AIMessage::BOOLEAN)
-        return luaEnumString_AIMessageParameterType_BOOLEAN;
-    if (e == AIMessage::STRING)
-        return luaEnumString_AIMessageParameterType_STRING;
-    return enumStringEmpty;
-}
-
-}
-

+ 0 - 15
gameplay/src/lua/lua_AIMessageParameterType.h

@@ -1,15 +0,0 @@
-#ifndef LUA_AIMESSAGEPARAMETERTYPE_H_
-#define LUA_AIMESSAGEPARAMETERTYPE_H_
-
-#include "AIMessage.h"
-
-namespace gameplay
-{
-
-// Lua bindings for enum conversion functions for AIMessage::ParameterType.
-AIMessage::ParameterType lua_enumFromString_AIMessageParameterType(const char* s);
-const char* lua_stringFromEnum_AIMessageParameterType(AIMessage::ParameterType e);
-
-}
-
-#endif

+ 4 - 85
gameplay/src/lua/lua_AIState.cpp

@@ -1,13 +1,14 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AIState.h"
+#include "AIAgent.h"
 #include "AIState.h"
 #include "AIStateMachine.h"
 #include "Base.h"
 #include "Game.h"
+#include "Node.h"
 #include "Ref.h"
-#include "ScriptController.h"
-#include "ScriptTarget.h"
 
 namespace gameplay
 {
@@ -17,11 +18,9 @@ void luaRegister_AIState()
     const luaL_Reg lua_members[] = 
     {
         {"addRef", lua_AIState_addRef},
-        {"addScriptCallback", lua_AIState_addScriptCallback},
         {"getId", lua_AIState_getId},
         {"getRefCount", lua_AIState_getRefCount},
         {"release", lua_AIState_release},
-        {"removeScriptCallback", lua_AIState_removeScriptCallback},
         {"setListener", lua_AIState_setListener},
         {NULL, NULL}
     };
@@ -112,46 +111,6 @@ int lua_AIState_addRef(lua_State* state)
     return 0;
 }
 
-int lua_AIState_addScriptCallback(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
-
-                AIState* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_AIState_addScriptCallback - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_AIState_getId(lua_State* state)
 {
     // Get the number of parameters.
@@ -254,46 +213,6 @@ int lua_AIState_release(lua_State* state)
     return 0;
 }
 
-int lua_AIState_removeScriptCallback(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
-
-                AIState* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_AIState_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_AIState_setListener(lua_State* state)
 {
     // Get the number of parameters.
@@ -351,7 +270,7 @@ int lua_AIState_static_create(lua_State* state)
                 // Get parameter 1 off the stack.
                 const char* param1 = gameplay::ScriptUtil::getString(1, false);
 
-                void* returnPtr = (void*)AIState::create(param1);
+                void* returnPtr = ((void*)AIState::create(param1));
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));

+ 1 - 2
gameplay/src/lua/lua_AIState.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_AISTATE_H_
 #define LUA_AISTATE_H_
 
@@ -7,11 +8,9 @@ namespace gameplay
 // Lua bindings for AIState.
 int lua_AIState__gc(lua_State* state);
 int lua_AIState_addRef(lua_State* state);
-int lua_AIState_addScriptCallback(lua_State* state);
 int lua_AIState_getId(lua_State* state);
 int lua_AIState_getRefCount(lua_State* state);
 int lua_AIState_release(lua_State* state);
-int lua_AIState_removeScriptCallback(lua_State* state);
 int lua_AIState_setListener(lua_State* state);
 int lua_AIState_static_create(lua_State* state);
 

+ 4 - 3
gameplay/src/lua/lua_AIStateListener.cpp

@@ -1,13 +1,14 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AIStateListener.h"
+#include "AIAgent.h"
 #include "AIState.h"
 #include "AIStateMachine.h"
 #include "Base.h"
 #include "Game.h"
+#include "Node.h"
 #include "Ref.h"
-#include "ScriptController.h"
-#include "ScriptTarget.h"
 
 namespace gameplay
 {
@@ -83,7 +84,7 @@ int lua_AIStateListener__init(lua_State* state)
     {
         case 0:
         {
-            void* returnPtr = (void*)new AIState::Listener();
+            void* returnPtr = ((void*)new AIState::Listener());
             if (returnPtr)
             {
                 gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));

+ 1 - 0
gameplay/src/lua/lua_AIStateListener.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_AISTATELISTENER_H_
 #define LUA_AISTATELISTENER_H_
 

+ 6 - 5
gameplay/src/lua/lua_AIStateMachine.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AIStateMachine.h"
@@ -54,7 +55,7 @@ int lua_AIStateMachine_addState(lua_State* state)
                     const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
                     AIStateMachine* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->addState(param1);
+                    void* returnPtr = ((void*)instance->addState(param1));
                     if (returnPtr)
                     {
                         gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -117,7 +118,7 @@ int lua_AIStateMachine_getActiveState(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 AIStateMachine* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getActiveState();
+                void* returnPtr = ((void*)instance->getActiveState());
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -161,7 +162,7 @@ int lua_AIStateMachine_getAgent(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 AIStateMachine* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getAgent();
+                void* returnPtr = ((void*)instance->getAgent());
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -209,7 +210,7 @@ int lua_AIStateMachine_getState(lua_State* state)
                 const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
                 AIStateMachine* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getState(param1);
+                void* returnPtr = ((void*)instance->getState(param1));
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -301,7 +302,7 @@ int lua_AIStateMachine_setState(lua_State* state)
                     const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
                     AIStateMachine* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->setState(param1);
+                    void* returnPtr = ((void*)instance->setState(param1));
                     if (returnPtr)
                     {
                         gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));

+ 1 - 0
gameplay/src/lua/lua_AIStateMachine.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_AISTATEMACHINE_H_
 #define LUA_AISTATEMACHINE_H_
 

+ 2 - 2
gameplay/src/lua/lua_AbsoluteLayout.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AbsoluteLayout.h"
@@ -8,7 +9,6 @@
 #include "Game.h"
 #include "Layout.h"
 #include "Ref.h"
-#include "lua_LayoutType.h"
 
 namespace gameplay
 {
@@ -157,7 +157,7 @@ int lua_AbsoluteLayout_getType(lua_State* state)
                 Layout::Type result = instance->getType();
 
                 // Push the return value onto the stack.
-                lua_pushstring(state, lua_stringFromEnum_LayoutType(result));
+                lua_pushnumber(state, (int)result);
 
                 return 1;
             }

+ 1 - 0
gameplay/src/lua/lua_AbsoluteLayout.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_ABSOLUTELAYOUT_H_
 #define LUA_ABSOLUTELAYOUT_H_
 

+ 5 - 4
gameplay/src/lua/lua_Animation.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_Animation.h"
@@ -141,7 +142,7 @@ int lua_Animation_createClip(lua_State* state)
                 unsigned long param3 = (unsigned long)luaL_checkunsigned(state, 4);
 
                 Animation* instance = getInstance(state);
-                void* returnPtr = (void*)instance->createClip(param1, param2, param3);
+                void* returnPtr = ((void*)instance->createClip(param1, param2, param3));
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -223,7 +224,7 @@ int lua_Animation_getClip(lua_State* state)
                 if ((lua_type(state, 1) == LUA_TUSERDATA))
                 {
                     Animation* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->getClip();
+                    void* returnPtr = ((void*)instance->getClip());
                     if (returnPtr)
                     {
                         gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -256,7 +257,7 @@ int lua_Animation_getClip(lua_State* state)
                     const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
                     Animation* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->getClip(param1);
+                    void* returnPtr = ((void*)instance->getClip(param1));
                     if (returnPtr)
                     {
                         gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -283,7 +284,7 @@ int lua_Animation_getClip(lua_State* state)
                     unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
 
                     Animation* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->getClip(param1);
+                    void* returnPtr = ((void*)instance->getClip(param1));
                     if (returnPtr)
                     {
                         gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));

+ 1 - 0
gameplay/src/lua/lua_Animation.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_ANIMATION_H_
 #define LUA_ANIMATION_H_
 

+ 448 - 180
gameplay/src/lua/lua_AnimationClip.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AnimationClip.h"
@@ -9,7 +10,7 @@
 #include "Quaternion.h"
 #include "Ref.h"
 #include "ScriptController.h"
-#include "lua_AnimationClipListenerEventType.h"
+#include "ScriptTarget.h"
 
 namespace gameplay
 {
@@ -22,6 +23,9 @@ void luaRegister_AnimationClip()
         {"addEndListener", lua_AnimationClip_addEndListener},
         {"addListener", lua_AnimationClip_addListener},
         {"addRef", lua_AnimationClip_addRef},
+        {"addScript", lua_AnimationClip_addScript},
+        {"addScriptCallback", lua_AnimationClip_addScriptCallback},
+        {"clearScripts", lua_AnimationClip_clearScripts},
         {"crossFade", lua_AnimationClip_crossFade},
         {"getActiveDuration", lua_AnimationClip_getActiveDuration},
         {"getAnimation", lua_AnimationClip_getAnimation},
@@ -33,8 +37,11 @@ void luaRegister_AnimationClip()
         {"getLoopBlendTime", lua_AnimationClip_getLoopBlendTime},
         {"getRefCount", lua_AnimationClip_getRefCount},
         {"getRepeatCount", lua_AnimationClip_getRepeatCount},
+        {"getScriptEvent", lua_AnimationClip_getScriptEvent},
         {"getSpeed", lua_AnimationClip_getSpeed},
         {"getStartTime", lua_AnimationClip_getStartTime},
+        {"getTypeName", lua_AnimationClip_getTypeName},
+        {"hasScriptListener", lua_AnimationClip_hasScriptListener},
         {"isPlaying", lua_AnimationClip_isPlaying},
         {"pause", lua_AnimationClip_pause},
         {"play", lua_AnimationClip_play},
@@ -42,6 +49,8 @@ void luaRegister_AnimationClip()
         {"removeBeginListener", lua_AnimationClip_removeBeginListener},
         {"removeEndListener", lua_AnimationClip_removeEndListener},
         {"removeListener", lua_AnimationClip_removeListener},
+        {"removeScript", lua_AnimationClip_removeScript},
+        {"removeScriptCallback", lua_AnimationClip_removeScriptCallback},
         {"setActiveDuration", lua_AnimationClip_setActiveDuration},
         {"setBlendWeight", lua_AnimationClip_setBlendWeight},
         {"setLoopBlendTime", lua_AnimationClip_setLoopBlendTime},
@@ -115,38 +124,23 @@ int lua_AnimationClip_addBeginListener(lua_State* state)
     {
         case 2:
         {
-            do
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
             {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                if (!param1Valid)
                 {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    AnimationClip* instance = getInstance(state);
-                    instance->addBeginListener(param1);
-                    
-                    return 0;
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'AnimationClip::Listener'.");
+                    lua_error(state);
                 }
-            } while (0);
 
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                    AnimationClip* instance = getInstance(state);
-                    instance->addBeginListener(param1);
-                    
-                    return 0;
-                }
-            } while (0);
+                AnimationClip* instance = getInstance(state);
+                instance->addBeginListener(param1);
+                
+                return 0;
+            }
 
             lua_pushstring(state, "lua_AnimationClip_addBeginListener - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
@@ -172,38 +166,23 @@ int lua_AnimationClip_addEndListener(lua_State* state)
     {
         case 2:
         {
-            do
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
             {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                if (!param1Valid)
                 {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    AnimationClip* instance = getInstance(state);
-                    instance->addEndListener(param1);
-                    
-                    return 0;
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'AnimationClip::Listener'.");
+                    lua_error(state);
                 }
-            } while (0);
-
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
-                    AnimationClip* instance = getInstance(state);
-                    instance->addEndListener(param1);
-                    
-                    return 0;
-                }
-            } while (0);
+                AnimationClip* instance = getInstance(state);
+                instance->addEndListener(param1);
+                
+                return 0;
+            }
 
             lua_pushstring(state, "lua_AnimationClip_addEndListener - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
@@ -229,48 +208,155 @@ int lua_AnimationClip_addListener(lua_State* state)
     {
         case 3:
         {
-            do
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER)
             {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
-                    lua_type(state, 3) == LUA_TNUMBER)
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                if (!param1Valid)
                 {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
-                    if (!param1Valid)
-                        break;
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'AnimationClip::Listener'.");
+                    lua_error(state);
+                }
 
-                    // Get parameter 2 off the stack.
-                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+                // Get parameter 2 off the stack.
+                unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
 
-                    AnimationClip* instance = getInstance(state);
-                    instance->addListener(param1, param2);
-                    
-                    return 0;
-                }
-            } while (0);
+                AnimationClip* instance = getInstance(state);
+                instance->addListener(param1, param2);
+                
+                return 0;
+            }
 
-            do
+            lua_pushstring(state, "lua_AnimationClip_addListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_addRef(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                    lua_type(state, 3) == LUA_TNUMBER)
+                AnimationClip* instance = getInstance(state);
+                instance->addRef();
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_AnimationClip_addRef - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_addScript(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                AnimationClip* instance = getInstance(state);
+                void* returnPtr = ((void*)instance->addScript(param1));
+                if (returnPtr)
                 {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Script");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
 
-                    // Get parameter 2 off the stack.
-                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+                return 1;
+            }
 
-                    AnimationClip* instance = getInstance(state);
-                    instance->addListener(param1, param2);
-                    
-                    return 0;
+            lua_pushstring(state, "lua_AnimationClip_addScript - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_addScriptCallback(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
+                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<ScriptTarget::Event> param1 = gameplay::ScriptUtil::getObjectPointer<ScriptTarget::Event>(2, "ScriptTargetEvent", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'ScriptTarget::Event'.");
+                    lua_error(state);
                 }
-            } while (0);
 
-            lua_pushstring(state, "lua_AnimationClip_addListener - Failed to match the given parameters to a valid function signature.");
+                // Get parameter 2 off the stack.
+                const char* param2 = gameplay::ScriptUtil::getString(3, false);
+
+                AnimationClip* instance = getInstance(state);
+                instance->addScriptCallback(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_AnimationClip_addScriptCallback - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             break;
         }
@@ -284,7 +370,7 @@ int lua_AnimationClip_addListener(lua_State* state)
     return 0;
 }
 
-int lua_AnimationClip_addRef(lua_State* state)
+int lua_AnimationClip_clearScripts(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -297,12 +383,12 @@ int lua_AnimationClip_addRef(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 AnimationClip* instance = getInstance(state);
-                instance->addRef();
+                instance->clearScripts();
                 
                 return 0;
             }
 
-            lua_pushstring(state, "lua_AnimationClip_addRef - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_AnimationClip_clearScripts - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             break;
         }
@@ -410,7 +496,7 @@ int lua_AnimationClip_getAnimation(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 AnimationClip* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getAnimation();
+                void* returnPtr = ((void*)instance->getAnimation());
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -721,6 +807,54 @@ int lua_AnimationClip_getRepeatCount(lua_State* state)
     return 0;
 }
 
+int lua_AnimationClip_getScriptEvent(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                AnimationClip* instance = getInstance(state);
+                void* returnPtr = ((void*)instance->getScriptEvent(param1));
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "ScriptTargetEvent");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_AnimationClip_getScriptEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_AnimationClip_getSpeed(lua_State* state)
 {
     // Get the number of parameters.
@@ -791,6 +925,104 @@ int lua_AnimationClip_getStartTime(lua_State* state)
     return 0;
 }
 
+int lua_AnimationClip_getTypeName(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                AnimationClip* instance = getInstance(state);
+                const char* result = instance->getTypeName();
+
+                // Push the return value onto the stack.
+                lua_pushstring(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_AnimationClip_getTypeName - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_hasScriptListener(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasScriptListener(param1);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<ScriptTarget::Event> param1 = gameplay::ScriptUtil::getObjectPointer<ScriptTarget::Event>(2, "ScriptTargetEvent", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasScriptListener(param1);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AnimationClip_hasScriptListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_AnimationClip_isPlaying(lua_State* state)
 {
     // Get the number of parameters.
@@ -932,38 +1164,23 @@ int lua_AnimationClip_removeBeginListener(lua_State* state)
     {
         case 2:
         {
-            do
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
             {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                if (!param1Valid)
                 {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    AnimationClip* instance = getInstance(state);
-                    instance->removeBeginListener(param1);
-                    
-                    return 0;
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'AnimationClip::Listener'.");
+                    lua_error(state);
                 }
-            } while (0);
 
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                    AnimationClip* instance = getInstance(state);
-                    instance->removeBeginListener(param1);
-                    
-                    return 0;
-                }
-            } while (0);
+                AnimationClip* instance = getInstance(state);
+                instance->removeBeginListener(param1);
+                
+                return 0;
+            }
 
             lua_pushstring(state, "lua_AnimationClip_removeBeginListener - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
@@ -989,38 +1206,23 @@ int lua_AnimationClip_removeEndListener(lua_State* state)
     {
         case 2:
         {
-            do
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
             {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                if (!param1Valid)
                 {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    AnimationClip* instance = getInstance(state);
-                    instance->removeEndListener(param1);
-                    
-                    return 0;
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'AnimationClip::Listener'.");
+                    lua_error(state);
                 }
-            } while (0);
-
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
-                    AnimationClip* instance = getInstance(state);
-                    instance->removeEndListener(param1);
-                    
-                    return 0;
-                }
-            } while (0);
+                AnimationClip* instance = getInstance(state);
+                instance->removeEndListener(param1);
+                
+                return 0;
+            }
 
             lua_pushstring(state, "lua_AnimationClip_removeEndListener - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
@@ -1046,48 +1248,114 @@ int lua_AnimationClip_removeListener(lua_State* state)
     {
         case 3:
         {
-            do
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER)
             {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
-                    lua_type(state, 3) == LUA_TNUMBER)
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                if (!param1Valid)
                 {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
-                    if (!param1Valid)
-                        break;
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'AnimationClip::Listener'.");
+                    lua_error(state);
+                }
 
-                    // Get parameter 2 off the stack.
-                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+                // Get parameter 2 off the stack.
+                unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
 
-                    AnimationClip* instance = getInstance(state);
-                    instance->removeListener(param1, param2);
-                    
-                    return 0;
-                }
-            } while (0);
+                AnimationClip* instance = getInstance(state);
+                instance->removeListener(param1, param2);
+                
+                return 0;
+            }
 
-            do
+            lua_pushstring(state, "lua_AnimationClip_removeListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_removeScript(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                    lua_type(state, 3) == LUA_TNUMBER)
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
-                    // Get parameter 2 off the stack.
-                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+                AnimationClip* instance = getInstance(state);
+                bool result = instance->removeScript(param1);
 
-                    AnimationClip* instance = getInstance(state);
-                    instance->removeListener(param1, param2);
-                    
-                    return 0;
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_AnimationClip_removeScript - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_removeScriptCallback(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
+                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<ScriptTarget::Event> param1 = gameplay::ScriptUtil::getObjectPointer<ScriptTarget::Event>(2, "ScriptTargetEvent", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'ScriptTarget::Event'.");
+                    lua_error(state);
                 }
-            } while (0);
 
-            lua_pushstring(state, "lua_AnimationClip_removeListener - Failed to match the given parameters to a valid function signature.");
+                // Get parameter 2 off the stack.
+                const char* param2 = gameplay::ScriptUtil::getString(3, false);
+
+                AnimationClip* instance = getInstance(state);
+                instance->removeScriptCallback(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_AnimationClip_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             break;
         }

+ 9 - 0
gameplay/src/lua/lua_AnimationClip.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_ANIMATIONCLIP_H_
 #define LUA_ANIMATIONCLIP_H_
 
@@ -10,6 +11,9 @@ int lua_AnimationClip_addBeginListener(lua_State* state);
 int lua_AnimationClip_addEndListener(lua_State* state);
 int lua_AnimationClip_addListener(lua_State* state);
 int lua_AnimationClip_addRef(lua_State* state);
+int lua_AnimationClip_addScript(lua_State* state);
+int lua_AnimationClip_addScriptCallback(lua_State* state);
+int lua_AnimationClip_clearScripts(lua_State* state);
 int lua_AnimationClip_crossFade(lua_State* state);
 int lua_AnimationClip_getActiveDuration(lua_State* state);
 int lua_AnimationClip_getAnimation(lua_State* state);
@@ -21,8 +25,11 @@ int lua_AnimationClip_getId(lua_State* state);
 int lua_AnimationClip_getLoopBlendTime(lua_State* state);
 int lua_AnimationClip_getRefCount(lua_State* state);
 int lua_AnimationClip_getRepeatCount(lua_State* state);
+int lua_AnimationClip_getScriptEvent(lua_State* state);
 int lua_AnimationClip_getSpeed(lua_State* state);
 int lua_AnimationClip_getStartTime(lua_State* state);
+int lua_AnimationClip_getTypeName(lua_State* state);
+int lua_AnimationClip_hasScriptListener(lua_State* state);
 int lua_AnimationClip_isPlaying(lua_State* state);
 int lua_AnimationClip_pause(lua_State* state);
 int lua_AnimationClip_play(lua_State* state);
@@ -30,6 +37,8 @@ int lua_AnimationClip_release(lua_State* state);
 int lua_AnimationClip_removeBeginListener(lua_State* state);
 int lua_AnimationClip_removeEndListener(lua_State* state);
 int lua_AnimationClip_removeListener(lua_State* state);
+int lua_AnimationClip_removeScript(lua_State* state);
+int lua_AnimationClip_removeScriptCallback(lua_State* state);
 int lua_AnimationClip_setActiveDuration(lua_State* state);
 int lua_AnimationClip_setBlendWeight(lua_State* state);
 int lua_AnimationClip_setLoopBlendTime(lua_State* state);

+ 4 - 3
gameplay/src/lua/lua_AnimationClipListener.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AnimationClipListener.h"
@@ -9,7 +10,7 @@
 #include "Quaternion.h"
 #include "Ref.h"
 #include "ScriptController.h"
-#include "lua_AnimationClipListenerEventType.h"
+#include "ScriptTarget.h"
 
 namespace gameplay
 {
@@ -85,7 +86,7 @@ int lua_AnimationClipListener_animationEvent(lua_State* state)
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
                 (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                lua_type(state, 3) == LUA_TNUMBER)
             {
                 // Get parameter 1 off the stack.
                 bool param1Valid;
@@ -97,7 +98,7 @@ int lua_AnimationClipListener_animationEvent(lua_State* state)
                 }
 
                 // Get parameter 2 off the stack.
-                AnimationClip::Listener::EventType param2 = (AnimationClip::Listener::EventType)lua_enumFromString_AnimationClipListenerEventType(luaL_checkstring(state, 3));
+                AnimationClip::Listener::EventType param2 = (AnimationClip::Listener::EventType)luaL_checkint(state, 3);
 
                 AnimationClip::Listener* instance = getInstance(state);
                 instance->animationEvent(param1, param2);

+ 1 - 0
gameplay/src/lua/lua_AnimationClipListener.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_ANIMATIONCLIPLISTENER_H_
 #define LUA_ANIMATIONCLIPLISTENER_H_
 

+ 0 - 36
gameplay/src/lua/lua_AnimationClipListenerEventType.cpp

@@ -1,36 +0,0 @@
-#include "Base.h"
-#include "lua_AnimationClipListenerEventType.h"
-
-namespace gameplay
-{
-
-static const char* enumStringEmpty = "";
-
-static const char* luaEnumString_AnimationClipListenerEventType_BEGIN = "BEGIN";
-static const char* luaEnumString_AnimationClipListenerEventType_END = "END";
-static const char* luaEnumString_AnimationClipListenerEventType_TIME = "TIME";
-
-AnimationClip::Listener::EventType lua_enumFromString_AnimationClipListenerEventType(const char* s)
-{
-    if (strcmp(s, luaEnumString_AnimationClipListenerEventType_BEGIN) == 0)
-        return AnimationClip::Listener::BEGIN;
-    if (strcmp(s, luaEnumString_AnimationClipListenerEventType_END) == 0)
-        return AnimationClip::Listener::END;
-    if (strcmp(s, luaEnumString_AnimationClipListenerEventType_TIME) == 0)
-        return AnimationClip::Listener::TIME;
-    return AnimationClip::Listener::BEGIN;
-}
-
-const char* lua_stringFromEnum_AnimationClipListenerEventType(AnimationClip::Listener::EventType e)
-{
-    if (e == AnimationClip::Listener::BEGIN)
-        return luaEnumString_AnimationClipListenerEventType_BEGIN;
-    if (e == AnimationClip::Listener::END)
-        return luaEnumString_AnimationClipListenerEventType_END;
-    if (e == AnimationClip::Listener::TIME)
-        return luaEnumString_AnimationClipListenerEventType_TIME;
-    return enumStringEmpty;
-}
-
-}
-

+ 0 - 15
gameplay/src/lua/lua_AnimationClipListenerEventType.h

@@ -1,15 +0,0 @@
-#ifndef LUA_ANIMATIONCLIPLISTENEREVENTTYPE_H_
-#define LUA_ANIMATIONCLIPLISTENEREVENTTYPE_H_
-
-#include "AnimationClip.h"
-
-namespace gameplay
-{
-
-// Lua bindings for enum conversion functions for AnimationClip::Listener::EventType.
-AnimationClip::Listener::EventType lua_enumFromString_AnimationClipListenerEventType(const char* s);
-const char* lua_stringFromEnum_AnimationClipListenerEventType(AnimationClip::Listener::EventType e);
-
-}
-
-#endif

+ 1 - 0
gameplay/src/lua/lua_AnimationController.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AnimationController.h"

+ 1 - 0
gameplay/src/lua/lua_AnimationController.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_ANIMATIONCONTROLLER_H_
 #define LUA_ANIMATIONCONTROLLER_H_
 

+ 17 - 17
gameplay/src/lua/lua_AnimationTarget.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AnimationTarget.h"
@@ -6,7 +7,6 @@
 #include "Base.h"
 #include "Game.h"
 #include "Node.h"
-#include "lua_CurveInterpolationType.h"
 
 namespace gameplay
 {
@@ -61,7 +61,7 @@ int lua_AnimationTarget_createAnimation(lua_State* state)
                     const char* param2 = gameplay::ScriptUtil::getString(3, false);
 
                     AnimationTarget* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->createAnimation(param1, param2);
+                    void* returnPtr = ((void*)instance->createAnimation(param1, param2));
                     if (returnPtr)
                     {
                         gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -95,7 +95,7 @@ int lua_AnimationTarget_createAnimation(lua_State* state)
                         break;
 
                     AnimationTarget* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->createAnimation(param1, param2);
+                    void* returnPtr = ((void*)instance->createAnimation(param1, param2));
                     if (returnPtr)
                     {
                         gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -127,7 +127,7 @@ int lua_AnimationTarget_createAnimation(lua_State* state)
                     lua_type(state, 4) == LUA_TNUMBER &&
                     (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
                     (lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA) &&
-                    (lua_type(state, 7) == LUA_TSTRING || lua_type(state, 7) == LUA_TNIL))
+                    lua_type(state, 7) == LUA_TNUMBER)
                 {
                     // Get parameter 1 off the stack.
                     const char* param1 = gameplay::ScriptUtil::getString(2, false);
@@ -145,10 +145,10 @@ int lua_AnimationTarget_createAnimation(lua_State* state)
                     gameplay::ScriptUtil::LuaArray<float> param5 = gameplay::ScriptUtil::getFloatPointer(6);
 
                     // Get parameter 6 off the stack.
-                    Curve::InterpolationType param6 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 7));
+                    Curve::InterpolationType param6 = (Curve::InterpolationType)luaL_checkint(state, 7);
 
                     AnimationTarget* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->createAnimation(param1, param2, param3, param4, param5, param6);
+                    void* returnPtr = ((void*)instance->createAnimation(param1, param2, param3, param4, param5, param6));
                     if (returnPtr)
                     {
                         gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -182,7 +182,7 @@ int lua_AnimationTarget_createAnimation(lua_State* state)
                     (lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA) &&
                     (lua_type(state, 7) == LUA_TTABLE || lua_type(state, 7) == LUA_TLIGHTUSERDATA) &&
                     (lua_type(state, 8) == LUA_TTABLE || lua_type(state, 8) == LUA_TLIGHTUSERDATA) &&
-                    (lua_type(state, 9) == LUA_TSTRING || lua_type(state, 9) == LUA_TNIL))
+                    lua_type(state, 9) == LUA_TNUMBER)
                 {
                     // Get parameter 1 off the stack.
                     const char* param1 = gameplay::ScriptUtil::getString(2, false);
@@ -206,10 +206,10 @@ int lua_AnimationTarget_createAnimation(lua_State* state)
                     gameplay::ScriptUtil::LuaArray<float> param7 = gameplay::ScriptUtil::getFloatPointer(8);
 
                     // Get parameter 8 off the stack.
-                    Curve::InterpolationType param8 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 9));
+                    Curve::InterpolationType param8 = (Curve::InterpolationType)luaL_checkint(state, 9);
 
                     AnimationTarget* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->createAnimation(param1, param2, param3, param4, param5, param6, param7, param8);
+                    void* returnPtr = ((void*)instance->createAnimation(param1, param2, param3, param4, param5, param6, param7, param8));
                     if (returnPtr)
                     {
                         gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -256,7 +256,7 @@ int lua_AnimationTarget_createAnimationFromBy(lua_State* state)
                 lua_type(state, 3) == LUA_TNUMBER &&
                 (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
                 (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
-                (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
+                lua_type(state, 6) == LUA_TNUMBER &&
                 lua_type(state, 7) == LUA_TNUMBER)
             {
                 // Get parameter 1 off the stack.
@@ -272,13 +272,13 @@ int lua_AnimationTarget_createAnimationFromBy(lua_State* state)
                 gameplay::ScriptUtil::LuaArray<float> param4 = gameplay::ScriptUtil::getFloatPointer(5);
 
                 // Get parameter 5 off the stack.
-                Curve::InterpolationType param5 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 6));
+                Curve::InterpolationType param5 = (Curve::InterpolationType)luaL_checkint(state, 6);
 
                 // Get parameter 6 off the stack.
                 unsigned long param6 = (unsigned long)luaL_checkunsigned(state, 7);
 
                 AnimationTarget* instance = getInstance(state);
-                void* returnPtr = (void*)instance->createAnimationFromBy(param1, param2, param3, param4, param5, param6);
+                void* returnPtr = ((void*)instance->createAnimationFromBy(param1, param2, param3, param4, param5, param6));
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -324,7 +324,7 @@ int lua_AnimationTarget_createAnimationFromTo(lua_State* state)
                 lua_type(state, 3) == LUA_TNUMBER &&
                 (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
                 (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
-                (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
+                lua_type(state, 6) == LUA_TNUMBER &&
                 lua_type(state, 7) == LUA_TNUMBER)
             {
                 // Get parameter 1 off the stack.
@@ -340,13 +340,13 @@ int lua_AnimationTarget_createAnimationFromTo(lua_State* state)
                 gameplay::ScriptUtil::LuaArray<float> param4 = gameplay::ScriptUtil::getFloatPointer(5);
 
                 // Get parameter 5 off the stack.
-                Curve::InterpolationType param5 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 6));
+                Curve::InterpolationType param5 = (Curve::InterpolationType)luaL_checkint(state, 6);
 
                 // Get parameter 6 off the stack.
                 unsigned long param6 = (unsigned long)luaL_checkunsigned(state, 7);
 
                 AnimationTarget* instance = getInstance(state);
-                void* returnPtr = (void*)instance->createAnimationFromTo(param1, param2, param3, param4, param5, param6);
+                void* returnPtr = ((void*)instance->createAnimationFromTo(param1, param2, param3, param4, param5, param6));
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -440,7 +440,7 @@ int lua_AnimationTarget_getAnimation(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 AnimationTarget* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getAnimation();
+                void* returnPtr = ((void*)instance->getAnimation());
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
@@ -470,7 +470,7 @@ int lua_AnimationTarget_getAnimation(lua_State* state)
                 const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
                 AnimationTarget* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getAnimation(param1);
+                void* returnPtr = ((void*)instance->getAnimation(param1));
                 if (returnPtr)
                 {
                     gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));

+ 1 - 0
gameplay/src/lua/lua_AnimationTarget.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_ANIMATIONTARGET_H_
 #define LUA_ANIMATIONTARGET_H_
 

+ 1 - 0
gameplay/src/lua/lua_AnimationValue.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AnimationValue.h"

+ 1 - 0
gameplay/src/lua/lua_AnimationValue.h

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #ifndef LUA_ANIMATIONVALUE_H_
 #define LUA_ANIMATIONVALUE_H_
 

+ 1 - 0
gameplay/src/lua/lua_AudioBuffer.cpp

@@ -1,3 +1,4 @@
+// Autogenerated by gameplay-luagen
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_AudioBuffer.h"

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini