Automap (client) [VS plugin mod]
Revision | 42eccdda673e6bb99c2b43afa21bbc9836d1c3b4 (tree) |
---|---|
Time | 2020-01-30 09:16:26 |
Author | melchior <melchior@user...> |
Commiter | melchior |
W.I.P. III: Translocator working Via BlockEntity scan (surface only, for now)
@@ -1,7 +1,7 @@ | ||
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Drawing; |
4 | - | |
4 | +using System.Text; | |
5 | 5 | using Vintagestory.API.Client; |
6 | 6 | using Vintagestory.API.Common; |
7 | 7 | using Vintagestory.API.Common.Entities; |
@@ -46,9 +46,9 @@ namespace Automap | ||
46 | 46 | public static BlockDesignator Translocators = |
47 | 47 | new BlockDesignator( |
48 | 48 | new AssetLocation("game", "statictranslocator-normal"), |
49 | - Color.Violet, | |
50 | - EnumBlockMaterial.Metal | |
51 | - //DecodeTranslocator | |
49 | + Color.SteelBlue, | |
50 | + EnumBlockMaterial.Metal, | |
51 | + DecodeTranslocator | |
52 | 52 | ); |
53 | 53 | |
54 | 54 | public static EntityDesignator Traders = |
@@ -59,7 +59,10 @@ namespace Automap | ||
59 | 59 | KeepTrackOfMerchant |
60 | 60 | ); |
61 | 61 | |
62 | - | |
62 | + /// <summary> | |
63 | + /// Not just blocks, but block-entities as well! | |
64 | + /// </summary> | |
65 | + /// <returns>The block designators.</returns> | |
63 | 66 | public static List<BlockDesignator> DefaultBlockDesignators( ) |
64 | 67 | { |
65 | 68 | return new List<BlockDesignator>{ |
@@ -67,6 +70,7 @@ namespace Automap | ||
67 | 70 | DefaultDesignators.GroundSigns, |
68 | 71 | DefaultDesignators.WallSigns, |
69 | 72 | DefaultDesignators.PostSigns, |
73 | + DefaultDesignators.Translocators, | |
70 | 74 | }; |
71 | 75 | } |
72 | 76 |
@@ -129,6 +133,33 @@ namespace Automap | ||
129 | 133 | } |
130 | 134 | poi.Upsert(entity, message); |
131 | 135 | } |
136 | + | |
137 | + internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block) | |
138 | + { | |
139 | + clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!"); | |
140 | + //Where to? and from! | |
141 | + | |
142 | + BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator; | |
143 | + | |
144 | + if (te != null ) { | |
145 | + | |
146 | + StringBuilder textTarget = new StringBuilder( ); | |
147 | + //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget); | |
148 | + | |
149 | + textTarget.Append(te.Activated ? "Online " : "offline "); | |
150 | + textTarget.Append(" Dest.: "); | |
151 | + textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords? | |
152 | + | |
153 | + poi.AddReplace( | |
154 | + new PointOfInterest { | |
155 | + Location = posn.Copy( ), | |
156 | + Notes = textTarget.ToString(), | |
157 | + Timestamp = DateTimeOffset.UtcNow, | |
158 | + } | |
159 | + ); | |
160 | + | |
161 | + } | |
162 | + } | |
132 | 163 | } |
133 | 164 | } |
134 | 165 |
@@ -112,7 +112,9 @@ namespace Automap | ||
112 | 112 | //Time to (re)write chunk shards |
113 | 113 | cartographer_thread.Interrupt( ); |
114 | 114 | } |
115 | + #if DEBUG | |
115 | 116 | ClientAPI.TriggerChatMessage($"Automap {updatedChunksTotal} Updates - MAX (N:{chunkTopMetadata.North_mostChunk},S:{chunkTopMetadata.South_mostChunk},E:{chunkTopMetadata.East_mostChunk}, W:{chunkTopMetadata.West_mostChunk} - TOTAL: {chunkTopMetadata.Count})"); |
117 | + #endif | |
116 | 118 | } |
117 | 119 | |
118 | 120 | } |
@@ -408,16 +410,16 @@ namespace Automap | ||
408 | 410 | tableWriter.RenderBeginTag(HtmlTextWriterTag.Ul); |
409 | 411 | foreach (var poi in this.POIs) { |
410 | 412 | tableWriter.RenderBeginTag(HtmlTextWriterTag.Li); |
411 | - tableWriter.WriteEncodedText(poi.Location.PrettyCoords(this.ClientAPI)); | |
412 | - tableWriter.WriteEncodedText(poi.Notes); | |
413 | + tableWriter.WriteEncodedText(poi.Location.PrettyCoords(this.ClientAPI)+"\t"); | |
414 | + tableWriter.WriteEncodedText(poi.Notes+ "\t"); | |
413 | 415 | tableWriter.WriteEncodedText(poi.Timestamp.ToString("u")); |
414 | 416 | tableWriter.RenderEndTag( ); |
415 | 417 | } |
416 | 418 | |
417 | 419 | foreach (var eoi in this.EOIs.PointsList) { |
418 | 420 | tableWriter.RenderBeginTag(HtmlTextWriterTag.Li); |
419 | - tableWriter.WriteEncodedText(eoi.Location.PrettyCoords(this.ClientAPI)); | |
420 | - tableWriter.WriteEncodedText(eoi.Notes); | |
421 | + tableWriter.WriteEncodedText(eoi.Location.PrettyCoords(this.ClientAPI)+ "\t"); | |
422 | + tableWriter.WriteEncodedText(eoi.Notes+ "\t"); | |
421 | 423 | tableWriter.WriteEncodedText(eoi.Timestamp.ToString("u") ); |
422 | 424 | tableWriter.RenderEndTag( ); |
423 | 425 | } |
@@ -528,17 +530,30 @@ namespace Automap | ||
528 | 530 | } |
529 | 531 | |
530 | 532 | /// <summary> |
531 | - /// Does the heavy lifting of Scanning the whole (surface) chunk - creates Heightmap and Processes POIs, Entities, and stats... | |
533 | + /// Does the heavy lifting of Scanning columns of chunks - creates Heightmap and Processes POIs, Entities, and stats... | |
532 | 534 | /// </summary> |
533 | 535 | /// <param name="key">Chunk Coordinate</param> |
534 | 536 | /// <param name="mapChunk">Map chunk.</param> |
535 | 537 | /// <param name="chunkMeta">Chunk metadata</param> |
536 | 538 | private void ProcessChunkBlocks(Vec2i key, IMapChunk mapChunk, ColumnMeta chunkMeta) |
537 | 539 | { |
540 | + //TODO: build stack of chunk(s) - surface down to bedrock | |
538 | 541 | int topChunkY = mapChunk.YMax / chunkSize; |
539 | 542 | WorldChunk chunkData = ( Vintagestory.Common.WorldChunk )ClientAPI.World.BlockAccessor.GetChunk(key.X, topChunkY, key.Y); |
540 | 543 | |
541 | - | |
544 | + if (chunkData.BlockEntities != null && chunkData.BlockEntities.Length > 0) { | |
545 | + #if DEBUG | |
546 | + Logger.VerboseDebug("Surface@ {0} = BlockEntities: {1}", key, chunkData.BlockEntities.Length); | |
547 | + | |
548 | + foreach (var blockEnt in chunkData.BlockEntities) { | |
549 | + if (BlockID_Designators.ContainsKey(blockEnt.Block.BlockId)) | |
550 | + { | |
551 | + var designator = BlockID_Designators[blockEnt.Block.BlockId]; | |
552 | + designator.SpecialAction(ClientAPI, POIs, blockEnt.Pos.Copy(), blockEnt.Block); | |
553 | + } | |
554 | + } | |
555 | + #endif | |
556 | + } | |
542 | 557 | |
543 | 558 | } |
544 | 559 |