public void RemoveHole(Hole hole) { this._holes.Remove(hole); }
private void SpawnFloor() { float num = float.MaxValue; float num2 = float.MinValue; Vector3[] array; if (this._wasBuilt) { this._raftRoot.rotation = base.transform.rotation; array = this._multiPointsPositions.ToArray(); } else { this._raftRoot.rotation = Quaternion.LookRotation(this._multiPointsPositions[1] - this._multiPointsPositions[0]); array = (from p in this._multiPointsPositions select base.transform.InverseTransformPoint(p)).ToArray <Vector3>(); } for (int i = 0; i < array.Length; i++) { if (array[i].z < num) { num = array[i].z; } if (array[i].z > num2) { num2 = array[i].z; } } float num3 = Mathf.Abs(num2 - num); this._rowCount = Mathf.CeilToInt(num3 / this._logWidth); this.InitRowPointsBuffer(this._rowCount, this._rowPointsBuffer, out this._rowPointsBuffer); this.CalcRowPointBufferForArray(array, num, this._rowPointsBuffer); if (this._holes != null) { for (int j = 0; j < this._holes.Count; j++) { Vector3[] array2 = new Vector3[5]; Hole hole = this._holes[j]; hole._used = false; if (this._wasBuilt) { array2[0] = base.transform.InverseTransformPoint(hole._position + new Vector3(hole._size.x, 0f, hole._size.y).RotateY(hole._yRotation)); array2[1] = base.transform.InverseTransformPoint(hole._position + new Vector3(hole._size.x, 0f, -hole._size.y).RotateY(hole._yRotation)); array2[2] = base.transform.InverseTransformPoint(hole._position + new Vector3(-hole._size.x, 0f, -hole._size.y).RotateY(hole._yRotation)); array2[3] = base.transform.InverseTransformPoint(hole._position + new Vector3(-hole._size.x, 0f, hole._size.y).RotateY(hole._yRotation)); } else { array2[0] = hole._position + base.transform.InverseTransformPoint(new Vector3(hole._size.x, 0f, hole._size.y).RotateY(hole._yRotation)); array2[1] = hole._position + base.transform.InverseTransformPoint(new Vector3(hole._size.x, 0f, -hole._size.y).RotateY(hole._yRotation)); array2[2] = hole._position + base.transform.InverseTransformPoint(new Vector3(-hole._size.x, 0f, -hole._size.y).RotateY(hole._yRotation)); array2[3] = hole._position + base.transform.InverseTransformPoint(new Vector3(-hole._size.x, 0f, hole._size.y).RotateY(hole._yRotation)); } array2[4] = array2[0]; for (int k = 0; k < 5; k++) { array2[k].y = array[0].y; } this.InitRowPointsBuffer(this._rowCount, this._holesRowPointsBuffer, out this._holesRowPointsBuffer); this.CalcRowPointBufferForArray(array2, num, this._holesRowPointsBuffer); for (int l = 0; l < this._rowCount; l++) { this._rowPointsBuffer[l].Sort((Vector3 x1, Vector3 x2) => x1.x.CompareTo(x2.x)); this._holesRowPointsBuffer[l].Sort((Vector3 x1, Vector3 x2) => x1.x.CompareTo(x2.x)); List <Vector3> list = this._rowPointsBuffer[l]; List <Vector3> list2 = this._holesRowPointsBuffer[l]; int num4 = list.Count; int count = list2.Count; for (int m = 1; m < num4; m += 2) { for (int n = 1; n < count; n += 2) { if (list[m - 1].x > list2[n - 1].x && list[m].x < list2[n].x) { list.RemoveAt(m); list.RemoveAt(m - 1); hole._used = true; if (n + 2 >= count) { if (m + 2 >= num4) { break; } m -= 2; num4 -= 2; } } else if (list[m - 1].x <list2[n - 1].x && list[m].x> list2[n].x) { list.Insert(m, list2[n - 1]); list.Insert(m + 1, list2[n]); hole._used = true; } else if (list[m - 1].x > list2[n - 1].x && list[m - 1].x < list2[n].x) { list[m - 1] = list2[n]; hole._used = true; } else if (list[m].x > list2[n - 1].x && list[m].x < list2[n].x) { list[m] = list2[n - 1]; hole._used = true; } } } } } } Transform transform = this._raftRoot; float num5 = 0f; float num6 = (this._maxScaleLogCost <= 0f) ? 0f : (this._maxLogScale / this._maxScaleLogCost); Vector3 one = Vector3.one; Quaternion rotation = Quaternion.LookRotation(base.transform.right); for (int num7 = 0; num7 < this._rowCount; num7++) { this._rowPointsBuffer[num7].Sort((Vector3 x1, Vector3 x2) => x1.x.CompareTo(x2.x)); int count2 = this._rowPointsBuffer[num7].Count; for (int num8 = 1; num8 < count2; num8 += 2) { Vector3 vector = base.transform.TransformPoint(this._rowPointsBuffer[num7][num8 - 1]); Vector3 a = base.transform.TransformPoint(this._rowPointsBuffer[num7][num8]) - vector; Vector3 normalized = a.normalized; if (num8 - 1 == 0) { vector -= normalized; } if (num8 + 1 == count2) { a += normalized * 2f; } else { a += normalized; } float magnitude = a.magnitude; int num9 = Mathf.CeilToInt(magnitude / this._maxChunkLength); one.z = magnitude / (float)num9 / this._logLength; Vector3 b = a / (float)num9; for (int num10 = 0; num10 < num9; num10++) { Transform transform2 = this.NewLog(vector, rotation); transform2.parent = null; if (num5 > 0f) { num5 -= one.z; transform2.parent = transform; Vector3 localScale = one; localScale.z /= transform.localScale.z; transform2.localScale = localScale; } else { transform = transform2; num5 = num6 - one.z; transform2.parent = this._raftRoot; transform2.localScale = one; } this._newPool.Push(transform2); vector += b; } } } }
public Hole AddSquareHole(Vector3 position, float yRotation, Vector2 size) { Hole hole = new Hole { _position = position, _yRotation = yRotation, _size = size, _used = true }; this._holes.Add(hole); return hole; }
public void RemoveHole(Hole hole) { this._holes.Remove(hole); this._holesCount = this._holes.Count; }