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 traderJoe = entity as EntityTrader;
137 var message = $"{entity.GetName()} Alive: {traderJoe.Alive}";
138 if (traderJoe.TradeProps != null)
140 message += $" - Gears: {traderJoe.TradeProps.Money}, ";
142 poi.AddReplace(new EntityOfInterest
144 Location = posn.Copy(),
146 Timestamp = DateTimeOffset.UtcNow,
147 EntityId = entity.EntityId
151 internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
153 clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
154 //Where to? and from!
156 BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
161 StringBuilder textTarget = new StringBuilder();
162 //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
164 textTarget.Append(te.Activated ? "Online " : "offline ");
165 textTarget.Append(" Dest.: ");
166 textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords?
171 Location = posn.Copy(),
172 Notes = textTarget.ToString(),
173 Timestamp = DateTimeOffset.UtcNow,