Beispiel #1
0
        public void Add(ObjectDisposer disposer)
        {
            IObjectEventFacade objectSystem;

            if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
            {
                return;
            }

            if (objectSystem is ILoad)
            {
                this.loaders.Enqueue(disposer);
            }

            if (objectSystem is IUpdate)
            {
                this.updates.Enqueue(disposer);
            }

            if (objectSystem is IStart)
            {
                this.starts.Enqueue(disposer);
            }

            if (objectSystem is ILateUpdate)
            {
                this.lateUpdates.Enqueue(disposer);
            }
        }
Beispiel #2
0
        private void Start()
        {
            unique.Clear();
            while (this.starts.Count > 0)
            {
                ObjectDisposer disposer = this.starts.Dequeue();

                if (!this.unique.Add(disposer))
                {
                    continue;
                }

                IObjectEventFacade objectEvent;

                if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent))
                {
                    continue;
                }
                IStart iStart = objectEvent as IStart;
                if (iStart == null)
                {
                    continue;
                }
                objectEvent.Set(disposer);
                iStart.Start();
            }
        }
Beispiel #3
0
        public void Update()
        {
            this.Start();

            unique.Clear();
            while (this.updates.Count > 0)
            {
                ObjectDisposer disposer = this.updates.Dequeue();
                if (disposer.IsDispose)
                {
                    continue;
                }

                if (!this.unique.Add(disposer))
                {
                    continue;
                }

                IObjectEventFacade objectEvent;

                if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent))
                {
                    continue;
                }

                this.updates2.Enqueue(disposer);

                IUpdate iUpdate = objectEvent as IUpdate;
                if (iUpdate == null)
                {
                    continue;
                }
                objectEvent.Set(disposer);
                try
                {
                    iUpdate.Update();
                }
                catch (Exception e)
                {
                    Logger.LogError(e.ToString());
                }
            }

            ObjectHelper.Swap(ref this.updates, ref this.updates2);
        }
Beispiel #4
0
        public void Awake(ObjectDisposer disposer)
        {
            this.Add(disposer);
            IObjectEventFacade objectEvent;

            if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent))
            {
                return;
            }
            IAwake iAwake = objectEvent as IAwake;

            if (iAwake == null)
            {
                return;
            }
            objectEvent.Set(disposer);
            iAwake.Awake();
        }
Beispiel #5
0
        public void Load()
        {
            unique.Clear();
            while (this.loaders.Count > 0)
            {
                ObjectDisposer disposer = this.loaders.Dequeue();
                if (disposer.Id == 0)
                {
                    continue;
                }

                if (!this.unique.Add(disposer))
                {
                    continue;
                }

                IObjectEventFacade objectEvent;

                if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent))
                {
                    continue;
                }

                this.loaders2.Enqueue(disposer);

                ILoad iLoad = objectEvent as ILoad;
                if (iLoad == null)
                {
                    continue;
                }
                objectEvent.Set(disposer);
                try
                {
                    iLoad.Load();
                }
                catch (Exception e)
                {
                    Logger.LogError(e.ToString());
                }
            }

            ObjectHelper.Swap(ref this.loaders, ref this.loaders2);
        }
Beispiel #6
0
        public void Awake <P1, P2, P3>(ObjectDisposer disposer, P1 p1, P2 p2, P3 p3)
        {
            this.Add(disposer);

            IObjectEventFacade objectEvent;

            if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent))
            {
                throw new Exception($"{disposer.GetType().Name} not found awake3");
            }
            IAwake <P1, P2, P3> iAwake = objectEvent as IAwake <P1, P2, P3>;

            if (iAwake == null)
            {
                throw new Exception($"{disposer.GetType().Name} not found awake3");
            }
            objectEvent.Set(disposer);
            iAwake.Awake(p1, p2, p3);
        }