예제 #1
0
        private static Invoker StartInvoker(object obj, InvokerHandlerType handlerType, Delegate handler, InvokerType type,
                                            ulong value, ulong repeatValue, CoroutineGroup group = CoroutineGroup.Tick, bool pool = PoolByDefault)
        {
            IntPtr  world    = IntPtr.Zero;
            UObject ownerObj = obj as UObject;

            if (ownerObj != null)
            {
                world = Native_UObject.GetWorld(ownerObj.Address);
                Debug.Assert(world != IntPtr.Zero, "UObject invokers must be objects with a UWorld reference (e.g. AActor) - " +
                             "this is so that the invoker can be stopped when the world is destroyed.");
            }

            Invoker invoker = pool ? InvokerPool.GetObject() : new Invoker();

            invoker.OwnerWorld = world;
            invoker.Owner      = obj;
            invoker.SetHandler(handlerType, handler);
            switch (type)
            {
            case InvokerType.Delay:
                TimeSpan time       = TimeSpan.FromTicks((long)value);
                TimeSpan repeatTime = TimeSpan.FromTicks((long)repeatValue);
                if (repeatTime != default(TimeSpan))
                {
                    invoker.SetTime(time, repeatTime);
                }
                else
                {
                    invoker.SetTime(time);
                }
                break;

            case InvokerType.Ticks:
                if (repeatValue != default(ulong))
                {
                    invoker.SetTicks(value, repeatValue);
                }
                else
                {
                    invoker.SetTicks(value);
                }
                break;

            case InvokerType.Frames:
                if (repeatValue != default(ulong))
                {
                    invoker.SetFrames(value, repeatValue);
                }
                else
                {
                    invoker.SetFrames(value);
                }
                break;
            }
            invoker.SetGroup(group);
            invoker.Start();
            return(invoker);
        }
예제 #2
0
        internal void SetHandler(InvokerHandlerType handlerType, Delegate handler)
        {
            switch (handlerType)
            {
            case InvokerHandlerType.Default: SetHandler((InvokerHandler)handler); break;

            case InvokerHandlerType.WithInvoker: SetHandler((InvokerHandlerWithInvoker)handler); break;

            case InvokerHandlerType.WithObject: SetHandler((InvokerHandlerWithObject)handler); break;

            case InvokerHandlerType.WithObjectInvoker: SetHandler((InvokerHandlerWithObjectInvoker)handler); break;
            }
        }
예제 #3
0
        internal void Reset()
        {
            // There is a lot going on here. We probably don't need to reset everything.

            OnStopped = null;

            Running    = false;
            IsFirstRun = false;
            Tag        = null;
            TagId      = 0;

            OwnerWorld = IntPtr.Zero;
            Owner      = null;
            IsRepeated = false;
            Type       = default(InvokerType);
            Group      = default(CoroutineGroup);

            Value         = 0;
            RepeatedValue = 0;

            HasStopAfterValue = false;
            stopAfterValue    = 0;
            stopAfterEndValue = 0;

            startingValue = 0;
            beginValue    = 0;
            EndValue      = 0;

            RepeatConstantTime = false;
            MaxCallCount       = 0;
            MaxTotalCallCount  = 0;
            totalCallCount     = 0;
            cancelInvoke       = false;

            if (collection != null)
            {
                collection.HeapRemove(this);
                collection = null;
            }
            collectionGroup = null;

            handlerType              = InvokerHandlerType.Default;
            handler                  = null;
            handlerWithObject        = null;
            handlerWithInvoker       = null;
            handlerWithObjectInvoker = null;

            invokersByUObjectIndex = -1;
            invokersByMethodIndex  = -1;
        }
예제 #4
0
        private void SetHandler(InvokerHandlerType handlerType,
                                InvokerHandler handler,
                                InvokerHandlerWithInvoker handlerWithInvoker,
                                InvokerHandlerWithObject handlerWithObject,
                                InvokerHandlerWithObjectInvoker handlerWithObjectInvoker)
        {
            RemoveInvokerFromInvokersByMethod();

            this.handlerType              = handlerType;
            this.handler                  = handler;
            this.handlerWithInvoker       = handlerWithInvoker;
            this.handlerWithObject        = handlerWithObject;
            this.handlerWithObjectInvoker = handlerWithObjectInvoker;

            AddInvokerToInvokersByMethod();
        }
예제 #5
0
        private static Invoker StartInvoker(object obj, InvokerHandlerType handlerType, Delegate handler, InvokerType type,
                                            ulong value, ulong repeatValue, CoroutineGroup group = CoroutineGroup.Tick, bool pool = PoolByDefault)
        {
            Invoker invoker = pool ? InvokerPool.GetObject() : new Invoker();

            invoker.SetHandler(handlerType, handler);
            switch (type)
            {
            case InvokerType.Delay:
                TimeSpan time       = TimeSpan.FromTicks((long)value);
                TimeSpan repeatTime = TimeSpan.FromTicks((long)repeatValue);
                if (repeatTime != default(TimeSpan))
                {
                    invoker.SetTime(time, repeatTime);
                }
                else
                {
                    invoker.SetTime(time);
                }
                break;

            case InvokerType.Ticks:
                if (repeatValue != default(ulong))
                {
                    invoker.SetTicks(value, repeatValue);
                }
                else
                {
                    invoker.SetTicks(value);
                }
                break;

            case InvokerType.Frames:
                if (repeatValue != default(ulong))
                {
                    invoker.SetFrames(value, repeatValue);
                }
                else
                {
                    invoker.SetFrames(value);
                }
                break;
            }
            invoker.SetGroup(group);
            invoker.Start();
            return(invoker);
        }