Пример #1
0
        public override ProgrammingElement Clone()
        {
            CountFilter clone = new CountFilter();

            CopyTo(clone);
            return(clone);
        }
Пример #2
0
 protected void CopyTo(CountFilter clone)
 {
     base.CopyTo(clone);
     clone.count1   = this.count1;
     clone.count2   = this.count2;
     clone.operand1 = this.operand1;
     clone.operand2 = this.operand2;
 }
Пример #3
0
        }   // end of ComposeSensorTargetSet()

        #endregion Public

        #region Internal
        /// <summary>
        /// See if the terrain types our object is touching match up with our filters.
        /// </summary>
        /// <param name="reflex"></param>
        /// <returns></returns>
        public new bool TestObjectSet(Reflex reflex)
        {
            GameActor     gameActor = reflex.Task.GameActor;
            List <Filter> filters   = reflex.Filters;

            bool   haveType = false;
            bool   match    = true;
            object param;

            // Only check all this if we're not jumping.  If we are jumping
            // we can just skip this.
            if (!gameActor.Chassis.Jumping)
            {
                for (int indexFilter = 0; indexFilter < filters.Count; indexFilter++)
                {
                    Filter filter = filters[indexFilter] as Filter;
                    if (!(filter is CountFilter))
                    {
                        if (filter is TerrainFilter)
                        {
                            haveType = true;
                        }
                        if (!filter.MatchAction(reflex, out param))
                        {
                            match = false;
                            break;
                        }
                    }
                }
                if (match && !haveType)
                {
                    match = _typeList.HasAnyValid((matIdx) => TerrainMaterial.IsValid((ushort)matIdx, false, false));
                }

                /// Manually apply the count filters, because they look at the sensorTargetSet.Count,
                /// which is always zero for non-object based sensors like this.
                for (int indexFilter = 0; indexFilter < filters.Count; indexFilter++)
                {
                    if (filters[indexFilter] is CountFilter)
                    {
                        CountFilter countFilter = filters[indexFilter] as CountFilter;
                        int         count       = match ? 1 : 0;
                        match = countFilter.Compare(count);
                    }
                }
            }
            else
            {
                // Jumping...
                match = false;
            }

            if (reflex.Data.GetFilterCountByType(typeof(NotFilter)) > 0)
            {
                match = !match;
            }

            match = PostProcessAction(match, reflex);

            return(match);
        }