Scene.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Scene.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho
  18. {
  19. /// <summary>
  20. /// Root scene node, represents the whole scene.
  21. /// </summary>
  22. public unsafe partial class Scene : Node
  23. {
  24. unsafe partial void OnSceneCreated ();
  25. [Preserve]
  26. public Scene (IntPtr handle) : base (handle)
  27. {
  28. OnSceneCreated ();
  29. }
  30. [Preserve]
  31. protected Scene (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnSceneCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Scene_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Scene_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Scene_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Scene_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Scene_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Scene));
  54. return new StringHash (Scene_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Scene_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Scene));
  61. return Marshal.PtrToStringAnsi (Scene_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Scene () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Scene_Scene (IntPtr context);
  69. [Preserve]
  70. public Scene (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Scene));
  73. handle = Scene_Scene ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnSceneCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void Scene_RegisterObject (IntPtr context);
  79. /// <summary>
  80. /// Register object factory. Node must be registered first.
  81. /// </summary>
  82. public new static void RegisterObject (Context context)
  83. {
  84. Runtime.Validate (typeof(Scene));
  85. Scene_RegisterObject ((object)context == null ? IntPtr.Zero : context.Handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern bool Scene_Load_File (IntPtr handle, IntPtr source, bool setInstanceDefault);
  89. /// <summary>
  90. /// Load from binary data. Removes all existing child nodes and components first. Return true if successful.
  91. /// </summary>
  92. public override bool Load (File source, bool setInstanceDefault = false)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. return Scene_Load_File (handle, (object)source == null ? IntPtr.Zero : source.Handle, setInstanceDefault);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern bool Scene_Load_MemoryBuffer (IntPtr handle, IntPtr source, bool setInstanceDefault);
  99. /// <summary>
  100. /// Load from binary data. Removes all existing child nodes and components first. Return true if successful.
  101. /// </summary>
  102. public override bool Load (MemoryBuffer source, bool setInstanceDefault = false)
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. return Scene_Load_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle, setInstanceDefault);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern bool Scene_Save_File (IntPtr handle, IntPtr dest);
  109. /// <summary>
  110. /// Save to binary data. Return true if successful.
  111. /// </summary>
  112. public override bool Save (File dest)
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. return Scene_Save_File (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern bool Scene_Save_MemoryBuffer (IntPtr handle, IntPtr dest);
  119. /// <summary>
  120. /// Save to binary data. Return true if successful.
  121. /// </summary>
  122. public override bool Save (MemoryBuffer dest)
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. return Scene_Save_MemoryBuffer (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern bool Scene_LoadXML (IntPtr handle, IntPtr source, bool setInstanceDefault);
  129. /// <summary>
  130. /// Load from XML data. Removes all existing child nodes and components first. Return true if successful.
  131. /// </summary>
  132. public override bool LoadXml (XmlElement source, bool setInstanceDefault = false)
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. return Scene_LoadXML (handle, (object)source == null ? IntPtr.Zero : source.Handle, setInstanceDefault);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern void Scene_MarkNetworkUpdate (IntPtr handle);
  139. /// <summary>
  140. /// Mark for attribute check on the next network update.
  141. /// </summary>
  142. public override void MarkNetworkUpdate ()
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. Scene_MarkNetworkUpdate (handle);
  146. }
  147. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  148. internal static extern void Scene_AddReplicationState (IntPtr handle, NodeReplicationState* state);
  149. /// <summary>
  150. /// Add a replication state that is tracking this scene.
  151. /// </summary>
  152. public override void AddReplicationState (NodeReplicationState* state)
  153. {
  154. Runtime.ValidateRefCounted (this);
  155. Scene_AddReplicationState (handle, state);
  156. }
  157. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  158. internal static extern bool Scene_LoadXML0_File (IntPtr handle, IntPtr source);
  159. /// <summary>
  160. /// Load from an XML file. Return true if successful.
  161. /// </summary>
  162. public bool LoadXml (File source)
  163. {
  164. Runtime.ValidateRefCounted (this);
  165. return Scene_LoadXML0_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  166. }
  167. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  168. internal static extern bool Scene_LoadXML0_MemoryBuffer (IntPtr handle, IntPtr source);
  169. /// <summary>
  170. /// Load from an XML file. Return true if successful.
  171. /// </summary>
  172. public bool LoadXml (MemoryBuffer source)
  173. {
  174. Runtime.ValidateRefCounted (this);
  175. return Scene_LoadXML0_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  176. }
  177. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  178. internal static extern bool Scene_LoadJSON_File (IntPtr handle, IntPtr source);
  179. /// <summary>
  180. /// Load from a JSON file. Return true if successful.
  181. /// </summary>
  182. public bool LoadJson (File source)
  183. {
  184. Runtime.ValidateRefCounted (this);
  185. return Scene_LoadJSON_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  186. }
  187. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  188. internal static extern bool Scene_LoadJSON_MemoryBuffer (IntPtr handle, IntPtr source);
  189. /// <summary>
  190. /// Load from a JSON file. Return true if successful.
  191. /// </summary>
  192. public bool LoadJson (MemoryBuffer source)
  193. {
  194. Runtime.ValidateRefCounted (this);
  195. return Scene_LoadJSON_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  196. }
  197. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  198. internal static extern bool Scene_SaveXML_File (IntPtr handle, IntPtr dest, string indentation);
  199. /// <summary>
  200. /// Save to an XML file. Return true if successful.
  201. /// </summary>
  202. public override bool SaveXml (File dest, string indentation = "\t")
  203. {
  204. Runtime.ValidateRefCounted (this);
  205. return Scene_SaveXML_File (handle, (object)dest == null ? IntPtr.Zero : dest.Handle, indentation);
  206. }
  207. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  208. internal static extern bool Scene_SaveXML_MemoryBuffer (IntPtr handle, IntPtr dest, string indentation);
  209. /// <summary>
  210. /// Save to an XML file. Return true if successful.
  211. /// </summary>
  212. public override bool SaveXml (MemoryBuffer dest, string indentation = "\t")
  213. {
  214. Runtime.ValidateRefCounted (this);
  215. return Scene_SaveXML_MemoryBuffer (handle, (object)dest == null ? IntPtr.Zero : dest.Handle, indentation);
  216. }
  217. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  218. internal static extern bool Scene_SaveJSON_File (IntPtr handle, IntPtr dest, string indentation);
  219. /// <summary>
  220. /// Save to a JSON file. Return true if successful.
  221. /// </summary>
  222. public override bool SaveJson (File dest, string indentation = "\t")
  223. {
  224. Runtime.ValidateRefCounted (this);
  225. return Scene_SaveJSON_File (handle, (object)dest == null ? IntPtr.Zero : dest.Handle, indentation);
  226. }
  227. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  228. internal static extern bool Scene_SaveJSON_MemoryBuffer (IntPtr handle, IntPtr dest, string indentation);
  229. /// <summary>
  230. /// Save to a JSON file. Return true if successful.
  231. /// </summary>
  232. public override bool SaveJson (MemoryBuffer dest, string indentation = "\t")
  233. {
  234. Runtime.ValidateRefCounted (this);
  235. return Scene_SaveJSON_MemoryBuffer (handle, (object)dest == null ? IntPtr.Zero : dest.Handle, indentation);
  236. }
  237. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  238. internal static extern bool Scene_LoadAsync (IntPtr handle, IntPtr file, LoadMode mode);
  239. /// <summary>
  240. /// Load from a binary file asynchronously. Return true if started successfully. The LOAD_RESOURCES_ONLY mode can also be used to preload resources from object prefab files.
  241. /// </summary>
  242. public bool LoadAsync (File file, LoadMode mode = LoadMode.SceneAndResources)
  243. {
  244. Runtime.ValidateRefCounted (this);
  245. return Scene_LoadAsync (handle, (object)file == null ? IntPtr.Zero : file.Handle, mode);
  246. }
  247. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  248. internal static extern bool Scene_LoadAsyncXML (IntPtr handle, IntPtr file, LoadMode mode);
  249. /// <summary>
  250. /// Load from an XML file asynchronously. Return true if started successfully. The LOAD_RESOURCES_ONLY mode can also be used to preload resources from object prefab files.
  251. /// </summary>
  252. public bool LoadAsyncXml (File file, LoadMode mode = LoadMode.SceneAndResources)
  253. {
  254. Runtime.ValidateRefCounted (this);
  255. return Scene_LoadAsyncXML (handle, (object)file == null ? IntPtr.Zero : file.Handle, mode);
  256. }
  257. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  258. internal static extern bool Scene_LoadAsyncJSON (IntPtr handle, IntPtr file, LoadMode mode);
  259. /// <summary>
  260. /// Load from a JSON file asynchronously. Return true if started successfully. The LOAD_RESOURCES_ONLY mode can also be used to preload resources from object prefab files.
  261. /// </summary>
  262. public bool LoadAsyncJson (File file, LoadMode mode = LoadMode.SceneAndResources)
  263. {
  264. Runtime.ValidateRefCounted (this);
  265. return Scene_LoadAsyncJSON (handle, (object)file == null ? IntPtr.Zero : file.Handle, mode);
  266. }
  267. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  268. internal static extern void Scene_StopAsyncLoading (IntPtr handle);
  269. /// <summary>
  270. /// Stop asynchronous loading.
  271. /// </summary>
  272. public void StopAsyncLoading ()
  273. {
  274. Runtime.ValidateRefCounted (this);
  275. Scene_StopAsyncLoading (handle);
  276. }
  277. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  278. internal static extern IntPtr Scene_Instantiate_File (IntPtr handle, IntPtr source, ref Urho.Vector3 position, ref Urho.Quaternion rotation, CreateMode mode);
  279. /// <summary>
  280. /// Instantiate scene content from binary data. Return root node if successful.
  281. /// </summary>
  282. public Node Instantiate (File source, Urho.Vector3 position, Urho.Quaternion rotation, CreateMode mode = CreateMode.Replicated)
  283. {
  284. Runtime.ValidateRefCounted (this);
  285. return Runtime.LookupObject<Node> (Scene_Instantiate_File (handle, (object)source == null ? IntPtr.Zero : source.Handle, ref position, ref rotation, mode));
  286. }
  287. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  288. internal static extern IntPtr Scene_Instantiate_MemoryBuffer (IntPtr handle, IntPtr source, ref Urho.Vector3 position, ref Urho.Quaternion rotation, CreateMode mode);
  289. /// <summary>
  290. /// Instantiate scene content from binary data. Return root node if successful.
  291. /// </summary>
  292. public Node Instantiate (MemoryBuffer source, Urho.Vector3 position, Urho.Quaternion rotation, CreateMode mode = CreateMode.Replicated)
  293. {
  294. Runtime.ValidateRefCounted (this);
  295. return Runtime.LookupObject<Node> (Scene_Instantiate_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle, ref position, ref rotation, mode));
  296. }
  297. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  298. internal static extern IntPtr Scene_InstantiateXML (IntPtr handle, IntPtr source, ref Urho.Vector3 position, ref Urho.Quaternion rotation, CreateMode mode);
  299. /// <summary>
  300. /// Instantiate scene content from XML data. Return root node if successful.
  301. /// </summary>
  302. public Node InstantiateXml (XmlElement source, Urho.Vector3 position, Urho.Quaternion rotation, CreateMode mode = CreateMode.Replicated)
  303. {
  304. Runtime.ValidateRefCounted (this);
  305. return Runtime.LookupObject<Node> (Scene_InstantiateXML (handle, (object)source == null ? IntPtr.Zero : source.Handle, ref position, ref rotation, mode));
  306. }
  307. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  308. internal static extern IntPtr Scene_InstantiateXML1_File (IntPtr handle, IntPtr source, ref Urho.Vector3 position, ref Urho.Quaternion rotation, CreateMode mode);
  309. /// <summary>
  310. /// Instantiate scene content from XML data. Return root node if successful.
  311. /// </summary>
  312. public Node InstantiateXml (File source, Urho.Vector3 position, Urho.Quaternion rotation, CreateMode mode = CreateMode.Replicated)
  313. {
  314. Runtime.ValidateRefCounted (this);
  315. return Runtime.LookupObject<Node> (Scene_InstantiateXML1_File (handle, (object)source == null ? IntPtr.Zero : source.Handle, ref position, ref rotation, mode));
  316. }
  317. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  318. internal static extern IntPtr Scene_InstantiateXML1_MemoryBuffer (IntPtr handle, IntPtr source, ref Urho.Vector3 position, ref Urho.Quaternion rotation, CreateMode mode);
  319. /// <summary>
  320. /// Instantiate scene content from XML data. Return root node if successful.
  321. /// </summary>
  322. public Node InstantiateXml (MemoryBuffer source, Urho.Vector3 position, Urho.Quaternion rotation, CreateMode mode = CreateMode.Replicated)
  323. {
  324. Runtime.ValidateRefCounted (this);
  325. return Runtime.LookupObject<Node> (Scene_InstantiateXML1_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle, ref position, ref rotation, mode));
  326. }
  327. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  328. internal static extern IntPtr Scene_InstantiateJSON_File (IntPtr handle, IntPtr source, ref Urho.Vector3 position, ref Urho.Quaternion rotation, CreateMode mode);
  329. /// <summary>
  330. /// Instantiate scene content from JSON data. Return root node if successful.
  331. /// </summary>
  332. public Node InstantiateJson (File source, Urho.Vector3 position, Urho.Quaternion rotation, CreateMode mode = CreateMode.Replicated)
  333. {
  334. Runtime.ValidateRefCounted (this);
  335. return Runtime.LookupObject<Node> (Scene_InstantiateJSON_File (handle, (object)source == null ? IntPtr.Zero : source.Handle, ref position, ref rotation, mode));
  336. }
  337. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  338. internal static extern IntPtr Scene_InstantiateJSON_MemoryBuffer (IntPtr handle, IntPtr source, ref Urho.Vector3 position, ref Urho.Quaternion rotation, CreateMode mode);
  339. /// <summary>
  340. /// Instantiate scene content from JSON data. Return root node if successful.
  341. /// </summary>
  342. public Node InstantiateJson (MemoryBuffer source, Urho.Vector3 position, Urho.Quaternion rotation, CreateMode mode = CreateMode.Replicated)
  343. {
  344. Runtime.ValidateRefCounted (this);
  345. return Runtime.LookupObject<Node> (Scene_InstantiateJSON_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle, ref position, ref rotation, mode));
  346. }
  347. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  348. internal static extern void Scene_Clear (IntPtr handle, bool clearReplicated, bool clearLocal);
  349. /// <summary>
  350. /// Clear scene completely of either replicated, local or all nodes and components.
  351. /// </summary>
  352. public void Clear (bool clearReplicated = true, bool clearLocal = true)
  353. {
  354. Runtime.ValidateRefCounted (this);
  355. Scene_Clear (handle, clearReplicated, clearLocal);
  356. }
  357. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  358. internal static extern void Scene_SetUpdateEnabled (IntPtr handle, bool enable);
  359. /// <summary>
  360. /// Enable or disable scene update.
  361. /// </summary>
  362. private void SetUpdateEnabled (bool enable)
  363. {
  364. Runtime.ValidateRefCounted (this);
  365. Scene_SetUpdateEnabled (handle, enable);
  366. }
  367. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  368. internal static extern void Scene_SetTimeScale (IntPtr handle, float scale);
  369. /// <summary>
  370. /// Set update time scale. 1.0 = real time (default.)
  371. /// </summary>
  372. private void SetTimeScale (float scale)
  373. {
  374. Runtime.ValidateRefCounted (this);
  375. Scene_SetTimeScale (handle, scale);
  376. }
  377. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  378. internal static extern void Scene_SetElapsedTime (IntPtr handle, float time);
  379. /// <summary>
  380. /// Set elapsed time in seconds. This can be used to prevent inaccuracy in the timer if the scene runs for a long time.
  381. /// </summary>
  382. private void SetElapsedTime (float time)
  383. {
  384. Runtime.ValidateRefCounted (this);
  385. Scene_SetElapsedTime (handle, time);
  386. }
  387. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  388. internal static extern void Scene_SetSmoothingConstant (IntPtr handle, float constant);
  389. /// <summary>
  390. /// Set network client motion smoothing constant.
  391. /// </summary>
  392. private void SetSmoothingConstant (float constant)
  393. {
  394. Runtime.ValidateRefCounted (this);
  395. Scene_SetSmoothingConstant (handle, constant);
  396. }
  397. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  398. internal static extern void Scene_SetSnapThreshold (IntPtr handle, float threshold);
  399. /// <summary>
  400. /// Set network client motion smoothing snap threshold.
  401. /// </summary>
  402. private void SetSnapThreshold (float threshold)
  403. {
  404. Runtime.ValidateRefCounted (this);
  405. Scene_SetSnapThreshold (handle, threshold);
  406. }
  407. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  408. internal static extern void Scene_SetAsyncLoadingMs (IntPtr handle, int ms);
  409. /// <summary>
  410. /// Set maximum milliseconds per frame to spend on async scene loading.
  411. /// </summary>
  412. private void SetAsyncLoadingMs (int ms)
  413. {
  414. Runtime.ValidateRefCounted (this);
  415. Scene_SetAsyncLoadingMs (handle, ms);
  416. }
  417. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  418. internal static extern void Scene_AddRequiredPackageFile (IntPtr handle, IntPtr package);
  419. /// <summary>
  420. /// Add a required package file for networking. To be called on the server.
  421. /// </summary>
  422. public void AddRequiredPackageFile (PackageFile package)
  423. {
  424. Runtime.ValidateRefCounted (this);
  425. Scene_AddRequiredPackageFile (handle, (object)package == null ? IntPtr.Zero : package.Handle);
  426. }
  427. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  428. internal static extern void Scene_ClearRequiredPackageFiles (IntPtr handle);
  429. /// <summary>
  430. /// Clear required package files.
  431. /// </summary>
  432. public void ClearRequiredPackageFiles ()
  433. {
  434. Runtime.ValidateRefCounted (this);
  435. Scene_ClearRequiredPackageFiles (handle);
  436. }
  437. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  438. internal static extern void Scene_RegisterVar (IntPtr handle, string name);
  439. /// <summary>
  440. /// Register a node user variable hash reverse mapping (for editing.)
  441. /// </summary>
  442. public void RegisterVar (string name)
  443. {
  444. Runtime.ValidateRefCounted (this);
  445. Scene_RegisterVar (handle, name);
  446. }
  447. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  448. internal static extern void Scene_UnregisterVar (IntPtr handle, string name);
  449. /// <summary>
  450. /// Unregister a node user variable hash reverse mapping.
  451. /// </summary>
  452. public void UnregisterVar (string name)
  453. {
  454. Runtime.ValidateRefCounted (this);
  455. Scene_UnregisterVar (handle, name);
  456. }
  457. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  458. internal static extern void Scene_UnregisterAllVars (IntPtr handle);
  459. /// <summary>
  460. /// Clear all registered node user variable hash reverse mappings.
  461. /// </summary>
  462. public void UnregisterAllVars ()
  463. {
  464. Runtime.ValidateRefCounted (this);
  465. Scene_UnregisterAllVars (handle);
  466. }
  467. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  468. internal static extern IntPtr Scene_GetNode (IntPtr handle, uint id);
  469. /// <summary>
  470. /// Return node from the whole scene by ID, or null if not found.
  471. /// </summary>
  472. public Node GetNode (uint id)
  473. {
  474. Runtime.ValidateRefCounted (this);
  475. return Runtime.LookupObject<Node> (Scene_GetNode (handle, id));
  476. }
  477. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  478. internal static extern IntPtr Scene_GetComponent (IntPtr handle, uint id);
  479. /// <summary>
  480. /// Return component from the whole scene by ID, or null if not found.
  481. /// </summary>
  482. public Component GetComponent (uint id)
  483. {
  484. Runtime.ValidateRefCounted (this);
  485. return Runtime.LookupObject<Component> (Scene_GetComponent (handle, id));
  486. }
  487. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  488. internal static extern bool Scene_IsUpdateEnabled (IntPtr handle);
  489. /// <summary>
  490. /// Return whether updates are enabled.
  491. /// </summary>
  492. private bool IsUpdateEnabled ()
  493. {
  494. Runtime.ValidateRefCounted (this);
  495. return Scene_IsUpdateEnabled (handle);
  496. }
  497. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  498. internal static extern bool Scene_IsAsyncLoading (IntPtr handle);
  499. /// <summary>
  500. /// Return whether an asynchronous loading operation is in progress.
  501. /// </summary>
  502. private bool IsAsyncLoading ()
  503. {
  504. Runtime.ValidateRefCounted (this);
  505. return Scene_IsAsyncLoading (handle);
  506. }
  507. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  508. internal static extern float Scene_GetAsyncProgress (IntPtr handle);
  509. /// <summary>
  510. /// Return asynchronous loading progress between 0.0 and 1.0, or 1.0 if not in progress.
  511. /// </summary>
  512. private float GetAsyncProgress ()
  513. {
  514. Runtime.ValidateRefCounted (this);
  515. return Scene_GetAsyncProgress (handle);
  516. }
  517. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  518. internal static extern LoadMode Scene_GetAsyncLoadMode (IntPtr handle);
  519. /// <summary>
  520. /// Return the load mode of the current asynchronous loading operation.
  521. /// </summary>
  522. private LoadMode GetAsyncLoadMode ()
  523. {
  524. Runtime.ValidateRefCounted (this);
  525. return Scene_GetAsyncLoadMode (handle);
  526. }
  527. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  528. internal static extern IntPtr Scene_GetFileName (IntPtr handle);
  529. /// <summary>
  530. /// Return source file name.
  531. /// </summary>
  532. private string GetFileName ()
  533. {
  534. Runtime.ValidateRefCounted (this);
  535. return Marshal.PtrToStringAnsi (Scene_GetFileName (handle));
  536. }
  537. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  538. internal static extern uint Scene_GetChecksum (IntPtr handle);
  539. /// <summary>
  540. /// Return source file checksum.
  541. /// </summary>
  542. private uint GetChecksum ()
  543. {
  544. Runtime.ValidateRefCounted (this);
  545. return Scene_GetChecksum (handle);
  546. }
  547. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  548. internal static extern float Scene_GetTimeScale (IntPtr handle);
  549. /// <summary>
  550. /// Return update time scale.
  551. /// </summary>
  552. private float GetTimeScale ()
  553. {
  554. Runtime.ValidateRefCounted (this);
  555. return Scene_GetTimeScale (handle);
  556. }
  557. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  558. internal static extern float Scene_GetElapsedTime (IntPtr handle);
  559. /// <summary>
  560. /// Return elapsed time in seconds.
  561. /// </summary>
  562. private float GetElapsedTime ()
  563. {
  564. Runtime.ValidateRefCounted (this);
  565. return Scene_GetElapsedTime (handle);
  566. }
  567. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  568. internal static extern float Scene_GetSmoothingConstant (IntPtr handle);
  569. /// <summary>
  570. /// Return motion smoothing constant.
  571. /// </summary>
  572. private float GetSmoothingConstant ()
  573. {
  574. Runtime.ValidateRefCounted (this);
  575. return Scene_GetSmoothingConstant (handle);
  576. }
  577. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  578. internal static extern float Scene_GetSnapThreshold (IntPtr handle);
  579. /// <summary>
  580. /// Return motion smoothing snap threshold.
  581. /// </summary>
  582. private float GetSnapThreshold ()
  583. {
  584. Runtime.ValidateRefCounted (this);
  585. return Scene_GetSnapThreshold (handle);
  586. }
  587. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  588. internal static extern int Scene_GetAsyncLoadingMs (IntPtr handle);
  589. /// <summary>
  590. /// Return maximum milliseconds per frame to spend on async loading.
  591. /// </summary>
  592. private int GetAsyncLoadingMs ()
  593. {
  594. Runtime.ValidateRefCounted (this);
  595. return Scene_GetAsyncLoadingMs (handle);
  596. }
  597. private IReadOnlyList<PackageFile> _GetRequiredPackageFiles_cache;
  598. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  599. internal static extern IntPtr Scene_GetRequiredPackageFiles (IntPtr handle);
  600. /// <summary>
  601. /// Return required package files.
  602. /// </summary>
  603. private IReadOnlyList<PackageFile> GetRequiredPackageFiles ()
  604. {
  605. Runtime.ValidateRefCounted (this);
  606. return _GetRequiredPackageFiles_cache != null ? _GetRequiredPackageFiles_cache : _GetRequiredPackageFiles_cache = Runtime.CreateVectorSharedPtrProxy<PackageFile> (Scene_GetRequiredPackageFiles (handle));
  607. }
  608. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  609. internal static extern IntPtr Scene_GetVarName (IntPtr handle, int hash);
  610. /// <summary>
  611. /// Return a node user variable name, or empty if not registered.
  612. /// </summary>
  613. public string GetVarName (StringHash hash)
  614. {
  615. Runtime.ValidateRefCounted (this);
  616. return Marshal.PtrToStringAnsi (Scene_GetVarName (handle, hash.Code));
  617. }
  618. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  619. internal static extern void Scene_Update (IntPtr handle, float timeStep);
  620. /// <summary>
  621. /// Update scene. Called by HandleUpdate.
  622. /// </summary>
  623. public void Update (float timeStep)
  624. {
  625. Runtime.ValidateRefCounted (this);
  626. Scene_Update (handle, timeStep);
  627. }
  628. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  629. internal static extern void Scene_BeginThreadedUpdate (IntPtr handle);
  630. /// <summary>
  631. /// Begin a threaded update. During threaded update components can choose to delay dirty processing.
  632. /// </summary>
  633. public void BeginThreadedUpdate ()
  634. {
  635. Runtime.ValidateRefCounted (this);
  636. Scene_BeginThreadedUpdate (handle);
  637. }
  638. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  639. internal static extern void Scene_EndThreadedUpdate (IntPtr handle);
  640. /// <summary>
  641. /// End a threaded update. Notify components that marked themselves for delayed dirty processing.
  642. /// </summary>
  643. public void EndThreadedUpdate ()
  644. {
  645. Runtime.ValidateRefCounted (this);
  646. Scene_EndThreadedUpdate (handle);
  647. }
  648. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  649. internal static extern void Scene_DelayedMarkedDirty (IntPtr handle, IntPtr component);
  650. /// <summary>
  651. /// Add a component to the delayed dirty notify queue. Is thread-safe.
  652. /// </summary>
  653. public void DelayedMarkedDirty (Component component)
  654. {
  655. Runtime.ValidateRefCounted (this);
  656. Scene_DelayedMarkedDirty (handle, (object)component == null ? IntPtr.Zero : component.Handle);
  657. }
  658. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  659. internal static extern bool Scene_IsThreadedUpdate (IntPtr handle);
  660. /// <summary>
  661. /// Return threaded update flag.
  662. /// </summary>
  663. private bool IsThreadedUpdate ()
  664. {
  665. Runtime.ValidateRefCounted (this);
  666. return Scene_IsThreadedUpdate (handle);
  667. }
  668. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  669. internal static extern uint Scene_GetFreeNodeID (IntPtr handle, CreateMode mode);
  670. /// <summary>
  671. /// Get free node ID, either non-local or local.
  672. /// </summary>
  673. public uint GetFreeNodeID (CreateMode mode)
  674. {
  675. Runtime.ValidateRefCounted (this);
  676. return Scene_GetFreeNodeID (handle, mode);
  677. }
  678. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  679. internal static extern uint Scene_GetFreeComponentID (IntPtr handle, CreateMode mode);
  680. /// <summary>
  681. /// Get free component ID, either non-local or local.
  682. /// </summary>
  683. public uint GetFreeComponentID (CreateMode mode)
  684. {
  685. Runtime.ValidateRefCounted (this);
  686. return Scene_GetFreeComponentID (handle, mode);
  687. }
  688. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  689. internal static extern void Scene_NodeTagAdded (IntPtr handle, IntPtr node, string tag);
  690. /// <summary>
  691. /// Cache node by tag if tag not zero, no checking if already added. Used internaly in Node::AddTag.
  692. /// </summary>
  693. public void NodeTagAdded (Node node, string tag)
  694. {
  695. Runtime.ValidateRefCounted (this);
  696. Scene_NodeTagAdded (handle, (object)node == null ? IntPtr.Zero : node.Handle, tag);
  697. }
  698. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  699. internal static extern void Scene_NodeTagRemoved (IntPtr handle, IntPtr node, string tag);
  700. /// <summary>
  701. /// Cache node by tag if tag not zero.
  702. /// </summary>
  703. public void NodeTagRemoved (Node node, string tag)
  704. {
  705. Runtime.ValidateRefCounted (this);
  706. Scene_NodeTagRemoved (handle, (object)node == null ? IntPtr.Zero : node.Handle, tag);
  707. }
  708. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  709. internal static extern void Scene_SetVarNamesAttr (IntPtr handle, string value);
  710. /// <summary>
  711. /// Set node user variable reverse mappings.
  712. /// </summary>
  713. public void SetVarNamesAttr (string value)
  714. {
  715. Runtime.ValidateRefCounted (this);
  716. Scene_SetVarNamesAttr (handle, value);
  717. }
  718. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  719. internal static extern IntPtr Scene_GetVarNamesAttr (IntPtr handle);
  720. /// <summary>
  721. /// Return node user variable reverse mappings.
  722. /// </summary>
  723. private string GetVarNamesAttr ()
  724. {
  725. Runtime.ValidateRefCounted (this);
  726. return Marshal.PtrToStringAnsi (Scene_GetVarNamesAttr (handle));
  727. }
  728. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  729. internal static extern void Scene_PrepareNetworkUpdate (IntPtr handle);
  730. /// <summary>
  731. /// Prepare network update by comparing attributes and marking replication states dirty as necessary.
  732. /// </summary>
  733. public override void PrepareNetworkUpdate ()
  734. {
  735. Runtime.ValidateRefCounted (this);
  736. Scene_PrepareNetworkUpdate (handle);
  737. }
  738. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  739. internal static extern void Scene_CleanupConnection (IntPtr handle, IntPtr connection);
  740. /// <summary>
  741. /// Clean up all references to a network connection that is about to be removed.
  742. /// </summary>
  743. public override void CleanupConnection (Connection connection)
  744. {
  745. Runtime.ValidateRefCounted (this);
  746. Scene_CleanupConnection (handle, (object)connection == null ? IntPtr.Zero : connection.Handle);
  747. }
  748. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  749. internal static extern void Scene_MarkNetworkUpdate2 (IntPtr handle, IntPtr node);
  750. /// <summary>
  751. /// Mark a node for attribute check on the next network update.
  752. /// </summary>
  753. public void MarkNetworkUpdate (Node node)
  754. {
  755. Runtime.ValidateRefCounted (this);
  756. Scene_MarkNetworkUpdate2 (handle, (object)node == null ? IntPtr.Zero : node.Handle);
  757. }
  758. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  759. internal static extern void Scene_MarkNetworkUpdate3 (IntPtr handle, IntPtr component);
  760. /// <summary>
  761. /// Mark a component for attribute check on the next network update.
  762. /// </summary>
  763. public void MarkNetworkUpdate (Component component)
  764. {
  765. Runtime.ValidateRefCounted (this);
  766. Scene_MarkNetworkUpdate3 (handle, (object)component == null ? IntPtr.Zero : component.Handle);
  767. }
  768. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  769. internal static extern void Scene_MarkReplicationDirty (IntPtr handle, IntPtr node);
  770. /// <summary>
  771. /// Mark a node dirty in scene replication states. The node does not need to have own replication state yet.
  772. /// </summary>
  773. public void MarkReplicationDirty (Node node)
  774. {
  775. Runtime.ValidateRefCounted (this);
  776. Scene_MarkReplicationDirty (handle, (object)node == null ? IntPtr.Zero : node.Handle);
  777. }
  778. public override StringHash Type {
  779. get {
  780. return UrhoGetType ();
  781. }
  782. }
  783. public override string TypeName {
  784. get {
  785. return GetTypeName ();
  786. }
  787. }
  788. [Preserve]
  789. public new static StringHash TypeStatic {
  790. get {
  791. return GetTypeStatic ();
  792. }
  793. }
  794. public new static string TypeNameStatic {
  795. get {
  796. return GetTypeNameStatic ();
  797. }
  798. }
  799. /// <summary>
  800. /// Return whether updates are enabled.
  801. /// Or
  802. /// Enable or disable scene update.
  803. /// </summary>
  804. public bool UpdateEnabled {
  805. get {
  806. return IsUpdateEnabled ();
  807. }
  808. set {
  809. SetUpdateEnabled (value);
  810. }
  811. }
  812. /// <summary>
  813. /// Return update time scale.
  814. /// Or
  815. /// Set update time scale. 1.0 = real time (default.)
  816. /// </summary>
  817. public float TimeScale {
  818. get {
  819. return GetTimeScale ();
  820. }
  821. set {
  822. SetTimeScale (value);
  823. }
  824. }
  825. /// <summary>
  826. /// Return elapsed time in seconds.
  827. /// Or
  828. /// Set elapsed time in seconds. This can be used to prevent inaccuracy in the timer if the scene runs for a long time.
  829. /// </summary>
  830. public float ElapsedTime {
  831. get {
  832. return GetElapsedTime ();
  833. }
  834. set {
  835. SetElapsedTime (value);
  836. }
  837. }
  838. /// <summary>
  839. /// Return motion smoothing constant.
  840. /// Or
  841. /// Set network client motion smoothing constant.
  842. /// </summary>
  843. public float SmoothingConstant {
  844. get {
  845. return GetSmoothingConstant ();
  846. }
  847. set {
  848. SetSmoothingConstant (value);
  849. }
  850. }
  851. /// <summary>
  852. /// Return motion smoothing snap threshold.
  853. /// Or
  854. /// Set network client motion smoothing snap threshold.
  855. /// </summary>
  856. public float SnapThreshold {
  857. get {
  858. return GetSnapThreshold ();
  859. }
  860. set {
  861. SetSnapThreshold (value);
  862. }
  863. }
  864. /// <summary>
  865. /// Return maximum milliseconds per frame to spend on async loading.
  866. /// Or
  867. /// Set maximum milliseconds per frame to spend on async scene loading.
  868. /// </summary>
  869. public int AsyncLoadingMs {
  870. get {
  871. return GetAsyncLoadingMs ();
  872. }
  873. set {
  874. SetAsyncLoadingMs (value);
  875. }
  876. }
  877. /// <summary>
  878. /// Return whether an asynchronous loading operation is in progress.
  879. /// </summary>
  880. public bool AsyncLoading {
  881. get {
  882. return IsAsyncLoading ();
  883. }
  884. }
  885. /// <summary>
  886. /// Return asynchronous loading progress between 0.0 and 1.0, or 1.0 if not in progress.
  887. /// </summary>
  888. public float AsyncProgress {
  889. get {
  890. return GetAsyncProgress ();
  891. }
  892. }
  893. /// <summary>
  894. /// Return the load mode of the current asynchronous loading operation.
  895. /// </summary>
  896. public LoadMode AsyncLoadMode {
  897. get {
  898. return GetAsyncLoadMode ();
  899. }
  900. }
  901. /// <summary>
  902. /// Return source file name.
  903. /// </summary>
  904. public string FileName {
  905. get {
  906. return GetFileName ();
  907. }
  908. }
  909. /// <summary>
  910. /// Return source file checksum.
  911. /// </summary>
  912. public uint Checksum {
  913. get {
  914. return GetChecksum ();
  915. }
  916. }
  917. /// <summary>
  918. /// Return required package files.
  919. /// </summary>
  920. public IReadOnlyList<PackageFile> RequiredPackageFiles {
  921. get {
  922. return GetRequiredPackageFiles ();
  923. }
  924. }
  925. /// <summary>
  926. /// Return threaded update flag.
  927. /// </summary>
  928. public bool ThreadedUpdate {
  929. get {
  930. return IsThreadedUpdate ();
  931. }
  932. }
  933. /// <summary>
  934. /// Return node user variable reverse mappings.
  935. /// </summary>
  936. public string VarNamesAttr {
  937. get {
  938. return GetVarNamesAttr ();
  939. }
  940. }
  941. }
  942. }