2 using System.Collections.Generic;
5 using System.Text.RegularExpressions;
7 using Vintagestory.API.Client;
8 using Vintagestory.API.Common;
9 using Vintagestory.API.Common.Entities;
10 using Vintagestory.API.Config;
11 using Vintagestory.API.MathTools;
12 using Vintagestory.GameContent;
16 public static class DefaultDesignators
18 public static BlockDesignator Roads =
20 new AssetLocation("game", "stonepath"),
22 EnumBlockMaterial.Gravel
25 public static BlockDesignator GroundSigns =
27 new AssetLocation("game", "sign-ground"),
29 EnumBlockMaterial.Wood,
33 public static BlockDesignator WallSigns =
35 new AssetLocation("game", "sign-wall"),
37 EnumBlockMaterial.Wood,
41 public static BlockDesignator PostSigns =
43 new AssetLocation("game", "signpost"),
45 EnumBlockMaterial.Wood,
49 public static BlockDesignator Translocators =
51 new AssetLocation("game", "statictranslocator-normal"),
53 EnumBlockMaterial.Metal,
57 public static EntityDesignator Traders =
59 new AssetLocation("game", "humanoid-trader"),
60 Color.LightGoldenrodYellow,
61 EnumEntityState.Active,
66 /// Not just blocks, but block-entities as well!
68 /// <returns>The block designators.</returns>
69 public static List<BlockDesignator> DefaultBlockDesignators()
71 return new List<BlockDesignator>{
72 DefaultDesignators.Roads,
73 DefaultDesignators.GroundSigns,
74 DefaultDesignators.WallSigns,
75 DefaultDesignators.PostSigns,
76 DefaultDesignators.Translocators,
80 public static List<EntityDesignator> DefaultEntityDesignators()
82 return new List<EntityDesignator>{
83 DefaultDesignators.Traders,
89 internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
92 clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
94 //sign Text into a POI field...
95 BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
97 if (signEntity != null && !String.IsNullOrEmpty(signEntity.text))
104 PrettyLocation = posn.PrettyCoords(clientAPI),
105 Location = posn.Copy(),
106 Notes = signEntity.text,
107 Timestamp = DateTime.UtcNow,
114 internal static void DecodePostSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
117 clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!");
119 //sign post Text into a POI field...
120 BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
122 if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0)
129 PrettyLocation = posn.PrettyCoords(clientAPI),
130 Location = posn.Copy(),
131 Notes = string.Join(",", signEntity.textByCardinalDirection),
132 Timestamp = DateTime.UtcNow,
138 internal static void KeepTrackOfMerchant(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity)
140 //clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
142 var traderJoe = entity as EntityTrader;
143 var traderName = entity.GetBehavior<EntityBehaviorNameTag>()?.DisplayName;
146 switch (entity.Code.Path) {
147 case "humanoid-trader-artisan":
148 code = "{0} the artisan";
150 case "humanoid-trader-treasurehunter":
151 code = "{0} the treasure hunter";
153 case "humanoid-trader-buildmaterials":
154 code = "{0} the building materials trader";
156 case "humanoid-trader-clothing":
157 code = "{0} the clothing merchant";
159 case "humanoid-trader-commodities":
160 code = "{0} the commodities merchant";
162 case "humanoid-trader-foods":
163 code = "{0} the foods supplier";
165 case "humanoid-trader-furniture":
166 code = "{0} the furniture trader";
168 case "humanoid-trader-luxuries":
169 code = "{0} the luxuries merchant";
171 case "humanoid-trader-survivalgoods":
172 code = "{0} the survival goods supplier";
178 var message = string.Format(code, traderName);
179 if (traderJoe.TradeProps != null)
181 message += $" - Gears: {traderJoe.TradeProps.Money}, ";
183 poi.AddReplace(new EntityOfInterest
186 PrettyLocation = posn.PrettyCoords(clientAPI),
187 Location = posn.Copy(),
189 Timestamp = DateTime.UtcNow,
190 EntityId = entity.EntityId
194 internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
197 clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
199 //Where to? and from!
201 BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
205 //FIXME: Delayed rescan ?
206 StringBuilder textTarget = new StringBuilder();
207 //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
208 textTarget.Append(te.FullyRepaired ? "Functional, " : "Broken, ");
209 textTarget.Append(te.Activated ? "Online, " : "Offline, ");
210 textTarget.Append(" Target: [ ");
211 textTarget.Append(te.TargetLocation != null ? "Set ]" : "Invalid ]");//Or ABS coords?
212 textTarget.AppendFormat(", Range ({0} ~ {1})", te.MinTeleporterRangeInBlocks, te.MaxTeleporterRangeInBlocks);
216 Name = "Translocator",
217 PrettyLocation = posn.PrettyCoords(clientAPI),
218 Location = posn.Copy(),
219 Notes = textTarget.ToString(),
220 Timestamp = DateTime.UtcNow,
221 Destination = te.TargetLocation != null ? new BlockPosJson(te.TargetLocation.Copy()) : null