private void Initialize(GameObject go, bool renderOK = true) { this.Tile = string.Empty; this.RenderString = string.Empty; this.BackgroundString = string.Empty; this.DetailColorChar = 'k'; this.ForegroundColorChar = 'y'; this.BackgroundColorChar = 'k'; this.DetailColor = QudColorUtility.ColorMap['k']; this.ForegroundColor = QudColorUtility.ColorMap['y']; this.BackgroundColor = QudColorUtility.ColorMap['k']; //gather render data for GameObject similar to how the game does it in Cell.cs Render pRender = go?.pRender; if (pRender == null || !pRender.Visible || Globals.RenderMode != RenderModeType.Tiles) { return; } RenderEvent renderData = new RenderEvent(); Examiner examinerPart = go.GetPart <Examiner>(); if (examinerPart != null && !string.IsNullOrEmpty(examinerPart.UnknownTile) && !go.Understood()) { renderData.Tile = examinerPart.UnknownTile; } else { renderData.Tile = go.pRender.Tile; } if (!string.IsNullOrEmpty(pRender.TileColor)) { renderData.ColorString = pRender.TileColor; } else { renderData.ColorString = pRender.ColorString; } if (renderOK) //we can't render blueprint-created objects, because the game will throw errors trying to check their current cell { go.Render(renderData); } //renderData.Tile can be null if something has a temporary character replacement, like the up arrow from flying this.Tile = !string.IsNullOrEmpty(renderData.Tile) ? renderData.Tile : pRender.Tile; this.RenderString = !string.IsNullOrEmpty(renderData.RenderString) ? renderData.RenderString : pRender.RenderString; this.BackgroundString = renderData.BackgroundString; //save render data in our custom TileColorData format, using logic similar to QudItemListElement.InitFrom() if (!string.IsNullOrEmpty(pRender.DetailColor)) { this.DetailColor = QudColorUtility.ColorMap[pRender.DetailColor[0]]; this.DetailColorChar = pRender.DetailColor[0]; } //from what I've been able to determine, I believe that the BackgroundString only applies to non-tiles (RenderString) entities (such as gas clouds) string colorString = renderData.ColorString + (string.IsNullOrEmpty(this.Tile) ? this.BackgroundString : string.Empty); if (!string.IsNullOrEmpty(colorString)) { for (int j = 0; j < colorString.Length; j++) { if (colorString[j] == '&' && j < colorString.Length - 1) { if (colorString[j + 1] == '&') { j++; } else { this.ForegroundColor = QudColorUtility.ColorMap[colorString[j + 1]]; this.ForegroundColorChar = colorString[j + 1]; } } if (colorString[j] == '^' && j < colorString.Length - 1) { if (colorString[j + 1] == '^') { j++; } else { this.BackgroundColor = QudColorUtility.ColorMap[colorString[j + 1]]; this.BackgroundColorChar = colorString[j + 1]; } } } } this.Attributes = QudColorUtility.MakeColor(QudColorUtility.CharToColorMap[this.ForegroundColorChar], QudColorUtility.CharToColorMap[this.BackgroundColorChar]); }
private ushort GetDarkenedAttributes() { return(QudColorUtility.MakeColor(QudColorUtility.CharToColorMap['K'], QudColorUtility.CharToColorMap['k'])); }