public void SpawnScientists()
 {
     if (this.shouldLand)
     {
         int num = Mathf.FloorToInt((float)(this.mountPoints.Length - 2) * CH47LandingZone.GetClosest(this.landingTarget).dropoffScale);
         for (int index = 0; index < num; ++index)
         {
             this.SpawnPassenger(Vector3.op_Addition(((Component)this).get_transform().get_position(), Vector3.op_Multiply(((Component)this).get_transform().get_forward(), 10f)), this.dismountablePrefab.resourcePath);
         }
         for (int index = 0; index < 1; ++index)
         {
             this.SpawnPassenger(Vector3.op_Subtraction(((Component)this).get_transform().get_position(), Vector3.op_Multiply(((Component)this).get_transform().get_forward(), 15f)));
         }
     }
     else
     {
         for (int index = 0; index < 4; ++index)
         {
             this.SpawnScientist(Vector3.op_Addition(((Component)this).get_transform().get_position(), Vector3.op_Multiply(((Component)this).get_transform().get_forward(), 10f)));
         }
         for (int index = 0; index < 1; ++index)
         {
             this.SpawnScientist(Vector3.op_Subtraction(((Component)this).get_transform().get_position(), Vector3.op_Multiply(((Component)this).get_transform().get_forward(), 15f)));
         }
     }
 }
Пример #2
0
        public override StateStatus StateThink(float delta)
        {
            base.StateThink(delta);
            if (killing)
            {
                return(StateStatus.Running);
            }
            Vector3 position = brain.GetEntity().transform.position;

            if (position.y < 85f && !egressAltitueAchieved)
            {
                CH47LandingZone closest = CH47LandingZone.GetClosest(position);
                if (closest != null && Vector3Ex.Distance2D(closest.transform.position, position) < 20f)
                {
                    float num = 0f;
                    if (TerrainMeta.HeightMap != null && TerrainMeta.WaterMap != null)
                    {
                        num = Mathf.Max(TerrainMeta.WaterMap.GetHeight(position), TerrainMeta.HeightMap.GetHeight(position));
                    }
                    num += 100f;
                    Vector3 moveTarget = position;
                    moveTarget.y = num;
                    brain.GetEntity().SetMoveTarget(moveTarget);
                    return(StateStatus.Running);
                }
            }
            egressAltitueAchieved = true;
            brain.GetEntity().SetMoveTarget(brain.mainInterestPoint);
            if (base.TimeInState > 300f)
            {
                brain.GetEntity().Invoke("DelayedKill", 2f);
                killing = true;
            }
            return(StateStatus.Running);
        }
Пример #3
0
    public void SpawnScientists()
    {
        if (!this.shouldLand)
        {
            for (int i = 0; i < 4; i++)
            {
                Vector3 vector3 = base.transform.position + (base.transform.forward * 10f);
                this.SpawnScientist(vector3);
            }
            for (int j = 0; j < 1; j++)
            {
                Vector3 vector31 = base.transform.position - (base.transform.forward * 15f);
                this.SpawnScientist(vector31);
            }
            return;
        }
        float closest = CH47LandingZone.GetClosest(this.landingTarget).dropoffScale;
        int   num     = Mathf.FloorToInt((float)((int)this.mountPoints.Length - 2) * closest);

        for (int k = 0; k < num; k++)
        {
            Vector3 vector32 = base.transform.position + (base.transform.forward * 10f);
            this.SpawnPassenger(vector32, this.dismountablePrefab.resourcePath);
        }
        for (int l = 0; l < 1; l++)
        {
            Vector3 vector33 = base.transform.position - (base.transform.forward * 15f);
            this.SpawnPassenger(vector33);
        }
    }
Пример #4
0
 public void SpawnScientists()
 {
     if (shouldLand)
     {
         float dropoffScale = CH47LandingZone.GetClosest(landingTarget).dropoffScale;
         int   num          = Mathf.FloorToInt((float)(mountPoints.Count - 2) * dropoffScale);
         for (int i = 0; i < num; i++)
         {
             Vector3 spawnPos = base.transform.position + base.transform.forward * 10f;
             SpawnPassenger(spawnPos, dismountablePrefab.resourcePath);
         }
         for (int j = 0; j < 1; j++)
         {
             Vector3 spawnPos2 = base.transform.position - base.transform.forward * 15f;
             SpawnPassenger(spawnPos2);
         }
     }
     else
     {
         for (int k = 0; k < 4; k++)
         {
             Vector3 spawnPos3 = base.transform.position + base.transform.forward * 10f;
             SpawnScientist(spawnPos3);
         }
         for (int l = 0; l < 1; l++)
         {
             Vector3 spawnPos4 = base.transform.position - base.transform.forward * 15f;
             SpawnScientist(spawnPos4);
         }
     }
 }
Пример #5
0
        public override void StateThink(float delta)
        {
            Vector3         position = ((Component)this.brain.GetEntity()).get_transform().get_position();
            CH47LandingZone closest  = CH47LandingZone.GetClosest(this.brain.GetEntity().landingTarget);

            if (!Object.op_Implicit((Object)closest))
            {
                return;
            }
            Vector3 velocity  = this.brain.GetEntity().rigidBody.get_velocity();
            float   magnitude = ((Vector3) ref velocity).get_magnitude();
            double  num1      = (double)Vector3.Distance(((Component)closest).get_transform().get_position(), position);
            float   num2      = Vector3Ex.Distance2D(((Component)closest).get_transform().get_position(), position);
            double  num3      = (double)Mathf.InverseLerp(1f, 20f, num2);
            bool    enabled   = (double)num2 < 100.0;
            bool    on        = (double)num2 > 15.0 && position.y < ((Component)closest).get_transform().get_position().y + 10.0;

            this.brain.GetEntity().EnableFacingOverride(enabled);
            this.brain.GetEntity().SetAltitudeProtection(on);
            int num4 = (double)Mathf.Abs((float)(((Component)closest).get_transform().get_position().y - position.y)) >= 3.0 || (double)num2 > 5.0 ? 0 : ((double)magnitude < 1.0 ? 1 : 0);

            if (num4 != 0)
            {
                this.landedForSeconds += delta;
                if ((double)this.lastLandtime == 0.0)
                {
                    this.lastLandtime = Time.get_time();
                }
            }
            this.landingHeight -= 4f * (1f - Mathf.InverseLerp(0.0f, 7f, num2)) * Time.get_deltaTime();
            if ((double)this.landingHeight < -5.0)
            {
                this.landingHeight = -5f;
            }
            this.brain.GetEntity().SetAimDirection(((Component)closest).get_transform().get_forward());
            this.brain.GetEntity().SetMoveTarget(Vector3.op_Addition(this.brain.mainInterestPoint, new Vector3(0.0f, this.landingHeight, 0.0f)));
            if (num4 == 0)
            {
                return;
            }
            if ((double)this.landedForSeconds > 1.0 && (double)Time.get_time() > (double)this.nextDismountTime)
            {
                foreach (BaseVehicle.MountPointInfo mountPoint in this.brain.GetEntity().mountPoints)
                {
                    if (Object.op_Implicit((Object)mountPoint.mountable) && mountPoint.mountable.IsMounted())
                    {
                        this.nextDismountTime = Time.get_time() + 0.5f;
                        mountPoint.mountable.DismountAllPlayers();
                        break;
                    }
                }
            }
            if ((double)this.landedForSeconds <= 8.0)
            {
                return;
            }
            ((CH47AIBrain)((Component)this.brain).GetComponent <CH47AIBrain>()).age = float.PositiveInfinity;
        }
Пример #6
0
    public void Call()
    {
        CH47HelicopterAIController component = GameManager.server.CreateEntity(heliPrefab.resourcePath).GetComponent <CH47HelicopterAIController>();

        if ((bool)component)
        {
            Vector3         size    = TerrainMeta.Size;
            CH47LandingZone closest = CH47LandingZone.GetClosest(base.transform.position);
            Vector3         zero    = Vector3.zero;
            zero.y = closest.transform.position.y;
            Vector3 vector   = Vector3Ex.Direction2D(closest.transform.position, zero);
            Vector3 position = closest.transform.position + vector * startDist;
            position.y = closest.transform.position.y;
            component.transform.position = position;
            component.SetLandingTarget(closest.transform.position);
            component.Spawn();
        }
    }
Пример #7
0
    public void Call()
    {
        CH47HelicopterAIController component = (CH47HelicopterAIController)((Component)GameManager.server.CreateEntity(this.heliPrefab.resourcePath, (Vector3)null, (Quaternion)null, true)).GetComponent <CH47HelicopterAIController>();

        if (!Object.op_Implicit((Object)component))
        {
            return;
        }
        Vector3         size    = TerrainMeta.Size;
        CH47LandingZone closest = CH47LandingZone.GetClosest(((Component)this).get_transform().get_position());
        Vector3         zero    = Vector3.get_zero();

        zero.y = ((Component)closest).get_transform().get_position().y;
        Vector3 vector3_1 = Vector3Ex.Direction2D(((Component)closest).get_transform().get_position(), zero);
        Vector3 vector3_2 = Vector3.op_Addition(((Component)closest).get_transform().get_position(), Vector3.op_Multiply(vector3_1, this.startDist));

        vector3_2.y = ((Component)closest).get_transform().get_position().y;
        ((Component)component).get_transform().set_position(vector3_2);
        component.SetLandingTarget(((Component)closest).get_transform().get_position());
        component.Spawn();
    }
    public void Call()
    {
        GameManager gameManager = GameManager.server;
        string      str         = this.heliPrefab.resourcePath;
        Vector3     vector3     = new Vector3();
        Quaternion  quaternion  = new Quaternion();
        CH47HelicopterAIController component = gameManager.CreateEntity(str, vector3, quaternion, true).GetComponent <CH47HelicopterAIController>();

        if (component)
        {
            Vector3         size     = TerrainMeta.Size;
            CH47LandingZone closest  = CH47LandingZone.GetClosest(base.transform.position);
            Vector3         vector31 = Vector3.zero;
            vector31.y = closest.transform.position.y;
            Vector3 vector32 = Vector3Ex.Direction2D(closest.transform.position, vector31);
            Vector3 vector33 = closest.transform.position + (vector32 * this.startDist);
            vector33.y = closest.transform.position.y;
            component.transform.position = vector33;
            component.SetLandingTarget(closest.transform.position);
            component.Spawn();
        }
    }
Пример #9
0
        public override StateStatus StateThink(float delta)
        {
            base.StateThink(delta);
            Vector3         position = brain.GetEntity().transform.position;
            Vector3         forward  = brain.GetEntity().transform.forward;
            CH47LandingZone closest  = CH47LandingZone.GetClosest(brain.GetEntity().landingTarget);

            if (!closest)
            {
                return(StateStatus.Error);
            }
            float magnitude          = brain.GetEntity().rigidBody.velocity.magnitude;
            float num                = Vector3Ex.Distance2D(closest.transform.position, position);
            bool  enabled            = num < 40f;
            bool  altitudeProtection = num > 15f && position.y < closest.transform.position.y + 10f;

            brain.GetEntity().EnableFacingOverride(enabled);
            brain.GetEntity().SetAltitudeProtection(altitudeProtection);
            bool num2 = Mathf.Abs(closest.transform.position.y - position.y) < 3f && num <= 5f && magnitude < 1f;

            if (num2)
            {
                landedForSeconds += delta;
                if (lastLandtime == 0f)
                {
                    lastLandtime = Time.time;
                }
            }
            float num3 = 1f - Mathf.InverseLerp(0f, 7f, num);

            landingHeight -= 4f * num3 * Time.deltaTime;
            if (landingHeight < -5f)
            {
                landingHeight = -5f;
            }
            brain.GetEntity().SetAimDirection(closest.transform.forward);
            Vector3 moveTarget = brain.mainInterestPoint + new Vector3(0f, landingHeight, 0f);

            if (num < 100f && num > 15f)
            {
                Vector3    vector = Vector3Ex.Direction2D(closest.transform.position, position);
                RaycastHit hitInfo;
                if (Physics.SphereCast(position, 15f, vector, out hitInfo, num, 1218511105))
                {
                    Vector3 vector2 = Vector3.Cross(vector, Vector3.up);
                    moveTarget = hitInfo.point + vector2 * 50f;
                }
            }
            brain.GetEntity().SetMoveTarget(moveTarget);
            if (num2)
            {
                if (landedForSeconds > 1f && Time.time > nextDismountTime)
                {
                    foreach (BaseVehicle.MountPointInfo mountPoint in brain.GetEntity().mountPoints)
                    {
                        if ((bool)mountPoint.mountable && mountPoint.mountable.IsMounted())
                        {
                            nextDismountTime = Time.time + 0.5f;
                            mountPoint.mountable.DismountAllPlayers();
                            break;
                        }
                    }
                }
                if (landedForSeconds > 8f)
                {
                    brain.GetComponent <CH47AIBrain>().ForceSetAge(float.PositiveInfinity);
                }
            }
            return(StateStatus.Running);
        }
Пример #10
0
        public override void StateThink(float delta)
        {
            bool            flag;
            Vector3         entity  = this.brain.GetEntity().transform.position;
            CH47LandingZone closest = CH47LandingZone.GetClosest(this.brain.GetEntity().landingTarget);

            if (!closest)
            {
                return;
            }
            float single = this.brain.GetEntity().rigidBody.velocity.magnitude;

            Vector3.Distance(closest.transform.position, entity);
            float single1 = Vector3Ex.Distance2D(closest.transform.position, entity);

            Mathf.InverseLerp(1f, 20f, single1);
            bool flag1 = single1 < 100f;
            bool flag2 = (single1 <= 15f ? false : entity.y < closest.transform.position.y + 10f);

            this.brain.GetEntity().EnableFacingOverride(flag1);
            this.brain.GetEntity().SetAltitudeProtection(flag2);
            flag = (Mathf.Abs(closest.transform.position.y - entity.y) >= 3f || single1 > 5f ? false : single < 1f);
            if (flag)
            {
                this.landedForSeconds += delta;
                if (this.lastLandtime == 0f)
                {
                    this.lastLandtime = Time.time;
                }
            }
            float single2 = 1f - Mathf.InverseLerp(0f, 7f, single1);

            this.landingHeight = this.landingHeight - 4f * single2 * Time.deltaTime;
            if (this.landingHeight < -5f)
            {
                this.landingHeight = -5f;
            }
            this.brain.GetEntity().SetAimDirection(closest.transform.forward);
            this.brain.GetEntity().SetMoveTarget(this.brain.mainInterestPoint + new Vector3(0f, this.landingHeight, 0f));
            if (flag)
            {
                if (this.landedForSeconds > 1f && Time.time > this.nextDismountTime)
                {
                    BaseVehicle.MountPointInfo[] mountPointInfoArray = this.brain.GetEntity().mountPoints;
                    int num = 0;
                    while (num < (int)mountPointInfoArray.Length)
                    {
                        BaseVehicle.MountPointInfo mountPointInfo = mountPointInfoArray[num];
                        if (!mountPointInfo.mountable || !mountPointInfo.mountable.IsMounted())
                        {
                            num++;
                        }
                        else
                        {
                            this.nextDismountTime = Time.time + 0.5f;
                            mountPointInfo.mountable.DismountAllPlayers();
                            break;
                        }
                    }
                }
                if (this.landedForSeconds > 8f)
                {
                    this.brain.GetComponent <CH47AIBrain>().age = Single.PositiveInfinity;
                }
            }
        }