Ejemplo n.º 1
0
        public override void StateEnter()
        {
            base.StateEnter();
            base.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Sprint);
            AIInformationZone informationZone = base.GetEntity().GetInformationZone();

            if (informationZone != null)
            {
                AICoverPoint bestCoverPoint = informationZone.GetBestCoverPoint(base.GetEntity().ServerPosition, base.GetEntity().ServerPosition, 25f, 50f, base.GetEntity());
                if (bestCoverPoint)
                {
                    bestCoverPoint.SetUsedBy(base.GetEntity(), 10f);
                }
                Vector3 vector3 = (bestCoverPoint == null ? base.GetEntity().ServerPosition : bestCoverPoint.transform.position);
                base.GetEntity().SetDestination(vector3);
                this.brain.mainInterestPoint = vector3;
            }
        }
Ejemplo n.º 2
0
        public override void StateEnter()
        {
            base.StateEnter();
            GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Sprint);
            AIInformationZone informationZone = GetEntity().GetInformationZone(GetEntity().transform.position);

            if (informationZone != null)
            {
                AICoverPoint bestCoverPoint = informationZone.GetBestCoverPoint(GetEntity().transform.position, GetEntity().transform.position, 25f, 50f, GetEntity());
                if ((bool)bestCoverPoint)
                {
                    bestCoverPoint.SetUsedBy(GetEntity(), 10f);
                }
                Vector3 vector = ((bestCoverPoint == null) ? GetEntity().transform.position : bestCoverPoint.transform.position);
                GetEntity().SetDestination(vector);
                brain.mainInterestPoint = vector;
            }
        }
Ejemplo n.º 3
0
        public override void StateEnter()
        {
            base.StateEnter();
            this.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Sprint);
            AIInformationZone informationZone = this.GetEntity().GetInformationZone();

            if (!Object.op_Inequality((Object)informationZone, (Object)null))
            {
                return;
            }
            AICoverPoint bestCoverPoint = informationZone.GetBestCoverPoint(this.GetEntity().ServerPosition, this.GetEntity().ServerPosition, 25f, 50f, (BaseEntity)this.GetEntity());

            if (Object.op_Implicit((Object)bestCoverPoint))
            {
                bestCoverPoint.SetUsedBy((BaseEntity)this.GetEntity(), 10f);
            }
            Vector3 newDestination = Object.op_Equality((Object)bestCoverPoint, (Object)null) ? this.GetEntity().ServerPosition : ((Component)bestCoverPoint).get_transform().get_position();

            this.GetEntity().SetDestination(newDestination);
            this.brain.mainInterestPoint = newDestination;
        }
Ejemplo n.º 4
0
        public override void StateThink(float delta)
        {
            bool flag;

            base.StateThink(delta);
            float single  = 2f;
            float single1 = 0f;

            if (Time.time > this.lastCoverTime + single && !this.isFleeing)
            {
                Vector3           vector3         = (base.GetEntity().currentTarget ? base.GetEntity().currentTarget.ServerPosition : base.GetEntity().ServerPosition + (base.GetEntity().LastAttackedDir * 30f));
                float             single2         = (base.GetEntity().currentTarget != null ? base.GetEntity().DistanceToTarget() : 30f);
                AIInformationZone informationZone = base.GetEntity().GetInformationZone();
                if (informationZone != null)
                {
                    float        secondsSinceAttacked = base.GetEntity().SecondsSinceAttacked;
                    float        single3        = (secondsSinceAttacked < 2f ? 2f : 0f);
                    float        single4        = 20f;
                    AICoverPoint bestCoverPoint = informationZone.GetBestCoverPoint(base.GetEntity().ServerPosition, vector3, single3, single4, base.GetEntity());
                    if (bestCoverPoint)
                    {
                        bestCoverPoint.SetUsedBy(base.GetEntity(), 5f);
                    }
                    Vector3 vector31 = (bestCoverPoint == null ? base.GetEntity().ServerPosition : bestCoverPoint.transform.position);
                    base.GetEntity().SetDestination(vector31);
                    float single5 = Vector3.Distance(vector31, base.GetEntity().ServerPosition);
                    base.GetEntity().DistanceToTarget();
                    int num  = (int)((secondsSinceAttacked >= 4f ? false : base.GetEntity().AmmoFractionRemaining() <= 0.25f));
                    int num1 = (int)((base.GetEntity().healthFraction >= 0.5f || secondsSinceAttacked >= 1f ? false : Time.time > single1));
                    if (single2 > 6f && single5 > 6f || base.GetEntity().currentTarget == null)
                    {
                        this.isFleeing = true;
                        single1        = Time.time + UnityEngine.Random.Range(4f, 7f);
                    }
                    if (single5 > 1f)
                    {
                        base.GetEntity().ClearStationaryAimPoint();
                    }
                }
                this.lastCoverTime = Time.time;
            }
            bool flag1 = Vector3.Distance(base.GetEntity().ServerPosition, base.GetEntity().finalDestination) <= 0.25f;

            if (!this.inCover & flag1)
            {
                if (this.isFleeing)
                {
                    base.GetEntity().SetStationaryAimPoint(base.GetEntity().finalDestination + (-base.GetEntity().eyes.BodyForward() * 5f));
                }
                else if (base.GetEntity().currentTarget)
                {
                    base.GetEntity().SetStationaryAimPoint(base.GetEntity().ServerPosition + (Vector3Ex.Direction2D(base.GetEntity().currentTarget.ServerPosition, base.GetEntity().ServerPosition) * 5f));
                }
            }
            this.inCover = flag1;
            if (!this.inCover)
            {
                this.timeInCover = 0f;
            }
            else
            {
                this.timeInCover += delta;
            }
            base.GetEntity().SetDucked(this.inCover);
            if (this.inCover)
            {
                this.isFleeing = false;
            }
            if (base.GetEntity().AmmoFractionRemaining() == 0f || this.isFleeing)
            {
                flag = true;
            }
            else
            {
                flag = (base.GetEntity().CanSeeTarget() || !this.inCover || base.GetEntity().SecondsSinceDealtDamage <= 2f ? false : base.GetEntity().AmmoFractionRemaining() < 0.25f);
            }
            if (flag)
            {
                base.GetEntity().AttemptReload();
            }
            if (!this.inCover)
            {
                if (base.TimeInState() > 1f && this.isFleeing)
                {
                    base.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Sprint);
                    return;
                }
                base.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Walk);
            }
        }
Ejemplo n.º 5
0
        public override StateStatus StateThink(float delta)
        {
            base.StateThink(delta);
            float num  = 2f;
            float num2 = 0f;

            if (Time.time > lastCoverTime + num && !isFleeing)
            {
                Vector3           hideFromPosition = (GetEntity().currentTarget ? GetEntity().currentTarget.transform.position : (GetEntity().transform.position + GetEntity().LastAttackedDir * 30f));
                float             num3             = ((GetEntity().currentTarget != null) ? GetEntity().DistanceToTarget() : 30f);
                AIInformationZone informationZone  = GetEntity().GetInformationZone(GetEntity().transform.position);
                if (informationZone != null)
                {
                    float secondsSinceAttacked = GetEntity().SecondsSinceAttacked;
                    float minRange             = ((secondsSinceAttacked < 2f) ? 2f : 0f);
                    float maxRange             = 25f;
                    if (currentCover != null)
                    {
                        currentCover.ClearIfUsedBy(GetEntity());
                        currentCover = null;
                    }
                    AICoverPoint bestCoverPoint = informationZone.GetBestCoverPoint(GetEntity().transform.position, hideFromPosition, minRange, maxRange, GetEntity());
                    if ((bool)bestCoverPoint)
                    {
                        bestCoverPoint.SetUsedBy(GetEntity(), 15f);
                        currentCover = bestCoverPoint;
                    }
                    Vector3 vector = ((bestCoverPoint == null) ? GetEntity().transform.position : bestCoverPoint.transform.position);
                    GetEntity().SetDestination(vector);
                    float num4 = Vector3.Distance(vector, GetEntity().transform.position);
                    bool  flag2;
                    int   num5;
                    if (secondsSinceAttacked < 4f)
                    {
                        flag2 = GetEntity().AmmoFractionRemaining() <= 0.25f;
                    }
                    else
                    {
                        num5 = 0;
                    }
                    bool flag3;
                    int  num6;
                    if (GetEntity().healthFraction < 0.5f && secondsSinceAttacked < 1f)
                    {
                        flag3 = Time.time > num2;
                    }
                    else
                    {
                        num6 = 0;
                    }
                    if ((num3 > 6f && num4 > 8f) || GetEntity().currentTarget == null)
                    {
                        isFleeing = true;
                        num2      = Time.time + Random.Range(4f, 7f);
                    }
                    if (num4 > 1f)
                    {
                        GetEntity().ClearStationaryAimPoint();
                    }
                }
                lastCoverTime = Time.time;
            }
            bool flag = Vector3.Distance(GetEntity().transform.position, GetEntity().finalDestination) <= 0.25f;

            if (!inCover && flag)
            {
                if (isFleeing)
                {
                    GetEntity().SetStationaryAimPoint(GetEntity().finalDestination + -GetEntity().eyes.BodyForward() * 5f);
                }
                else if ((bool)GetEntity().currentTarget)
                {
                    GetEntity().SetStationaryAimPoint(GetEntity().transform.position + Vector3Ex.Direction2D(GetEntity().currentTarget.transform.position, GetEntity().transform.position) * 5f);
                }
            }
            inCover = flag;
            if (inCover)
            {
                timeInCover += delta;
            }
            else
            {
                timeInCover = 0f;
            }
            GetEntity().SetDucked(inCover);
            if (inCover)
            {
                isFleeing = false;
            }
            if (GetEntity().AmmoFractionRemaining() == 0f || isFleeing || (!GetEntity().CanSeeTarget() && inCover && GetEntity().SecondsSinceDealtDamage > 2f && GetEntity().AmmoFractionRemaining() < 0.25f))
            {
                GetEntity().AttemptReload();
            }
            if (!inCover)
            {
                if (base.TimeInState > 1f && isFleeing)
                {
                    GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Sprint);
                }
                else
                {
                    GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Walk);
                }
            }
            return(StateStatus.Running);
        }
Ejemplo n.º 6
0
        public override void StateThink(float delta)
        {
            base.StateThink(delta);
            float num1 = 2f;
            float num2 = 0.0f;

            if ((double)Time.get_time() > (double)this.lastCoverTime + (double)num1 && !this.isFleeing)
            {
                Vector3           hideFromPosition = Object.op_Implicit((Object)this.GetEntity().currentTarget) ? this.GetEntity().currentTarget.ServerPosition : Vector3.op_Addition(this.GetEntity().ServerPosition, Vector3.op_Multiply(this.GetEntity().LastAttackedDir, 30f));
                float             num3             = Object.op_Inequality((Object)this.GetEntity().currentTarget, (Object)null) ? this.GetEntity().DistanceToTarget() : 30f;
                AIInformationZone informationZone  = this.GetEntity().GetInformationZone();
                if (Object.op_Inequality((Object)informationZone, (Object)null))
                {
                    float        secondsSinceAttacked = this.GetEntity().SecondsSinceAttacked;
                    float        minRange             = (double)secondsSinceAttacked < 2.0 ? 2f : 0.0f;
                    float        maxRange             = 20f;
                    AICoverPoint bestCoverPoint       = informationZone.GetBestCoverPoint(this.GetEntity().ServerPosition, hideFromPosition, minRange, maxRange, (BaseEntity)this.GetEntity());
                    if (Object.op_Implicit((Object)bestCoverPoint))
                    {
                        bestCoverPoint.SetUsedBy((BaseEntity)this.GetEntity(), 5f);
                    }
                    Vector3 newDestination = Object.op_Equality((Object)bestCoverPoint, (Object)null) ? this.GetEntity().ServerPosition : ((Component)bestCoverPoint).get_transform().get_position();
                    this.GetEntity().SetDestination(newDestination);
                    float  num4   = Vector3.Distance(newDestination, this.GetEntity().ServerPosition);
                    double target = (double)this.GetEntity().DistanceToTarget();
                    int    num5   = (double)secondsSinceAttacked >= 4.0 ? 0 : ((double)this.GetEntity().AmmoFractionRemaining() <= 0.25 ? 1 : 0);
                    int    num6   = (double)this.GetEntity().healthFraction >= 0.5 || (double)secondsSinceAttacked >= 1.0 ? 0 : ((double)Time.get_time() > (double)num2 ? 1 : 0);
                    if ((double)num3 > 6.0 && (double)num4 > 6.0 || Object.op_Equality((Object)this.GetEntity().currentTarget, (Object)null))
                    {
                        this.isFleeing = true;
                        float num7 = Time.get_time() + Random.Range(4f, 7f);
                    }
                    if ((double)num4 > 1.0)
                    {
                        this.GetEntity().ClearStationaryAimPoint();
                    }
                }
                this.lastCoverTime = Time.get_time();
            }
            bool flag = (double)Vector3.Distance(this.GetEntity().ServerPosition, this.GetEntity().finalDestination) <= 0.25;

            if (!this.inCover & flag)
            {
                if (this.isFleeing)
                {
                    this.GetEntity().SetStationaryAimPoint(Vector3.op_Addition(this.GetEntity().finalDestination, Vector3.op_Multiply(Vector3.op_UnaryNegation(this.GetEntity().eyes.BodyForward()), 5f)));
                }
                else if (Object.op_Implicit((Object)this.GetEntity().currentTarget))
                {
                    this.GetEntity().SetStationaryAimPoint(Vector3.op_Addition(this.GetEntity().ServerPosition, Vector3.op_Multiply(Vector3Ex.Direction2D(this.GetEntity().currentTarget.ServerPosition, this.GetEntity().ServerPosition), 5f)));
                }
            }
            this.inCover = flag;
            if (this.inCover)
            {
                this.timeInCover += delta;
            }
            else
            {
                this.timeInCover = 0.0f;
            }
            this.GetEntity().SetDucked(this.inCover);
            if (this.inCover)
            {
                this.isFleeing = false;
            }
            if (((double)this.GetEntity().AmmoFractionRemaining() == 0.0 || this.isFleeing ? 1 : (this.GetEntity().CanSeeTarget() || !this.inCover || (double)this.GetEntity().SecondsSinceDealtDamage <= 2.0 ? 0 : ((double)this.GetEntity().AmmoFractionRemaining() < 0.25 ? 1 : 0))) != 0)
            {
                this.GetEntity().AttemptReload();
            }
            if (this.inCover)
            {
                return;
            }
            if ((double)this.TimeInState() > 1.0 && this.isFleeing)
            {
                this.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Sprint);
            }
            else
            {
                this.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Walk);
            }
        }