• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Automap (client) [VS plugin mod]


Commit MetaInfo

Revision42eccdda673e6bb99c2b43afa21bbc9836d1c3b4 (tree)
Time2020-01-30 09:16:26
Authormelchior <melchior@user...>
Commitermelchior

Log Message

W.I.P. III: Translocator working Via BlockEntity scan (surface only, for now)

Change Summary

Incremental Difference

--- a/Automap/Designators/DefaultDesignators.cs
+++ b/Automap/Designators/DefaultDesignators.cs
@@ -1,7 +1,7 @@
11 using System;
22 using System.Collections.Generic;
33 using System.Drawing;
4-
4+using System.Text;
55 using Vintagestory.API.Client;
66 using Vintagestory.API.Common;
77 using Vintagestory.API.Common.Entities;
@@ -46,9 +46,9 @@ namespace Automap
4646 public static BlockDesignator Translocators =
4747 new BlockDesignator(
4848 new AssetLocation("game", "statictranslocator-normal"),
49- Color.Violet,
50- EnumBlockMaterial.Metal
51- //DecodeTranslocator
49+ Color.SteelBlue,
50+ EnumBlockMaterial.Metal,
51+ DecodeTranslocator
5252 );
5353
5454 public static EntityDesignator Traders =
@@ -59,7 +59,10 @@ namespace Automap
5959 KeepTrackOfMerchant
6060 );
6161
62-
62+ /// <summary>
63+ /// Not just blocks, but block-entities as well!
64+ /// </summary>
65+ /// <returns>The block designators.</returns>
6366 public static List<BlockDesignator> DefaultBlockDesignators( )
6467 {
6568 return new List<BlockDesignator>{
@@ -67,6 +70,7 @@ namespace Automap
6770 DefaultDesignators.GroundSigns,
6871 DefaultDesignators.WallSigns,
6972 DefaultDesignators.PostSigns,
73+ DefaultDesignators.Translocators,
7074 };
7175 }
7276
@@ -129,6 +133,33 @@ namespace Automap
129133 }
130134 poi.Upsert(entity, message);
131135 }
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+ }
132163 }
133164 }
134165
--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -112,7 +112,9 @@ namespace Automap
112112 //Time to (re)write chunk shards
113113 cartographer_thread.Interrupt( );
114114 }
115+ #if DEBUG
115116 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
116118 }
117119
118120 }
@@ -408,16 +410,16 @@ namespace Automap
408410 tableWriter.RenderBeginTag(HtmlTextWriterTag.Ul);
409411 foreach (var poi in this.POIs) {
410412 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");
413415 tableWriter.WriteEncodedText(poi.Timestamp.ToString("u"));
414416 tableWriter.RenderEndTag( );
415417 }
416418
417419 foreach (var eoi in this.EOIs.PointsList) {
418420 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");
421423 tableWriter.WriteEncodedText(eoi.Timestamp.ToString("u") );
422424 tableWriter.RenderEndTag( );
423425 }
@@ -528,17 +530,30 @@ namespace Automap
528530 }
529531
530532 /// <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...
532534 /// </summary>
533535 /// <param name="key">Chunk Coordinate</param>
534536 /// <param name="mapChunk">Map chunk.</param>
535537 /// <param name="chunkMeta">Chunk metadata</param>
536538 private void ProcessChunkBlocks(Vec2i key, IMapChunk mapChunk, ColumnMeta chunkMeta)
537539 {
540+ //TODO: build stack of chunk(s) - surface down to bedrock
538541 int topChunkY = mapChunk.YMax / chunkSize;
539542 WorldChunk chunkData = ( Vintagestory.Common.WorldChunk )ClientAPI.World.BlockAccessor.GetChunk(key.X, topChunkY, key.Y);
540543
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+ }
542557
543558 }
544559