OSDN Git Service

Merge branch 'vgd' of into Split_renderers
[automap/automap.git] / Automap / Designators / DefaultDesignators.cs
index a6b653f..929d618 100644 (file)
@@ -55,7 +55,7 @@ namespace Automap
                         new EntityDesignator(
                                new AssetLocation("game", "humanoid-trader"),
                                Color.LightGoldenrodYellow,
-                                EnumEntityState.Active,
+                               EnumEntityState.Active,
                                KeepTrackOfMerchant
                        );
 
@@ -63,9 +63,9 @@ namespace Automap
                /// Not just blocks, but block-entities as well!
                /// </summary>
                /// <returns>The block designators.</returns>
-               public static List<BlockDesignator>  DefaultBlockDesignators( )
+               public static List<BlockDesignator> DefaultBlockDesignators()
                {
-               return  new List<BlockDesignator>{
+                       return new List<BlockDesignator>{
                                DefaultDesignators.Roads,
                                DefaultDesignators.GroundSigns,
                                DefaultDesignators.WallSigns,
@@ -74,96 +74,116 @@ namespace Automap
                                };
                }
 
-               public static List<EntityDesignator> DefaultEntityDesignators( )
+               public static List<EntityDesignator> DefaultEntityDesignators()
                {
                        return new List<EntityDesignator>{
                                DefaultDesignators.Traders,
                };
                }
 
+               #region Designators
+
                internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
                {
-               #if DEBUG
-               clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
-               #endif
-               //sign Text into a POI field...
-               BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
-               
-               if (signEntity != null && !String.IsNullOrEmpty(signEntity.text))
-               {
-               
-               poi.AddReplace(
-                                       new PointOfInterest {
-                                               Location = posn.Copy( ),
-                                               Notes = signEntity.text,
-                                               Timestamp = DateTimeOffset.UtcNow,
-                                       }
-                                       );
-               
-               }
+#if DEBUG
+                       clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
+#endif
+                       //sign Text into a POI field...
+                       BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
+
+                       if (signEntity != null && !String.IsNullOrEmpty(signEntity.text))
+                       {
+
+                               poi.AddReplace(
+                                                       new PointOfInterest
+                                                       {
+                                                               Name = "Sign",
+                                                               Location = posn.Copy(),
+                                                               Notes = signEntity.text,
+                                                               Timestamp = DateTime.UtcNow,
+                                                       }
+                                                       );
+
+                       }
 
                }
 
 
                internal static void DecodePostSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
                {
-               #if DEBUG
-               clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!");
-               #endif
-               //sign post Text into a POI field...
-               BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
-
-               if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0 ) {
-
-               poi.AddReplace(
-                                       new PointOfInterest {
-                                               Location = posn.Copy( ),
-                                               Notes = string.Join(",", signEntity.textByCardinalDirection),
-                                               Timestamp = DateTimeOffset.UtcNow,
-                                       }
-                                       );
-
-               }
+#if DEBUG
+                       clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!");
+#endif
+                       //sign post Text into a POI field...
+                       BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
+
+                       if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0)
+                       {
+
+                               poi.AddReplace(
+                                                       new PointOfInterest
+                                                       {
+                                                               Name = "Signpost",
+                                                               Location = posn.Copy(),
+                                                               Notes = string.Join(",", signEntity.textByCardinalDirection),
+                                                               Timestamp = DateTime.UtcNow,
+                                                       }
+                                                       );
+
+                       }
                }
 
                internal static void KeepTrackOfMerchant(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity)
                {
-               clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName( ), posn);
-
-               var message = $"{entity.GetName( )}";
-               var traderJoe = entity as EntityTrader;
-               if (traderJoe.TradeProps != null) {
-               message = $"{traderJoe.GetName( )} Alive:{traderJoe.Alive} - Gears: {traderJoe.TradeProps.Money}, ";
-               }
-               poi.Upsert(entity, message);
+                       //clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
+
+                       var traderJoe = entity as EntityTrader;
+                       var message = $"{entity.GetName()} Alive: {traderJoe.Alive}";
+                       if (traderJoe.TradeProps != null)
+                       {
+                               message += $" - Gears: {traderJoe.TradeProps.Money}, ";
+                       }
+                       poi.AddReplace(new EntityOfInterest
+                       {
+                               Name = "Trader",
+                               Location = posn.Copy(),
+                               Notes = message,
+                               Timestamp = DateTime.UtcNow,
+                               EntityId = entity.EntityId
+                       });
                }
 
                internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
                {
-               clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
-               //Where to? and from!
-               
-               BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
+                       clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
+                       //Where to? and from!
 
-               if (te != null ) {
+                       BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
 
-               StringBuilder textTarget = new StringBuilder( );
-               //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
+                       if (te != null)
+                       {
 
-               textTarget.Append(te.Activated ? "Online " : "offline ");
-               textTarget.Append(" Dest.: ");
-               textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords?               
+                               StringBuilder textTarget = new StringBuilder();
+                               //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
 
-               poi.AddReplace(
-                                       new PointOfInterest {
-                                               Location = posn.Copy( ),
-                                               Notes = textTarget.ToString(),
-                                               Timestamp = DateTimeOffset.UtcNow,
-                                       }
-                                       );
+                               textTarget.Append(te.Activated ? "Online " : "offline ");
+                               textTarget.Append(" Dest.: ");
+                               textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords?               
 
+                               poi.AddReplace(
+                                                       new PointOfInterest
+                                                       {
+                                                               Name = "Translocator",
+                                                               Location = posn.Copy(),
+                                                               Notes = textTarget.ToString(),
+                                                               Timestamp = DateTime.UtcNow,
+                                                       }
+                                                       );
+
+                       }
                }
-               }
+
+               #endregion
        }
 }