예제 #1
0
        public static T Create <T, A>(AComponent parent, A a) where T : AComponent
        {
            var component = Generate <T>(parent);

            App.Inst.EventSystem.Awake(component, a);
            return(component);
        }
예제 #2
0
        public static T Create <T, A, B, C, D>(AComponent parent, A a, B b, C c, D d) where T : AComponent
        {
            var component = Generate <T>(parent);

            App.Inst.EventSystem.Awake(component, a, b, c, d);
            return(component);
        }
예제 #3
0
        public void Destroy(AComponent component)
        {
            var iDestroySystems = this.destroySystems[component.GetType()];

            if (iDestroySystems == null)
            {
                return;
            }

            foreach (var iDestroySystem in iDestroySystems)
            {
                if (iDestroySystem == null)
                {
                    continue;
                }

                try
                {
                    iDestroySystem.Run(component);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
예제 #4
0
        public void Awake <A, B, C, D>(AComponent component, A a, B b, C c, D d)
        {
            var iAwakeSystems = this.awakeSystems[component.GetType()];

            if (iAwakeSystems == null)
            {
                return;
            }

            foreach (var aAwakeSystem in iAwakeSystems)
            {
                if (!(aAwakeSystem is IAwakeRun <A, B, C, D> iAwake))
                {
                    continue;
                }
                try
                {
                    iAwake.Run(component, a, b, c, d);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
예제 #5
0
        public void Awake(AComponent component)
        {
            var iAwakeSystems = this.awakeSystems[component.GetType()];

            if (iAwakeSystems == null)
            {
                return;
            }

            foreach (var aAwakeSystem in iAwakeSystems)
            {
                if (!(aAwakeSystem is IAwakeRun iAwake))
                {
                    continue;
                }
                try
                {
                    iAwake.Run(component);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
예제 #6
0
        public AComponent Get(long id)
        {
            AComponent component = null;

            this.allComponents.TryGetValue(id, out component);
            return(component);
        }
예제 #7
0
        public void AddComponent(AComponent component)
        {
            this.allComponents.Add(component.Id, component);

            Type type = component.GetType();

            if (this.loadSystems.ContainsKey(type))
            {
                this.loaders.Enqueue(component.Id);
            }

            if (this.updateSystems.ContainsKey(type))
            {
                this.updates.Enqueue(component.Id);
            }

            if (this.startSystems.ContainsKey(type))
            {
                this.starts.Enqueue(component.Id);
            }

            if (this.lateUpdateSystems.ContainsKey(type))
            {
                this.lateUpdates.Enqueue(component.Id);
            }
        }
예제 #8
0
        private static T Generate <T>(AComponent parent) where T : AComponent
        {
            var type = typeof(T);

            var component = (T)Activator.CreateInstance(type);

            component.Id     = IdGenerateHelper.GenerateComponentId();
            component.Parent = parent;

            App.Inst.EventSystem.AddComponent(component);
            return(component);
        }