2 using System.Collections.Generic;
5 using Vintagestory.API.Client;
6 using Vintagestory.API.Common;
7 using Vintagestory.API.Common.Entities;
8 using Vintagestory.API.MathTools;
9 using Vintagestory.GameContent;
13 public static class DefaultDesignators
15 public static BlockDesignator Roads =
17 new AssetLocation("game", "stonepath"),
19 EnumBlockMaterial.Gravel
22 public static BlockDesignator GroundSigns =
24 new AssetLocation("game", "sign-ground"),
26 EnumBlockMaterial.Wood,
30 public static BlockDesignator WallSigns =
32 new AssetLocation("game", "sign-wall"),
34 EnumBlockMaterial.Wood,
38 public static BlockDesignator PostSigns =
40 new AssetLocation("game", "signpost"),
42 EnumBlockMaterial.Wood,
46 public static BlockDesignator Translocators =
48 new AssetLocation("game", "statictranslocator-normal"),
50 EnumBlockMaterial.Metal,
54 public static EntityDesignator Traders =
56 new AssetLocation("game", "humanoid-trader"),
57 Color.LightGoldenrodYellow,
58 EnumEntityState.Active,
63 /// Not just blocks, but block-entities as well!
65 /// <returns>The block designators.</returns>
66 public static List<BlockDesignator> DefaultBlockDesignators()
68 return new List<BlockDesignator>{
69 DefaultDesignators.Roads,
70 DefaultDesignators.GroundSigns,
71 DefaultDesignators.WallSigns,
72 DefaultDesignators.PostSigns,
73 DefaultDesignators.Translocators,
77 public static List<EntityDesignator> DefaultEntityDesignators()
79 return new List<EntityDesignator>{
80 DefaultDesignators.Traders,
86 internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
89 clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
91 //sign Text into a POI field...
92 BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
94 if (signEntity != null && !String.IsNullOrEmpty(signEntity.text))
101 PrettyLocation = posn.PrettyCoords(clientAPI),
102 Location = posn.Copy(),
103 Notes = signEntity.text.Replace("\n"," "),
104 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).Replace("\n", " "),
131 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 message = $"{entity.GetName()} Alive: {traderJoe.Alive}";
144 if (traderJoe.TradeProps != null)
146 message += $" - Gears: {traderJoe.TradeProps.Money}, ";
148 poi.AddReplace(new EntityOfInterest
151 PrettyLocation = posn.PrettyCoords(clientAPI),
152 Location = posn.Copy(),
154 Timestamp = DateTime.UtcNow,
155 EntityId = entity.EntityId
159 internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
162 clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
164 //Where to? and from!
166 BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
171 StringBuilder textTarget = new StringBuilder();
172 //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
174 textTarget.Append(te.Activated ? "Online " : "offline ");
175 textTarget.Append(" Dest.: ");
176 textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords?
181 Name = "Translocator",
182 PrettyLocation = posn.PrettyCoords(clientAPI),
183 Location = posn.Copy(),
184 Notes = textTarget.ToString(),
185 Timestamp = DateTime.UtcNow,
186 Destination = new BlockPosJson(te.TargetLocation)