public void Add(string key, ICacheDrawItem cmd, object state, float duration = 5.0f, float before = 0f, float after = 0f)
        {
            if (duration < 0 || after < 0 || before < 0)
            {
                return;
            }

            if (HasKey(key))
            {
                return;
            }

            float     killTime = before + duration + after;
            DateTime  n        = DateTime.Now;
            CacheItem item     = new CacheItem
            {
                cmd           = cmd,
                state         = state,
                StartDrawTime = n.AddSeconds(before),
                EndDrawTime   = n.AddSeconds(before + duration),
                ClearTime     = n.AddSeconds(killTime)
            };

            data[key] = item;
        }
Example #2
0
        public override void Drawing(DrawingContext ctx, GameObject obj)
        {
            foreach (var c in Commands)
            {
                ICacheDrawItem cacheDrawItem = c as ICacheDrawItem;
                if (cacheDrawItem == null)
                {
                    c.Drawing(ctx, obj);
                    continue;
                }

                HandleCacheCommand(cacheDrawItem, ctx, obj);
            }
        }
Example #3
0
        public void HandleCacheCommand(ICacheDrawItem cmd, DrawingContext ctx, GameObject obj)
        {
            if (!cmd.CanDrawing(ctx, obj))
            {
                return;
            }

            string subKey = cmd.Key(ctx, obj);
            string k      = baseKey + subKey;

            if (cacheManager.HasKey(k))
            {
                return;
            }

            object s = cmd.State(ctx, obj);

            cacheManager.Add(k, cmd, s, Duration, Before, After);
        }