Exemple #1
0
        public override void TriggerLeave(PoolObjHandle <ActorRoot> src, ITrigger inTrigger)
        {
            GameObject inSrc   = (src == 0) ? null : src.handle.gameObject;
            GameObject inAtker = (inTrigger == null) ? null : inTrigger.GetTriggerObj();

            this.PlayAgeActionPrivate(AreaEventTrigger.EActTiming.Leave, inSrc, inAtker);
            AreaEventTrigger trigger = inTrigger as AreaEventTrigger;

            if (trigger != null)
            {
                AreaEventTrigger.STriggerContext context = trigger._inActors[src.handle.ObjID];
                RefParamOperator @operator = context.refParams[this];
                if (@operator != null)
                {
                    ListView <AGE.Action> refParamObject = @operator.GetRefParamObject <ListView <AGE.Action> >("TriggerActionAgeEnterDura");
                    if (refParamObject != null)
                    {
                        ListView <AGE.Action> .Enumerator enumerator = refParamObject.GetEnumerator();
                        while (enumerator.MoveNext())
                        {
                            enumerator.Current.Stop(false);
                        }
                    }
                }
            }
        }
        public override void TriggerLeave(PoolObjHandle <ActorRoot> src, ITrigger inTrigger)
        {
            int leaveUniqueId = base.LeaveUniqueId;

            if (leaveUniqueId > 0)
            {
                new BufConsumer(leaveUniqueId, src, new PoolObjHandle <ActorRoot>(null)).Use();
            }
            int enterUniqueId = base.EnterUniqueId;

            if ((base.bStopWhenLeaving && (enterUniqueId > 0)) && (inTrigger != null))
            {
                AreaEventTrigger trigger = inTrigger as AreaEventTrigger;
                if (trigger != null)
                {
                    AreaEventTrigger.STriggerContext context = trigger._inActors[src.handle.ObjID];
                    RefParamOperator @operator = context.refParams[this];
                    if (@operator != null)
                    {
                        ListView <string> view       = new ListView <string>();
                        GameObject[]      refObjList = base.RefObjList;
                        if (refObjList != null)
                        {
                            int length = refObjList.Length;
                            for (int i = 0; i < length; i++)
                            {
                                view.Add(string.Format("TriggerActionBuffTar_{0}", i));
                            }
                        }
                        if (base.bSrc)
                        {
                            view.Add("TriggerActionBuffSrc");
                        }
                        if (base.bAtker)
                        {
                            view.Add("TriggerActionBuffAtker");
                        }
                        ListView <string> .Enumerator enumerator = view.GetEnumerator();
                        while (enumerator.MoveNext())
                        {
                            string current = enumerator.Current;
                            if (!string.IsNullOrEmpty(current))
                            {
                                BuffFense refParamObject = @operator.GetRefParamObject <BuffFense>(current);
                                if (refParamObject != null)
                                {
                                    refParamObject.Stop();
                                }
                            }
                        }
                    }
                }
            }
        }
        private void UpdateLogicEnterLeave(int delta)
        {
            this._testToken++;
            int collidingActors = this.GetCollidingActors();
            int num             = 0;

            while (num < collidingActors && num < this.Capacity)
            {
                PoolObjHandle <ActorRoot> actor = this._actorTestCache[num];
                uint objID = actor.handle.ObjID;
                if (this._inActors.ContainsKey(objID))
                {
                    AreaEventTrigger.STriggerContext sTriggerContext = this._inActors.get_Item(objID);
                    sTriggerContext.token = this._testToken;
                    if (this.UpdateInterval > 0)
                    {
                        sTriggerContext.updateTimer -= delta;
                        if (sTriggerContext.updateTimer <= 0)
                        {
                            sTriggerContext.updateTimer = this.UpdateInterval;
                            this.DoActorUpdate(ref actor);
                        }
                    }
                    this._inActors.set_Item(objID, sTriggerContext);
                }
                else if (this.TriggerTimes <= 0 || this.m_triggeredCount < this.TriggerTimes)
                {
                    if (this.InActorCount + 1 >= this.Capacity && this.actionWhenFull == AreaEventTrigger.ActionWhenFull.Destroy)
                    {
                        this.DoSelfDeactivating();
                        return;
                    }
                    bool flag = false;
                    if (this.bTriggerByTeam)
                    {
                        if (this._inActorsCache == null)
                        {
                            this._inActorsCache = new Dictionary <uint, int>();
                        }
                        if (this._inActorsCache.ContainsKey(objID))
                        {
                            this._inActorsCache.set_Item(objID, this._testToken);
                        }
                        else
                        {
                            this._inActorsCache.Add(objID, this._testToken);
                            ReadonlyContext <PoolObjHandle <ActorRoot> > allHeroes = Singleton <GamePlayerCenter> .GetInstance().GetHostPlayer().GetAllHeroes();

                            bool flag2 = true;
                            for (int i = 0; i < allHeroes.Count; i++)
                            {
                                if (!this._inActorsCache.ContainsKey(allHeroes[i].handle.ObjID))
                                {
                                    flag2 = false;
                                    break;
                                }
                            }
                            if (flag2)
                            {
                                flag = true;
                            }
                        }
                    }
                    else
                    {
                        flag = true;
                    }
                    if (flag)
                    {
                        DictionaryView <TriggerActionBase, RefParamOperator> inRefParams = this.DoActorEnter(ref actor);
                        this._inActors.Add(actor.handle.ObjID, new AreaEventTrigger.STriggerContext(actor, this._testToken, inRefParams, this.UpdateInterval));
                        if (this.UpdateInterval > 0)
                        {
                            this.DoActorUpdate(ref actor);
                        }
                        if (++this.m_triggeredCount >= this.TriggerTimes && this.TriggerTimes > 0)
                        {
                            this.bDoDeactivating = this.bDeactivateSelf;
                        }
                    }
                }
                num++;
            }
            int num2 = 0;

            Dictionary <uint, AreaEventTrigger.STriggerContext> .Enumerator enumerator = this._inActors.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <uint, AreaEventTrigger.STriggerContext> current = enumerator.get_Current();
                if (current.get_Value().token != this._testToken)
                {
                    uint[] actorTormvCache = this._actorTormvCache;
                    int    num3            = num2++;
                    KeyValuePair <uint, AreaEventTrigger.STriggerContext> current2 = enumerator.get_Current();
                    actorTormvCache[num3] = current2.get_Key();
                }
            }
            for (int j = 0; j < num2; j++)
            {
                uint num4 = this._actorTormvCache[j];
                PoolObjHandle <ActorRoot> actor2 = this._inActors.get_Item(num4).actor;
                this.DoActorLeave(ref actor2);
                this._inActors.Remove(num4);
            }
            if (this._inActorsCache != null)
            {
                num2 = 0;
                Dictionary <uint, int> .Enumerator enumerator2 = this._inActorsCache.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    KeyValuePair <uint, int> current3 = enumerator2.get_Current();
                    if (current3.get_Value() != this._testToken)
                    {
                        uint[] actorTormvCache2           = this._actorTormvCache;
                        int    num5                       = num2++;
                        KeyValuePair <uint, int> current4 = enumerator2.get_Current();
                        actorTormvCache2[num5] = current4.get_Key();
                    }
                }
                for (int k = 0; k < num2; k++)
                {
                    this._inActorsCache.Remove(this._actorTormvCache[k]);
                }
            }
        }