private void UpdateDisplacement(bool on) { Vector3 vector3 = new Vector3(); Vector2 vector2 = new Vector2(); Vector2 vector21 = new Vector2(); Camera camera; if (!on) { Shader.SetGlobalVector("_DisplacementWorldMin", Vector2.zero); Shader.SetGlobalVector("_DisplacementWorldMax", Vector2.zero); return; } FPGrassDisplacementCamera fPGrassDisplacementCamera = FPGrassDisplacementCamera.Get(); if (fPGrassDisplacementCamera == null) { camera = null; } else { camera = fPGrassDisplacementCamera.camera; } Camera vector31 = camera; if (vector31 == null) { return; } float single = vector31.orthographicSize; float single1 = single / (float)vector31.targetTexture.width; Vector3 vector32 = base.camera.transform.position; if (TransformHelpers.Dist2D(vector32, vector31.transform.position) > 5f) { vector3.x = Mathf.Round(vector32.x / single1) * single1; vector3.y = Mathf.Round(vector32.y / single1) * single1; vector3.z = Mathf.Round(vector32.z / single1) * single1; vector31.transform.position = vector3 + new Vector3(0f, 50f, 0f); } Vector3 vector33 = vector31.transform.position; vector2.x = vector33.x - single; vector2.y = vector33.z - single; vector21.x = vector33.x + single; vector21.y = vector33.z + single; Shader.SetGlobalVector("_DisplacementWorldMin", vector2); Shader.SetGlobalVector("_DisplacementWorldMax", vector21); vector31.Render(); }
public bool CheckBlockers(Vector3 pos) { if (this._structureToPlace.type == StructureComponent.StructureComponentType.Foundation) { foreach (Collider collider in Physics.OverlapSphere(pos, 12f, 0x10360401)) { IDMain main = IDBase.GetMain(collider.gameObject); if (main != null) { float num2 = TransformHelpers.Dist2D(main.transform.position, pos); if ((main.GetComponent <SpikeWall>() != null) && (num2 < 5f)) { return(false); } } } } if (!NoPlacementZone.ValidPos(pos)) { return(false); } return(true); }
private void UpdateDisplacement(bool on) { if (!on) { Shader.SetGlobalVector("_DisplacementWorldMin", Vector2.zero); Shader.SetGlobalVector("_DisplacementWorldMax", Vector2.zero); } else { FPGrassDisplacementCamera camera = FPGrassDisplacementCamera.Get(); Camera camera2 = (camera == null) ? null : camera.camera; if (camera2 != null) { Vector2 vector4; Vector2 vector5; float orthographicSize = camera2.orthographicSize; float num2 = orthographicSize / ((float)camera2.targetTexture.width); Vector3 position = base.camera.transform.position; if (TransformHelpers.Dist2D(position, camera2.transform.position) > 5f) { Vector3 vector2; vector2.x = Mathf.Round(position.x / num2) * num2; vector2.y = Mathf.Round(position.y / num2) * num2; vector2.z = Mathf.Round(position.z / num2) * num2; camera2.transform.position = vector2 + new Vector3(0f, 50f, 0f); } Vector3 vector3 = camera2.transform.position; vector4.x = vector3.x - orthographicSize; vector4.y = vector3.z - orthographicSize; vector5.x = vector3.x + orthographicSize; vector5.y = vector3.z + orthographicSize; Shader.SetGlobalVector("_DisplacementWorldMin", vector4); Shader.SetGlobalVector("_DisplacementWorldMax", vector5); camera2.Render(); } } }
public bool CheckBlockers(Vector3 pos) { if (this._structureToPlace.type == StructureComponent.StructureComponentType.Foundation) { Collider[] colliderArray = Physics.OverlapSphere(pos, 12f, 271975425); for (int i = 0; i < (int)colliderArray.Length; i++) { IDMain main = IDBase.GetMain(colliderArray[i].gameObject); if (main) { float single = TransformHelpers.Dist2D(main.transform.position, pos); if (main.GetComponent <SpikeWall>() && single < 5f) { return(false); } } } } if (!NoPlacementZone.ValidPos(pos)) { return(false); } return(true); }
public float GetVectorsDistance(Vector3 v1, Vector3 v2) { return(TransformHelpers.Dist2D(v1, v2)); }