예제 #1
0
        public void Prepare(int facet, int x, int y)
        {
            if (this.facet == facet && this.ax == x && this.ay == y)
            {
                return;
            }
            TileMatrix matrix    = Map.GetMatrix(facet);
            Tile       landTile1 = matrix.GetLandTile(x, y);
            Tile       landTile2 = matrix.GetLandTile(x, y + 1);
            Tile       landTile3 = matrix.GetLandTile(x + 1, y);
            Tile       landTile4 = matrix.GetLandTile(x + 1, y + 1);

            this.LandId          = landTile1.landId;
            this.facet           = facet;
            this.ax              = x;
            this.ay              = y;
            this.z00             = landTile1.z;
            this.z01             = landTile2.z;
            this.z11             = landTile4.z;
            this.z10             = landTile3.z;
            this.m_Z             = this.m_SortZ = this.z00;
            this.m_FoldLeftRight = Math.Abs((int)this.z00 - (int)this.z11) <= Math.Abs((int)this.z01 - (int)this.z10);
            this.m_SortZ         = !this.m_FoldLeftRight ? (sbyte)Map.FloorAverage((int)this.z01, (int)this.z10) : (sbyte)Map.FloorAverage((int)this.z00, (int)this.z11);
            this.m_Guarded       = Region.Find(Region.GuardedRegions, x, y, (int)this.z00, facet) != null;
            this.m_Height        = (byte)0;
            this.m_sDraw         = (Texture)null;
            this.normal          = new Point3D?();
            this._mesh           = (TerrainMesh)null;
            this.rev             = -1;
        }
예제 #2
0
        public void EnsureMesh(IHue hue, TerrainMeshProvider meshProvider)
        {
            if (this._mesh != null && this._lastMeshHue == hue && this._lastMeshProvider == meshProvider)
            {
                return;
            }
            this._lastMeshHue      = hue;
            this._lastMeshProvider = (IMeshProvider)meshProvider;
            int     landId    = this.graphicId;
            int     textureId = (int)Map.GetTexture(landId);
            Texture tex;

            if (textureId > 0 && textureId < 16384)
            {
                tex = hue.GetTerrainTexture(textureId);
                if (tex == null || tex.IsEmpty())
                {
                    tex = hue.GetTerrainIsometric(landId);
                    if (tex == null || tex.IsEmpty())
                    {
                        tex = hue.GetTerrainTexture(1);
                        if (tex == null || tex.IsEmpty())
                        {
                            return;
                        }
                    }
                }
            }
            else
            {
                tex = hue.GetTerrainIsometric(landId);
                if (tex == null || tex.IsEmpty())
                {
                    if (textureId > 0 && textureId < 16384)
                    {
                        tex = hue.GetTerrainTexture(textureId);
                    }
                    if (tex == null || tex.IsEmpty())
                    {
                        tex = hue.GetTerrainTexture(1);
                        if (tex == null || tex.IsEmpty())
                        {
                            this._mesh = (TerrainMesh)null;
                            return;
                        }
                    }
                }
            }
            this.m_sDraw = tex;
            if (tex.Width == 44 && !(this._mesh is TerrainMesh2D))
            {
                this._mesh = (TerrainMesh) new TerrainMesh2D();
                this._mesh.Load(this, tex);
            }
            else
            {
                if (tex.Width == 44 || this._mesh is TerrainMesh3D && ((TerrainMesh3D)this._mesh).Provider == meshProvider)
                {
                    return;
                }
                this._mesh = (TerrainMesh) new TerrainMesh3D(meshProvider);
                this._mesh.Load(this, tex);
            }
        }