<OutputType>Library</OutputType>
<RootNamespace>Automap</RootNamespace>
<AssemblyName>Automap</AssemblyName>
- <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
{
-#if DEBUG
+ #if DEBUG
clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
-#endif
+ #endif
//Where to? and from!
BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
if (te != null) {
//FIXME: Delayed rescan ?
StringBuilder textTarget = new StringBuilder( );
- //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
+
textTarget.Append(te.FullyRepaired ? "Functional, " : "Broken, ");
- textTarget.Append(te.Activated ? "Online, " : "Offline, ");
+ textTarget.Append(te.Activated ? "Online, " : "Offline, ");//Property hardcoded TRUE ?!
textTarget.Append(" Target: [ ");
textTarget.Append(te.TargetLocation != null ? "Set ]" : "Invalid ]");//Or ABS coords?
textTarget.AppendFormat(", Range ({0} ~ {1})", te.MinTeleporterRangeInBlocks, te.MaxTeleporterRangeInBlocks);
public class AutomapSystem
{
private Thread cartographer_thread;
- private Thread snapshotThread;
+
private Snapshotter snapshot;
private ICoreClientAPI ClientAPI { get; set; }
private ILogger Logger { get; set; }
if (configuration.Autostart)
{
CurrentState = CommandType.Run;
- Logger.Debug("Autostart is Enabled.");
+ Logger.Notification("Autostart is Enabled.");
}
}
IsBackground = true
};
- snapshot = new Snapshotter(path, chunkTopMetadata, chunkSize,ClientAPI.World.Seed );
- snapshotThread = new Thread(Snap)
- {
- Name = "Snapshot",
- Priority = ThreadPriority.Lowest,
- IsBackground = true
- };
-
- ClientAPI.Event.RegisterGameTickListener(AwakenCartographer, 6000);
+ ClientAPI.Event.RegisterGameTickListener(ThreadDecider, 6000);
}
private void ChunkAChanging(Vec3i chunkCoord, IWorldChunk chunk, EnumChunkDirtyReason reason)
}
- private void AwakenCartographer(float delayed)
+ /// <summary>
+ /// Cartographer Thread 'decider'
+ /// </summary>
+ /// <param name="delayed">called delay offset</param>
+ private void ThreadDecider(float delayed)
{
if (CurrentState == CommandType.Run && (ClientAPI.IsGamePaused != false || ClientAPI.IsShuttingDown != true))
{
-#if DEBUG
- Logger.VerboseDebug("Cartographer re-trigger from [{0}]", cartographer_thread.ThreadState);
-#endif
+ #if DEBUG
+ Logger.VerboseDebug("ThreadDecider re-trigger from [{0}]", cartographer_thread.ThreadState);
+ #endif
if (cartographer_thread.ThreadState.HasFlag(ThreadState.Unstarted))
{
}
else if (CurrentState == CommandType.Snapshot)
{
- if (snapshotThread.ThreadState.HasFlag(ThreadState.Unstarted))
- {
- snapshotThread.Start();
- } else if (snapshotThread.ThreadState.HasFlag(ThreadState.WaitSleepJoin))
- {
- snapshotThread.Interrupt();
+ //Prepare for taking a snopshot
+ if (snapshot == null) {
+ snapshot = new Snapshotter(path, chunkTopMetadata, chunkSize, ClientAPI.World.Seed);
+ #if DEBUG
+ Logger.VerboseDebug("Starting new Snapshot: {0} Wx{1} Hx{2}", snapshot.fileName, snapshot.Width, snapshot.Height);
+ #endif
+ snapshot.Take( );
+ }
+ else if (snapshot != null && snapshot.Finished) {
+ #if DEBUG
+ Logger.VerboseDebug("COMPLETED Snapshot: {0} Wx{1} Hx{2}, taking {3}", snapshot.fileName, snapshot.Width, snapshot.Height, snapshot.Timer.Elapsed);
+ #endif
+ snapshot = null;
+ CurrentState = CommandType.Run;
}
}
-
}
mdWriter.WriteLine("WorldSeed {0}", ClientAPI.World.Seed);
mdWriter.WriteLine("PlayerChunkCoords {0:D} {1:D}", startChunkColumn.X, startChunkColumn.Y);
mdWriter.WriteLine("DefaultSpawnPos {0:D} {1:D} {2:D}", ClientAPI.World.DefaultSpawnPosition.AsBlockPos.X,ClientAPI.World.DefaultSpawnPosition.AsBlockPos.Y,ClientAPI.World.DefaultSpawnPosition.AsBlockPos.Z);
+ //mdWriter.WriteLine("CurrentPlayerSpawn", ClientAPI.World.Player.WorldData.EntityPlayer.);
mdWriter.WriteLine("ChunkSize {0}", chunkSize);
mdWriter.WriteLine("SeaLevel {0:D}", ClientAPI.World.SeaLevel);
mdWriter.WriteLine("WorldSize {0:D} {1:D} {2:D}", ClientAPI.World.BulkBlockAccessor.MapSizeX, ClientAPI.World.BulkBlockAccessor.MapSizeY,ClientAPI.World.BulkBlockAccessor.MapSizeZ);
if (CurrentState != cmdData.State)
{
CurrentState = cmdData.State;
- AwakenCartographer(0.0f);
+ ThreadDecider(0.0f);
}
break;
{
public class Snapshotter
{
- public readonly int chunkSize;
private const string customTimeFormat = @"yyyy.MM.dd.HH.mm.ssZzz";
- public string fileName;
- public string chunkPath;
- public ColumnsMetadata cols;
- //TODO: Refactor - so Edges are set at construction time, as ColumnsMetadata is async updating in real time!
- public int NorthEdge => cols.North_mostChunk;
- public int WestEdge => cols.West_mostChunk;
- public int Width => (cols.East_mostChunk - WestEdge + 1);
- public int Height => (cols.South_mostChunk - NorthEdge + 1);
-
+ public readonly int chunkSize;
+ public readonly int worldSeed;
+ public readonly string fileName;
+ public readonly string chunkPath;
+ public readonly int NorthEdge;
+ public readonly int WestEdge;
+ public readonly int Width;
+ public readonly int Height;
+
+ public ColumnsMetadata colMetadata;
+ public bool Imaging { get; private set; }
+ public bool Finished { get; private set; }
+ public Stopwatch Timer { get; private set;}
- public Snapshotter(string path, ColumnsMetadata cols, int chunkSize, int worldSeed)
- {
- this.fileName = Path.Combine(path, $"snapshot_{worldSeed}_{DateTime.Now.ToString(customTimeFormat)}.png");
- this.chunkPath = Path.Combine(path, AutomapSystem._chunkPath);
- this.cols = cols;
- this.chunkSize = chunkSize;
+ /// <summary>
+ /// Prepares class to take "snapshot" (single use!)
+ /// </summary>
+ /// <param name="path">path to the map dir</param>
+ /// <param name="cols">Input metadata</param>
+ /// <param name="chunkSizeP">size in blocks of std. chunk</param>
+ /// <param name="worldSeedP">World Seed #</param>
+ public Snapshotter(string path, ColumnsMetadata cols, int chunkSizeP, int worldSeedP)
+ {
+ colMetadata = cols;
+ chunkSize = chunkSizeP;
+ worldSeed = worldSeedP;
+ NorthEdge = cols.North_mostChunk;
+ WestEdge = cols.West_mostChunk;
+ Width = (cols.East_mostChunk - WestEdge + 1);
+ Height = (cols.South_mostChunk - NorthEdge + 1);
+ fileName = Path.Combine(path, $"snapshot_{worldSeed}_{DateTime.Now.ToString(customTimeFormat)}.png");
+ chunkPath = Path.Combine(path, AutomapSystem._chunkPath);
}
/// <summary>
/// takes a snapshot. this should be called from an extra thread.
/// </summary>
- /// <param name="path">path to the map dir</param>
- /// <param name="chunkPath">name of the chunks dir part thing</param>
- /// <param name="cols"></param>
- /// <param name="chunkSize"></param>
public async void Take()
{
- var t = new Stopwatch();
- t.Start();
+ if (Imaging || Finished) return;//Can't take annother photo...this one is started or complete
+ Imaging = true;
+ Timer = new Stopwatch();
+ Timer.Start();
Debug.WriteLine("snapshot started");
var orderedList =
- from ch in cols
+ from ch in colMetadata
group ch by ch.Location.Y into g
orderby g.Key
select g;
try
{
snapWriter.End();
+ Timer.Stop( );
+ Imaging = false;
+ Finished = true;
}
catch (Exception)
{
Debug.WriteLine("Snapshot exception!");
}
- Debug.WriteLine($"snapshot finished in {t.ElapsedMilliseconds}");
+ Debug.WriteLine($"snapshot finished in {Timer.ElapsedMilliseconds}");
}
private async Task<Dictionary<int, byte[][]>> ReadAllInGroup(IGrouping<int, ColumnMeta> group)
"description" : "Automap; Generates a static HTML5 map dynamically, with P.O.I. Tracking & more.",
"authors": ["Melchior","VeryGoodDog"],
"contributors":["VeryGoodDog"],
- "version": "0.1.7",
+ "version": "0.1.8",
"side":"Client",
"dependencies": {
- "game": "1.14.10"
+ "game": "1.16.0"
},
"website": "http://automap.osdn.io/"
}
\ No newline at end of file