/// Update this.tilable graphics according to the tilable connections. public void UpdateGraphics() { int connsInt = 0; this.SetLinks(); int i = 0; foreach (int direction in DirectionUtils.cardinals) { if (this.connections[direction]) { connsInt += DirectionUtils.connections[i]; } i++; } // Check if we need a roof or basicly checks corners here. i = 0; this.allCorners = true; bool hasCorner = false; foreach (int direction in DirectionUtils.corners) { if ( (i != 0 || this.connections[direction] && (this.connections[(int)Direction.W] && this.connections[(int)Direction.S])) && (i != 1 || this.connections[direction] && (this.connections[(int)Direction.W] && this.connections[(int)Direction.N])) && (i != 2 || this.connections[direction] && (this.connections[(int)Direction.E] && this.connections[(int)Direction.N])) && (i != 3 || this.connections[direction] && (this.connections[(int)Direction.E] && this.connections[(int)Direction.S])) ) { this.corners[i] = true; hasCorner = true; } else { this.corners[i] = false; this.allCorners = false; } i++; } if (connsInt != this.connectionsInt) { this.connectionsInt = connsInt; if (this.allCorners) { this.tilable.mainGraphic = GraphicInstance.GetNew( this.tilable.def.graphics, default(Color), Res.textures[this.tilable.def.graphics.textureName + "_cover"], 1 ); Loki.map.GetTilableAt(this.tilable.position, Layer.Ground).hidden = true; } else { this.tilable.mainGraphic = GraphicInstance.GetNew( this.tilable.def.graphics, default(Color), Res.textures[this.tilable.def.graphics.textureName + "_" + this.connectionsInt.ToString()], 1 ); if (hasCorner) { this.tilable.addGraphics.Add("cover", GraphicInstance.GetNew( this.tilable.def.graphics, default(Color), Res.textures[this.tilable.def.graphics.textureName + "_cover"], 2, MeshPool.GetCornersPlane(this.corners) ) ); } Loki.map.GetTilableAt(this.tilable.position, Layer.Ground).hidden = false; } } }