Scene.pkg 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. $#include "Scene.h"
  2. static const unsigned FIRST_REPLICATED_ID;
  3. static const unsigned LAST_REPLICATED_ID;
  4. static const unsigned FIRST_LOCAL_ID;
  5. static const unsigned LAST_LOCAL_ID;
  6. class Scene : public Node
  7. {
  8. Scene(Context* context);
  9. virtual ~Scene();
  10. tolua_outside bool SceneLoadXML @ LoadXML(File* source);
  11. tolua_outside bool SceneSaveXML @ SaveXML(File* dest) const;
  12. tolua_outside bool SceneLoadXML @ LoadXML(const String fileName);
  13. tolua_outside bool SceneSaveXML @ SaveXML(const String fileName) const;
  14. bool LoadAsync(File* file);
  15. bool LoadAsyncXML(File* file);
  16. void StopAsyncLoading();
  17. void Clear(bool clearReplicated = true, bool clearLocal = true);
  18. void SetUpdateEnabled(bool enable);
  19. void SetTimeScale(float scale);
  20. void SetElapsedTime(float time);
  21. void SetSmoothingConstant(float constant);
  22. void SetSnapThreshold(float threshold);
  23. Node* GetNode(unsigned id) const;
  24. //Component* GetComponent(unsigned id) const;
  25. bool IsUpdateEnabled() const;
  26. bool IsAsyncLoading() const;
  27. float GetAsyncProgress() const;
  28. const String& GetFileName() const;
  29. unsigned GetChecksum() const;
  30. float GetTimeScale() const;
  31. float GetElapsedTime() const;
  32. float GetSmoothingConstant() const;
  33. float GetSnapThreshold() const;
  34. const String& GetVarName(ShortStringHash hash) const;
  35. void Update(float timeStep);
  36. void BeginThreadedUpdate();
  37. void EndThreadedUpdate();
  38. void DelayedMarkedDirty(Component* component);
  39. bool IsThreadedUpdate() const;
  40. unsigned GetFreeNodeID(CreateMode mode);
  41. unsigned GetFreeComponentID(CreateMode mode);
  42. void NodeAdded(Node* node);
  43. void NodeRemoved(Node* node);
  44. void ComponentAdded(Component* component);
  45. void ComponentRemoved(Component* component);
  46. void SetVarNamesAttr(String value);
  47. String GetVarNamesAttr() const;
  48. void PrepareNetworkUpdate();
  49. void CleanupConnection(Connection* connection);
  50. void MarkNetworkUpdate(Node* node);
  51. void MarkNetworkUpdate(Component* component);
  52. void MarkReplicationDirty(Node* node);
  53. tolua_property__is_set bool updateEnabled;
  54. tolua_readonly tolua_property__is_set bool asyncLoading;
  55. tolua_readonly tolua_property__get_set float asyncProgress;
  56. tolua_property__get_set const String fileName;
  57. tolua_readonly tolua_property__get_set unsigned checksum;
  58. tolua_property__get_set float timeScale;
  59. tolua_property__get_set float elapsedTime;
  60. tolua_property__get_set float smoothingConstant;
  61. tolua_property__get_set float snapThreshold;
  62. tolua_readonly tolua_property__is_set bool threadedUpdate;
  63. tolua_property__get_set String varNamesAttr;
  64. };
  65. ${
  66. static bool SceneLoadXML(Scene* scene, File* file)
  67. {
  68. return file ? scene->LoadXML(*file) : false;
  69. }
  70. static bool SceneSaveXML(const Scene* scene, File* file)
  71. {
  72. return file ? scene->SaveXML(*file) : false;
  73. }
  74. static bool SceneLoadXML(Scene* scene, const String& fileName)
  75. {
  76. File file(scene->GetContext(), fileName, FILE_READ);
  77. if (!file.IsOpen())
  78. return false;
  79. return scene->LoadXML(file);
  80. }
  81. static bool SceneSaveXML(const Scene* scene, const String& fileName)
  82. {
  83. File file(scene->GetContext(), fileName, FILE_WRITE);
  84. if (!file.IsOpen())
  85. return false;
  86. return scene->SaveXML(file);
  87. }
  88. $}