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.MathTools;
11 using Vintagestory.GameContent;
15 public static class DefaultDesignators
17 public static BlockDesignator Roads =
19 new AssetLocation("game", "stonepath"),
21 EnumBlockMaterial.Gravel
24 public static BlockDesignator GroundSigns =
26 new AssetLocation("game", "sign-ground"),
28 EnumBlockMaterial.Wood,
32 public static BlockDesignator WallSigns =
34 new AssetLocation("game", "sign-wall"),
36 EnumBlockMaterial.Wood,
40 public static BlockDesignator PostSigns =
42 new AssetLocation("game", "signpost"),
44 EnumBlockMaterial.Wood,
48 public static BlockDesignator Translocators =
50 new AssetLocation("game", "statictranslocator-normal"),
52 EnumBlockMaterial.Metal,
56 public static EntityDesignator Traders =
58 new AssetLocation("game", "humanoid-trader"),
59 Color.LightGoldenrodYellow,
60 EnumEntityState.Active,
65 /// Not just blocks, but block-entities as well!
67 /// <returns>The block designators.</returns>
68 public static List<BlockDesignator> DefaultBlockDesignators()
70 return new List<BlockDesignator>{
71 DefaultDesignators.Roads,
72 DefaultDesignators.GroundSigns,
73 DefaultDesignators.WallSigns,
74 DefaultDesignators.PostSigns,
75 DefaultDesignators.Translocators,
79 public static List<EntityDesignator> DefaultEntityDesignators()
81 return new List<EntityDesignator>{
82 DefaultDesignators.Traders,
88 internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
91 clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
93 //sign Text into a POI field...
94 BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
96 if (signEntity != null && !String.IsNullOrEmpty(signEntity.text))
103 PrettyLocation = posn.PrettyCoords(clientAPI),
104 Location = posn.Copy(),
105 Notes = signEntity.text,
106 Timestamp = DateTime.UtcNow,
113 internal static void DecodePostSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
116 clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!");
118 //sign post Text into a POI field...
119 BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
121 if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0)
128 PrettyLocation = posn.PrettyCoords(clientAPI),
129 Location = posn.Copy(),
130 Notes = string.Join(",", signEntity.textByCardinalDirection),
131 Timestamp = DateTime.UtcNow,
137 internal static void KeepTrackOfMerchant(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity)
139 //clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
141 var traderJoe = entity as EntityTrader;
142 var message = $"{entity.GetName()} Alive: {traderJoe.Alive}";
143 if (traderJoe.TradeProps != null)
145 message += $" - Gears: {traderJoe.TradeProps.Money}, ";
147 poi.AddReplace(new EntityOfInterest
150 PrettyLocation = posn.PrettyCoords(clientAPI),
151 Location = posn.Copy(),
153 Timestamp = DateTime.UtcNow,
154 EntityId = entity.EntityId
158 internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
161 clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
163 //Where to? and from!
165 BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
169 //FIXME: Delayed rescan ?
170 StringBuilder textTarget = new StringBuilder();
171 //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
172 textTarget.Append(te.FullyRepaired ? "Functional, " : "Broken, ");
173 textTarget.Append(te.Activated ? "Online, " : "Offline, ");
174 textTarget.Append(" Target: [ ");
175 textTarget.Append(te.TargetLocation != null ? "Set ]" : "Invalid ]");//Or ABS coords?
176 textTarget.AppendFormat(", Range ({0} ~ {1})", te.MinTeleporterRangeInBlocks, te.MaxTeleporterRangeInBlocks);
180 Name = "Translocator",
181 PrettyLocation = posn.PrettyCoords(clientAPI),
182 Location = posn.Copy(),
183 Notes = textTarget.ToString(),
184 Timestamp = DateTime.UtcNow,
185 Destination = te.TargetLocation != null ? new BlockPosJson(te.TargetLocation.Copy()) : null