CSComponent.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace AtomicEngine
  4. {
  5. public class CSComponent : Component
  6. {
  7. public uint ManagedID;
  8. public CSComponent ()
  9. {
  10. // component being created native side
  11. if (ComponentCore.CurrentCSComponentNativeInstance != IntPtr.Zero) {
  12. nativeInstance = ComponentCore.CurrentCSComponentNativeInstance;
  13. NativeCore.RegisterNative (nativeInstance, this);
  14. ComponentCore.CurrentCSComponentNativeInstance = IntPtr.Zero;
  15. } else {
  16. nativeInstance = NativeCore.RegisterNative (csb_Atomic_CSComponent_Constructor(), this);
  17. ComponentCore.RegisterCSComponent (this);
  18. }
  19. }
  20. virtual public void Update(float timeStep)
  21. {
  22. }
  23. public void SetManagedID(uint id)
  24. {
  25. csb_Atomic_CSComponent_SetManagedID (nativeInstance, id);
  26. }
  27. [DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  28. private static extern IntPtr csb_Atomic_CSComponent_Constructor();
  29. [DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  30. private static extern void csb_Atomic_CSComponent_SetManagedID(IntPtr self, uint managedID);
  31. }
  32. }