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;
144 var message = Lang.Get("tradingwindow-" + entity.Code.Path, traderName);
145 if (traderJoe.TradeProps != null)
147 message += $" - Gears: {traderJoe.TradeProps.Money}, ";
149 poi.AddReplace(new EntityOfInterest
152 PrettyLocation = posn.PrettyCoords(clientAPI),
153 Location = posn.Copy(),
155 Timestamp = DateTime.UtcNow,
156 EntityId = entity.EntityId
160 internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
163 clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
165 //Where to? and from!
167 BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
171 //FIXME: Delayed rescan ?
172 StringBuilder textTarget = new StringBuilder();
173 //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
174 textTarget.Append(te.FullyRepaired ? "Functional, " : "Broken, ");
175 textTarget.Append(te.Activated ? "Online, " : "Offline, ");
176 textTarget.Append(" Target: [ ");
177 textTarget.Append(te.TargetLocation != null ? "Set ]" : "Invalid ]");//Or ABS coords?
178 textTarget.AppendFormat(", Range ({0} ~ {1})", te.MinTeleporterRangeInBlocks, te.MaxTeleporterRangeInBlocks);
182 Name = "Translocator",
183 PrettyLocation = posn.PrettyCoords(clientAPI),
184 Location = posn.Copy(),
185 Notes = textTarget.ToString(),
186 Timestamp = DateTime.UtcNow,
187 Destination = te.TargetLocation != null ? new BlockPosJson(te.TargetLocation.Copy()) : null