Ejemplo n.º 1
0
        public Invoker SetTicks(ulong value)
        {
            InvokerType oldType = Type;

            Type  = InvokerType.Ticks;
            Value = value;
            UpdateValues(Type != oldType);
            return(this);
        }
Ejemplo n.º 2
0
        public Invoker SetFrames(ulong value)
        {
            InvokerType oldType = Type;

            Type  = InvokerType.Frames;
            Value = value;
            UpdateValues(oldType != Type);
            return(this);
        }
Ejemplo n.º 3
0
        public Invoker SetTime(TimeSpan value)
        {
            InvokerType oldType = Type;

            Type  = InvokerType.Delay;
            Value = (ulong)value.Ticks;
            UpdateValues(oldType != Type);
            return(this);
        }
Ejemplo n.º 4
0
        public Invoker SetTicks(ulong value, ulong repeatedValue)
        {
            InvokerType oldType = Type;

            Type          = InvokerType.Ticks;
            Value         = value;
            RepeatedValue = repeatedValue;
            IsRepeated    = true;
            UpdateValues(oldType != Type);
            return(this);
        }
Ejemplo n.º 5
0
        public Invoker SetTime(TimeSpan value, TimeSpan repeatedValue)
        {
            InvokerType oldType = Type;

            Type          = InvokerType.Delay;
            Value         = (ulong)value.Ticks;
            RepeatedValue = (ulong)repeatedValue.Ticks;
            IsRepeated    = true;
            UpdateValues(oldType != Type);
            return(this);
        }
Ejemplo n.º 6
0
        public UnrealBinaryHeapEx <Invoker> GetCollection(InvokerType type)
        {
            switch (type)
            {
            case InvokerType.Delay: return(delayInvokers);

            case InvokerType.Ticks: return(ticksInvokers);

            case InvokerType.Frames: return(framesInvokers);
            }
            return(null);
        }
Ejemplo n.º 7
0
        public MethodInvoker GetInvoker(string name, int argsCount, InvokerType type)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var key = CacheKey(type, name, argsCount);

            if (InvokerCache.TryGetValue(key, out MethodInvoker invoker))
            {
                return(invoker);
            }

            var method = GetFilterMethod(key);

            if (method == null)
            {
                return(null);
            }

            return(InvokerCache[key] = TypeExtensions.GetInvokerToCache(method));
        }
Ejemplo n.º 8
0
 private string CacheKey(InvokerType type, string methodName, int argsCount) =>
 type + "::" + methodName.ToLower() + "`" + argsCount;
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
 public MethodInvoker GetInvoker(string name, int argsCount, InvokerType type) => type == InvokerType.Filter
     ? GetInvoker(name, argsCount)
     : type == InvokerType.ContextFilter
         ? GetContextFilterInvoker(name, argsCount)
         : GetContextBlockInvoker(name, argsCount);
Ejemplo n.º 11
0
 public virtual IInvoker Build(InvokerType type)
 {
     return(invokers[type]);
 }
Ejemplo n.º 12
0
 private string CacheKey(InvokerType type, string methodName, int argsCount) =>
 $"{type}::{methodName.ToLower()}`{argsCount}";
Ejemplo n.º 13
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);
        }