Ejemplo n.º 1
0
        public override void ComposeSensorTargetSet(GameActor gameActor, Reflex reflex)
        {
            List <Filter> filters = reflex.Filters;

            foreach (SensorTarget target in sightSet)
            {
                // Don't see things we are holding.
                if (target.GameThing == gameActor.ThingBeingHeldByThisActor)
                {
                    continue;
                }

                bool match = true;
                bool cursorFilterPresent = false;

                for (int indexFilter = 0; indexFilter < filters.Count; indexFilter++)
                {
                    Filter filter = filters[indexFilter] as Filter;
                    ClassificationFilter cursorFilter = filter as ClassificationFilter;
                    if (cursorFilter != null && cursorFilter.classification.IsCursor)
                    {
                        cursorFilterPresent = true;
                    }

                    if (!filter.MatchTarget(reflex, target))
                    {
                        match = false;
                        break;
                    }
                }
                if (match)
                {
                    if (!target.Classification.IsCursor || cursorFilterPresent)
                    {
                        reflex.targetSet.Add(target);
                    }
                }
            }


            reflex.targetSet.Action = TestObjectSet(reflex);

            if (reflex.targetSet.Action)
            {
                SensorTarget nearest = reflex.targetSet.Nearest;
                if (nearest != null)
                {
                    gameActor.AddSightLine(nearest.GameThing);
                }
            }
            else
            {
                reflex.targetSet.Clear();
            }
        }   // end of ComposeSensorTargetSet()