OSDN Git Service

W.I.P. III: Translocator working Via BlockEntity scan (surface only, for now)
[automap/automap.git] / Automap / Designators / DefaultDesignators.cs
index d6d9fd7..8c88a89 100644 (file)
@@ -1,7 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Drawing;
-
+using System.Text;
 using Vintagestory.API.Client;
 using Vintagestory.API.Common;
 using Vintagestory.API.Common.Entities;
@@ -46,9 +46,9 @@ namespace Automap
                public static BlockDesignator Translocators =
                         new BlockDesignator(
                                new AssetLocation("game", "statictranslocator-normal"),
-                               Color.Violet,
-                               EnumBlockMaterial.Metal
-                               //DecodeTranslocator
+                               Color.SteelBlue,
+                               EnumBlockMaterial.Metal,
+                               DecodeTranslocator
                        );
 
                public static EntityDesignator Traders =
@@ -59,7 +59,10 @@ namespace Automap
                                KeepTrackOfMerchant
                        );
 
-
+               /// <summary>
+               /// Not just blocks, but block-entities as well!
+               /// </summary>
+               /// <returns>The block designators.</returns>
                public static List<BlockDesignator>  DefaultBlockDesignators( )
                {
                return  new List<BlockDesignator>{
@@ -67,6 +70,7 @@ namespace Automap
                                DefaultDesignators.GroundSigns,
                                DefaultDesignators.WallSigns,
                                DefaultDesignators.PostSigns,
+                               DefaultDesignators.Translocators,
                                };
                }
 
@@ -129,6 +133,33 @@ namespace Automap
                }
                poi.Upsert(entity, message);
                }
+
+               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;
+
+               if (te != null ) {
+
+               StringBuilder textTarget = new StringBuilder( );
+               //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
+
+               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 {
+                                               Location = posn.Copy( ),
+                                               Notes = textTarget.ToString(),
+                                               Timestamp = DateTimeOffset.UtcNow,
+                                       }
+                                       );
+
+               }
+               }
        }
 }