Ejemplo n.º 1
0
    public static Plane Load(System.IO.Stream fs, IPlanable host)
    {
        var data = new byte[9];

        fs.Read(data, 0, data.Length);
        int   materialID = System.BitConverter.ToInt32(data, 2);
        Plane p;

        if (data[0] == BASIC_PLANE_CODE)
        {
            p = new Plane(host, (MeshType)data[1], materialID, data[6], data[7]);
        }
        else
        {
            p = new MultimaterialPlane(host, (MeshType)data[1], data[6], data[7]);
        }
        switch (data[8])
        {
        case 1:
            PlaneExtension.Load(fs, p); break;

        case 2:
            Structure.LoadStructure(fs, p);
            break;
        }
        return(p);
    }
Ejemplo n.º 2
0
    public Plane CreatePlane(byte faceIndex, bool redrawCall)
    {
        if (planes == null)
        {
            planes = new Dictionary <byte, Plane>();
        }
        else
        {
            if (planes.ContainsKey(faceIndex))
            {
                return(planes[faceIndex]);
            }
        }

        var   pos = myBlock.pos;
        Plane p;

        if (faceIndex < 4)
        {
            MeshType mtype = MeshType.Quad;
            var      f     = Random.value;
            if (f < 0.8f)
            {
                if (f < 0.4f)
                {
                    mtype = MeshType.StorageEntrance;
                }
                else
                {
                    mtype = MeshType.StorageSide;
                }
            }
            else
            {
                mtype = MeshType.DoubleWindows;
            }
            var mp = new MultimaterialPlane(this, mtype, faceIndex, 0);
            mp.SetActivationStatus(isActive);
            p = mp;
        }
        else
        {
            if (faceIndex == Block.UP_FACE_INDEX && pos.y == Chunk.chunkSize - 1)
            {
                p = MeshMaster.GetRooftop(this, Random.value < 0.1f, true);
            }
            else
            {
                p = new Plane(this, MeshType.Quad, PoolMaster.MATERIAL_ADVANCED_COVERING_ID, faceIndex, 0);
            }
        }
        //
        planes.Add(faceIndex, p);
        if (redrawCall)
        {
            myBlock.myChunk.RefreshBlockVisualising(myBlock, faceIndex);
        }
        return(p);
    }
Ejemplo n.º 3
0
    public Plane CreatePlane(byte faceIndex, bool redrawCall)
    {
        if (planes == null)
        {
            planes = new Dictionary <byte, Plane>();
        }
        else
        {
            if (planes.ContainsKey(faceIndex))
            {
                return(planes[faceIndex]);
            }
        }

        var   pos = myBlock.pos;
        Plane p;

        if (faceIndex < 4)
        {
            var mtype = (ID == FARM_BLOCK_ID ? MeshType.FarmSide : MeshType.LumbermillSide);
            var f     = Random.value;
            if (f < 0.25f)
            {
                mtype = (ID == FARM_BLOCK_ID ? MeshType.FarmFace : MeshType.LumbermillFace);
            }
            else
            {
                if (f > 0.8f)
                {
                    mtype = f > 0.9f ? MeshType.IndustryHeater0 : MeshType.IndustryHeater1;
                }
                else
                {
                    if (f > 0.7f)
                    {
                        if (f > 0.75f)
                        {
                            mtype = MeshType.BigWindow;
                        }
                        else
                        {
                            mtype = MeshType.SmallWindows;
                        }
                    }
                }
            }
            var mp = new MultimaterialPlane(this, mtype, faceIndex, 0);
            mp.SetActivationStatus(isActive);
            p = mp;
        }
        else
        {
            if (faceIndex == Block.UP_FACE_INDEX && pos.y == Chunk.chunkSize - 1)
            {
                p = MeshMaster.GetRooftop(this, Random.value < 0.1f, true);
            }
            else
            {
                p = new Plane(this, MeshType.Quad, PoolMaster.MATERIAL_ADVANCED_COVERING_ID, faceIndex, 0);
            }
        }
        //
        planes.Add(faceIndex, p);
        if (redrawCall)
        {
            myBlock.myChunk.RefreshBlockVisualising(myBlock, faceIndex);
        }
        return(p);
    }
Ejemplo n.º 4
0
    public Plane CreatePlane(byte faceIndex, bool redrawCall)
    {
        if (planes == null)
        {
            planes = new Dictionary <byte, Plane>();
        }
        else
        {
            if (planes.ContainsKey(faceIndex))
            {
                return(planes[faceIndex]);
            }
        }

        var   pos = myBlock.pos;
        Plane p;

        if (faceIndex < 4)
        {
            var   mtype = MeshType.Housing_0;
            float f     = Random.value;
            if (f < 0.75f)
            {
                if (f > 0.5f)
                {
                    mtype = MeshType.Housing_0;
                }
                else
                {
                    if (f < 0.25f)
                    {
                        mtype = MeshType.Housing_1;
                    }
                    else
                    {
                        mtype = MeshType.Housing_2;
                    }
                }
            }
            else
            {
                if (f > 0.92f)
                {
                    mtype = MeshType.SimpleHeater_0;
                }
                else
                {
                    if (f > 0.83f)
                    {
                        mtype = MeshType.BigWindow;
                    }
                    else
                    {
                        mtype = MeshType.SmallWindows;
                    }
                }
            }
            var mp = new MultimaterialPlane(this, mtype, faceIndex, 0);
            mp.SetActivationStatus(isActive);
            p = mp;
        }
        else
        {
            if (faceIndex == Block.UP_FACE_INDEX && pos.y == Chunk.chunkSize - 1)
            {
                p = MeshMaster.GetRooftop(this, Random.value < 0.1f, true);
            }
            else
            {
                p = new Plane(this, MeshType.Quad, PoolMaster.MATERIAL_ADVANCED_COVERING_ID, faceIndex, 0);
            }
        }
        //
        planes.Add(faceIndex, p);
        if (redrawCall)
        {
            myBlock.myChunk.RefreshBlockVisualising(myBlock, faceIndex);
        }
        return(p);
    }