Пример #1
0
        public Vector3 GetRandomPointInTankSpace(bool check_terrain = true, float range = 0.5f)
        {
            Vector3 vector = Vector3.zero;
            int     num    = 10000;
            bool    flag   = false;
            int     num2   = 0;

            while (num2 < num && !flag)
            {
                vector.x = UnityEngine.Random.Range(-range, range);
                vector.y = UnityEngine.Random.Range(-range, range);
                vector.z = UnityEngine.Random.Range(-range, range);
                vector   = base.gameObject.transform.TransformPoint(vector);
                if (check_terrain)
                {
                    float terrainY = MainLevel.GetTerrainY(vector);
                    flag = (terrainY < vector.y);
                }
                else
                {
                    flag = true;
                }
                num2++;
            }
            if (!flag)
            {
                return(base.transform.position);
            }
            return(vector);
        }
Пример #2
0
    private void SetupHookInWaterPos()
    {
        if (!this.m_Hook)
        {
            return;
        }
        float terrainY = MainLevel.GetTerrainY(this.m_FloatPos);

        if (terrainY >= this.m_FloatPos.y)
        {
            DebugUtils.Assert("[FishingRod:OnEnterState] Float is under terrain!", true, DebugUtils.AssertType.Info);
        }
        Vector3 floatPos = this.m_FloatPos;

        if (this.m_FishTank)
        {
            floatPos.y = this.m_FishTank.transform.position.y;
        }
        if (floatPos.y < terrainY + 0.2f)
        {
            floatPos.y = terrainY + 0.2f;
        }
        floatPos.y = Mathf.Min(floatPos.y, this.m_FloatPos.y);
        this.m_Hook.transform.position = floatPos;
        this.m_HookInWaterPos          = floatPos;
    }
Пример #3
0
    private Vector3?GetPosition(AmbientSounds.AmbientDefinition def)
    {
        if (def.m_DistanceMin > 0f)
        {
            switch (def.m_Position)
            {
            case AmbientSounds.EAmbientPositionType.Ground:
            {
                Vector3 randomPos2D = this.GetRandomPos2D(def);
                randomPos2D.y = MainLevel.GetTerrainY(randomPos2D);
                break;
            }

            case AmbientSounds.EAmbientPositionType.Bush:
                return(this.GetTagBasedPos(def));

            case AmbientSounds.EAmbientPositionType.HighInAir:
                this.GetRandomPos2D(def).y += UnityEngine.Random.Range(10f, 30f);
                break;

            case AmbientSounds.EAmbientPositionType.TreeTops:
            {
                Vector3?tagBasedPos = this.GetTagBasedPos(def);
                if (tagBasedPos != null)
                {
                    Vector3 value = tagBasedPos.Value;
                    value.y += this.m_AmbientSounds.m_BigTreeAdditionalY;
                    return(new Vector3?(value));
                }
                break;
            }
            }
        }
        return(null);
    }
Пример #4
0
        private void AllignToTerrain()
        {
            Vector3 position = base.transform.position;

            position.y = MainLevel.GetTerrainY(position);
            base.transform.position = position;
            if (base.IsVisible())
            {
                Vector3 normalized2D = base.transform.forward.GetNormalized2D();
                Vector3 vector       = this.m_BoxCollider.bounds.center + normalized2D * this.m_BoxCollider.size.z + Vector3.up * this.m_BoxCollider.size.y;
                vector.y = MainLevel.GetTerrainY(vector);
                Vector3 vector2 = this.m_BoxCollider.bounds.center - normalized2D * this.m_BoxCollider.size.z + Vector3.up * this.m_BoxCollider.size.y;
                vector2.y = MainLevel.GetTerrainY(vector2);
                Vector3 vector3       = vector - vector2;
                Vector3 normalized2D2 = base.transform.right.GetNormalized2D();
                Vector3 vector4       = this.m_BoxCollider.bounds.center + normalized2D2 * this.m_BoxCollider.size.x + Vector3.up * this.m_BoxCollider.size.y;
                vector4.y = MainLevel.GetTerrainY(vector4);
                Vector3 vector5 = this.m_BoxCollider.bounds.center - normalized2D2 * this.m_BoxCollider.size.x + Vector3.up * this.m_BoxCollider.size.y;
                vector5.y = MainLevel.GetTerrainY(vector5);
                Vector3 vector6 = vector4 - vector5;
                Vector3 vector7 = Vector3.Cross(vector3.normalized, vector6.normalized);
                if (!vector7.IsZero())
                {
                    base.transform.rotation = Quaternion.Slerp(base.transform.rotation, Quaternion.LookRotation(vector3.normalized, vector7.normalized), 1f);
                }
            }
        }
Пример #5
0
    protected override void Start()
    {
        base.Start();

        // store the local reference
        _level = GameManager.Instance.CurrentScene.As <MainLevel>();
    }
Пример #6
0
        protected virtual bool SetupPath()
        {
            Vector3 a            = Vector3.zero;
            Vector3 normalized2D = (this.m_AI.transform.position - Player.Get().transform.position).GetNormalized2D();

            if (this.m_Direction == Direction.Right)
            {
                a = Vector3.Cross(Vector3.up, normalized2D);
            }
            else
            {
                a = Vector3.Cross(normalized2D, Vector3.up);
            }
            for (int i = 0; i < 10; i++)
            {
                Vector3 vector = Player.Get().transform.position + normalized2D * this.m_Range + a * 5f;
                vector.y = MainLevel.GetTerrainY(vector);
                NavMeshHit navMeshHit;
                if (NavMesh.SamplePosition(vector, out navMeshHit, 1f, AIManager.s_WalkableAreaMask) && NavMesh.CalculatePath(this.m_AI.m_PathModule.m_Agent.nextPosition, navMeshHit.position, AIManager.s_WalkableAreaMask, this.m_TempPath) && this.m_TempPath.status == NavMeshPathStatus.PathComplete)
                {
                    this.m_AI.m_PathModule.m_Agent.SetPath(this.m_TempPath);
                    return(true);
                }
                this.m_Range += this.ADD_RANGE;
            }
            this.m_AI.m_PerformEmergency = true;
            return(false);
        }
Пример #7
0
 protected override void UpdateSwimState()
 {
     base.UpdateSwimState();
     this.UpdateBlend();
     if (Time.time - this.m_LastIdleTime > 60f && base.transform.position.y - MainLevel.GetTerrainY(base.transform.position) <= 0f)
     {
         base.SetState(Fish.State.Idle);
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        AssignMenuChildren();
        mainLevelRef    = this.GetComponent <MainLevel>();
        spawnManagerRef = this.GetComponent <SpawnManager>();


        HUD.transform.GetChild(1).GetChild(2).GetComponent <Text>().text = Mathf.FloorToInt(mainLevelRef.currency).ToString();
    }
Пример #9
0
 private void Start()
 {
     if (MainLevel.GetTerrainY(base.transform.position) >= this.m_BoxCollider.bounds.max.y)
     {
         base.enabled = false;
         DebugUtils.Assert(false, "[FishTank::Start] Fish tank " + base.name + " is under terrain!", true, DebugUtils.AssertType.Info);
         return;
     }
 }
Пример #10
0
 public void Deconstruct()
 {
     if (this.m_Fulfilled)
     {
         Vector3 position = base.transform.position;
         float   terrainY = MainLevel.GetTerrainY(position);
         position.y = Mathf.Max(position.y, terrainY);
         ItemsManager.Get().CreateItem(this.m_ItemID, true, position, Quaternion.identity);
     }
 }
Пример #11
0
    // Start is called before the first frame update
    public virtual void Start()
    {
        currentHealth       = maxHealth;
        healthRecoveryTimer = healthRecoveryDelay;
        mainLevelRef        = FindObjectOfType <MainLevel>();
        healthBar.transform.parent.GetComponent <Canvas>().worldCamera = FindObjectOfType <PlayerController>().transform.GetChild(0).GetComponent <Camera>();

        upgradePrice = structurePrice * (currentUpgrades * 0.75f + 1);
        mainLevelRef.audioRef.PlaySFX("BuildStructure");
    }
Пример #12
0
    public void ReturnToMainMenu()
    {
        MainLevel instance = MainLevel.Instance;

        if (instance != null)
        {
            instance.EnableTerrainRendering(true);
        }
        this.m_LoadState = GreenHellGame.LoadState.ReturnToMainMenuRequest;
    }
Пример #13
0
        public override void Load()
        {
            StreamReader gfile    = new StreamReader(System.IO.Path.Combine(Application.persistentDataPath, "myLevel" + who));
            string       loadJson = gfile.ReadToEnd();

            gfile.Close();

            load = new MainLevel();
            load = JsonUtility.FromJson <MainLevel>(loadJson);
        }
Пример #14
0
        private void TrySpawnWave()
        {
            Vector3        position = Player.Get().transform.position;
            List <Vector3> list     = null;

            for (int i = 0; i < 20; i++)
            {
                Vector3 insideUnitSphere = UnityEngine.Random.insideUnitSphere;
                Vector3 vector           = position + insideUnitSphere.GetNormalized2D() * UnityEngine.Random.Range(this.m_MinRange, this.m_MaxRange);
                vector.y = MainLevel.GetTerrainY(vector);
                float num = Vector3.Distance(vector, position);
                for (int j = 0; j < this.m_Count; j++)
                {
                    NavMeshHit navMeshHit;
                    if (NavMesh.SamplePosition(vector, out navMeshHit, this.m_MaxSampleRange, AIManager.s_WalkableAreaMask))
                    {
                        if (NavMesh.CalculatePath(navMeshHit.position, position, AIManager.s_WalkableAreaMask, this.m_TempPath) && this.m_TempPath.status == NavMeshPathStatus.PathComplete)
                        {
                            if (list == null)
                            {
                                list = new List <Vector3>();
                            }
                            list.Add(navMeshHit.position);
                            if (list.Count == this.m_Count)
                            {
                                break;
                            }
                        }
                    }
                }
                if (list != null && list.Count == this.m_Count)
                {
                    break;
                }
            }
            if (list == null || list.Count != this.m_Count)
            {
                return;
            }
            Debug.Log("HumanAIWave - " + list.Count);
            for (int k = 0; k < list.Count; k++)
            {
                GameObject prefab     = GreenHellGame.Instance.GetPrefab((k != 0) ? "Hunter" : "Savage");
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(prefab, list[k], Quaternion.identity);
                gameObject.transform.parent = base.transform;
                HumanAI component = gameObject.GetComponent <HumanAI>();
                component.m_AnimationModule.m_StartFromRandomFrame = true;
                component.m_Hallucination = this.m_Hallucination;
                this.AddAI(component);
            }
            base.Activate();
            this.m_WaveSpawned = true;
        }
Пример #15
0
        public override void Save(params int[] value)
        {
            MainLevel mp = new MainLevel();

            mp.Level = value[0];
            string saveString = JsonUtility.ToJson(mp);

            StreamWriter file = new StreamWriter(System.IO.Path.Combine(Application.persistentDataPath, "myLevel" + who));

            file.Write(saveString);
            file.Close();
        }
Пример #16
0
    private void SpawnStalker()
    {
        Vector3 forward = Camera.main.transform.forward;
        Vector3 vector  = Player.Get().GetHeadTransform().position - forward * this.m_MoveAwayRange;

        vector.y = MainLevel.GetTerrainY(vector);
        NavMeshHit navMeshHit;

        if (NavMesh.SamplePosition(vector, out navMeshHit, this.m_MoveAwayRange / 3f, AIManager.s_WalkableAreaMask) && NavMesh.CalculatePath(vector, Player.Get().transform.position, AIManager.s_WalkableAreaMask, this.m_TempPath) && this.m_TempPath.status == NavMeshPathStatus.PathComplete)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_StalkerPrefab, vector, Player.Get().transform.rotation);
            this.m_Stalker = gameObject.GetComponent <Stalker>();
        }
    }
Пример #17
0
    // Start is called before the first frame update
    protected virtual void Start()
    {
        anim                    = GetComponent <Animator>();
        mainLevelRef            = spawnManagerRef.GetComponent <MainLevel>();
        rangeCollider           = this.GetComponent <SphereCollider>();
        rangeCollider.isTrigger = true;
        rangeCollider.radius    = range;
        attackTimer             = 0.0f;
        currentHealth           = maxHealth;

        nearbyStructuresQueue = new List <BaseStructureClass>();
        spawnLoc = new Vector2(tileMapRef.size_x - 1, tileMapRef.size_z - 1);
        ResetPath();
    }
Пример #18
0
 private void DebugRender()
 {
     if (!GreenHellGame.DEBUG)
     {
         return;
     }
     for (int i = 1; i < this.m_Agent.path.corners.Length; i++)
     {
         Vector3 vector = this.m_Agent.path.corners[i - 1];
         vector.y = MainLevel.GetTerrainY(vector);
         Vector3 vector2 = this.m_Agent.path.corners[i];
         vector2.y = MainLevel.GetTerrainY(vector2);
         Debug.DrawLine(vector, vector2, Color.blue);
     }
 }
Пример #19
0
        private void AllignToTerrain()
        {
            Vector3 position = this.m_AI.transform.position;

            this.GetRaycastHit(position + Vector3.up * this.m_AI.m_BoxCollider.size.y);
            position.y = Mathf.Max(TransformModule.s_RaycastHit.point.y, MainLevel.GetTerrainY(position));
            this.m_AI.transform.position = position;
            if (this.m_AI.m_Params.m_Human)
            {
                return;
            }
            if (this.m_AI.m_Visible)
            {
                Vector3 normalized2D = this.m_AI.transform.forward.GetNormalized2D();
                Vector3 vector       = this.m_AI.m_BoxCollider.bounds.center + normalized2D * this.m_AI.m_BoxCollider.size.z + Vector3.up * this.m_AI.m_BoxCollider.size.y;
                this.GetRaycastHit(vector);
                vector = TransformModule.s_RaycastHit.point;
                Vector3 vector2 = this.m_AI.m_BoxCollider.bounds.center - normalized2D * this.m_AI.m_BoxCollider.size.z + Vector3.up * this.m_AI.m_BoxCollider.size.y;
                this.GetRaycastHit(vector2);
                vector2 = TransformModule.s_RaycastHit.point;
                Vector3 lhs           = vector - vector2;
                Vector3 normalized2D2 = this.m_AI.transform.right.GetNormalized2D();
                Vector3 vector3       = Vector3.zero;
                if (this.m_AI.m_Params.m_AllignToTerrainFull)
                {
                    Vector3 vector4 = this.m_AI.m_BoxCollider.bounds.center + normalized2D2 * this.m_AI.m_BoxCollider.size.x + Vector3.up * this.m_AI.m_BoxCollider.size.y;
                    this.GetRaycastHit(vector4);
                    vector4 = TransformModule.s_RaycastHit.point;
                    Vector3 vector5 = this.m_AI.m_BoxCollider.bounds.center - normalized2D2 * this.m_AI.m_BoxCollider.size.x + Vector3.up * this.m_AI.m_BoxCollider.size.y;
                    this.GetRaycastHit(vector5);
                    vector5 = TransformModule.s_RaycastHit.point;
                    Vector3 vector6 = vector4 - vector5;
                    vector3 = Vector3.Cross(lhs.normalized, vector6.normalized);
                }
                else
                {
                    vector3 = Vector3.Cross(lhs, normalized2D2);
                }
                if (!vector3.IsZero())
                {
                    this.m_AI.transform.rotation = Quaternion.Slerp(this.m_AI.transform.rotation, Quaternion.LookRotation(lhs.normalized, vector3.normalized), 1f);
                }
            }
            this.m_AI.m_BoxCollider.enabled = true;
        }
Пример #20
0
        public Vector3 GetRandomPointInTankSpace()
        {
            Vector3 vector = Vector3.zero;
            int     num    = 99;

            for (int i = 0; i < num; i++)
            {
                vector.x = UnityEngine.Random.Range(-0.5f, 0.5f);
                vector.y = UnityEngine.Random.Range(-0.5f, 0.5f);
                vector.z = UnityEngine.Random.Range(-0.5f, 0.5f);
                vector   = base.gameObject.transform.TransformPoint(vector);
                if (vector.y >= MainLevel.GetTerrainY(vector))
                {
                    return(vector);
                }
            }
            return(base.transform.position);
        }
Пример #21
0
    private void AllignToTerrain()
    {
        if (!this.m_AllignToTerrain)
        {
            return;
        }
        bool enabled = this.m_BoxCollider.enabled;

        this.m_BoxCollider.enabled = false;
        RaycastHit raycastHit   = default(RaycastHit);
        Vector3    normalized2D = base.transform.forward.GetNormalized2D();
        Vector3    vector       = this.m_BoxCollider.bounds.center + normalized2D * this.m_BoxCollider.size.z + Vector3.up * this.m_BoxCollider.size.y;

        this.GetRaycastHit(vector, ref raycastHit);
        vector = raycastHit.point;
        Vector3 vector2 = this.m_BoxCollider.bounds.center - normalized2D * this.m_BoxCollider.size.z + Vector3.up * this.m_BoxCollider.size.y;

        this.GetRaycastHit(vector2, ref raycastHit);
        vector2 = raycastHit.point;
        Vector3 vector3       = vector - vector2;
        Vector3 normalized2D2 = base.transform.right.GetNormalized2D();
        Vector3 vector4       = Vector3.zero;
        Vector3 vector5       = this.m_BoxCollider.bounds.center + normalized2D2 * this.m_BoxCollider.size.x + Vector3.up * this.m_BoxCollider.size.y;

        this.GetRaycastHit(vector5, ref raycastHit);
        vector5 = raycastHit.point;
        Vector3 vector6 = this.m_BoxCollider.bounds.center - normalized2D2 * this.m_BoxCollider.size.x + Vector3.up * this.m_BoxCollider.size.y;

        this.GetRaycastHit(vector6, ref raycastHit);
        vector6 = raycastHit.point;
        Vector3 vector7 = vector5 - vector6;

        vector4 = Vector3.Cross(vector3.normalized, vector7.normalized);
        if (!vector4.IsZero())
        {
            base.transform.rotation = Quaternion.Slerp(base.transform.rotation, Quaternion.LookRotation(vector3.normalized, vector4.normalized), 1f);
        }
        Vector3 position = base.transform.position;

        this.GetRaycastHit(position + Vector3.up * this.m_BoxCollider.size.y, ref raycastHit);
        position.y = Mathf.Max(raycastHit.point.y, MainLevel.GetTerrainY(position)) + (this.m_BoxCollider.size.y * 0.5f - this.m_BoxCollider.center.y) + 0.1f;
        base.transform.position    = position;
        this.m_BoxCollider.enabled = enabled;
    }
Пример #22
0
        private Vector3 GetSpawnPosition()
        {
            int num = 50;

            for (int i = 0; i < num; i++)
            {
                Vector3 randomPositionInside = this.GetRandomPositionInside();
                randomPositionInside.y = MainLevel.GetTerrainY(randomPositionInside);
                if (this.m_Bounds.Contains(randomPositionInside))
                {
                    NavMeshHit navMeshHit;
                    if (NavMesh.SamplePosition(randomPositionInside, out navMeshHit, 2f, AIManager.s_WalkableAreaMask) && this.IsPoisitionAvailable(navMeshHit.position))
                    {
                        return(navMeshHit.position);
                    }
                }
            }
            return(Vector3.zero);
        }
Пример #23
0
        private void GetRaycastHit(Vector3 pos)
        {
            float terrainY = MainLevel.GetTerrainY(pos);

            pos.y = Mathf.Max(pos.y, terrainY + 0.1f);
            int num = Physics.RaycastNonAlloc(pos, -Vector3.up, TransformModule.s_RaycastHitCache, pos.y - terrainY + 0.1f);

            this.m_RaycastOrig = pos;
            Array.Sort <RaycastHit>(TransformModule.s_RaycastHitCache, 0, num, TransformModule.s_DistComparer);
            for (int i = 0; i < num; i++)
            {
                RaycastHit raycastHit = TransformModule.s_RaycastHitCache[i];
                if (!(raycastHit.collider.gameObject == base.gameObject) && !raycastHit.collider.isTrigger && !this.m_LayerMasksToIgnore.Contains(raycastHit.collider.gameObject.layer))
                {
                    TransformModule.s_RaycastHit = raycastHit;
                    return;
                }
            }
        }
Пример #24
0
 private void UpdateHook()
 {
     if (FishingController.Get().m_State == FishingController.State.Cast || FishingController.Get().m_State == FishingController.State.Aim)
     {
         if (this.m_Hook.gameObject.activeSelf)
         {
             this.m_Hook.gameObject.SetActive(false);
         }
     }
     else if (!this.m_Hook.gameObject.activeSelf)
     {
         this.m_Hook.gameObject.SetActive(true);
     }
     if (this.m_State == FishingRod.State.None && this.m_Hook.gameObject.activeSelf)
     {
         Vector3 vector = this.m_Top.transform.position + Vector3.down * 1f;
         vector.y = Mathf.Max(vector.y, MainLevel.GetTerrainY(vector) + 0.2f);
         this.m_Hook.transform.position = vector;
     }
 }
Пример #25
0
    public Item ReplaceItem()
    {
        if (this.m_Hallucination)
        {
            base.Disappear(true);
            return(null);
        }
        this.OnReplaceItem();
        Vector3 position = base.transform.position;

        position.y = Mathf.Max(MainLevel.GetTerrainY(position), position.y);
        Item result = ItemsManager.Get().CreateItem(this.m_ReplaceInfo.m_ID, true, position, Quaternion.identity);

        if (!this.m_IsThisUnlimited)
        {
            base.TryRemoveFromFallenObjectsMan();
            this.ReplRequestOwnership(false);
            UnityEngine.Object.Destroy(base.gameObject);
        }
        return(result);
    }
Пример #26
0
    private void GetRaycastHit(Vector3 pos, ref RaycastHit hit)
    {
        pos.y = Mathf.Max(pos.y, MainLevel.GetTerrainY(pos) + 0.1f);
        RaycastHit[] collection = Physics.RaycastAll(pos, -Vector3.up);
        this.m_RaycastOrig = pos;
        List <RaycastHit> list = new List <RaycastHit>(collection);

        list.Sort(new Comparison <RaycastHit>(this.CompareListByDist));
        foreach (RaycastHit raycastHit in list)
        {
            if (!(raycastHit.collider.gameObject == base.gameObject))
            {
                if (!raycastHit.collider.isTrigger)
                {
                    if (!this.m_LayerMasksToIgnore.Contains(raycastHit.collider.gameObject.layer))
                    {
                        hit = raycastHit;
                        break;
                    }
                }
            }
        }
    }
Пример #27
0
    private void SetupHookInWaterPos()
    {
        Ray ray = new Ray(this.m_FloatPos + Vector3.up * 0.1f, Vector3.down);

        RaycastHit[]      collection = Physics.RaycastAll(ray);
        List <RaycastHit> list       = new List <RaycastHit>(collection);
        FishTank          fishTank   = null;
        Vector3           vector     = Vector3.zero;

        foreach (RaycastHit raycastHit in list)
        {
            fishTank = raycastHit.collider.gameObject.GetComponent <FishTank>();
            if (fishTank)
            {
                vector = raycastHit.point;
                break;
            }
        }
        float terrainY = MainLevel.GetTerrainY(this.m_FloatPos);

        if (terrainY >= this.m_FloatPos.y)
        {
            DebugUtils.Assert("[FishingRod:OnEnterState] Float is under terrain!", true, DebugUtils.AssertType.Info);
        }
        Vector3 floatPos = this.m_FloatPos;

        if (fishTank)
        {
            floatPos.y = vector.y - fishTank.m_BoxCollider.size.y * 0.5f;
        }
        if (floatPos.y < terrainY + 0.2f)
        {
            floatPos.y = terrainY + 0.2f;
        }
        floatPos.y = Mathf.Min(floatPos.y, this.m_FloatPos.y);
        this.m_Hook.transform.position = floatPos;
    }
Пример #28
0
 protected virtual bool IsPointInsideTank(Vector3 point)
 {
     return(this.m_Tank && point.y > MainLevel.GetTerrainY(point) && this.m_Tank.IsPointInside(point));
 }
Пример #29
0
        private bool IsTankUnderTerrain()
        {
            float terrainY = MainLevel.GetTerrainY(base.transform.position);

            return(terrainY >= base.transform.position.y);
        }
Пример #30
0
        private void AllignToTerrain(bool use_temp_transform)
        {
            Vector3 position           = this.m_AI.transform.position;
            bool    autoSyncTransforms = Physics.autoSyncTransforms;

            Physics.autoSyncTransforms = false;
            this.GetRaycastHit(position + Vector3.up * this.m_AI.m_BoxCollider.size.y);
            position.y            = Mathf.Max(TransformModule.s_RaycastHit.point.y, MainLevel.GetTerrainY(position));
            this.m_TempTerrainPos = position;
            if (Time.time - this.m_SwimmingLastTime < 1f)
            {
                float num = (Time.time - this.m_SwimmingLastTime) / 1f;
                this.m_AI.transform.position = this.m_LastPosition * (1f - num) + position * num;
            }
            else
            {
                this.m_AI.transform.position = position;
            }
            if (this.m_AI.m_Params.m_Human)
            {
                Physics.autoSyncTransforms = autoSyncTransforms;
                return;
            }
            if (this.m_AI.IsVisible())
            {
                Vector3 normalized2D = this.m_AI.transform.forward.GetNormalized2D();
                Vector3 vector       = this.m_AI.m_BoxCollider.bounds.center + normalized2D * this.m_AI.m_BoxCollider.size.z + Vector3.up * this.m_AI.m_BoxCollider.size.y;
                this.GetRaycastHit(vector);
                vector = TransformModule.s_RaycastHit.point;
                if (use_temp_transform)
                {
                    this.m_TempTerrainPosFront = vector;
                }
                Vector3 vector2 = this.m_AI.m_BoxCollider.bounds.center - normalized2D * this.m_AI.m_BoxCollider.size.z + Vector3.up * this.m_AI.m_BoxCollider.size.y;
                this.GetRaycastHit(vector2);
                vector2 = TransformModule.s_RaycastHit.point;
                Vector3 lhs           = vector - vector2;
                Vector3 normalized2D2 = this.m_AI.transform.right.GetNormalized2D();
                Vector3 vector3       = Vector3.zero;
                if (this.m_AI.m_Params.m_AllignToTerrainFull)
                {
                    Vector3 vector4 = this.m_AI.m_BoxCollider.bounds.center + normalized2D2 * this.m_AI.m_BoxCollider.size.x + Vector3.up * this.m_AI.m_BoxCollider.size.y;
                    this.GetRaycastHit(vector4);
                    vector4 = TransformModule.s_RaycastHit.point;
                    Vector3 vector5 = this.m_AI.m_BoxCollider.bounds.center - normalized2D2 * this.m_AI.m_BoxCollider.size.x + Vector3.up * this.m_AI.m_BoxCollider.size.y;
                    this.GetRaycastHit(vector5);
                    vector5 = TransformModule.s_RaycastHit.point;
                    Vector3 vector6 = vector4 - vector5;
                    vector3 = Vector3.Cross(lhs.normalized, vector6.normalized);
                }
                else
                {
                    vector3 = Vector3.Cross(lhs, normalized2D2);
                }
                if (!vector3.IsZero())
                {
                    if (use_temp_transform)
                    {
                        this.m_TempTerrainRot = Quaternion.Slerp(this.m_AI.transform.rotation, Quaternion.LookRotation(lhs.normalized, vector3.normalized), 1f);
                    }
                    else
                    {
                        this.m_AI.transform.rotation = Quaternion.Slerp(this.m_AI.transform.rotation, Quaternion.LookRotation(lhs.normalized, vector3.normalized), 1f);
                    }
                }
            }
            Physics.autoSyncTransforms = autoSyncTransforms;
        }