Ejemplo n.º 1
0
        public CSComponentInfo(Type type)
        {
            this.Type = type;

            // Fields

            var fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                         .Where(field => field.IsDefined(typeof(InspectorAttribute), true));

            InspectorFields = fields.ToArray <FieldInfo>();

            foreach (var field in InspectorFields)
            {
                fieldLookup[AtomicNET.StringToStringHash(field.Name)] = field;
            }

            // Methods
            Type[] updateParms = new Type[1] {
                typeof(float)
            };
            UpdateMethod = type.GetMethod("Update", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, updateParms, null);

            Type[] startParms = new Type[0] {
            };
            StartMethod = type.GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, startParms, null);
        }
Ejemplo n.º 2
0
        public static int Run(Type appDelegateType, string[] args)
        {
            // Create the Application

            AppBase app = null;

#if ATOMIC_DESKTOP
            app = NETIPCPlayerApp.Create(args);
#endif

#if ATOMIC_ANDROID
            app = NETAtomicPlayer.Create(args);

            var renderer = AtomicNET.GetSubsystem <Renderer>();
            renderer.ReuseShadowMaps = false;
            renderer.ShadowQuality   = ShadowQuality.SHADOWQUALITY_SIMPLE_16BIT;
#endif

            appDelegate = (AppDelegate)Activator.CreateInstance(appDelegateType);

            appDelegate.Start();

            // Managed code in charge of main loop
            while (app.RunFrame())
            {
                appDelegate.PostFrame();
            }

            appDelegate.Shutdown();

            // Shut 'er down
            app.Shutdown();

            return(0);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///  Release the handle, which will release the native instance immediately if in main thread
        ///  otherwise, will queue
        /// </summary>
        override protected bool ReleaseHandle()
        {
            if (handle == IntPtr.Zero)
            {
                throw new InvalidOperationException("RefCountedSafeFileHandle.ReleaseHandle - native == IntPtr.Zero");
            }

            // We can be called from Dispose in main thread or from finalizers, which aren't in the main thread
            if (AtomicNET.IsMainThread())
            {
                NativeCore.csi_AtomicEngine_ReleaseRef(handle);
            }
            else
            {
                // We're in a finalizer, need to add to queue to release when
                // back in main thread
                lock (RefCounted.refCountedFinalizerQueue)
                {
                    RefCounted.refCountedFinalizerQueue.Add(handle);
                }
            }

            handle = IntPtr.Zero;

            return(true);
        }
Ejemplo n.º 4
0
        public static int Run(Type appDelegateType, string[] args)
        {
            // Create the Application

            AppBase app = null;

#if ATOMIC_DESKTOP
            app = NETIPCPlayerApp.Create(args);
#endif

#if ATOMIC_IOS
            // On iOS, we need to set main ready as main() isn't being called
            SDLEvents.SetMainReady();
#endif


#if ATOMIC_MOBILE
            app = NETAtomicPlayer.Create(args);

            var renderer = AtomicNET.GetSubsystem <Renderer>();
            renderer.ReuseShadowMaps = false;
            renderer.ShadowQuality   = ShadowQuality.SHADOWQUALITY_SIMPLE_16BIT;
#endif

            appDelegate = (AppDelegate)Activator.CreateInstance(appDelegateType);

            try
            {
                appDelegate.Start();

                // Managed code in charge of main loop
                while (app.RunFrame())
                {
                    appDelegate.PostFrame();
                }

                appDelegate.Shutdown();

                // Shut 'er down
                app.Shutdown();
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    Log.Error(e.InnerException.StackTrace);
                    // rethrow inner exception
                    throw e.InnerException;
                }
                else
                {
                    Log.Error(e.StackTrace);
                    // rethrow
                    throw e;
                }
            }

            return(0);
        }
Ejemplo n.º 5
0
        public static void Initialize()
        {
            // Atomic Modules
            CoreModule.Initialize();
            MathModule.Initialize();
            EngineModule.Initialize();
            InputModule.Initialize();
            IOModule.Initialize();
            ResourceModule.Initialize();
            AudioModule.Initialize();
            GraphicsModule.Initialize();
            SceneModule.Initialize();
            Atomic2DModule.Initialize();
            NavigationModule.Initialize();
            NetworkModule.Initialize();
            PhysicsModule.Initialize();
            EnvironmentModule.Initialize();
            UIModule.Initialize();

#if ATOMIC_DESKTOP
            IPCModule.Initialize();
#endif

            AtomicAppModule.Initialize();
            ScriptModule.Initialize();

            AtomicNETScriptModule.Initialize();
            AtomicNETNativeModule.Initialize();

            PlayerModule.Initialize();

            coreDelegates = new CoreDelegates();
            coreDelegates.eventDispatch  = NativeCore.EventDispatch;
            coreDelegates.updateDispatch = NativeCore.UpdateDispatch;

            IntPtr coreptr = csi_Atomic_NETCore_Initialize(ref coreDelegates);

            NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative <NETCore>(coreptr));

            if (core != null)
            {
                AtomicNET.RegisterSubsystem("NETCore", core);
            }

            context = core.Context;

            NativeCore.Initialize();
            CSComponentCore.Initialize();

#if ATOMIC_DESKTOP
            string[] arguments = Environment.GetCommandLineArgs();
            foreach (string arg in arguments)
            {
                AppBase.AddArgument(arg);
            }
#endif
        }
Ejemplo n.º 6
0
        public static NETServiceApplication Create()
        {
            // Initialize AtomicNET
            AtomicNET.Initialize();

            var app = CreateInternal();

            app.Initialize();

            return(app);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///  IPC Player App used with the Atomic Editor
        /// </summary>
        /// <param name="args"></param>
        /// <param name="headless"></param>
        /// <returns></returns>
        public static NETIPCServerApp Create(string[] args, bool headless = false)
        {
            // Initialize AtomicNET
            AtomicNET.Initialize();

            var app = CreateInternal();

            app.Initialize();

            return(app);
        }
Ejemplo n.º 8
0
        public CSComponentInfo(Type type)
        {
#if ATOMIC_DESKTOP || ATOMIC_MOBILE
            this.Type = type;

            // Fields
            List <FieldInfo> fields = new List <FieldInfo>();
            fields.AddRange(type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                            .Where(field => field.IsDefined(typeof(InspectorAttribute), true)));

            // Inspector fields may be private. BindingFlags.NonPublic does not report private fields in superclasses
            var baseType = type.BaseType;
            while (baseType != typeof(CSComponent))
            {
                fields.AddRange(baseType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                                .Where(field => field.IsDefined(typeof(InspectorAttribute), true)));
                baseType = baseType.BaseType;
            }

            InspectorFields = fields.ToArray <FieldInfo>();

            foreach (var field in InspectorFields)
            {
                fieldLookup[AtomicNET.StringToStringHash(field.Name)] = field;
            }

            // Methods
            Type[] updateParms = new Type[1] {
                typeof(float)
            };
            UpdateMethod = type.GetMethod("Update", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, updateParms, null);

            Type[] postUpdateParms = new Type[1] {
                typeof(float)
            };
            PostUpdateMethod = type.GetMethod("PostUpdate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, postUpdateParms, null);

            Type[] physicsPreStepParms = new Type[1] {
                typeof(float)
            };
            PhysicsPreStepMethod = type.GetMethod("PhysicsPreStep", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, physicsPreStepParms, null);

            Type[] physicsPostStepParms = new Type[1] {
                typeof(float)
            };
            PhysicsPostStepMethod = type.GetMethod("PhysicsPostStep", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, physicsPostStepParms, null);

            Type[] startParms = new Type[0] {
            };
            StartMethod = type.GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, startParms, null);
#endif
        }
        public static NETServiceApplication Create()
        {
            // Initialize AtomicNET
            AtomicNET.Initialize();

            var app = CreateInternal();

            app.Initialize();

            AtomicNET.RegisterSubsystem("IPC");

            return(app);
        }
Ejemplo n.º 10
0
        static protected void RegisterSubsystems()
        {
            // TODO: Refactor these registrations
            AtomicNET.RegisterSubsystem("FileSystem");

            AtomicNET.RegisterSubsystem("Graphics");
            AtomicNET.RegisterSubsystem("Player");

            AtomicNET.RegisterSubsystem("Input");
            AtomicNET.RegisterSubsystem("Renderer");

            AtomicNET.RegisterSubsystem("ResourceCache");
            AtomicNET.Cache = AtomicNET.GetSubsystem <ResourceCache>();
        }
Ejemplo n.º 11
0
        public static void RegisterEventID <T>(string eventName) where T : NativeEventData
        {
            var eventID = AtomicNET.StringToStringHash(eventName);
            var type    = typeof(T);

            eventIDLookup[type] = eventID;
            typeLookup[eventID] = type;

            // create event data cache
            var cache = new NativeEventDataCache(type);

            eventCache[type]             = cache;
            eventCacheByEventID[eventID] = cache;
        }
Ejemplo n.º 12
0
        /// <summary>
        ///  IPC Player App used with the Atomic Editor
        /// </summary>
        /// <param name="args"></param>
        /// <param name="headless"></param>
        /// <returns></returns>
        public static NETIPCPlayerApp Create(string[] args, bool headless = false)
        {
            // Initialize AtomicNET
            AtomicNET.Initialize();

            var app = CreateInternal();

            app.Initialize();

            RegisterSubsystems();

            ExecuteAtomicMain(args);

            return(app);
        }
Ejemplo n.º 13
0
        public static void Initialize()
        {
            // Atomic Modules
            CoreModule.Initialize();
            MathModule.Initialize();
            EngineModule.Initialize();
            InputModule.Initialize();
            IOModule.Initialize();
            ResourceModule.Initialize();
            AudioModule.Initialize();
            GraphicsModule.Initialize();
            SceneModule.Initialize();
            Atomic2DModule.Initialize();
            Atomic3DModule.Initialize();
            NavigationModule.Initialize();
            NetworkModule.Initialize();
            PhysicsModule.Initialize();
            EnvironmentModule.Initialize();
            UIModule.Initialize();
            IPCModule.Initialize();
            AtomicAppModule.Initialize();
            ScriptModule.Initialize();

            AtomicNETScriptModule.Initialize();
            AtomicNETNativeModule.Initialize();

            PlayerModule.Initialize();

            coreDelegates = new CoreDelegates();
            coreDelegates.eventDispatch  = NativeCore.EventDispatch;
            coreDelegates.updateDispatch = NativeCore.UpdateDispatch;

            IntPtr coreptr = csb_Atomic_NETCore_Initialize(ref coreDelegates);

            NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative <NETCore>(coreptr));

            if (core != null)
            {
                AtomicNET.RegisterSubsystem("NETCore", core);
            }

            context = core.Context;

            NativeCore.Initialize();
            CSComponentCore.Initialize();
        }
Ejemplo n.º 14
0
        static protected void RegisterSubsystems()
        {
            // TODO: Refactor these registrations
            AtomicNET.RegisterSubsystem("FileSystem");

            AtomicNET.RegisterSubsystem("Graphics");
            AtomicNET.RegisterSubsystem("Player");

            AtomicNET.RegisterSubsystem("Input");
            AtomicNET.RegisterSubsystem("Renderer");

            AtomicNET.RegisterSubsystem("ResourceCache");
            AtomicNET.Cache = AtomicNET.GetSubsystem <ResourceCache>();

            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += new ResolveEventHandler(AtomicResolveEventHandler);
        }
Ejemplo n.º 15
0
 public static T GetSubsystem <T>() where T : AObject
 {
     return(AtomicNET.GetSubsystem <T>());
 }
Ejemplo n.º 16
0
 public void SubscribeToEvent(string eventType, EventDelegate eventDelegate)
 {
     SubscribeToEvent(AtomicNET.StringToStringHash(eventType), eventDelegate);
 }
Ejemplo n.º 17
0
 public void SubscribeToEvent(AObject sender, string eventType, SenderEventDelegate eventDelegate)
 {
     SubscribeToEvent(sender, AtomicNET.StringToStringHash(eventType), eventDelegate);
 }
Ejemplo n.º 18
0
        public static void SendWindowEvent(SdlWindowEvent wndEvent, int data1 = 0, int data2 = 0)
        {
            var graphics = AtomicNET.GetSubsystem <Graphics>();

            SDL_SendWindowEvent(graphics.SDLWindow, (byte)wndEvent, data1, data2);
        }