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,
84 internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
87 clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
89 //sign Text into a POI field...
90 BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
92 if (signEntity != null && !String.IsNullOrEmpty(signEntity.text))
98 Location = posn.Copy(),
99 Notes = signEntity.text,
100 Timestamp = DateTimeOffset.UtcNow,
109 internal static void DecodePostSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
112 clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!");
114 //sign post Text into a POI field...
115 BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
117 if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0)
123 Location = posn.Copy(),
124 Notes = string.Join(",", signEntity.textByCardinalDirection),
125 Timestamp = DateTimeOffset.UtcNow,
132 internal static void KeepTrackOfMerchant(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity)
134 clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
136 var message = $"{entity.GetName()}";
137 var traderJoe = entity as EntityTrader;
138 if (traderJoe.TradeProps != null)
140 message = $"{traderJoe.GetName()} Alive:{traderJoe.Alive} - Gears: {traderJoe.TradeProps.Money}, ";
142 poi.Upsert(entity, message);
145 internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
147 clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
148 //Where to? and from!
150 BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
155 StringBuilder textTarget = new StringBuilder();
156 //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
158 textTarget.Append(te.Activated ? "Online " : "offline ");
159 textTarget.Append(" Dest.: ");
160 textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords?
165 Location = posn.Copy(),
166 Notes = textTarget.ToString(),
167 Timestamp = DateTimeOffset.UtcNow,