Beispiel #1
0
    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);
            }
        }
    }
Beispiel #2
0
    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);
        }
    }
Beispiel #7
0
    protected virtual void OnDestroy()
    {
        SgtHelper.Destroy(material);

        for (var i = planes.Count - 1; i >= 0; i--)
        {
            SgtProminencePlane.MarkForDestruction(planes[i]);
        }

        planes.Clear();
    }
Beispiel #8
0
    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();
    }
Beispiel #9
0
    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);
    }