AmbientForceController_ScriptBinding.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. ConsoleMethodGroupBeginWithDocs(AmbientForceController, GroupedSceneController)
  23. /*! Sets the ambient force to use.
  24. @param x The component of the ambient force along the horizontal (world) axis.
  25. @param y The component of the ambient force along the vertical (world) axis.
  26. @return No return value.
  27. */
  28. ConsoleMethodWithDocs(AmbientForceController, setForce, ConsoleVoid, 3, 4, (float x, float y))
  29. {
  30. // The new force.
  31. b2Vec2 force;
  32. // Elements in the first argument.
  33. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  34. // ("x y")
  35. if ((elementCount == 2) && (argc == 3))
  36. force = Utility::mGetStringElementVector(argv[2]);
  37. // (x, y)
  38. else if ((elementCount == 1) && (argc == 4))
  39. force.Set(dAtof(argv[2]), dAtof(argv[3]));
  40. // Invalid
  41. else
  42. {
  43. Con::warnf("AmbientForceController::setForce() - Invalid number of parameters!");
  44. return;
  45. }
  46. object->setForce( force );
  47. }
  48. //-----------------------------------------------------------------------------
  49. /*! Gets the ambient force being used.
  50. @return The ambient force being used.
  51. */
  52. ConsoleMethodWithDocs(AmbientForceController, getForce, ConsoleString, 2, 2, ())
  53. {
  54. return object->getForce().scriptThis();
  55. }
  56. ConsoleMethodGroupEndWithDocs(AmbientForceController)