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

            SensorTargetSet.Enumerator senseSetIter = (SensorTargetSet.Enumerator)gameActor.GivenSet.GetEnumerator();
            senseSetIter.Reset();
            while (senseSetIter.MoveNext())
            {
                SensorTarget target = (SensorTarget)senseSetIter.Current;

                bool match = true;
                for (int indexFilter = 0; indexFilter < filters.Count; indexFilter++)
                {
                    Filter filter = filters[indexFilter] as Filter;
                    if (!filter.MatchTarget(reflex, target))
                    {
                        match = false;
                        break;
                    }
                }
                if (match)
                {
                    reflex.targetSet.Add(target);
                }
            }

            reflex.targetSet.Action = TestObjectSet(reflex);
        }
Example #2
0
        public void Add(SensorTargetSet otherSet)
        {
            if (otherSet.Count > 0)
            {
                SensorTargetSet.Enumerator setIter = (SensorTargetSet.Enumerator)otherSet.GetEnumerator();

                while (setIter.MoveNext())
                {
                    Add(setIter.Current as SensorTarget);
                }
            }
        }
        public override void ComposeSensorTargetSet(GameActor gameActor, Reflex reflex)
        {
            List <Filter> filters = reflex.Filters;

            SensorTargetSet.Enumerator beamedSetIter = gameActor.BeamedSetIter;
            beamedSetIter.Reset();
            while (beamedSetIter.MoveNext())
            {
                SensorTarget target = (SensorTarget)beamedSetIter.Current;

                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);
        }
Example #4
0
 public TouchSensor()
 {
     senseSetIter = (SensorTargetSet.Enumerator)senseSet.GetEnumerator();
 }
 public EndofPathSensor()
 {
     senseSetIter = (SensorTargetSet.Enumerator)senseSet.GetEnumerator();
 }
Example #6
0
 public ScanSensor()
 {
     WantThingUpdate = true;
     category        = Sensor.Category.Scan;
     senseSetIter    = (SensorTargetSet.Enumerator)senseSet.GetEnumerator();
 }
Example #7
0
 public HoldingObjectSensor()
 {
     senseSetIter = (SensorTargetSet.Enumerator)senseSet.GetEnumerator();
 }
 public MissileHitSensor()
 {
     senseSetIter = (SensorTargetSet.Enumerator)senseSet.GetEnumerator();
 }
        public override void ComposeSensorTargetSet(GameActor gameActor, Reflex reflex)
        {
            List <Filter> filters = reflex.Filters;

            // If we have a "me" filter we need to look at the ShooterHitSet to
            // see if anything hit us.
            if (reflex.Data.HasTile("filter.me"))
            {
                SensorTargetSet.Enumerator shooterSetIter = (SensorTargetSet.Enumerator)gameActor.ShooterHitSet.GetEnumerator();
                shooterSetIter.Reset();
                while (shooterSetIter.MoveNext())
                {
                    SensorTarget target = (SensorTarget)shooterSetIter.Current;

                    // Filtering doesn't make much sense since the "target" is me.  What
                    // I really want to filter on are the characteristics of the shooter.
                    // Which means I need to know the shooter.
                    SensorTarget shooter = SensorTargetSpares.Alloc();
                    shooter.Init(target.Shooter, target.Direction, target.Range);
                    shooter.Tag = target.Tag;

                    bool match = true;
                    for (int indexFilter = 0; indexFilter < filters.Count; indexFilter++)
                    {
                        Filter filter = filters[indexFilter] as Filter;
                        // Ignore me filter since it shouldn't be possible to shoot yourself.
                        if (filter.upid != "filter.me")
                        {
                            if (!filter.MatchTarget(reflex, shooter))
                            {
                                match = false;
                                break;
                            }
                        }
                    }
                    if (match)
                    {
                        reflex.targetSet.Add(target);
                    }
                }
            }
            else
            {
                // add sensorSet of items to the targetset
                senseSetIter.Reset();
                while (senseSetIter.MoveNext())
                {
                    SensorTarget target = (SensorTarget)senseSetIter.Current;

                    bool match = true;
                    for (int indexFilter = 0; indexFilter < filters.Count; indexFilter++)
                    {
                        Filter filter = filters[indexFilter] as Filter;
                        if (!filter.MatchTarget(reflex, target))
                        {
                            match = false;
                            break;
                        }
                    }
                    if (match)
                    {
                        reflex.targetSet.Add(target);

                        // Until we enable payloads on the 'shot hit' reflex, leave the target in the hit set
                        // so that it will have the payload from the shoot reflex applied to it.
                        //gameActor.MissileHitSet.Remove(target.GameThing);

                        MissileHitTargetParam param = target.Tag as MissileHitTargetParam;

                        SetUpShotDamage(reflex, param);
                    }
                }
            }

            reflex.targetSet.Action = TestObjectSet(reflex);
        }
 public SoundSensor()
 {
     senseSetIter = (SensorTargetSet.Enumerator)senseSet.GetEnumerator();
 }