CSComponent.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4. namespace AtomicEngine
  5. {
  6. public class CSComponent : Component
  7. {
  8. public uint ManagedID;
  9. public CSComponent ()
  10. {
  11. nativeInstance = NativeCore.RegisterNative (csb_Atomic_CSComponent_Constructor(), this);
  12. ComponentCore.RegisterCSComponent (this);
  13. }
  14. virtual public void Start()
  15. {
  16. }
  17. virtual public void Update(float timeStep)
  18. {
  19. }
  20. public void SendEvent(string eventType, Dictionary<string, object> eventData = null)
  21. {
  22. }
  23. // function would be a C# method, and all classes other than component and uiwidget are sealed
  24. // so basically, not having inheritance means no local state for native classes
  25. // allowing inheritance, neans need to GCHandle the object as can have local state
  26. // and can't regenerate it, comes down to components and UI?
  27. public void SubscribeToEvent(AObject sender, string eventType, object function)
  28. {
  29. }
  30. public void SubscribeToEvent(string eventType, object function)
  31. {
  32. }
  33. void handleEvent(string eventType, Dictionary<uint, object> eventData)
  34. {
  35. }
  36. [DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  37. private static extern IntPtr csb_Atomic_CSComponent_Constructor();
  38. [DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  39. private static extern void csb_Atomic_CSComponent_SetManagedID(IntPtr self, uint managedID);
  40. }
  41. }