private void AddComponentType <T>(int index) where T : IComponent, new()
        {
            ComponentHelper <TEntity, T> .Initialize(index);

            ComponentNames.Add(typeof(T).PrettyPrintGenericTypeName());
            ComponentTypes.Add(typeof(T));
            ComponentCount++;
        }
Example #2
0
        public ComponentDesignVM(GameVM gameVM)
        {
            _gameVM        = gameVM;
            _staticData    = gameVM.Game.StaticData;
            _factionEntity = gameVM.CurrentFaction;
            _factionTech   = gameVM.CurrentFaction.GetDataBlob <FactionTechDB>();


            foreach (var componentSD in gameVM.Game.StaticData.ComponentTemplates.Values)
            {
                ComponentTypes.Add(componentSD.Name, componentSD.ID);
            }
            ComponentTypes.SelectedIndex = 0;
        }
Example #3
0
        internal static void Init()
        {
            var kvps =
                AppDomain.CurrentDomain.GetAssemblies()
                .SelectMany(x => x.GetTypes())
                .Where(t => typeof(Component).IsAssignableFrom(t))
                .Select(x => KeyValuePair.Create(x.AssemblyQualifiedName, x));

            foreach (var kvp in kvps)
            {
                ComponentTypes.Add(kvp.Key, kvp.Value);
            }

            new Font("Inconsolata", Path.Combine(AppContext.BaseDirectory, "EngineAssets/Fonts/Inconsolata.fnt"));
            new Font("Impact", Path.Combine(AppContext.BaseDirectory, "EngineAssets/Fonts/Impact.fnt"));
        }
Example #4
0
            public static int GetTypeID(Type type)
            {
                if (!IDlookups.TryGetValue(type, out var value))
                {
                    ComponentTypes.Add(type);
                    IDlookups[type] = value = IDlookups.Count;
                    if (value == component_pools.Length)
                    {
                        Array.Resize(ref entity_pools, value * 2);
                        Array.Resize(ref component_pools, value * 2);
                    }

                    entity_pools[value] = new ECSCollection <Entity>();
                    var poolType = typeof(Components <>).MakeGenericType(new Type[] { type });
                    component_pools[value] = (Activator.CreateInstance(poolType) as Components);
                }
                return(value);
            }
Example #5
0
        public void Connect()
        {
            if (_model.EngineEmbedControl == null)
            {
                Logger.Log("MInt Error: must set AppControl to embed");
                return;
            }

            Thread thread = new Thread(new ThreadStart(_model.T_EngineThread));

            thread.Start();
            Thread.Sleep(10);
            while (Engine.getInstance().GetIsInited() == false)
            {
                Thread.Sleep(1);
            }

            //prep engine for editor mode
            Engine.getInstance().RegisterEditorMode();
            //EditorSubsystemManaged.getInstance().RegisterTick();

            _model.EngineEmbedControl.Recreate();

            //generate component type list
            ComponentTypes.Clear();
            var lListOfBs = (from lAssembly in AppDomain.CurrentDomain.GetAssemblies()
                             from lType in lAssembly.GetTypes()
                             where typeof(MochaInterface.Component).IsAssignableFrom(lType)
                             select lType).ToList();

            foreach (Type t in lListOfBs)
            {
                if (t != typeof(MochaInterface.Component))
                {
                    ComponentTypes.Add(t.Name);
                }
            }

            //run roaster
            Thread roasterThread = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    if (EngineManagerViewModel.instance.BusyMessage == null)    //don't run roaster if another operation is pending
                    {
                        //start up the roaster, wait for it to idle, output it's info to the log
                        ProcessStartInfo startInfo       = new ProcessStartInfo();
                        startInfo.FileName               = "Roaster.exe";
                        startInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                        startInfo.CreateNoWindow         = true;
                        startInfo.UseShellExecute        = false;
                        startInfo.RedirectStandardOutput = true;
                        try
                        {
                            using (Process roastProc = System.Diagnostics.Process.Start(startInfo))
                            {
                                Thread.Sleep(1000);
                                if (roastProc.HasExited == false)
                                {
                                    EngineManagerViewModel.instance.BusyMessage = "... Roasting New Assets ...";
                                    roastProc.WaitForExit();
                                    EngineManagerViewModel.instance.BusyMessage = null;
                                }
                                using (StreamReader reader = roastProc.StandardOutput)
                                {
                                    string result = reader.ReadToEnd();
                                    if (!String.IsNullOrWhiteSpace(result))
                                    {
                                        Logger.Log(result);
                                    }
                                }
                            }
                        }
                        catch (Win32Exception)
                        {
                            //roaster was not found
                            Console.WriteLine("Roaster.exe not found - assets will not be reloaded.");
                            Thread.CurrentThread.Abort();
                        }
                    }
                    Thread.Sleep(ROASTERINTERVAL);
                }
            }));

            roasterThread.Start();

            IsConnected = true;
        }