Ejemplo n.º 1
0
 static private void initSubsystems()
 {
     registerSubsystem(NativeCore.WrapNative <Player> (csb_AtomicEngine_GetSubsystem("Player")));
     registerSubsystem(NativeCore.WrapNative <Graphics> (csb_AtomicEngine_GetSubsystem("Graphics")));
     registerSubsystem(NativeCore.WrapNative <Renderer> (csb_AtomicEngine_GetSubsystem("Renderer")));
     registerSubsystem(NativeCore.WrapNative <ResourceCache> (csb_AtomicEngine_GetSubsystem("ResourceCache")));
 }
Ejemplo n.º 2
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.º 3
0
        public T Get <T>(string key) where T : RefCounted
        {
            checkValid();

            // TODO: safe case

            IntPtr r = csb_Atomic_VariantMap_GetInstance(native, key);

            return(r == IntPtr.Zero ? null :  NativeCore.WrapNative <T> (r));
        }
Ejemplo n.º 4
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.º 5
0
        // This will need to be optimized
        public static void CSComponentApplyFields(IntPtr componentPtr, IntPtr fieldMapPtr)
        {
            NETVariantMap fieldMap  = NativeCore.WrapNative <NETVariantMap>(fieldMapPtr);;
            CSComponent   component = NativeCore.WrapNative <CSComponent>(componentPtr);;

            if (fieldMap == null || component == null)
            {
                return;
            }

            FieldInfo[] fields = componentClassFields[component.GetType()];

            foreach (var field in fields)
            {
                if (fieldMap.Contains(field.Name))
                {
                    //Console.WriteLine("Applying: {0} {1}", field.Name, field.FieldType.Name);

                    var fieldType = field.FieldType;

                    if (fieldType.IsEnum)
                    {
                        field.SetValue(component, fieldMap.GetInt(field.Name));
                        continue;
                    }

                    switch (Type.GetTypeCode(fieldType))
                    {
                    case TypeCode.Boolean:
                        field.SetValue(component, fieldMap.GetBool(field.Name));
                        break;

                    case TypeCode.Int32:
                        field.SetValue(component, fieldMap.GetInt(field.Name));
                        break;

                    case TypeCode.Single:
                        field.SetValue(component, fieldMap.GetFloat(field.Name));
                        break;

                    case TypeCode.String:
                        field.SetValue(component, fieldMap.GetString(field.Name));
                        break;

                    default:

                        if (fieldType == typeof(Vector3))
                        {
                            field.SetValue(component, fieldMap.GetVector3(field.Name));
                        }
                        else if (fieldType == typeof(Quaternion))
                        {
                            field.SetValue(component, fieldMap.GetQuaternion(field.Name));
                        }
                        else if (fieldType.IsSubclassOf(typeof(Resource)))
                        {
                            field.SetValue(component, fieldMap.GetResourceFromRef(field.Name));
                        }
                        else if (fieldType.IsSubclassOf(typeof(RefCounted)))
                        {
                            field.SetValue(component, fieldMap.GetPtr(field.Name));
                        }

                        break;
                    }
                }
            }
        }