public void UpdatePlanes() { updatePlanesCalled = true; SgtHelper.BeginRandomSeed(Seed); { for (var i = 0; i < PlaneCount; i++) { var plane = GetOrAddPlane(i); plane.SetRotation(Random.rotationUniform); } } SgtHelper.EndRandomSeed(); // Remove any excess if (Planes != null) { var min = Mathf.Max(0, PlaneCount); for (var i = Planes.Count - 1; i >= min; i--) { SgtProminencePlane.Pool(Planes[i]); Planes.RemoveAt(i); } } }
private SgtProminencePlane GetOrAddPlane(int index) { var plane = default(SgtProminencePlane); if (Planes == null) { Planes = new List <SgtProminencePlane>(); } if (index < Planes.Count) { plane = Planes[index]; } else { Planes.Add(plane); } if (plane == null) { plane = Planes[index] = SgtProminencePlane.Create(this); plane.SetMaterial(Material); plane.SetMesh(Mesh); } return(plane); }
public static void Pool(SgtProminencePlane plane) { if (plane != null) { plane.Prominence = null; SgtComponentPool<SgtProminencePlane>.Add(plane); } }
public static void MarkForDestruction(SgtProminencePlane plane) { if (plane != null) { plane.Prominence = null; plane.gameObject.SetActive(true); } }
public static void MarkForDestruction(SgtProminencePlane plane) { if (plane != null) { plane.Prominence = null; plane.gameObject.SetActive(true); } }
public static void Pool(SgtProminencePlane plane) { if (plane != null) { plane.Prominence = null; SgtComponentPool <SgtProminencePlane> .Add(plane); } }
protected virtual void OnDestroy() { SgtHelper.Destroy(material); for (var i = planes.Count - 1; i >= 0; i--) { SgtProminencePlane.MarkForDestruction(planes[i]); } planes.Clear(); }
private void UpdatePlanes() { planes.RemoveAll(p => p == null); if (PlaneCount != planes.Count) { SgtHelper.ResizeArrayTo(ref planes, PlaneCount, i => SgtProminencePlane.Create(this), p => SgtProminencePlane.Pool(p)); } SgtHelper.BeginRandomSeed(Seed); { for (var i = planes.Count - 1; i >= 0; i--) { planes[i].ManualUpdate(mesh, material, Random.rotationUniform); } } SgtHelper.EndRandomSeed(); }
protected virtual void OnDestroy() { if (Planes != null) { for (var i = Planes.Count - 1; i >= 0; i--) { SgtProminencePlane.MarkForDestruction(Planes[i]); } } if (Mesh != null) { Mesh.Clear(false); SgtObjectPool <Mesh> .Add(Mesh); } SgtHelper.Destroy(Material); }