Example #1
0
        public T SetSystem <T>(T system, ExecutionType execType, int layer = 0) where T : EntitySystem
        {
            system.World = world;

            if (systems.ContainsKey(typeof(T)))
            {
                systems[typeof(T)].Add((EntitySystem)system);
            }
            else
            {
                systems[typeof(T)] = new List <EntitySystem>();
                systems[typeof(T)].Add((EntitySystem)system);
            }


            if (execType == ExecutionType.Draw)
            {
                if (!Drawlayers.ContainsKey(layer))
                {
                    Drawlayers[layer] = new Bag <EntitySystem>();
                }

                Bag <EntitySystem> drawBag = Drawlayers[layer];
                if (drawBag == null)
                {
                    drawBag = Drawlayers[layer] = new Bag <EntitySystem>();
                }
                if (!drawBag.Contains((EntitySystem)system))
                {
                    drawBag.Add((EntitySystem)system);
                }
                Drawlayers = (from d in Drawlayers orderby d.Key ascending select d).ToDictionary(pair => pair.Key, pair => pair.Value);
            }
            else if (execType == ExecutionType.Update)
            {
                if (!Updatelayers.ContainsKey(layer))
                {
                    Updatelayers[layer] = new Bag <EntitySystem>();
                }

                Bag <EntitySystem> updateBag = Updatelayers[layer];
                if (updateBag == null)
                {
                    updateBag = Updatelayers[layer] = new Bag <EntitySystem>();
                }
                if (!updateBag.Contains((EntitySystem)system))
                {
                    updateBag.Add((EntitySystem)system);
                }
                Updatelayers = (from d in Updatelayers orderby d.Key ascending select d).ToDictionary(pair => pair.Key, pair => pair.Value);
            }
            if (!mergedBag.Contains((EntitySystem)system))
            {
                mergedBag.Add((EntitySystem)system);
            }
            system.SystemBit = SystemBitManager.GetBitFor(system);

            return((T)system);
        }
Example #2
0
        public T SetSystem <T>(T system, ExecutionType execType, int layer = 0) where T : EntitySystem
        {
            system.World = world;

            systems.Add(typeof(T), (EntitySystem)system);

            if (execType == ExecutionType.Draw)
            {
                if (!Drawlayers.ContainsKey(layer))
                {
                    Drawlayers[layer] = new Bag <EntitySystem>();
                }

                Bag <EntitySystem> drawBag = Drawlayers[layer];
                if (drawBag == null)
                {
                    drawBag = Drawlayers[layer] = new Bag <EntitySystem>();
                }
                if (!drawBag.Contains((EntitySystem)system))
                {
                    drawBag.Add((EntitySystem)system);
                }
            }
            else if (execType == ExecutionType.Update)
            {
                if (!Updatelayers.ContainsKey(layer))
                {
                    Updatelayers[layer] = new Bag <EntitySystem>();
                }

                Bag <EntitySystem> updateBag = Updatelayers[layer];
                if (updateBag == null)
                {
                    updateBag = Updatelayers[layer] = new Bag <EntitySystem>();
                }
                if (!updateBag.Contains((EntitySystem)system))
                {
                    updateBag.Add((EntitySystem)system);
                }
            }
            if (!mergedBag.Contains((EntitySystem)system))
            {
                mergedBag.Add((EntitySystem)system);
            }
            system.SystemBit = SystemBitManager.GetBitFor(system);

            return((T)system);
        }