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);
        }
        public override void ComposeSensorTargetSet(GameActor gameActor, Reflex reflex)
        {
            List <Filter> filters = reflex.Filters;

            // add normal sightSet of items to the targetset
            //
            senseSetIter.Reset();
            while (senseSetIter.MoveNext())
            {
                SensorTarget target = (SensorTarget)senseSetIter.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);
                    }
                }
            }

            if (ListeningForMusic(filters))
            {
                if (HearMusic(filters))
                {
                    SensorTarget sensorTarget = SensorTargetSpares.Alloc();
                    sensorTarget.Init(gameActor, Vector3.UnitZ, 0.0f);
                    reflex.targetSet.AddOrFree(sensorTarget);
                }
            }

            reflex.targetSet.Action = TestObjectSet(reflex);
            if (reflex.targetSet.Action)
            {
                foreach (SensorTarget targ in reflex.targetSet)
                {
                    gameActor.AddSoundLine(targ.GameThing);
                }
            }
        }
Example #3
0
        public override void ComposeSensorTargetSet(GameActor gameActor, Reflex reflex)
        {
            List <Filter> filters = reflex.Filters;

            // add normal senseSet of items to the targetset
            //
            senseSetIter.Reset();
            while (senseSetIter.MoveNext())
            {
                SensorTarget target = (SensorTarget)senseSetIter.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.Finialize();
            if (reflex.targetSet.Nearest == null)
            {
                /// Didn't come up with anything, try searching our memory
                if (SearchMemory(gameActor, reflex))
                {
                    /// Find nearest again, but don't check LOS. This matches old
                    /// behavior, which assumes that if we remember it, we could see it.
                    reflex.targetSet.Finialize();
                }
            }
            else
            {
                /// We got something, memorize it.
                gameActor.Brain.Memory.MemorizeThing(reflex.targetSet.Nearest.GameThing);
            }
            reflex.targetSet.Action = TestObjectSet(reflex);
        }   // end of ComposeSensorTargetSet()
Example #4
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);
        }
        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);
        }