public bool TryGetCoord(DynamicValueContext context, out Coord coord)
        {
            CastTargetContext castTargetContext = context as CastTargetContext;

            if (castTargetContext != null)
            {
                Target target = castTargetContext.GetTarget(1);
                if (target.type == Target.Type.Coord)
                {
                    coord = target.coord;
                    return(true);
                }
            }
            coord = default(Coord);
            return(false);
        }
Пример #2
0
        public bool TryGetEntity <T>(DynamicValueContext context, out T entity) where T : class, IEntity
        {
            CastTargetContext castTargetContext = context as CastTargetContext;

            if (castTargetContext != null)
            {
                Target target = castTargetContext.GetTarget(0);
                if (target.type == Target.Type.Entity)
                {
                    IEntity entity2 = target.entity;
                    if (entity2 is T)
                    {
                        entity = (T)entity2;
                        return(true);
                    }
                }
            }
            entity = null;
            return(false);
        }
        public bool TryGetEntity <T>(DynamicValueContext context, out T entity) where T : class, IEntity
        {
            CastTargetContext castTargetContext = context as CastTargetContext;

            if (castTargetContext != null)
            {
                Target target = castTargetContext.GetTarget(1);
                if (target.type == Target.Type.Entity)
                {
                    T val = target.entity as T;
                    if (val != null)
                    {
                        entity = val;
                        return(true);
                    }
                }
            }
            entity = null;
            return(false);
        }
Пример #4
0
        public IEnumerable <IEntity> Filter(IEnumerable <IEntity> entities, DynamicValueContext context)
        {
            CastTargetContext castTargetContext = context as CastTargetContext;

            if (castTargetContext != null)
            {
                Target target = castTargetContext.GetTarget(m_castTargetIndex);
                if (target.type == Target.Type.Entity)
                {
                    IEntity entity = target.entity;
                    foreach (IEntity entity2 in entities)
                    {
                        if (entity == entity2)
                        {
                            yield return(entity);

                            yield break;
                        }
                    }
                }
            }
        }