netObject_ScriptBinding.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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(NetObject, SimObject)
  23. /*! Use the scopeToClient method to force this object to be SCOPE_ALWAYS on client.
  24. When an object is SCOPE_ALWAYS it is always ghosted. Therefore, if you have an object that should always be ghosted to a client, use this method.
  25. @param client The ID of the client to force this object to be SCOPE_ALWAYS for.
  26. @return No return value.
  27. @sa clearScopeToClient, setScopeAlways
  28. */
  29. ConsoleMethodWithDocs(NetObject,scopeToClient, ConsoleVoid,3,3, ( client ))
  30. {
  31. NetConnection *conn;
  32. if(!Sim::findObject(argv[2], conn))
  33. {
  34. Con::errorf(ConsoleLogEntry::General, "NetObject::scopeToClient: Couldn't find connection %s", argv[2]);
  35. return;
  36. }
  37. conn->objectLocalScopeAlways(object);
  38. }
  39. /*! Use the clearScopeToClient method to undo the effects of a previous call to scopeToClient.
  40. @param client The ID of the client to stop forcing scoping this object for.
  41. @return No return value.
  42. @sa scopeToClient
  43. */
  44. ConsoleMethodWithDocs(NetObject,clearScopeToClient, ConsoleVoid,3,3, ( client ))
  45. {
  46. NetConnection *conn;
  47. if(!Sim::findObject(argv[2], conn))
  48. {
  49. Con::errorf(ConsoleLogEntry::General, "NetObject::clearScopeToClient: Couldn't find connection %s", argv[2]);
  50. return;
  51. }
  52. conn->objectLocalClearAlways(object);
  53. }
  54. /*! Use the setScopeAlways method to force an object to be SCOPE_ALWAYS for all clients.
  55. When an object is SCOPE_ALWAYS it is always ghosted. Therefore, if you have an object that should always be ghosted to all clients, use this method.
  56. @return No return value.
  57. @sa scopeToClient
  58. */
  59. ConsoleMethodWithDocs(NetObject,setScopeAlways, ConsoleVoid,2,2, ())
  60. {
  61. object->setScopeAlways();
  62. }
  63. /*! @return Returns the ghost ID of the object
  64. */
  65. ConsoleMethodWithDocs( NetObject, getGhostID, ConsoleInt, 2, 2, ())
  66. {
  67. return object->getNetIndex();
  68. }
  69. ConsoleMethodGroupEndWithDocs(NetObject)