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 Location = posn.Copy(),
102 Notes = signEntity.text,
103 Timestamp = DateTime.UtcNow,
112 internal static void DecodePostSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
115 clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!");
117 //sign post Text into a POI field...
118 BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
120 if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0)
127 Location = posn.Copy(),
128 Notes = string.Join(",", signEntity.textByCardinalDirection),
129 Timestamp = DateTime.UtcNow,
136 internal static void KeepTrackOfMerchant(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity)
138 clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
140 var traderJoe = entity as EntityTrader;
141 var message = $"{entity.GetName()} Alive: {traderJoe.Alive}";
142 if (traderJoe.TradeProps != null)
144 message += $" - Gears: {traderJoe.TradeProps.Money}, ";
146 poi.AddReplace(new EntityOfInterest
149 Location = posn.Copy(),
151 Timestamp = DateTime.UtcNow,
152 EntityId = entity.EntityId
156 internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
158 clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
159 //Where to? and from!
161 BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
166 StringBuilder textTarget = new StringBuilder();
167 //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
169 textTarget.Append(te.Activated ? "Online " : "offline ");
170 textTarget.Append(" Dest.: ");
171 textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords?
176 Name = "Translocator",
177 Location = posn.Copy(),
178 Notes = textTarget.ToString(),
179 Timestamp = DateTime.UtcNow,