Beispiel #1
0
        public virtual void OnEnable()
        {
            if (state.enabled || state.requireStarter ||
                state.requireActorParent)
            {
                return;
            }

            state.released = false;
            state.enabled  = true;


            if (ProcessingSignals.TryAddToGlobal(this))
            {
                if (signals == null)
                {
                    signals = new ProcessingSignals();
                }

                signals.Add(this);
            }


            ProcessingUpdate.Default.Add(this);

            HandleEnable();
        }
Beispiel #2
0
        protected virtual void Awake()
        {
            selfTransform = transform;

            state.enabled     = false;
            state.initialized = false;

            conditionSignals = ProcessingSignals.Check(this);


            if (Starter.initialized == false)
            {
                state.requireStarter = true;
                return;
            }


            if (state.requireActorParent)
            {
                actorParent = GetComponentInParent <Actor>();
            }


            Setup();
            state.initialized = true;
        }
Beispiel #3
0
//TODO: refactor

        public override void OnDisable()
        {
            if (Toolbox.isQuittingOrChangingScene() || state.released ||
                !state.enabled)
            {
                return;
            }

            state.enabled  = false;
            state.disabled = true;
            ProcessingEntities.Default.CheckGroups(id, false);

            var len = compositionNoTags.Count;
            int i;

            for (i = 0; i < len; i++)
            {
                Behavior.behaviors[compositionNoTags[i]].RemoveElement(id);
            }


            len = compositions != null ? compositions.Count : -1;

            for (i = 0; i < len; i++)
            {
                var composition = compositions[i];
                if (composition.changed || !composition.Contain(tags))
                {
                    continue;
                }
                composition.changed = true;
                var l = composition.ids.Count;
                for (var j = 0; j < l; j++)
                {
                    Behavior.behaviors[composition.ids[j]].RemoveElement(id);
                }

                l = composition.delegates.Count;
                for (var j = 0; j < l; j++)
                {
                    composition.delegates[j](false);
                }
            }


            if (ProcessingSignals.TryRemoveGlobal(this))
            {
                signals?.Remove(this);
            }


            ProcessingUpdate.Default.Remove(this);

            HandleDisable();
        }
Beispiel #4
0
        protected override void HandleReturnToPool()
        {
            ClearTagsAll();

            ProcessingEntities.Default.CheckGroups(id, false);

            var len = compositionNoTags.Count;
            int i;

            for (i = 0; i < len; i++)
            {
                Behavior.behaviors[compositionNoTags[i]].RemoveElement(id);
            }


            len = compositions != null ? compositions.Count : -1;

            for (i = 0; i < len; i++)
            {
                var composition = compositions[i];

                composition.changed = false;
                var l = composition.ids.Count;
                for (var j = 0; j < l; j++)
                {
                    Behavior.behaviors[composition.ids[j]].RemoveElement(id);
                }

                l = composition.delegates.Count;
                for (var j = 0; j < l; j++)
                {
                    composition.delegates[j](false);
                }
            }


            if (ProcessingSignals.TryRemoveGlobal(this))
            {
                signals?.Remove(this);
            }


            ProcessingUpdate.Default.Remove(this);

//            len = compositions != null ? compositions.Count : -1;
//
//            for (i = 0; i < len; i++)
//            {
//                compositions[i].changed = false;
//            }

            base.HandleReturnToPool();
        }
Beispiel #5
0
        protected void OnDestroy()
        {
            if (Toolbox.isQuittingOrChangingScene())
            {
                return;
            }
            prevID.Push(id);


            ProcessingEntities.Default.CheckGroups(id, false);

            var len = compositionNoTags.Count;
            int i;

            for (i = 0; i < len; i++)
            {
                Behavior.behaviors[compositionNoTags[i]].RemoveElement(id);
            }


            len = compositions != null ? compositions.Count : -1;

            for (i = 0; i < len; i++)
            {
                var composition = compositions[i];

                var l = composition.ids.Count;
                for (var j = 0; j < l; j++)
                {
                    Behavior.behaviors[composition.ids[j]].RemoveElement(id);
                }

                composition.delegates.Clear();
            }


            if (ProcessingSignals.TryRemoveGlobal(this))
            {
                signals?.Remove(this);
            }


            ProcessingUpdate.Default.Remove(this);


            compositionNoTags.Clear();
            compositions.Clear();
            tags?.Clear();
            signals?.Dispose();
            signals = null;
        }
Beispiel #6
0
        public virtual void OnDisable()
        {
            if (Toolbox.isQuittingOrChangingScene() || !state.enabled)
            {
                return;
            }

            state.enabled = false;


            if (ProcessingSignals.TryRemoveGlobal(this))
            {
                signals?.Remove(this);
            }


            ProcessingUpdate.Default.Remove(this);

            HandleDisable();
        }
Beispiel #7
0
 protected void BindSignals()
 {
     signals = new ProcessingSignals();
 }
Beispiel #8
0
 protected ProcessingBase()
 {
     ProcessingSystemAttributes.Setup(this);
     ProcessingGroupAttributes.Setup(this);
     ProcessingSignals.TryAddToGlobal(this);
 }
Beispiel #9
0
        public override void OnEnable()
        {
            if (state.enabled || state.requireStarter ||
                state.requireActorParent)
            {
                return;
            }


            if (state.disabled)
            {
                ProcessingEntities.Default.CheckGroups(id, true);
            }


            HandleEnable();
            state.released = false;
            state.disabled = false;
            state.enabled  = true;

            if (ProcessingSignals.TryAddToGlobal(this))
            {
                if (signals == null)
                {
                    signals = new ProcessingSignals();
                }

                signals.Add(this);
            }


            var len = compositionNoTags.Count;
            int i;

            for (i = 0; i < len; i++)
            {
                Behavior.behaviors[compositionNoTags[i]].AddElement(id);
            }


            len = compositions != null ? compositions.Count : -1;

            for (i = 0; i < len; i++)
            {
                var composition = compositions[i];

                if (composition.changed || !composition.Contain(tags))
                {
                    continue;
                }
                composition.changed = true;
                var l = composition.ids.Count;

                for (var j = 0; j < l; j++)
                {
                    Behavior.behaviors[composition.ids[j]].AddElement(id);
                }

                l = composition.delegates.Count;
                for (var j = 0; j < l; j++)
                {
                    composition.delegates[j](true);
                }
            }


            ProcessingUpdate.Default.Add(this);
        }