OSDN Git Service

the previous way could return non english stuff, which is bad
[automap/automap.git] / Automap / Designators / DefaultDesignators.cs
index 41bd4af..102de1b 100644 (file)
@@ -7,15 +7,14 @@ using System.Text.RegularExpressions;
 using Vintagestory.API.Client;
 using Vintagestory.API.Common;
 using Vintagestory.API.Common.Entities;
+using Vintagestory.API.Config;
 using Vintagestory.API.MathTools;
 using Vintagestory.GameContent;
 
 namespace Automap
 {
        public static class DefaultDesignators
-       {
-               private static Regex stripControlChars = new Regex(@"\s", RegexOptions.Multiline);
-
+       {               
                public static BlockDesignator Roads =
                         new BlockDesignator(
                                new AssetLocation("game", "stonepath"),
@@ -104,13 +103,11 @@ namespace Automap
                                                                Name = "Sign",
                                                                PrettyLocation = posn.PrettyCoords(clientAPI),
                                                                Location = posn.Copy(),
-                                                               Notes = stripControlChars.Replace(signEntity.text, " "),
+                                                               Notes = signEntity.text,
                                                                Timestamp = DateTime.UtcNow,
                                                        }
                                                        );
-
                        }
-
                }
 
 
@@ -131,11 +128,10 @@ namespace Automap
                                                                Name = "Signpost",
                                                                PrettyLocation = posn.PrettyCoords(clientAPI),
                                                                Location = posn.Copy(),
-                                                               Notes = stripControlChars.Replace(string.Join(",", signEntity.textByCardinalDirection), " "),
+                                                               Notes = string.Join(",", signEntity.textByCardinalDirection),
                                                                Timestamp = DateTime.UtcNow,
                                                        }
                                                        );
-
                        }
                }
 
@@ -144,7 +140,42 @@ namespace Automap
                        //clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
 
                        var traderJoe = entity as EntityTrader;
-                       var message = $"{entity.GetName()} Alive: {traderJoe.Alive}";
+                       var traderName = entity.GetBehavior<EntityBehaviorNameTag>()?.DisplayName;
+                       string code;
+                       // this makes me ill
+                       switch (entity.Code.Path) {
+                               case "humanoid-trader-artisan":
+                                       code = "{0} the artisan";
+                                       break;
+                               case "humanoid-trader-treasurehunter":
+                                       code = "{0} the treasure hunter";
+                                       break;
+                               case "humanoid-trader-buildmaterials":
+                                       code = "{0} the building materials trader";
+                                       break;
+                               case "humanoid-trader-clothing":
+                                       code = "{0} the clothing merchant";
+                                       break;
+                               case "humanoid-trader-commodities":
+                                       code = "{0} the commodities merchant";
+                                       break;
+                               case "humanoid-trader-foods":
+                                       code = "{0} the foods supplier";
+                                       break;
+                               case "humanoid-trader-furniture":
+                                       code = "{0} the furniture trader";
+                                       break;
+                               case "humanoid-trader-luxuries":
+                                       code = "{0} the luxuries merchant";
+                                       break;
+                               case "humanoid-trader-survivalgoods":
+                                       code = "{0} the survival goods supplier";
+                                       break;
+                               default:
+                                       code = "";
+                                       break;
+                       }
+                       var message = string.Format(code, traderName);
                        if (traderJoe.TradeProps != null)
                        {
                                message += $" - Gears: {traderJoe.TradeProps.Money}, ";