示例#1
0
 public IEnumerable <IEntity> Filter(IEnumerable <IEntity> entities, DynamicValueContext context)
 {
     if (m_reference.TryGetEntity(context, out IEntityWithOwner entity))
     {
         int referenceOwnerId = entity.ownerId;
         foreach (IEntity entity2 in entities)
         {
             IEntityWithOwner entityWithOwner = entity2 as IEntityWithOwner;
             if (entityWithOwner != null && entityWithOwner.ownerId == referenceOwnerId == isIdentical)
             {
                 yield return(entity2);
             }
         }
     }
 }
        public override IEnumerable <IEntity> EnumerateEntities(DynamicValueContext context)
        {
            DynamicValueFightContext fightContext = context as DynamicValueFightContext;

            if (fightContext != null)
            {
                List <int> ownerIds = ListPool <int> .Get(2);

                foreach (IEntity item in m_selector.EnumerateEntities(context))
                {
                    IEntityWithOwner entityWithOwner = item as IEntityWithOwner;
                    if (entityWithOwner != null && !ownerIds.Contains(entityWithOwner.ownerId))
                    {
                        ownerIds.Add(entityWithOwner.ownerId);
                        if (fightContext.fightStatus.TryGetEntity(entityWithOwner.ownerId, out IEntity entityStatus))
                        {
                            yield return(entityStatus);
                        }
                    }
                }
                ListPool <int> .Release(ownerIds);
            }
        }
        public IEnumerable <Target> EnumerateTargets(DynamicValueContext context)
        {
            int casterId = -1;

            foreach (IEntity item in EnumerateEntities(context))
            {
                if (!item.HasProperty(PropertyId.Untargetable))
                {
                    yield return(new Target(item));
                }
                else
                {
                    if (casterId == -1)
                    {
                        casterId = 0;
                        DynamicValueFightContext dynamicValueFightContext = context as DynamicValueFightContext;
                        if (dynamicValueFightContext == null)
                        {
                            Log.Warning("Selector " + GetType().Name + " tried to retrieve caster but wasn't given a compatible context.", 47, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\TargetSelectors\\ISelectorForCast.cs");
                            continue;
                        }
                        if (!dynamicValueFightContext.fightStatus.TryGetEntity(dynamicValueFightContext.playerId, out PlayerStatus entityStatus))
                        {
                            Log.Warning("Selector " + GetType().Name + " tried to retrieve caster but could not find it.", 41, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\TargetSelectors\\ISelectorForCast.cs");
                            continue;
                        }
                        casterId = entityStatus.id;
                    }
                    IEntityWithOwner entityWithOwner = item as IEntityWithOwner;
                    if (entityWithOwner != null && entityWithOwner.ownerId == casterId)
                    {
                        yield return(new Target(item));
                    }
                }
            }
        }