| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using AtomicPlayer;
- namespace AtomicEngine
- {
- public static class AtomicNET
- {
- public static Context Context => context;
- public static ResourceCache Cache;
- public static T GetSubsystem<T>() where T : AObject
- {
- AObject subSystem = null;
- subSystems.TryGetValue(typeof(T), out subSystem);
- return (T)subSystem;
- }
- public static void RegisterSubsystem(String name, AObject instance = null)
- {
- if (instance != null)
- {
- subSystems[instance.GetType()] = instance;
- return;
- }
- var subsystem = AtomicNET.Context.GetSubsystem(name);
- if (subsystem == null)
- {
- throw new System.InvalidOperationException("AtomicNET.RegisterSubsystem - Attempting to register null subsystem");
- }
- subSystems[subsystem.GetType()] = subsystem;
- }
- public static uint StringToStringHash(string value)
- {
- return csi_Atomic_AtomicNET_StringToStringHash(value);
- }
- [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
- private static extern uint csi_Atomic_AtomicNET_StringToStringHash(string name);
- 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
- }
- [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
- private static extern IntPtr csi_Atomic_NETCore_Initialize(ref CoreDelegates delegates);
- private static Context context;
- private static CoreDelegates coreDelegates;
- private static Dictionary<Type, AObject> subSystems = new Dictionary<Type, AObject>();
- }
- }
|