public static bool Prefix(TradeUI __instance, XRL.World.GameObject Trader) { Debug.Log("Running Trade Patch to check willingness!"); if (Trader.HasPart("DynamicPersonality")) { DynamicPersonality personality = Trader.GetPart <DynamicPersonality>(); if (personality.WillingToTrade) { Debug.Log("Is willing to trade!"); return(true); } else { Debug.Log("Is NOT willing to trade!"); Popup.ShowFail(Trader.The + Trader.ShortDisplayName + " does not like you well enough to trade."); return(false); } } else { Debug.LogError($"CheckTradeWillingnessPatch run on gameobject {Trader.DebugName} which has no DynamicPersonality part"); return(true); } }
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 = ConsoleLib.Console.ColorUtility.ColorMap['k']; this.ForegroundColor = ConsoleLib.Console.ColorUtility.ColorMap['y']; this.BackgroundColor = ConsoleLib.Console.ColorUtility.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; ////DEBUG //UnityEngine.Debug.Log("Render data from GameObject.Render() for " + go.DisplayName + ":\n Tile=" + renderData.Tile // + "\n ColorString=" + renderData.ColorString // + "\n DetailColor=" + renderData.DetailColor // + "\n RenderString=" + renderData.RenderString // + "\n BackgroundString=" + renderData.BackgroundString // + "\nRender data from object itself:" // + "\n Tile=" + pRender.Tile // + "\n RenderString=" + pRender.RenderString // + "\n TileColor=" + pRender.TileColor // + "\n ColorString=" + pRender.ColorString // + "\n DetailColor=" + pRender.DetailColor); ////DEBUG //save render data in our custom TileColorData format, using logic similar to QudItemListElement.InitFrom() if (!string.IsNullOrEmpty(pRender.DetailColor)) { this.DetailColor = ConsoleLib.Console.ColorUtility.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 = ConsoleLib.Console.ColorUtility.ColorMap[colorString[j + 1]]; this.ForegroundColorChar = colorString[j + 1]; } } if (colorString[j] == '^' && j < colorString.Length - 1) { if (colorString[j + 1] == '^') { j++; } else { this.BackgroundColor = ConsoleLib.Console.ColorUtility.ColorMap[colorString[j + 1]]; this.BackgroundColorChar = colorString[j + 1]; } } } } this.Attributes = ColorUtility.MakeColor(ColorUtility.CharToColorMap[this.ForegroundColorChar], ColorUtility.CharToColorMap[this.BackgroundColorChar]); }