Esempio n. 1
0
        public override void StateThink(float delta)
        {
            base.StateThink(delta);
            if (Object.op_Equality((Object)this.GetEntity().currentTarget, (Object)null))
            {
                return;
            }
            float num1 = Vector3.Distance(this.GetEntity().currentTarget.ServerPosition, this.GetEntity().ServerPosition);

            if ((double)num1 < 5.0)
            {
                this.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.SlowWalk);
            }
            else if ((double)num1 < 10.0)
            {
                this.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Walk);
            }
            else
            {
                this.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Sprint);
            }
            if ((double)Time.get_time() <= (double)this.nextPositionUpdateTime)
            {
                return;
            }
            double  num2           = (double)Random.Range(1f, 2f);
            Vector3 newDestination = this.GetEntity().ServerPosition;

            if (Object.op_Equality((Object)this.GetEntity().GetInformationZone(), (Object)null))
            {
                return;
            }
            AIMovePoint bestMovePointNear = this.GetEntity().GetInformationZone().GetBestMovePointNear(this.GetEntity().currentTarget.ServerPosition, this.GetEntity().ServerPosition, 0.0f, 35f, true, (BaseEntity)null);

            if (Object.op_Implicit((Object)bestMovePointNear))
            {
                bestMovePointNear.MarkUsedForEngagement(5f, (BaseEntity)this.GetEntity());
                newDestination = this.GetEntity().GetRandomPositionAround(((Component)bestMovePointNear).get_transform().get_position(), 0.0f, bestMovePointNear.radius - 0.3f);
            }
            else
            {
                this.GetEntity().GetRandomPositionAround(this.GetEntity().currentTarget.ServerPosition, 1f, 2f);
            }
            this.GetEntity().SetDestination(newDestination);
        }
        public override void StateThink(float delta)
        {
            base.StateThink(delta);
            if (base.GetEntity().currentTarget == null)
            {
                return;
            }
            float single = Vector3.Distance(base.GetEntity().currentTarget.ServerPosition, base.GetEntity().ServerPosition);

            if (single < 5f)
            {
                base.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.SlowWalk);
            }
            else if (single >= 10f)
            {
                base.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Sprint);
            }
            else
            {
                base.GetEntity().SetDesiredSpeed(HumanNPC.SpeedType.Walk);
            }
            if (Time.time > this.nextPositionUpdateTime)
            {
                UnityEngine.Random.Range(1f, 2f);
                Vector3 serverPosition = base.GetEntity().ServerPosition;
                if (base.GetEntity().GetInformationZone() == null)
                {
                    return;
                }
                AIMovePoint bestMovePointNear = base.GetEntity().GetInformationZone().GetBestMovePointNear(base.GetEntity().currentTarget.ServerPosition, base.GetEntity().ServerPosition, 0f, 35f, true, null);
                if (!bestMovePointNear)
                {
                    base.GetEntity().GetRandomPositionAround(base.GetEntity().currentTarget.ServerPosition, 1f, 2f);
                }
                else
                {
                    bestMovePointNear.MarkUsedForEngagement(5f, base.GetEntity());
                    serverPosition = bestMovePointNear.transform.position;
                    serverPosition = base.GetEntity().GetRandomPositionAround(serverPosition, 0f, bestMovePointNear.radius - 0.3f);
                }
                base.GetEntity().SetDestination(serverPosition);
            }
        }