Exemplo n.º 1
0
        public void Start()
        {
            mInstanceBase = InstanceBaseManager.instance.Find(InstanceID);

            if (null == mInstanceBase)
            {
                Logger.LogError($"找不到副本配置 id -> {InstanceID}");
                return;
            }

            var tmpUnitCtrl = Game.ControllerMgr.Get <UnitController>();

            Game.WindowsMgr.ShowWindow <FadeWnd, bool, bool>(true, false);

            Game.TimerMgr.AddTimer(0.5f, obj => {
                Game.WindowsMgr.CloseWindow <InstanceWnd>();
                mLocalPlayer = new LocalPlayer();
                mLocalPlayer.Init(1003, 1);
                mLocalPlayer.SetPosition(new Vector3(1000, 0, 0));
                GameObject.DontDestroyOnLoad(mLocalPlayer.UGameObject);
                ACT.ActionSystem.Instance.ActUnitMgr.Add(mLocalPlayer);
                ACT.ActionSystem.Instance.ActUnitMgr.LocalPlayer = mLocalPlayer;
                tmpUnitCtrl.SetLocalPlayer(mLocalPlayer);
                Game.WindowsMgr.ShowWindow <FightMainWnd>();
                SceneLoader.Instance.LoadSceneAsync(mInstanceBase.SceneName, OnSceneLoaded);
            }, null);
        }
Exemplo n.º 2
0
        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            if (Context == null)
            {
                throw new ArgumentNullException("InstallContext");
            }

            if (Context.Parameters["AssemblyName"] == null)
            {
                throw new ArgumentNullException("assemblyName");
            }

            if (Context.Parameters["InstanceTypeName"] == null)
            {
                throw new ArgumentNullException("instanceTypeName");
            }

            if (Context.Parameters["InstanceName"] == null)
            {
                throw new ArgumentNullException("instanceName");
            }

            Assembly asm = Assembly.LoadFrom(Path.Combine(Environment.CurrentDirectory, Context.Parameters["AssemblyName"]) + ".dll");

            InstanceBase instance = (InstanceBase)asm.CreateInstance(Context.Parameters["InstanceTypeName"], true, BindingFlags.CreateInstance, null, new object[] { Context.Parameters["InstanceName"] }, null, null);

            string name        = instance.applicationName + " (" + Context.Parameters["InstanceName"] + ")";
            string description = instance.applicationName;

            serviceInstaller.ServiceName = name;
            serviceInstaller.DisplayName = name;

            base.Uninstall(savedState);
        }
Exemplo n.º 3
0
        public Device(InstanceBase instance, DeviceType type, AdapterInfo[] adapters)
            : base(instance, type)
        {
            if (adapters == null || adapters.Length <= 1)
            {
                throw new ArgumentException("Adapters must be at least two in length");
            }
            devices = new DeviceBase[adapters.Length];
            for (int i = 0; i != devices.Length; ++i)
            {
                // allocate API specific device
                if (instance is D3D12.Instance)
                {
                    devices[i] = new D3D12.Device((D3D12.Instance)instance, adapters[i].isPrimary ? type : DeviceType.Background);
                }
                else if (instance is Vulkan.Instance)
                {
                    devices[i] = new Vulkan.Device((Vulkan.Instance)instance, adapters[i].isPrimary ? type : DeviceType.Background);
                }
                else
                {
                    throw new NotImplementedException("Failed to create devices based on instance type: " + instance.GetType().ToString());
                }

                // set primary device
                if (adapters[i].isPrimary)
                {
                    primaryDevice = devices[i];
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes first API avaliable to the hardware
        /// NOTE: 'desc' may be modified
        /// </summary>
        public static bool InitFirstAvaliable(AbstractionDesc desc, out InstanceBase instance)
        {
            // validate supported APIs is configured
            if (desc.supportedAPIs == null)
            {
                instance = null;
                return(false);
            }

            // try to init each API until we find one supported by this hardware
            foreach (var api in desc.supportedAPIs)
            {
                switch (api)
                {
                //case AbstractionAPI.WindowsGamingInput:
                //{
                //	throw new NotImplementedException();
                //}
                //break;

                case AbstractionAPI.XInput:
                {
                    var instanceXInput = new XInput.Instance(desc.autoConfigureAbstractions);
                    if (instanceXInput.Init())
                    {
                        instance = instanceXInput;
                        return(true);
                    }
                    else
                    {
                        instanceXInput.Dispose();
                    }
                }
                break;

                case AbstractionAPI.DirectInput:
                {
                    if (!LoadNativeLib(Path.Combine(desc.nativeLibPathDirectInput, DirectInput.Instance.lib)))
                    {
                        continue;
                    }
                    var instanceXInput = new DirectInput.Instance(desc.ignoreXInputDevices, desc.autoConfigureAbstractions);
                    if (instanceXInput.Init(IntPtr.Zero, DirectInput.FeatureLevel.Level_1))
                    {
                        instance = instanceXInput;
                        return(true);
                    }
                    else
                    {
                        instanceXInput.Dispose();
                    }
                }
                break;
                }
            }

            instance = null;
            return(false);
        }
Exemplo n.º 5
0
 public void Dispose()
 {
     if (instance != null)
     {
         instance.Dispose();
         instance = null;
     }
 }
        protected override void OnStop()
        {
            if (instance != null)
            {
                InstanceFactory.UnloadInstance(instance);
            }

            instance = null;
        }
Exemplo n.º 7
0
        private void RefreshDesc()
        {
            InstanceBase tmpInstanceBase = InstanceBaseManager.instance.Find(mInstanceID);

            if (null != tmpInstanceBase)
            {
                mDescLab.text = tmpInstanceBase.Desc;
            }
        }
Exemplo n.º 8
0
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            if (Context == null)
            {
                throw new ArgumentNullException("InstallContext");
            }

            if (Context.Parameters["AssemblyName"] == null)
            {
                throw new ArgumentNullException("assemblyName");
            }

            if (Context.Parameters["InstanceTypeName"] == null)
            {
                throw new ArgumentNullException("instanceTypeName");
            }

            if (Context.Parameters["InstanceName"] == null)
            {
                throw new ArgumentNullException("instanceName");
            }


            Assembly asm = Assembly.LoadFrom(Path.Combine(Environment.CurrentDirectory, Context.Parameters["AssemblyName"]) + ".dll");

            InstanceBase instance = (InstanceBase)asm.CreateInstance(Context.Parameters["InstanceTypeName"], true, BindingFlags.CreateInstance, null, new object[] { Context.Parameters["InstanceName"] }, null, null);

            string name        = instance.applicationName + " (" + Context.Parameters["InstanceName"] + ")";
            string description = instance.applicationName;

            serviceInstaller.ServiceName = name;
            serviceInstaller.DisplayName = name;

            base.Install(stateSaver);

            Microsoft.Win32.RegistryKey serviceDescriptionKey = null;

            try
            {
                serviceDescriptionKey =
                    Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\" + serviceInstaller.ServiceName, true);

                serviceDescriptionKey.SetValue("Description", description);

                string imagePath = serviceDescriptionKey.GetValue("ImagePath") as string;
                serviceDescriptionKey.SetValue("ImagePath", string.Format("{0} \"{1}\" \"{2}\" \"{3}\"", imagePath, Context.Parameters["assemblyName"], Context.Parameters["instanceTypeName"], Context.Parameters["instanceName"]));
            }
            finally
            {
                if (serviceDescriptionKey != null)
                {
                    serviceDescriptionKey.Close();
                }
            }
        }
Exemplo n.º 9
0
    protected ObjectBase CreateObject(int templateId, int idForGenerateName, bool clientNotServer, int createionMethod = ObjectCreationContext.CreationMethodType.OBJECT_CREATION_METHOD)
    {
        ObjectCreationContext context = new ObjectCreationContext();

        context.templateId      = templateId;
        context.clientNotServer = clientNotServer;
        context.CreationMethod  = createionMethod;
        context.NetworkID       = idForGenerateName;

        return(InstanceBase.GetCurrentInstance().GetObjectManager().CreateObject(context));
    }
Exemplo n.º 10
0
        public MessagingServiceProcess(string assemblyName, string instanceTypeName, string instanceName)
        {
            InitializeComponent();

            this.assemblyName     = assemblyName;
            this.instanceTypeName = instanceTypeName;
            this.instanceName     = instanceName;

            instance = InstanceFactory.CreateInstance <InstanceBase>(assemblyName, instanceTypeName, instanceName);

            this.ServiceName = instance.applicationName + " (" + instanceName + ")";
        }
Exemplo n.º 11
0
        void IAdaptorHost.Invoke(InstanceBase instance, string name, Type[] types, object[] args)
        {
            var token   = $"{this.adaptorImpl.Token}";
            var datas   = this.serializer.SerializeMany(types, args);
            var request = new InvokeRequest()
            {
                ServiceName = instance.ServiceName,
                Name        = name,
                Token       = token
            };

            request.Datas.AddRange(datas);
            var reply = this.adaptorImpl.Invoke(request);
            var id    = Guid.Parse(reply.ID);

            if (id != Guid.Empty)
            {
                this.ThrowException(id, reply.Data);
            }
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            System.Console.CancelKeyPress += new ConsoleCancelEventHandler(CancelKeyPressEventHandler);
            System.Console.BufferWidth     = 1000;

            stopWaitEvent = new ManualResetEvent(false);

            CommandLineParser parser = new CommandLineParser(args);

            string instanceName = parser["instance"];

            if (String.IsNullOrEmpty(instanceName))
            {
                instanceName = ConfigurationManager.AppSettings["instance"];
            }

            instance = InstanceFactory.CreateInstance <InstanceBase>("Imi.Wms.Mobile.Server", "Imi.Wms.Mobile.Server.ServerInstance", instanceName);

            try
            {
                instance.Initialize();
                instance.Start();

                System.Console.WriteLine("Press Ctrl+C to terminate...");

                stopWaitEvent.WaitOne();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex);
            }
            finally
            {
                instance.Stop();
            }

            System.Console.WriteLine("Press any key to exit...");
            System.Console.ReadKey();

            Environment.Exit(0);
        }
Exemplo n.º 13
0
 protected override void OnStart(string[] args)
 {
     instance = InstanceFactory.CreateInstance("", "");
     instance.Initialize();
     instance.Start();
 }
Exemplo n.º 14
0
        public void Dispose()
        {
            if (texture != null)
            {
                texture.Dispose();
                texture = null;
            }

            if (texture2 != null)
            {
                texture2.Dispose();
                texture2 = null;
            }

            if (constantBuffer != null)
            {
                constantBuffer.Dispose();
                constantBuffer = null;
            }

            if (vertexBuffer != null)
            {
                vertexBuffer.Dispose();
                vertexBuffer = null;
            }

            if (renderState != null)
            {
                renderState.Dispose();
                renderState = null;
            }

            if (shaderEffect != null)
            {
                shaderEffect.Dispose();
                shaderEffect = null;
            }

            if (renderPass != null)
            {
                renderPass.Dispose();
                renderPass = null;
            }

            if (commandList != null)
            {
                commandList.Dispose();
                commandList = null;
            }

            if (device != null)
            {
                device.Dispose();
                device = null;
            }

            if (instance != null)
            {
                instance.Dispose();
                instance = null;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes first API avaliable to the hardware
        /// NOTE: 'desc' may be modified
        /// </summary>
        public static bool InitFirstAvaliable(AbstractionDesc desc, out InstanceBase instance, out DeviceBase device)
        {
            // validate supported APIs is configured
            if (desc.supportedAPIs == null)
            {
                instance = null;
                device   = null;
                return(false);
            }

            // try to init each API until we find one supported by this hardware
            foreach (var api in desc.supportedAPIs)
            {
                switch (api)
                {
                                        #if WIN32 || WIN32
                case AbstractionAPI.D3D12:
                {
                    if (!LoadNativeLib(Path.Combine(desc.nativeLibPathD3D12, D3D12.Instance.lib)))
                    {
                        continue;
                    }
                    var instanceD3D12 = new D3D12.Instance();
                    if (instanceD3D12.Init(desc.instanceDescD3D12))
                    {
                        var deviceBase = CreateDevice(desc, instanceD3D12);
                        if (deviceBase is D3D12.Device)
                        {
                            var deviceD3D12 = (D3D12.Device)deviceBase;
                            if (deviceD3D12.Init(desc.deviceDescD3D12))
                            {
                                instance = instanceD3D12;
                                device   = deviceD3D12;
                                return(true);
                            }

                            deviceD3D12.Dispose();
                        }
                        else if (deviceBase is mGPU.Device)
                        {
                            var deviceMGPU = (mGPU.Device)deviceBase;
                            if (deviceMGPU.Init(desc))
                            {
                                instance = instanceD3D12;
                                device   = deviceMGPU;
                                return(true);
                            }

                            deviceMGPU.Dispose();
                        }

                        instanceD3D12.Dispose();
                    }
                    else
                    {
                        instanceD3D12.Dispose();
                    }
                }
                break;

                    /*case AbstractionAPI.Vulkan:
                     * {
                     *      if (!LoadNativeLib(Path.Combine(desc.nativeLibPathVulkan, "vulkan-1.dll"))) continue;
                     *      if (!LoadNativeLib(Path.Combine(desc.nativeLibPathVulkan, Vulkan.Instance.lib))) continue;
                     *      var instanceVulkan = new Vulkan.Instance();
                     *      if (instanceVulkan.Init(desc.instanceDescVulkan))
                     *      {
                     *              var deviceVulkan = new Vulkan.Device(instanceVulkan, desc.deviceType);
                     *              if (deviceVulkan.Init(desc.deviceDescVulkan))
                     *              {
                     *                      instance = instanceVulkan;
                     *                      device = deviceVulkan;
                     *                      return true;
                     *              }
                     *
                     *              deviceVulkan.Dispose();
                     *              instanceVulkan.Dispose();
                     *      }
                     *      else
                     *      {
                     *              instanceVulkan.Dispose();
                     *      }
                     * }
                     * break;*/
                                        #endif
                }
            }

            instance = null;
            device   = null;
            return(false);
        }
Exemplo n.º 16
0
        private static DeviceBase CreateDevice(AbstractionDesc desc, InstanceBase instance)
        {
            DeviceBase device = null;

            AdapterInfo[] adapters           = null;
            bool          createSingleDevice = false;
            var           initType           = desc.type;

            if (initType == AbstractionInitType.SingleGPU_Standard)
            {
                initType           = AbstractionInitType.SingleGPU_Standard;
                createSingleDevice = true;                // single gpu mode only
            }
            else if (initType == AbstractionInitType.MultiGPU_BestAvaliable_AFR)
            {
                if (!instance.QuerySupportedAdapters(false, out adapters))
                {
                    throw new Exception("Failed to get supported adapters");
                }
                if (adapters.Length >= 1)
                {
                    // test for linked-gpus
                    foreach (var adapter in adapters)
                    {
                        if (adapter.isPrimary && adapter.nodeCount > 1)
                        {
                            initType = AbstractionInitType.MultiGPU_LinkedNode_AFR;
                            break;
                        }
                    }

                    // test for mixed-gpu support
                    if (initType == AbstractionInitType.MultiGPU_BestAvaliable_AFR)
                    {
                        if (adapters.Length >= 2)
                        {
                            foreach (var adapter in adapters)
                            {
                                if (adapter.isPrimary)
                                {
                                    initType = AbstractionInitType.MultiGPU_MixedDevice_AFR;
                                    break;
                                }
                            }
                        }
                    }
                }

                // set to single gpu if no mGPU support found
                if (initType == AbstractionInitType.MultiGPU_BestAvaliable_AFR)
                {
                    initType           = AbstractionInitType.SingleGPU_Standard;
                    createSingleDevice = true;
                }
            }

            if (initType == AbstractionInitType.MultiGPU_LinkedNode_AFR)
            {
                if (adapters == null && !instance.QuerySupportedAdapters(false, out adapters))
                {
                    throw new Exception("Failed to get supported adapters");
                }
                bool linkedNodesFound = false;
                foreach (var adapter in adapters)
                {
                    if (adapter.isPrimary && adapter.nodeCount > 1)
                    {
                        linkedNodesFound = true;
                        break;
                    }
                }

                if (!linkedNodesFound)
                {
                    initType = AbstractionInitType.SingleGPU_Standard; // default to single gpu mode if only adapter-node found
                }
                createSingleDevice = true;                             // always create a single device
            }
            else if (initType == AbstractionInitType.MultiGPU_MixedDevice_AFR)
            {
                if (adapters == null && !instance.QuerySupportedAdapters(false, out adapters))
                {
                    throw new Exception("Failed to get supported adapters");
                }
                if (adapters.Length > 1)
                {
                    // gather all supported adapters
                    List <AdapterInfo> supportedAdapters;
                    if (desc.vendorIgnores_MixedDevices != null)
                    {
                        supportedAdapters = new List <AdapterInfo>();
                        foreach (var adapter in adapters)
                        {
                            if (!IsVendorIgnored(adapter.vendor, desc.vendorIgnores_MixedDevices))
                            {
                                supportedAdapters.Add(adapter);
                            }
                        }
                    }
                    else
                    {
                        supportedAdapters = new List <AdapterInfo>(adapters);
                    }

                    if (supportedAdapters.Count > 1)
                    {
                        device = new mGPU.Device(instance, desc.deviceType, supportedAdapters.ToArray());
                    }
                    else
                    {
                        initType           = AbstractionInitType.SingleGPU_Standard;              // default to single gpu mode if only adapter found
                        createSingleDevice = true;
                    }
                }
                else
                {
                    initType           = AbstractionInitType.SingleGPU_Standard;          // default to single gpu mode if only adapter found
                    createSingleDevice = true;
                }
            }

            // force mixed-device AFR requirements
            if (initType == AbstractionInitType.MultiGPU_MixedDevice_AFR)
            {
                desc.deviceDescD3D12.swapChainType  = SwapChainType.SingleGPU_Standard;
                desc.deviceDescVulkan.swapChainType = SwapChainType.SingleGPU_Standard;
            }

            // create single device if needed
            if (createSingleDevice)
            {
                if (instance is D3D12.Instance)
                {
                    device = new D3D12.Device((D3D12.Instance)instance, desc.deviceType);
                }
                else if (instance is Vulkan.Instance)
                {
                    device = new Vulkan.Device((Vulkan.Instance)instance, desc.deviceType);
                }
            }

            return(device);
        }
Exemplo n.º 17
0
        public static bool InitFirstAvaliable(AbstractionDesc desc, out InstanceBase instance, out DeviceBase device)
        {
            if (desc.supportedAPIs == null)
            {
                instance = null;
                device   = null;
                return(false);
            }

            foreach (var api in desc.supportedAPIs)
            {
                switch (api)
                {
                                        #if WIN32 || WIN32
                case AbstractionAPI.D3D12:
                {
                    if (!LoadNativeLib(Path.Combine(desc.nativeLibPathD3D12, D3D12.Instance.lib)))
                    {
                        continue;
                    }
                    var instanceD3D12 = new D3D12.Instance();
                    if (instanceD3D12.Init(desc.instanceDescD3D12))
                    {
                        var deviceD3D12 = new D3D12.Device(instanceD3D12, desc.type);
                        if (deviceD3D12.Init(desc.deviceDescD3D12))
                        {
                            instance = instanceD3D12;
                            device   = deviceD3D12;
                            return(true);
                        }

                        deviceD3D12.Dispose();
                        instanceD3D12.Dispose();
                    }
                    else
                    {
                        instanceD3D12.Dispose();
                    }
                }
                break;

                case AbstractionAPI.Vulkan:
                {
                    if (!LoadNativeLib(Path.Combine(desc.nativeLibPathVulkan, "vulkan-1.dll")))
                    {
                        continue;
                    }
                    if (!LoadNativeLib(Path.Combine(desc.nativeLibPathVulkan, Vulkan.Instance.lib)))
                    {
                        continue;
                    }
                    var instanceVulkan = new Vulkan.Instance();
                    if (instanceVulkan.Init(desc.instanceDescVulkan))
                    {
                        var deviceVulkan = new Vulkan.Device(instanceVulkan, desc.type);
                        if (deviceVulkan.Init(desc.deviceDescVulkan))
                        {
                            instance = instanceVulkan;
                            device   = deviceVulkan;
                            return(true);
                        }

                        deviceVulkan.Dispose();
                        instanceVulkan.Dispose();
                    }
                    else
                    {
                        instanceVulkan.Dispose();
                    }
                }
                break;
                                        #endif
                }
            }

            instance = null;
            device   = null;
            return(false);
        }