Exemplo n.º 1
0
        public override void Execute(IAIContext context)
        {
            EntityTargetContext entityTargetContext = context as EntityTargetContext;

            if (entityTargetContext != null)
            {
                TargetSelectorExplosives.TryGetBest(entityTargetContext, base.scorers, entityTargetContext.Entities, entityTargetContext.EntityCount, this.allScorersMustScoreAboveZero, out entityTargetContext.ExplosiveTarget, out entityTargetContext.ExplosiveScore);
            }
        }
        public override void Execute(IAIContext context)
        {
            EntityTargetContext entityTargetContext = context as EntityTargetContext;

            if (entityTargetContext != null)
            {
                TargetSelectorAnimal.Evaluate(entityTargetContext, base.scorers, entityTargetContext.Entities, entityTargetContext.EntityCount, this.allScorersMustScoreAboveZero, out entityTargetContext.AnimalTarget, out entityTargetContext.AnimalScore);
            }
        }
        public virtual void Execute(IAIContext context)
        {
            EntityTargetContext context1 = context as EntityTargetContext;

            if (context1 == null)
            {
                return;
            }
            TargetSelectorExplosives.TryGetBest(context1, this.get_scorers(), context1.Entities, context1.EntityCount, this.allScorersMustScoreAboveZero, out context1.ExplosiveTarget, out context1.ExplosiveScore);
        }
Exemplo n.º 4
0
        public override float Score(IAIContext context, BaseEntity option)
        {
            EntityTargetContext entityTargetContext = context as EntityTargetContext;

            if (entityTargetContext != null)
            {
                option.IsVisible(entityTargetContext.Self.Entity.CenterPoint(), entityTargetContext.Self.GetStats.CloseRange);
            }
            return(0f);
        }
        public virtual void Execute(IAIContext context)
        {
            EntityTargetContext context1 = context as EntityTargetContext;

            if (context1 == null)
            {
                return;
            }
            TargetSelectorAnimal.Evaluate(context1, this.get_scorers(), context1.Entities, context1.EntityCount, this.allScorersMustScoreAboveZero, out context1.AnimalTarget, out context1.AnimalScore);
        }
Exemplo n.º 6
0
        public virtual float Score(IAIContext context, BaseEntity option)
        {
            EntityTargetContext entityTargetContext = context as EntityTargetContext;

            if (entityTargetContext == null)
            {
                return(0.0f);
            }
            Vector3 vector3 = Vector3.op_Subtraction(entityTargetContext.Self.Entity.ServerPosition, option.ServerPosition);

            return((double)((Vector3) ref vector3).get_sqrMagnitude() > (double)entityTargetContext.Self.GetStats.CloseRange * (double)entityTargetContext.Self.GetStats.CloseRange ? 0.0f : 1f);
        }
        public override float Score(IAIContext context, BaseEntity option)
        {
            EntityTargetContext entityTargetContext = context as EntityTargetContext;

            if (entityTargetContext == null)
            {
                return(0f);
            }
            if ((entityTargetContext.Self.Entity.ServerPosition - option.ServerPosition).sqrMagnitude > entityTargetContext.Self.GetStats.CloseRange * entityTargetContext.Self.GetStats.CloseRange)
            {
                return(0f);
            }
            return(1f);
        }
        public static bool Evaluate(
            EntityTargetContext context,
            IList <IOptionScorer <BaseEntity> > scorers,
            BaseEntity[] options,
            int numOptions,
            bool allScorersMustScoreAboveZero,
            out BaseNpc best,
            out float bestScore)
        {
            bestScore = float.MinValue;
            best      = (BaseNpc)null;
            BaseEntity baseEntity = (BaseEntity)null;

            for (int index1 = 0; index1 < numOptions; ++index1)
            {
                float danger = 0.0f;
                bool  flag   = true;
                for (int index2 = 0; index2 < ((ICollection <IOptionScorer <BaseEntity> >)scorers).Count; ++index2)
                {
                    if (!((ICanBeDisabled)scorers[index2]).get_isDisabled())
                    {
                        float num = scorers[index2].Score((IAIContext)context, options[index1]);
                        if (allScorersMustScoreAboveZero && (double)num <= 0.0)
                        {
                            flag = false;
                            break;
                        }
                        danger += num;
                    }
                }
                if (flag)
                {
                    (context.Self.GetContext(Guid.Empty) as BaseContext)?.Memory.Update(options[index1], danger);
                    if ((double)danger > (double)bestScore)
                    {
                        bestScore  = danger;
                        baseEntity = options[index1];
                    }
                }
            }
            if (Object.op_Inequality((Object)baseEntity, (Object)null))
            {
                best = baseEntity as BaseNpc;
            }
            return(Object.op_Inequality((Object)best, (Object)null));
        }
        public static bool Evaluate(EntityTargetContext context, IList <IOptionScorer <BaseEntity> > scorers, BaseEntity[] options, int numOptions, bool allScorersMustScoreAboveZero, out BaseNpc best, out float bestScore)
        {
            bestScore = Single.MinValue;
            best      = null;
            BaseEntity baseEntity = null;

            for (int i = 0; i < numOptions; i++)
            {
                float single = 0f;
                bool  flag   = true;
                for (int j = 0; j < scorers.Count; j++)
                {
                    if (!scorers[j].isDisabled)
                    {
                        float single1 = scorers[j].Score(context, options[i]);
                        if (!allScorersMustScoreAboveZero || single1 > 0f)
                        {
                            single += single1;
                        }
                        else
                        {
                            flag = false;
                            break;
                        }
                    }
                }
                if (flag)
                {
                    BaseContext baseContext = context.Self.GetContext(Guid.Empty) as BaseContext;
                    if (baseContext != null)
                    {
                        baseContext.Memory.Update(options[i], single);
                    }
                    if (single > bestScore)
                    {
                        bestScore  = single;
                        baseEntity = options[i];
                    }
                }
            }
            if (baseEntity != null)
            {
                best = baseEntity as BaseNpc;
            }
            return(best != null);
        }
        public static bool TryGetBest(
            EntityTargetContext context,
            IList <IOptionScorer <BaseEntity> > scorers,
            BaseEntity[] options,
            int numOptions,
            bool allScorersMustScoreAboveZero,
            out TimedExplosive best,
            out float bestScore)
        {
            bestScore = float.MinValue;
            best      = (TimedExplosive)null;
            BaseEntity baseEntity = (BaseEntity)null;

            for (int index1 = 0; index1 < numOptions; ++index1)
            {
                float num1 = 0.0f;
                bool  flag = true;
                for (int index2 = 0; index2 < ((ICollection <IOptionScorer <BaseEntity> >)scorers).Count; ++index2)
                {
                    if (!((ICanBeDisabled)scorers[index2]).get_isDisabled())
                    {
                        float num2 = scorers[index2].Score((IAIContext)context, options[index1]);
                        if (allScorersMustScoreAboveZero && (double)num2 <= 0.0)
                        {
                            flag = false;
                            break;
                        }
                        num1 += num2;
                    }
                }
                if (flag && (double)num1 > (double)bestScore)
                {
                    bestScore  = num1;
                    baseEntity = options[index1];
                }
            }
            if (Object.op_Inequality((Object)baseEntity, (Object)null))
            {
                best = baseEntity as TimedExplosive;
            }
            return(Object.op_Inequality((Object)best, (Object)null));
        }
Exemplo n.º 11
0
        public static bool TryGetBest(EntityTargetContext context, IList <IOptionScorer <BaseEntity> > scorers, BaseEntity[] options, int numOptions, bool allScorersMustScoreAboveZero, out TimedExplosive best, out float bestScore)
        {
            bestScore = Single.MinValue;
            best      = null;
            BaseEntity baseEntity = null;

            for (int i = 0; i < numOptions; i++)
            {
                float single = 0f;
                bool  flag   = true;
                for (int j = 0; j < scorers.Count; j++)
                {
                    if (!scorers[j].isDisabled)
                    {
                        float single1 = scorers[j].Score(context, options[i]);
                        if (!allScorersMustScoreAboveZero || single1 > 0f)
                        {
                            single += single1;
                        }
                        else
                        {
                            flag = false;
                            break;
                        }
                    }
                }
                if (flag && single > bestScore)
                {
                    bestScore  = single;
                    baseEntity = options[i];
                }
            }
            if (baseEntity != null)
            {
                best = baseEntity as TimedExplosive;
            }
            return(best != null);
        }