SceneObject.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. // TODO - Unfinished
  6. public sealed class SceneObject : GameObject
  7. {
  8. public SceneObject parent
  9. {
  10. set { Internal_SetParent(mCachedPtr, value); }
  11. get { return Internal_GetParent(mCachedPtr); }
  12. }
  13. // For internal use
  14. private SceneObject()
  15. {
  16. }
  17. public SceneObject(string name)
  18. {
  19. Internal_CreateInstance(this, name);
  20. }
  21. public T AddComponent<T>() where T : Component
  22. {
  23. return (T)Component.Internal_AddComponent(this, typeof (T));
  24. }
  25. public T GetComponent<T>() where T : Component
  26. {
  27. return (T)Component.Internal_GetComponent(this, typeof(T));
  28. }
  29. public Component[] GetComponents()
  30. {
  31. throw new NotImplementedException();
  32. }
  33. public void RemoveComponent<T>() where T : Component
  34. {
  35. Component.Internal_RemoveComponent(this, typeof(T));
  36. }
  37. public int GetNumChildren()
  38. {
  39. return Internal_GetNumChildren(mCachedPtr);
  40. }
  41. public SceneObject GetChild(int idx)
  42. {
  43. return Internal_GetChild(mCachedPtr, idx);
  44. }
  45. [MethodImpl(MethodImplOptions.InternalCall)]
  46. private static extern void Internal_CreateInstance(SceneObject instance, string name);
  47. [MethodImpl(MethodImplOptions.InternalCall)]
  48. private static extern void Internal_SetParent(IntPtr nativeInstance, SceneObject parent);
  49. [MethodImpl(MethodImplOptions.InternalCall)]
  50. private static extern SceneObject Internal_GetParent(IntPtr nativeInstance);
  51. [MethodImpl(MethodImplOptions.InternalCall)]
  52. private static extern int Internal_GetNumChildren(IntPtr nativeInstance);
  53. [MethodImpl(MethodImplOptions.InternalCall)]
  54. private static extern SceneObject Internal_GetChild(IntPtr nativeInstance, int idx);
  55. }
  56. }