CSComponent.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 Start()
  21. {
  22. }
  23. virtual public void Update(float timeStep)
  24. {
  25. }
  26. public void SetManagedID(uint id)
  27. {
  28. csb_Atomic_CSComponent_SetManagedID (nativeInstance, id);
  29. }
  30. [DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  31. private static extern IntPtr csb_Atomic_CSComponent_Constructor();
  32. [DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  33. private static extern void csb_Atomic_CSComponent_SetManagedID(IntPtr self, uint managedID);
  34. }
  35. }