示例#1
0
        public void Send()
        {
            if (Sending)
            {
                return;
            }

            Sending = true;

            VitaNexCore.TryCatch(
                () =>
            {
                Update();

                if (Count == 0 || this[0] == null)
                {
                    return;
                }

                Processing = true;

                CurrentQueue = this[0];
                CurrentQueue.Process();

                OnSend();
            },
                VitaNexCore.ToConsole);
        }
示例#2
0
文件: BaseFX.cs 项目: zerodowned/Core
 private void InternalMoveNext(TQueue next)
 {
     CurrentQueue = next;
     CurrentQueue.Process();
 }
示例#3
0
        public void Update()
        {
            this.Free(true);

            if (Effects == null || Effects.Length == 0)
            {
                return;
            }

            var points = GetTargetPoints(CurrentProcess);

            if (points == null || points.Length == 0)
            {
                return;
            }

            Capacity = points.Length;

            this.SetAll(i => null);

            for (int i = 0; i < points.Length; i++)
            {
                var list = points[i];

                if (list == null || list.Length == 0)
                {
                    continue;
                }

                var fx = new TEffectInfo[list.Length][];

                fx.SetAll(fxi => new TEffectInfo[Effects.Length]);

                Parallel.For(
                    0,
                    list.Length,
                    index =>
                {
                    Point3D p = list[index];

                    int pIndex = 0;

                    for (int ei = 0; ei < Effects.Length; ei++)
                    {
                        TEffectInfo e = CloneEffectInfo(Effects[ei]);

                        if (e == null)
                        {
                            continue;
                        }

                        e.QueueIndex   = index;
                        e.ProcessIndex = pIndex++;

                        e.Source = new Entity(Serial.Zero, p, Map);
                        e.Map    = Map;

                        if (EnableMutate)
                        {
                            MutateEffect(e);
                        }

                        fx[index][ei] = e;
                    }
                });

                TQueue q = CreateEffectQueue(fx.Combine());

                if (q.Mutator == null && EffectMutator != null)
                {
                    q.Mutator = EffectMutator;
                }

                if (q.Handler == null && EffectHandler != null)
                {
                    q.Handler = EffectHandler;
                }

                this[i] = q;
            }

            RemoveAll(l => l == null);

            this.Free(false);

            if (Reversed)
            {
                Reverse();
            }

            int idx = 0;

            foreach (TQueue cur in this)
            {
                if (++idx >= Count)
                {
                    cur.Callback = () =>
                    {
                        if (Callback != null)
                        {
                            Callback();
                        }

                        Sending = false;

                        if (++CurrentProcess <= Repeat)
                        {
                            Timer.DelayCall(Interval, Send);
                        }
                        else
                        {
                            CurrentProcess = 0;
                            Processing     = false;
                        }

                        this.Free(true);
                    };

                    break;
                }

                TQueue next = this[idx];

                cur.Callback = () =>
                {
                    Processing = true;

                    Timer.DelayCall(
                        Interval,
                        () =>
                    {
                        CurrentQueue = next;
                        CurrentQueue.Process();
                    });
                };
            }

            OnUpdated();
        }