• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Automap (client) [VS plugin mod]


Commit MetaInfo

Revisione928c814ee4fd92ef6ad708947e33e4d8ad6f726 (tree)
Time2020-02-21 09:00:41
AuthorThe Grand Dog <alex.h@me.c...>
CommiterThe Grand Dog

Log Message

indentation

Change Summary

Incremental Difference

--- a/Automap/AutomapMod.cs
+++ b/Automap/AutomapMod.cs
@@ -20,36 +20,37 @@ namespace Automap
2020 }
2121
2222 public override void StartClientSide(ICoreClientAPI api)
23- {
23+ {
2424 this.API = api;
2525
26- if (api.Side == EnumAppSide.Client) {
27- this.ClientAPI = api as ICoreClientAPI;
28- this.Logger = Mod.Logger;
26+ if (api.Side == EnumAppSide.Client)
27+ {
28+ this.ClientAPI = api as ICoreClientAPI;
29+ this.Logger = Mod.Logger;
2930
3031
31- ClientAPI.Logger.VerboseDebug("Automap Present!");
32- _localAutomap = new AutomapSystem( this.ClientAPI, this.Logger);
33- _automapDialog = new AutomapGUIDialog(ClientAPI, _localAutomap);
32+ ClientAPI.Logger.VerboseDebug("Automap Present!");
33+ _localAutomap = new AutomapSystem(this.ClientAPI, this.Logger);
34+ _automapDialog = new AutomapGUIDialog(ClientAPI, _localAutomap);
3435
35- ClientAPI.Input.RegisterHotKey(AutomapGUIDialog._automapControlPanelKey, "Automap control panel", GlKeys.M, HotkeyType.GUIOrOtherControls, shiftPressed: true);
36- ClientAPI.Input.SetHotKeyHandler(AutomapGUIDialog._automapControlPanelKey, ToggleAM_Dialog);
36+ ClientAPI.Input.RegisterHotKey(AutomapGUIDialog._automapControlPanelKey, "Automap control panel", GlKeys.M, HotkeyType.GUIOrOtherControls, shiftPressed: true);
37+ ClientAPI.Input.SetHotKeyHandler(AutomapGUIDialog._automapControlPanelKey, ToggleAM_Dialog);
3738 }
3839
3940 base.StartClientSide(api);
4041 }
4142
42- public override double ExecuteOrder( )
43+ public override double ExecuteOrder()
4344 {
44- return 0.2;
45+ return 0.2;
4546 }
4647
4748 private bool ToggleAM_Dialog(KeyCombination comb)
4849 {
49- if (_automapDialog.IsOpened( )) _automapDialog.TryClose( );
50- else _automapDialog.TryOpen( );
50+ if (_automapDialog.IsOpened()) _automapDialog.TryClose();
51+ else _automapDialog.TryOpen();
5152
52- return true;
53+ return true;
5354 }
5455 }
5556 }
--- a/Automap/Data/BlockDesignator.cs
+++ b/Automap/Data/BlockDesignator.cs
@@ -15,38 +15,38 @@ namespace Automap
1515 /// Point of Interest Rule Designator
1616 /// </summary>
1717 public class BlockDesignator
18- {
18+ {
1919 public Color OverwriteColor;
2020 public BlockDesignatonAction SpecialAction;
2121 public AssetLocation Pattern;
2222 public EnumBlockMaterial? Material;
2323 public bool Enabled { get; set; }
2424
25- private BlockDesignator( )
25+ private BlockDesignator()
2626 {
27- throw new NotSupportedException( );
27+ throw new NotSupportedException();
2828 }
2929
30- public BlockDesignator( AssetLocation pattern , Color overwriteColor, EnumBlockMaterial? material)
31- {
30+ public BlockDesignator(AssetLocation pattern, Color overwriteColor, EnumBlockMaterial? material)
31+ {
3232 this.Pattern = pattern;
3333 this.OverwriteColor = overwriteColor;
3434 this.Material = material;
3535 this.Enabled = true;
3636 }
3737
38- public BlockDesignator(AssetLocation pattern, Color overwriteColor, EnumBlockMaterial? material ,BlockDesignatonAction specialAct )
38+ public BlockDesignator(AssetLocation pattern, Color overwriteColor, EnumBlockMaterial? material, BlockDesignatonAction specialAct)
3939 {
40- this.Pattern = pattern;
41- this.OverwriteColor = overwriteColor;
42- this.Material = material;
43- this.SpecialAction = specialAct;
44- this.Enabled = true;
40+ this.Pattern = pattern;
41+ this.OverwriteColor = overwriteColor;
42+ this.Material = material;
43+ this.SpecialAction = specialAct;
44+ this.Enabled = true;
4545 }
4646
47- public override string ToString( )
47+ public override string ToString()
4848 {
49- return Pattern.ToShortString() +"|"+ OverwriteColor.Name + "|" + Material ?? "";
49+ return Pattern.ToShortString() + "|" + OverwriteColor.Name + "|" + Material ?? "";
5050 }
5151 }
5252 }
--- a/Automap/Data/ColumnMeta.cs
+++ b/Automap/Data/ColumnMeta.cs
@@ -27,7 +27,7 @@ namespace Automap
2727 public ushort YMax;// Y feature height
2828
2929 [ProtoMember(5)]
30- public Dictionary<int,uint> RockRatio;//[Column] Geographic region (rock) Ratio. [BlockID * count]
30+ public Dictionary<int, uint> RockRatio;//[Column] Geographic region (rock) Ratio. [BlockID * count]
3131
3232 [ProtoMember(6)]
3333 public float Fertility;
@@ -49,105 +49,115 @@ namespace Automap
4949
5050 //[ProtoMember(12,OverwriteList = true)]
5151 [ProtoIgnore]
52- public ushort[ , ] HeightMap;
52+ public ushort[,] HeightMap;
5353
5454 public ColumnMeta(Vec2i loc, int chunkSize = 32)
5555 {
56- Location = loc;
57- ChunkAge = TimeSpan.Zero;
58- Temperature = 0f;
59- YMax = 0;
60- RockRatio = new Dictionary<int, uint>( 10 );
61- Fertility = 0f;
62- ForestDensity = 0f;
63- Rainfall = 0f;
64- ShrubDensity = 0f;
65- AirBlocks = 0;
66- NonAirBlocks = 0;
67- HeightMap = new ushort[chunkSize, chunkSize];
68- }
69-
70- internal void UpdateFieldsFrom(ClimateCondition climate, IMapChunk mapChunk ,TimeSpan chunkAge)
56+ Location = loc;
57+ ChunkAge = TimeSpan.Zero;
58+ Temperature = 0f;
59+ YMax = 0;
60+ RockRatio = new Dictionary<int, uint>(10);
61+ Fertility = 0f;
62+ ForestDensity = 0f;
63+ Rainfall = 0f;
64+ ShrubDensity = 0f;
65+ AirBlocks = 0;
66+ NonAirBlocks = 0;
67+ HeightMap = new ushort[chunkSize, chunkSize];
68+ }
69+
70+ internal void UpdateFieldsFrom(ClimateCondition climate, IMapChunk mapChunk, TimeSpan chunkAge)
7171 {
72- this.ChunkAge = chunkAge;
73- this.Temperature = climate.Temperature;
74- this.Fertility = climate.Fertility;
75- this.ForestDensity = climate.ForestDensity;
76- this.Rainfall = climate.Rainfall;
77- this.ShrubDensity = climate.ShrubDensity;
78-
79- this.YMax = mapChunk.YMax;
80-
72+ this.ChunkAge = chunkAge;
73+ this.Temperature = climate.Temperature;
74+ this.Fertility = climate.Fertility;
75+ this.ForestDensity = climate.ForestDensity;
76+ this.Rainfall = climate.Rainfall;
77+ this.ShrubDensity = climate.ShrubDensity;
78+
79+ this.YMax = mapChunk.YMax;
80+
8181 }
8282 }
8383
8484 public class ColumnsMetadata : KeyedCollection<Vec2i, ColumnMeta>
8585 {
86- private ColumnsMetadata( )
86+ private ColumnsMetadata()
8787 {
8888 throw new NotSupportedException();
8989 }
9090
9191 public ColumnsMetadata(Vec2i startChunkColumn)
9292 {
93- North_mostChunk = startChunkColumn.Y;
94- South_mostChunk = startChunkColumn.Y;
95- East_mostChunk = startChunkColumn.X;
96- West_mostChunk = startChunkColumn.X;
93+ North_mostChunk = startChunkColumn.Y;
94+ South_mostChunk = startChunkColumn.Y;
95+ East_mostChunk = startChunkColumn.X;
96+ West_mostChunk = startChunkColumn.X;
9797 }
9898
99- public int North_mostChunk {
99+ public int North_mostChunk
100+ {
100101 get; private set;
101102 }
102103
103- public int South_mostChunk {
104+ public int South_mostChunk
105+ {
104106 get; private set;
105107 }
106108
107- public int East_mostChunk {
109+ public int East_mostChunk
110+ {
108111 get; private set;
109112 }
110113
111- public int West_mostChunk {
114+ public int West_mostChunk
115+ {
112116 get; private set;
113117 }
114118
115119 protected override Vec2i GetKeyForItem(ColumnMeta item)
116120 {
117- return item.Location;
121+ return item.Location;
118122 }
119123
120124 internal void Update(ColumnMeta metaData)
121125 {
122- if (this.Contains(metaData.Location)) {
123- this.Remove(metaData.Location);
124- this.Add(metaData);
125- }
126- else {
127- this.Add(metaData);
128- }
126+ if (this.Contains(metaData.Location))
127+ {
128+ this.Remove(metaData.Location);
129+ this.Add(metaData);
130+ }
131+ else
132+ {
133+ this.Add(metaData);
134+ }
129135
130136 }
131137
132138 public new void Add(ColumnMeta newItem)
133139 {
134- if (North_mostChunk > newItem.Location.Y) {
135- North_mostChunk = newItem.Location.Y;
136- }
137-
138- if (South_mostChunk < newItem.Location.Y) {
139- South_mostChunk = newItem.Location.Y;
140- }
141-
142- if (East_mostChunk < newItem.Location.X) {
143- East_mostChunk = newItem.Location.X;
144- }
145-
146- if (West_mostChunk > newItem.Location.X) {
147- West_mostChunk = newItem.Location.X;
148- }
149-
150- base.Add(newItem);
140+ if (North_mostChunk > newItem.Location.Y)
141+ {
142+ North_mostChunk = newItem.Location.Y;
143+ }
144+
145+ if (South_mostChunk < newItem.Location.Y)
146+ {
147+ South_mostChunk = newItem.Location.Y;
148+ }
149+
150+ if (East_mostChunk < newItem.Location.X)
151+ {
152+ East_mostChunk = newItem.Location.X;
153+ }
154+
155+ if (West_mostChunk > newItem.Location.X)
156+ {
157+ West_mostChunk = newItem.Location.X;
158+ }
159+
160+ base.Add(newItem);
151161 }
152162
153163 }
--- a/Automap/Data/CommandData.cs
+++ b/Automap/Data/CommandData.cs
@@ -29,72 +29,74 @@ namespace Automap
2929 //Choose : Renderer(s)
3030
3131
32- public CommandData( RunState assumeState, bool[] theseDelegates)
32+ public CommandData(RunState assumeState, bool[] theseDelegates)
3333 {
34- State = assumeState;
34+ State = assumeState;
3535
36- DelegatesFlags = new List<DelegateState>(theseDelegates.Length);
37- foreach (var df in theseDelegates) {
38- DelegatesFlags.Add(new DelegateState( ) {
36+ DelegatesFlags = new List<DelegateState>(theseDelegates.Length);
37+ foreach (var df in theseDelegates)
38+ {
39+ DelegatesFlags.Add(new DelegateState()
40+ {
3941 Enabled = df,
4042 AlternateColor = null,
41- });
43+ });
4244
43- }
45+ }
4446
4547 }
4648
4749 public CommandData(RunState assumeState)
4850 {
49- State = assumeState;//Never RUN.
51+ State = assumeState;//Never RUN.
5052
51- DelegatesFlags = new List<DelegateState>();
53+ DelegatesFlags = new List<DelegateState>();
5254 }
5355
5456
5557 public void FromBytes(BinaryReader stream)
5658 {
57- var temp = ProtoBuf.Serializer.Deserialize<CommandData>(stream.BaseStream);
58- this.State = temp.State;
59- this.DelegatesFlags = temp.DelegatesFlags;
59+ var temp = ProtoBuf.Serializer.Deserialize<CommandData>(stream.BaseStream);
60+ this.State = temp.State;
61+ this.DelegatesFlags = temp.DelegatesFlags;
6062
6163 }
6264
6365 public void ToBytes(BinaryWriter stream)
6466 {
65- ProtoBuf.Serializer.Serialize<CommandData>(stream.BaseStream, this);
66-
67+ ProtoBuf.Serializer.Serialize<CommandData>(stream.BaseStream, this);
68+
6769
6870 }
6971
7072
7173
72- public int GetAttributeId( )
74+ public int GetAttributeId()
7375 {
74- return 12346;
76+ return 12346;
7577 }
7678
77- public object GetValue( )
79+ public object GetValue()
7880 {
79- return this;
81+ return this;
8082 }
8183
8284
83- public string ToJsonToken( )
85+ public string ToJsonToken()
8486 {
8587 return $"New-State:{State}, Delegates# {DelegatesFlags.Count} ";
8688 }
8789
8890 public bool Equals(IWorldAccessor worldForResolve, IAttribute attr)
8991 {
90- var other = attr.GetValue( ) as CommandData;
92+ var other = attr.GetValue() as CommandData;
9193
92- if (this.State == other.State )
93- {
94- return true;
94+ if (this.State == other.State)
95+ {
96+ return true;
9597 }
9698
97- return false;
99+ return false;
98100 }
99101 }
100102
--- a/Automap/Data/EntitiesOfInterest.cs
+++ b/Automap/Data/EntitiesOfInterest.cs
@@ -12,33 +12,35 @@ namespace Automap
1212 /// Entities of interest.
1313 /// </summary>
1414 /// <remarks>Tracked by ID - these never leave.</remarks>
15- public class EntitiesOfInterest
15+ public class EntitiesOfInterest
1616 {
1717 private Dictionary<long, PointOfInterest> entitySet = new Dictionary<long, PointOfInterest>(50);
1818
1919
2020 internal void Upsert(Entity something, string message = @"")
2121 {
22- if (entitySet.ContainsKey(something.EntityId)) {
23- var movingPOI = entitySet[something.EntityId];
24- movingPOI.Location = something.Pos.AsBlockPos.Copy( );
25- movingPOI.Timestamp = DateTimeOffset.UtcNow;
26- }
27- else {
28- PointOfInterest newPOI = new PointOfInterest( );
29- newPOI.EntityId = something.EntityId;
30- newPOI.Location = something.Pos.AsBlockPos.Copy( );
31- newPOI.Timestamp = DateTimeOffset.UtcNow;
32- newPOI.Notes = message;
33- entitySet.Add(something.EntityId, newPOI );
34- }
35-
22+ if (entitySet.ContainsKey(something.EntityId))
23+ {
24+ var movingPOI = entitySet[something.EntityId];
25+ movingPOI.Location = something.Pos.AsBlockPos.Copy();
26+ movingPOI.Timestamp = DateTimeOffset.UtcNow;
27+ }
28+ else
29+ {
30+ PointOfInterest newPOI = new PointOfInterest();
31+ newPOI.EntityId = something.EntityId;
32+ newPOI.Location = something.Pos.AsBlockPos.Copy();
33+ newPOI.Timestamp = DateTimeOffset.UtcNow;
34+ newPOI.Notes = message;
35+ entitySet.Add(something.EntityId, newPOI);
36+ }
37+
3638 }
3739
3840
39- public List<PointOfInterest> PointsList {
40- get
41- {
41+ public List<PointOfInterest> PointsList
42+ {
43+ get {
4244 return entitySet.Values.ToList();
4345 }
4446 }
--- a/Automap/Data/EntityDesignator.cs
+++ b/Automap/Data/EntityDesignator.cs
@@ -23,31 +23,31 @@ namespace Automap
2323 public EnumEntityState? StateCheck;//Needed?
2424 public bool Enabled { get; set; }
2525
26- private EntityDesignator( )
26+ private EntityDesignator()
2727 {
28- throw new NotSupportedException( );
28+ throw new NotSupportedException();
2929 }
3030
3131 public EntityDesignator(AssetLocation pattern, Color overwriteColor, EnumEntityState? state)
3232 {
33- this.Pattern = pattern;
34- this.OverwriteColor = overwriteColor;
35- this.StateCheck = state;
36- this.Enabled = true;
33+ this.Pattern = pattern;
34+ this.OverwriteColor = overwriteColor;
35+ this.StateCheck = state;
36+ this.Enabled = true;
3737 }
3838
3939 public EntityDesignator(AssetLocation pattern, Color overwriteColor, EnumEntityState? state, EntityDesignatonAction specialAct)
4040 {
41- this.Pattern = pattern;
42- this.OverwriteColor = overwriteColor;
43- this.StateCheck = state;
44- this.SpecialAction = specialAct;
45- this.Enabled = true;
41+ this.Pattern = pattern;
42+ this.OverwriteColor = overwriteColor;
43+ this.StateCheck = state;
44+ this.SpecialAction = specialAct;
45+ this.Enabled = true;
4646 }
4747
48- public override string ToString( )
48+ public override string ToString()
4949 {
50- return Pattern.ToShortString( ) + "|" + OverwriteColor.Name + "|" + StateCheck ?? "";
50+ return Pattern.ToShortString() + "|" + OverwriteColor.Name + "|" + StateCheck ?? "";
5151 }
5252 }
5353 }
--- a/Automap/Data/PngMetadataChunk.cs
+++ b/Automap/Data/PngMetadataChunk.cs
@@ -21,33 +21,33 @@ namespace Automap
2121
2222 public PngMetadataChunk(ImageInfo info) : base(ID, info)
2323 {
24-
24+
2525 }
2626
27- public override ChunkOrderingConstraint GetOrderingConstraint( )
27+ public override ChunkOrderingConstraint GetOrderingConstraint()
2828 {
29- return ChunkOrderingConstraint.NONE;
29+ return ChunkOrderingConstraint.NONE;
3030 }
3131
32- public override ChunkRaw CreateRawChunk( )
33- {
34- var datas = SerializerUtil.Serialize<ColumnMeta>(ChunkMetadata);
32+ public override ChunkRaw CreateRawChunk()
33+ {
34+ var datas = SerializerUtil.Serialize<ColumnMeta>(ChunkMetadata);
3535
36- ChunkRaw rawChunk = createEmptyChunk(datas.Length, true);
37- rawChunk.Data = datas;
36+ ChunkRaw rawChunk = createEmptyChunk(datas.Length, true);
37+ rawChunk.Data = datas;
3838
39- return rawChunk;
39+ return rawChunk;
4040 }
4141
4242 public override void ParseFromRaw(ChunkRaw rawChunk)
4343 {
44- this.ChunkMetadata = SerializerUtil.Deserialize<ColumnMeta>(rawChunk.Data);
44+ this.ChunkMetadata = SerializerUtil.Deserialize<ColumnMeta>(rawChunk.Data);
4545 }
4646
4747 public override void CloneDataFromRead(PngChunk other)
4848 {
49- PngMetadataChunk clone = ( PngMetadataChunk )other;
50- this.ChunkMetadata = clone.ChunkMetadata;
49+ PngMetadataChunk clone = (PngMetadataChunk) other;
50+ this.ChunkMetadata = clone.ChunkMetadata;
5151 }
5252
5353 }
--- a/Automap/Data/PointOfInterest.cs
+++ b/Automap/Data/PointOfInterest.cs
@@ -10,7 +10,7 @@ namespace Automap
1010 /// Actual Physical Point in space - that is interesting.
1111 /// </summary>
1212 public struct PointOfInterest
13- {
13+ {
1414 public string Notes;
1515 public BlockPos Location;
1616 public DateTimeOffset Timestamp;
@@ -21,18 +21,20 @@ namespace Automap
2121 {
2222 protected override BlockPos GetKeyForItem(PointOfInterest item)
2323 {
24- return item.Location;
24+ return item.Location;
2525 }
2626
2727 internal void AddReplace(PointOfInterest poi)
2828 {
29- if (this.Contains(poi.Location)) {
30- this.Remove(poi.Location);
31- this.Add(poi);
32- }
33- else {
34- this.Add(poi);
35- }
29+ if (this.Contains(poi.Location))
30+ {
31+ this.Remove(poi.Location);
32+ this.Add(poi);
33+ }
34+ else
35+ {
36+ this.Add(poi);
37+ }
3638
3739 }
3840 }
--- a/Automap/Data/StatusData.cs
+++ b/Automap/Data/StatusData.cs
@@ -3,66 +3,57 @@ using System.IO;
33 using Vintagestory.API.Common;
44 using Vintagestory.API.Datastructures;
55
6-namespace Automap
7-{
8- public class StatusData : IAttribute
9- {
6+namespace Automap {
7+ public class StatusData : IAttribute {
108 public uint TotalUpdates { get; set; }
119 public uint VoidChunks { get; set; }
1210 public uint Delta { get; set; }
1311 public uint Max_N, Max_E, Max_S, Max_W;
1412 public RunState CurrentState { get; set; }
1513
16- public StatusData(uint totalUpdates, uint voidChunks, uint delta, RunState currently )
17- {
18- TotalUpdates = totalUpdates;
19- VoidChunks = voidChunks;
20- Delta = delta;
21- CurrentState = currently;
14+ public StatusData(uint totalUpdates, uint voidChunks, uint delta, RunState currently) {
15+ TotalUpdates = totalUpdates;
16+ VoidChunks = voidChunks;
17+ Delta = delta;
18+ CurrentState = currently;
2219 }
2320
24- public void FromBytes(BinaryReader stream)
25- {
26- TotalUpdates = stream.ReadUInt32( );
27- VoidChunks = stream.ReadUInt32( );
28- Delta = stream.ReadUInt32( );
29- CurrentState = ( RunState )stream.ReadByte( );
21+ public void FromBytes(BinaryReader stream) {
22+ TotalUpdates = stream.ReadUInt32();
23+ VoidChunks = stream.ReadUInt32();
24+ Delta = stream.ReadUInt32();
25+ CurrentState = (RunState) stream.ReadByte();
3026 }
3127
32- public int GetAttributeId( )
33- {
34- return 12345;
28+ public int GetAttributeId() {
29+ return 12345;
3530 }
3631
37- public object GetValue( )
38- {
39- return this;
32+ public object GetValue() {
33+ return this;
4034 }
4135
42- public void ToBytes(BinaryWriter stream)
43- {
44- stream.Write(TotalUpdates);
45- stream.Write(VoidChunks);
46- stream.Write(Delta);
47- stream.Write((byte)CurrentState);
36+ public void ToBytes(BinaryWriter stream) {
37+ stream.Write(TotalUpdates);
38+ stream.Write(VoidChunks);
39+ stream.Write(Delta);
40+ stream.Write((byte) CurrentState);
4841 }
4942
50- public string ToJsonToken( )
51- {
52- return $"TotalUpdate:{TotalUpdates}, VoidChunks:{VoidChunks}, Delta:{Delta}";
43+ public string ToJsonToken() {
44+ return $"TotalUpdate:{TotalUpdates}, VoidChunks:{VoidChunks}, Delta:{Delta}";
5345 }
5446
55- public bool Equals(IWorldAccessor worldForResolve, IAttribute attr)
56- {
57- StatusData other = attr.GetValue( ) as StatusData;
47+ public bool Equals(IWorldAccessor worldForResolve, IAttribute attr) {
48+ StatusData other = attr.GetValue() as StatusData;
5849
59- if (this.TotalUpdates == other.TotalUpdates &&
60- this.VoidChunks == other.VoidChunks &&
61- this.Delta == other.Delta &&
62- this.CurrentState == other.CurrentState) {
63- return true;
64- }
65- return false;
50+ if (this.TotalUpdates == other.TotalUpdates &&
51+ this.VoidChunks == other.VoidChunks &&
52+ this.Delta == other.Delta &&
53+ this.CurrentState == other.CurrentState) {
54+ return true;
55+ }
56+ return false;
6657 }
6758 }
6859 }
--- a/Automap/Designators/DefaultDesignators.cs
+++ b/Automap/Designators/DefaultDesignators.cs
@@ -55,7 +55,7 @@ namespace Automap
5555 new EntityDesignator(
5656 new AssetLocation("game", "humanoid-trader"),
5757 Color.LightGoldenrodYellow,
58- EnumEntityState.Active,
58+ EnumEntityState.Active,
5959 KeepTrackOfMerchant
6060 );
6161
@@ -63,9 +63,9 @@ namespace Automap
6363 /// Not just blocks, but block-entities as well!
6464 /// </summary>
6565 /// <returns>The block designators.</returns>
66- public static List<BlockDesignator> DefaultBlockDesignators( )
66+ public static List<BlockDesignator> DefaultBlockDesignators()
6767 {
68- return new List<BlockDesignator>{
68+ return new List<BlockDesignator>{
6969 DefaultDesignators.Roads,
7070 DefaultDesignators.GroundSigns,
7171 DefaultDesignators.WallSigns,
@@ -74,7 +74,7 @@ namespace Automap
7474 };
7575 }
7676
77- public static List<EntityDesignator> DefaultEntityDesignators( )
77+ public static List<EntityDesignator> DefaultEntityDesignators()
7878 {
7979 return new List<EntityDesignator>{
8080 DefaultDesignators.Traders,
@@ -83,86 +83,92 @@ namespace Automap
8383
8484 internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
8585 {
86- #if DEBUG
87- clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
88- #endif
89- //sign Text into a POI field...
90- BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
91-
92- if (signEntity != null && !String.IsNullOrEmpty(signEntity.text))
93- {
94-
95- poi.AddReplace(
96- new PointOfInterest {
97- Location = posn.Copy( ),
98- Notes = signEntity.text,
99- Timestamp = DateTimeOffset.UtcNow,
100- }
101- );
102-
103- }
86+#if DEBUG
87+ clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
88+#endif
89+ //sign Text into a POI field...
90+ BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
91+
92+ if (signEntity != null && !String.IsNullOrEmpty(signEntity.text))
93+ {
94+
95+ poi.AddReplace(
96+ new PointOfInterest
97+ {
98+ Location = posn.Copy(),
99+ Notes = signEntity.text,
100+ Timestamp = DateTimeOffset.UtcNow,
101+ }
102+ );
103+
104+ }
104105
105106 }
106107
107108
108109 internal static void DecodePostSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
109110 {
110- #if DEBUG
111- clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!");
112- #endif
113- //sign post Text into a POI field...
114- BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
115-
116- if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0 ) {
117-
118- poi.AddReplace(
119- new PointOfInterest {
120- Location = posn.Copy( ),
121- Notes = string.Join(",", signEntity.textByCardinalDirection),
122- Timestamp = DateTimeOffset.UtcNow,
123- }
124- );
125-
126- }
111+#if DEBUG
112+ clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!");
113+#endif
114+ //sign post Text into a POI field...
115+ BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
116+
117+ if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0)
118+ {
119+
120+ poi.AddReplace(
121+ new PointOfInterest
122+ {
123+ Location = posn.Copy(),
124+ Notes = string.Join(",", signEntity.textByCardinalDirection),
125+ Timestamp = DateTimeOffset.UtcNow,
126+ }
127+ );
128+
129+ }
127130 }
128131
129132 internal static void KeepTrackOfMerchant(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity)
130133 {
131- clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName( ), posn);
132-
133- var message = $"{entity.GetName( )}";
134- var traderJoe = entity as EntityTrader;
135- if (traderJoe.TradeProps != null) {
136- message = $"{traderJoe.GetName( )} Alive:{traderJoe.Alive} - Gears: {traderJoe.TradeProps.Money}, ";
137- }
138- poi.Upsert(entity, message);
134+ clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
135+
136+ var message = $"{entity.GetName()}";
137+ var traderJoe = entity as EntityTrader;
138+ if (traderJoe.TradeProps != null)
139+ {
140+ message = $"{traderJoe.GetName()} Alive:{traderJoe.Alive} - Gears: {traderJoe.TradeProps.Money}, ";
141+ }
142+ poi.Upsert(entity, message);
139143 }
140144
141145 internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
142146 {
143- clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
144- //Where to? and from!
145-
146- BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
147+ clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
148+ //Where to? and from!
147149
148- if (te != null ) {
150+ BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
149151
150- StringBuilder textTarget = new StringBuilder( );
151- //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
152+ if (te != null)
153+ {
152154
153- textTarget.Append(te.Activated ? "Online " : "offline ");
154- textTarget.Append(" Dest.: ");
155- textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords?
155+ StringBuilder textTarget = new StringBuilder();
156+ //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
156157
157- poi.AddReplace(
158- new PointOfInterest {
159- Location = posn.Copy( ),
160- Notes = textTarget.ToString(),
161- Timestamp = DateTimeOffset.UtcNow,
162- }
163- );
158+ textTarget.Append(te.Activated ? "Online " : "offline ");
159+ textTarget.Append(" Dest.: ");
160+ textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords?
164161
165- }
162+ poi.AddReplace(
163+ new PointOfInterest
164+ {
165+ Location = posn.Copy(),
166+ Notes = textTarget.ToString(),
167+ Timestamp = DateTimeOffset.UtcNow,
168+ }
169+ );
170+
171+ }
166172 }
167173 }
168174 }
--- a/Automap/Renderers/AlternateRenderer.cs
+++ b/Automap/Renderers/AlternateRenderer.cs
@@ -21,106 +21,114 @@ namespace Automap
2121 /// <param name="logger">Logger.</param>
2222 public AlternateRenderer(ICoreClientAPI clientAPI, ILogger logger) : base(clientAPI, logger)
2323 {
24- chunkSize = ClientAPI.World.BlockAccessor.ChunkSize;
24+ chunkSize = ClientAPI.World.BlockAccessor.ChunkSize;
2525 }
2626
2727 public override void GenerateChunkPngShard(Vec2i chunkPos, IMapChunk mc, ColumnMeta metaData, PngWriter pngWriter, out uint pixelCount)
28- {
29- pixelCount = 0;
30- BlockPos tmpPos = new BlockPos( );
31- Vec2i localpos = new Vec2i( );
32- var chunksColumn = new IWorldChunk[ClientAPI.World.BlockAccessor.MapSizeY / chunkSize];
33-
34- int topChunkY = mc.YMax / chunkSize;//Heywaitaminute -- this isn't a highest FEATURE, if Rainmap isn't accurate!
35- //Metadata of DateTime chunk was edited, chunk coords.,world-seed? Y-Max feature height
36- //Grab a chunk COLUMN... Topmost Y down...
37- for (int chunkY = 0; chunkY <= topChunkY; chunkY++) {
38- chunksColumn[chunkY] = ClientAPI.World.BlockAccessor.GetChunk(chunkPos.X, chunkY, chunkPos.Y);
39- //What to do if chunk is a void? invalid?
40- }
41-
42- //pre-create PNG line slices...
43- ImageLine[ ] lines = Enumerable.Repeat(new object( ), chunkSize).Select(l => new ImageLine(pngWriter.ImgInfo)).ToArray( );
44- ushort[ ] allMapYs = mc.RainHeightMap;
45- for (int posIndex = 0; posIndex < (chunkSize * chunkSize); posIndex++) {
46- int currY = allMapYs[posIndex];
47- int localChunkY = currY / chunkSize;
48- if (localChunkY >= (chunksColumn.Length)) continue; //Out of range!
49- if (chunksColumn[localChunkY] == null) continue;
50-
51- MapUtil.PosInt2d(posIndex, chunkSize, localpos);
52- int localX = localpos.X;
53- int localZ = localpos.Y;
54-
55- chunksColumn[localChunkY].Unpack( );
56- int blockId = chunksColumn[localChunkY].Blocks[MapUtil.Index3d(localX, currY % chunkSize, localZ, chunkSize, chunkSize)];
57-
58- Block block = ClientAPI.World.Blocks[blockId];
59-
60- tmpPos.Set(chunkSize * chunkPos.X + localX, currY, chunkSize * chunkPos.Y + localZ);
61-
62- int red;
63- int green;
64- int blue;
65-
66- //============ POI Population =================
67- if (BlockID_Designators.ContainsKey(blockId)) {
68- var desig = BlockID_Designators[blockId];
69- red = desig.OverwriteColor.R;
70- green = desig.OverwriteColor.G;
71- blue = desig.OverwriteColor.B;
72-
73-
74- ImageLineHelper.SetPixel(lines[localZ], localX, red, green, blue);
75- continue;
76- }
77-
78- float b = GetSlope(localX, localZ, allMapYs);
79-
80- int col = block.GetColor(ClientAPI, tmpPos);
81- int packedFormat = ColorUtil.ColorMultiply3Clamped(col, b);
82-
83- red = ColorUtil.ColorB(packedFormat);
84- green = ColorUtil.ColorG(packedFormat);
85- blue = ColorUtil.ColorR(packedFormat);
86- ImageLineHelper.SetPixel(lines[localZ], localX, red, green, blue);
87-
88- //chunkImage.SetPixel(localX, localZ, pixelColor);
89- pixelCount++;
90- }
91-
92- for (int row = 0; row < pngWriter.ImgInfo.Rows; row++) {
93- pngWriter.WriteRow(lines[row], row);
94- }
95-
96- pngWriter.End( );
28+ {
29+ pixelCount = 0;
30+ BlockPos tmpPos = new BlockPos();
31+ Vec2i localpos = new Vec2i();
32+ var chunksColumn = new IWorldChunk[ClientAPI.World.BlockAccessor.MapSizeY / chunkSize];
33+
34+ int topChunkY = mc.YMax / chunkSize;//Heywaitaminute -- this isn't a highest FEATURE, if Rainmap isn't accurate!
35+ //Metadata of DateTime chunk was edited, chunk coords.,world-seed? Y-Max feature height
36+ //Grab a chunk COLUMN... Topmost Y down...
37+ for (int chunkY = 0; chunkY <= topChunkY; chunkY++)
38+ {
39+ chunksColumn[chunkY] = ClientAPI.World.BlockAccessor.GetChunk(chunkPos.X, chunkY, chunkPos.Y);
40+ //What to do if chunk is a void? invalid?
41+ }
42+
43+ //pre-create PNG line slices...
44+ ImageLine[] lines = Enumerable.Repeat(new object(), chunkSize).Select(l => new ImageLine(pngWriter.ImgInfo)).ToArray();
45+ ushort[] allMapYs = mc.RainHeightMap;
46+ for (int posIndex = 0; posIndex < (chunkSize * chunkSize); posIndex++)
47+ {
48+ int currY = allMapYs[posIndex];
49+ int localChunkY = currY / chunkSize;
50+ if (localChunkY >= (chunksColumn.Length)) continue; //Out of range!
51+ if (chunksColumn[localChunkY] == null) continue;
52+
53+ MapUtil.PosInt2d(posIndex, chunkSize, localpos);
54+ int localX = localpos.X;
55+ int localZ = localpos.Y;
56+
57+ chunksColumn[localChunkY].Unpack();
58+ int blockId = chunksColumn[localChunkY].Blocks[MapUtil.Index3d(localX, currY % chunkSize, localZ, chunkSize, chunkSize)];
59+
60+ Block block = ClientAPI.World.Blocks[blockId];
61+
62+ tmpPos.Set(chunkSize * chunkPos.X + localX, currY, chunkSize * chunkPos.Y + localZ);
63+
64+ int red;
65+ int green;
66+ int blue;
67+
68+ //============ POI Population =================
69+ if (BlockID_Designators.ContainsKey(blockId))
70+ {
71+ var desig = BlockID_Designators[blockId];
72+ red = desig.OverwriteColor.R;
73+ green = desig.OverwriteColor.G;
74+ blue = desig.OverwriteColor.B;
75+
76+
77+ ImageLineHelper.SetPixel(lines[localZ], localX, red, green, blue);
78+ continue;
79+ }
80+
81+ float b = GetSlope(localX, localZ, allMapYs);
82+
83+ int col = block.GetColor(ClientAPI, tmpPos);
84+ int packedFormat = ColorUtil.ColorMultiply3Clamped(col, b);
85+
86+ red = ColorUtil.ColorB(packedFormat);
87+ green = ColorUtil.ColorG(packedFormat);
88+ blue = ColorUtil.ColorR(packedFormat);
89+ ImageLineHelper.SetPixel(lines[localZ], localX, red, green, blue);
90+
91+ //chunkImage.SetPixel(localX, localZ, pixelColor);
92+ pixelCount++;
93+ }
94+
95+ for (int row = 0; row < pngWriter.ImgInfo.Rows; row++)
96+ {
97+ pngWriter.WriteRow(lines[row], row);
98+ }
99+
100+ pngWriter.End();
97101 }
98102
99- private float GetSlope(int x, int y, ushort[ ] heightMap)
103+ private float GetSlope(int x, int y, ushort[] heightMap)
100104 {
101- int baseY = heightMap[MapUtil.Index2d(x, y, chunkSize)];
102- float runningY = 0;
103- // check bounds. i hate this.
104- int locIndex;
105- if (x > 0) {
106- locIndex = MapUtil.Index2d(x - 1, y, chunkSize);
107- runningY += (baseY - heightMap[locIndex]);
108- }
109- if (x < chunkSize - 1) {
110- locIndex = MapUtil.Index2d(x + 1, y, chunkSize);
111- runningY += (baseY - heightMap[locIndex]);
112- }
113- if (y > 0) {
114- locIndex = MapUtil.Index2d(x, y - 1, chunkSize);
115- runningY += (baseY - heightMap[locIndex]);
116- }
117- if (y < chunkSize - 1) {
118- locIndex = MapUtil.Index2d(x, y + 1, chunkSize);
119- runningY += (baseY - heightMap[locIndex]);
120- }
121- runningY /= 4; // average now
122- runningY /= 5; // idk
123- return 1 + runningY;
105+ int baseY = heightMap[MapUtil.Index2d(x, y, chunkSize)];
106+ float runningY = 0;
107+ // check bounds. i hate this.
108+ int locIndex;
109+ if (x > 0)
110+ {
111+ locIndex = MapUtil.Index2d(x - 1, y, chunkSize);
112+ runningY += (baseY - heightMap[locIndex]);
113+ }
114+ if (x < chunkSize - 1)
115+ {
116+ locIndex = MapUtil.Index2d(x + 1, y, chunkSize);
117+ runningY += (baseY - heightMap[locIndex]);
118+ }
119+ if (y > 0)
120+ {
121+ locIndex = MapUtil.Index2d(x, y - 1, chunkSize);
122+ runningY += (baseY - heightMap[locIndex]);
123+ }
124+ if (y < chunkSize - 1)
125+ {
126+ locIndex = MapUtil.Index2d(x, y + 1, chunkSize);
127+ runningY += (baseY - heightMap[locIndex]);
128+ }
129+ runningY /= 4; // average now
130+ runningY /= 5; // idk
131+ return 1 + runningY;
124132 }
125133 }
126134 }
--- a/Automap/Renderers/IChunkRenderer.cs
+++ b/Automap/Renderers/IChunkRenderer.cs
@@ -17,8 +17,8 @@ namespace Automap
1717
1818 protected IChunkRenderer(ICoreClientAPI clientAPI, ILogger logger)
1919 {
20- this.ClientAPI = clientAPI;
21- this.Logger = logger;
20+ this.ClientAPI = clientAPI;
21+ this.Logger = logger;
2222 }
2323
2424 public abstract void GenerateChunkPngShard(Vec2i chunkPos, IMapChunk mapChunk, ColumnMeta metaData, PngWriter pngWriter, out uint pixelCount);
--- a/Automap/Renderers/StandardRenerer.cs
+++ b/Automap/Renderers/StandardRenerer.cs
@@ -19,133 +19,142 @@ namespace Automap
1919 /// </summary>
2020 /// <param name="clientAPI">Client API.</param>
2121 /// <param name="logger">Logger.</param>
22- public StandardRenderer(ICoreClientAPI clientAPI, ILogger logger) : base (clientAPI, logger)
22+ public StandardRenderer(ICoreClientAPI clientAPI, ILogger logger) : base(clientAPI, logger)
2323 {
24- chunkSize = ClientAPI.World.BlockAccessor.ChunkSize;
24+ chunkSize = ClientAPI.World.BlockAccessor.ChunkSize;
2525 }
2626
2727 public override void GenerateChunkPngShard(Vec2i chunkPos, IMapChunk mc, ColumnMeta metaData, PngWriter pngWriter, out uint pixelCount)
2828 {
29- pixelCount = 0;
30- BlockPos tmpPos = new BlockPos( );
31- Vec2i localpos = new Vec2i( );
32-
33- var chunksColumn = new IWorldChunk[ClientAPI.World.BlockAccessor.MapSizeY / chunkSize];
29+ pixelCount = 0;
30+ BlockPos tmpPos = new BlockPos();
31+ Vec2i localpos = new Vec2i();
3432
35- int topChunkY = mc.YMax / chunkSize;//Heywaitaminute -- this isn't a highest FEATURE, if Rainmap isn't accurate!
33+ var chunksColumn = new IWorldChunk[ClientAPI.World.BlockAccessor.MapSizeY / chunkSize];
3634
37- for (int chunkY = 0; chunkY <= topChunkY; chunkY++) {
38- chunksColumn[chunkY] = ClientAPI.World.BlockAccessor.GetChunk(chunkPos.X, chunkY, chunkPos.Y);
39- //What to do if chunk is a void? invalid?
40- }
35+ int topChunkY = mc.YMax / chunkSize;//Heywaitaminute -- this isn't a highest FEATURE, if Rainmap isn't accurate!
4136
42- // Prefetch map chunks, in pattern
43- IMapChunk[ ] mapChunks = new IMapChunk[ ]
44- {
37+ for (int chunkY = 0; chunkY <= topChunkY; chunkY++)
38+ {
39+ chunksColumn[chunkY] = ClientAPI.World.BlockAccessor.GetChunk(chunkPos.X, chunkY, chunkPos.Y);
40+ //What to do if chunk is a void? invalid?
41+ }
42+
43+ // Prefetch map chunks, in pattern
44+ IMapChunk[] mapChunks = new IMapChunk[]
45+ {
4546 ClientAPI.World.BlockAccessor.GetMapChunk(chunkPos.X - 1, chunkPos.Y - 1),
4647 ClientAPI.World.BlockAccessor.GetMapChunk(chunkPos.X - 1, chunkPos.Y),
4748 ClientAPI.World.BlockAccessor.GetMapChunk(chunkPos.X, chunkPos.Y - 1)
48- };
49-
50- //pre-create PNG line slices...
51- ImageLine[ ] lines = Enumerable.Repeat(new object( ), chunkSize).Select(l => new ImageLine(pngWriter.ImgInfo)).ToArray( );
52-
53- for (int posIndex = 0; posIndex < (chunkSize * chunkSize); posIndex++) {
54- int mapY = mc.RainHeightMap[posIndex];
55- int localChunkY = mapY / chunkSize;
56- if (localChunkY >= (chunksColumn.Length)) continue;//Out of range!
57-
58- MapUtil.PosInt2d(posIndex, chunkSize, localpos);
59- int localX = localpos.X;
60- int localZ = localpos.Y;
61-
62- float b = 1;
63- int leftTop, rightTop, leftBot;
64-
65- IMapChunk leftTopMapChunk = mc;
66- IMapChunk rightTopMapChunk = mc;
67- IMapChunk leftBotMapChunk = mc;
68-
69- int topX = localX - 1;
70- int botX = localX;
71- int leftZ = localZ - 1;
72- int rightZ = localZ;
73-
74- if (topX < 0 && leftZ < 0) {
75- leftTopMapChunk = mapChunks[0];
76- rightTopMapChunk = mapChunks[1];
77- leftBotMapChunk = mapChunks[2];
78- }
79- else {
80- if (topX < 0) {
81- leftTopMapChunk = mapChunks[1];
82- rightTopMapChunk = mapChunks[1];
83- }
84- if (leftZ < 0) {
85- leftTopMapChunk = mapChunks[2];
86- leftBotMapChunk = mapChunks[2];
87- }
88- }
89-
90- topX = GameMath.Mod(topX, chunkSize);
91- leftZ = GameMath.Mod(leftZ, chunkSize);
92-
93- leftTop = leftTopMapChunk == null ? 0 : Math.Sign(mapY - leftTopMapChunk.RainHeightMap[leftZ * chunkSize + topX]);
94- rightTop = rightTopMapChunk == null ? 0 : Math.Sign(mapY - rightTopMapChunk.RainHeightMap[rightZ * chunkSize + topX]);
95- leftBot = leftBotMapChunk == null ? 0 : Math.Sign(mapY - leftBotMapChunk.RainHeightMap[leftZ * chunkSize + botX]);
49+ };
9650
97- float slopeness = (leftTop + rightTop + leftBot);
51+ //pre-create PNG line slices...
52+ ImageLine[] lines = Enumerable.Repeat(new object(), chunkSize).Select(l => new ImageLine(pngWriter.ImgInfo)).ToArray();
9853
99- if (slopeness > 0) b = 1.2f;
100- if (slopeness < 0) b = 0.8f;
101-
102- b -= 0.15f; //Slope boost value
103-
104- if (chunksColumn[localChunkY] == null) {
105-
106- continue;
107- }
108-
109- chunksColumn[localChunkY].Unpack( );
110- int blockId = chunksColumn[localChunkY].Blocks[MapUtil.Index3d(localpos.X, mapY % chunkSize, localpos.Y, chunkSize, chunkSize)];
111-
112- Block block = ClientAPI.World.Blocks[blockId];
113-
114- tmpPos.Set(chunkSize * chunkPos.X + localpos.X, mapY, chunkSize * chunkPos.Y + localpos.Y);
115-
116- int avgCol = block.GetColor(ClientAPI, tmpPos);
117- int rndCol = block.GetRandomColor(ClientAPI, tmpPos, BlockFacing.UP);
118- int col = ColorUtil.ColorOverlay(avgCol, rndCol, 0.125f);
119- var packedFormat = ColorUtil.ColorMultiply3Clamped(col, b);
120-
121- int red = ColorUtil.ColorB(packedFormat);
122- int green = ColorUtil.ColorG(packedFormat);
123- int blue = ColorUtil.ColorR(packedFormat);
124-
125-
126- //============ POI Population =================
127- if (BlockID_Designators.ContainsKey(blockId)) {
128- var desig = BlockID_Designators[blockId];
129-
130- if (desig.Enabled)
54+ for (int posIndex = 0; posIndex < (chunkSize * chunkSize); posIndex++)
13155 {
132- red = desig.OverwriteColor.R;
133- green = desig.OverwriteColor.G;
134- blue = desig.OverwriteColor.B;
56+ int mapY = mc.RainHeightMap[posIndex];
57+ int localChunkY = mapY / chunkSize;
58+ if (localChunkY >= (chunksColumn.Length)) continue;//Out of range!
59+
60+ MapUtil.PosInt2d(posIndex, chunkSize, localpos);
61+ int localX = localpos.X;
62+ int localZ = localpos.Y;
63+
64+ float b = 1;
65+ int leftTop, rightTop, leftBot;
66+
67+ IMapChunk leftTopMapChunk = mc;
68+ IMapChunk rightTopMapChunk = mc;
69+ IMapChunk leftBotMapChunk = mc;
70+
71+ int topX = localX - 1;
72+ int botX = localX;
73+ int leftZ = localZ - 1;
74+ int rightZ = localZ;
75+
76+ if (topX < 0 && leftZ < 0)
77+ {
78+ leftTopMapChunk = mapChunks[0];
79+ rightTopMapChunk = mapChunks[1];
80+ leftBotMapChunk = mapChunks[2];
81+ }
82+ else
83+ {
84+ if (topX < 0)
85+ {
86+ leftTopMapChunk = mapChunks[1];
87+ rightTopMapChunk = mapChunks[1];
88+ }
89+ if (leftZ < 0)
90+ {
91+ leftTopMapChunk = mapChunks[2];
92+ leftBotMapChunk = mapChunks[2];
93+ }
94+ }
95+
96+ topX = GameMath.Mod(topX, chunkSize);
97+ leftZ = GameMath.Mod(leftZ, chunkSize);
98+
99+ leftTop = leftTopMapChunk == null ? 0 : Math.Sign(mapY - leftTopMapChunk.RainHeightMap[leftZ * chunkSize + topX]);
100+ rightTop = rightTopMapChunk == null ? 0 : Math.Sign(mapY - rightTopMapChunk.RainHeightMap[rightZ * chunkSize + topX]);
101+ leftBot = leftBotMapChunk == null ? 0 : Math.Sign(mapY - leftBotMapChunk.RainHeightMap[leftZ * chunkSize + botX]);
102+
103+ float slopeness = (leftTop + rightTop + leftBot);
104+
105+ if (slopeness > 0) b = 1.2f;
106+ if (slopeness < 0) b = 0.8f;
107+
108+ b -= 0.15f; //Slope boost value
109+
110+ if (chunksColumn[localChunkY] == null)
111+ {
112+
113+ continue;
114+ }
115+
116+ chunksColumn[localChunkY].Unpack();
117+ int blockId = chunksColumn[localChunkY].Blocks[MapUtil.Index3d(localpos.X, mapY % chunkSize, localpos.Y, chunkSize, chunkSize)];
118+
119+ Block block = ClientAPI.World.Blocks[blockId];
120+
121+ tmpPos.Set(chunkSize * chunkPos.X + localpos.X, mapY, chunkSize * chunkPos.Y + localpos.Y);
122+
123+ int avgCol = block.GetColor(ClientAPI, tmpPos);
124+ int rndCol = block.GetRandomColor(ClientAPI, tmpPos, BlockFacing.UP);
125+ int col = ColorUtil.ColorOverlay(avgCol, rndCol, 0.125f);
126+ var packedFormat = ColorUtil.ColorMultiply3Clamped(col, b);
127+
128+ int red = ColorUtil.ColorB(packedFormat);
129+ int green = ColorUtil.ColorG(packedFormat);
130+ int blue = ColorUtil.ColorR(packedFormat);
131+
132+
133+ //============ POI Population =================
134+ if (BlockID_Designators.ContainsKey(blockId))
135+ {
136+ var desig = BlockID_Designators[blockId];
137+
138+ if (desig.Enabled)
139+ {
140+ red = desig.OverwriteColor.R;
141+ green = desig.OverwriteColor.G;
142+ blue = desig.OverwriteColor.B;
143+ }
144+ }
145+
146+ ImageLineHelper.SetPixel(lines[localZ], localX, red, green, blue);
147+
148+ //chunkImage.SetPixel(localX, localZ, pixelColor);
149+ pixelCount++;
135150 }
136- }
137151
138- ImageLineHelper.SetPixel(lines[localZ], localX, red, green, blue);
139-
140- //chunkImage.SetPixel(localX, localZ, pixelColor);
141- pixelCount++;
142- }
143-
144- for (int row = 0; row < pngWriter.ImgInfo.Rows; row++) {
145- pngWriter.WriteRow(lines[row], row);
146- }
152+ for (int row = 0; row < pngWriter.ImgInfo.Rows; row++)
153+ {
154+ pngWriter.WriteRow(lines[row], row);
155+ }
147156
148- pngWriter.End( );
157+ pngWriter.End();
149158 }
150159 }
151160 }
--- a/Automap/Subsystems/AutomapGUIDialog.cs
+++ b/Automap/Subsystems/AutomapGUIDialog.cs
@@ -17,9 +17,9 @@ namespace Automap
1717
1818 private long dashTickHandle;
1919
20- public override string ToggleKeyCombinationCode {
21- get
22- {
20+ public override string ToggleKeyCombinationCode
21+ {
22+ get {
2323 return _automapControlPanelKey;
2424 }
2525 }
@@ -28,53 +28,53 @@ namespace Automap
2828 private RunState lastState;
2929
3030
31- public AutomapGUIDialog(ICoreClientAPI capi,AutomapSystem ams) : base(capi)
32- {
31+ public AutomapGUIDialog(ICoreClientAPI capi, AutomapSystem ams) : base(capi)
32+ {
33+
34+ Logger = capi.Logger;
35+ SetupDialog();
36+ capi.Event.RegisterEventBusListener(AutomapStatusMsg, 1.0D, AutomapSystem.AutomapStatusEventKey);
3337
34- Logger = capi.Logger;
35- SetupDialog( );
36- capi.Event.RegisterEventBusListener(AutomapStatusMsg, 1.0D, AutomapSystem.AutomapStatusEventKey);
37-
3838 }
3939
4040 //Event for GUI status display
4141
42- private void SetupDialog( )
42+ private void SetupDialog()
4343 {
44- ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);
45-
46- ElementBounds textBounds = ElementBounds.Fixed(0, 40, 500, 300);
47-
48- ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);
49- bgBounds.BothSizing = ElementSizing.FitToChildren;
50- bgBounds.WithChildren(textBounds);
51-
52- ElementBounds toggleBounds = textBounds.CopyOffsetedSibling(0, 72, 5, 2);
53- toggleBounds.fixedHeight = 24;
54- toggleBounds.fixedWidth = 64;
55-
56- ElementBounds txtStatusBounds = textBounds.CopyOffsetedSibling(0, 26, 2, 4);
57- txtStatusBounds.fixedHeight = 16;
58- txtStatusBounds.percentWidth = 1;
59-
60- ElementBounds btnNoteArea = textBounds.CopyOffsetedSibling(0, 42, 2, 5);
61- btnNoteArea.fixedHeight = 24;
62- btnNoteArea.fixedWidth = 20;
63-
64- ElementBounds txtNoteArea = btnNoteArea.CopyOffsetedSibling(64, 0, 1, 6);
65- txtNoteArea.fixedHeight = 24;
66- txtNoteArea.fixedWidth = 256;
67-
68-
69- this.SingleComposer = capi.Gui.CreateCompo("automapControlPanel", dialogBounds)
70- .AddShadedDialogBG(bgBounds)
71- .AddDialogTitleBar("Automap Controls", OnTitleBarCloseClicked)
72- .AddStaticText("Configure Automap settings:", CairoFont.WhiteDetailText( ), textBounds)
73- .AddToggleButton("Run", CairoFont.ButtonText( ), RunToggle, toggleBounds, "btnRun")
74- .AddDynamicText("Idle.", CairoFont.WhiteSmallText( ).WithFontSize(12), EnumTextOrientation.Left, txtStatusBounds, _statusTextKey)
75- .AddTextInput(txtNoteArea,null,CairoFont.WhiteMediumText().WithFontSize(16),_noteTextKey)
76- .AddButton("Note:",CreateNote,btnNoteArea,CairoFont.ButtonText())
77- .Compose( );
44+ ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);
45+
46+ ElementBounds textBounds = ElementBounds.Fixed(0, 40, 500, 300);
47+
48+ ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);
49+ bgBounds.BothSizing = ElementSizing.FitToChildren;
50+ bgBounds.WithChildren(textBounds);
51+
52+ ElementBounds toggleBounds = textBounds.CopyOffsetedSibling(0, 72, 5, 2);
53+ toggleBounds.fixedHeight = 24;
54+ toggleBounds.fixedWidth = 64;
55+
56+ ElementBounds txtStatusBounds = textBounds.CopyOffsetedSibling(0, 26, 2, 4);
57+ txtStatusBounds.fixedHeight = 16;
58+ txtStatusBounds.percentWidth = 1;
59+
60+ ElementBounds btnNoteArea = textBounds.CopyOffsetedSibling(0, 42, 2, 5);
61+ btnNoteArea.fixedHeight = 24;
62+ btnNoteArea.fixedWidth = 20;
63+
64+ ElementBounds txtNoteArea = btnNoteArea.CopyOffsetedSibling(64, 0, 1, 6);
65+ txtNoteArea.fixedHeight = 24;
66+ txtNoteArea.fixedWidth = 256;
67+
68+
69+ this.SingleComposer = capi.Gui.CreateCompo("automapControlPanel", dialogBounds)
70+ .AddShadedDialogBG(bgBounds)
71+ .AddDialogTitleBar("Automap Controls", OnTitleBarCloseClicked)
72+ .AddStaticText("Configure Automap settings:", CairoFont.WhiteDetailText(), textBounds)
73+ .AddToggleButton("Run", CairoFont.ButtonText(), RunToggle, toggleBounds, "btnRun")
74+ .AddDynamicText("Idle.", CairoFont.WhiteSmallText().WithFontSize(12), EnumTextOrientation.Left, txtStatusBounds, _statusTextKey)
75+ .AddTextInput(txtNoteArea, null, CairoFont.WhiteMediumText().WithFontSize(16), _noteTextKey)
76+ .AddButton("Note:", CreateNote, btnNoteArea, CairoFont.ButtonText())
77+ .Compose();
7878
7979 //Controls for ALL Block & Entity Designators (Enable/Disable)
8080 //_automapSystem.BlockID_Designators
@@ -86,9 +86,9 @@ namespace Automap
8686
8787 }
8888
89- private void OnTitleBarCloseClicked( )
89+ private void OnTitleBarCloseClicked()
9090 {
91- TryClose( );
91+ TryClose();
9292 }
9393
9494 /// <summary>
@@ -98,51 +98,54 @@ namespace Automap
9898 /// <param name="toggle">Run.</param>
9999 internal void RunToggle(bool toggle)
100100 {
101- Logger.VerboseDebug("Dialog Changed; [ Automap Enabled: {0} ]", toggle);
102- var statusText = this.SingleComposer.GetDynamicText(_statusTextKey);
103- statusText.SetNewText($"State: {(toggle? "Run": "Halt" )}, Total: {totalShards}, Nulls: {voidShards} " );
101+ Logger.VerboseDebug("Dialog Changed; [ Automap Enabled: {0} ]", toggle);
102+ var statusText = this.SingleComposer.GetDynamicText(_statusTextKey);
103+ statusText.SetNewText($"State: {(toggle ? "Run" : "Halt")}, Total: {totalShards}, Nulls: {voidShards} ");
104104
105- CommandData cmd;
105+ CommandData cmd;
106106
107- if (toggle) {
108- dashTickHandle = capi.Event.RegisterGameTickListener(UpdateDashDisplay, 6001);
109- cmd = new CommandData(toggle ? RunState.Run : RunState.Stop, new bool[ ] { true, true, true, true, true });
110- }
111- else {
112- capi.Event.UnregisterGameTickListener(dashTickHandle);
113- cmd = new CommandData(toggle ? RunState.Run : RunState.Stop);
114- }
115-
116- capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, cmd);
107+ if (toggle)
108+ {
109+ dashTickHandle = capi.Event.RegisterGameTickListener(UpdateDashDisplay, 6001);
110+ cmd = new CommandData(toggle ? RunState.Run : RunState.Stop, new bool[] { true, true, true, true, true });
111+ }
112+ else
113+ {
114+ capi.Event.UnregisterGameTickListener(dashTickHandle);
115+ cmd = new CommandData(toggle ? RunState.Run : RunState.Stop);
116+ }
117+
118+ capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, cmd);
117119 }
118120
119- private bool CreateNote( )
121+ private bool CreateNote()
120122 {
121- var noteCmd = new CommandData(RunState.Notation);
122- var txtNote = this.SingleComposer.GetTextInput(_noteTextKey);
123- if (!String.IsNullOrWhiteSpace(txtNote.GetText( ))) {
124- noteCmd.Notation = txtNote.GetText( );
125- txtNote.SetValue(string.Empty);
123+ var noteCmd = new CommandData(RunState.Notation);
124+ var txtNote = this.SingleComposer.GetTextInput(_noteTextKey);
125+ if (!String.IsNullOrWhiteSpace(txtNote.GetText()))
126+ {
127+ noteCmd.Notation = txtNote.GetText();
128+ txtNote.SetValue(string.Empty);
126129
127- capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, noteCmd);
128- }
129- return false;//???
130+ capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, noteCmd);
131+ }
132+ return false;//???
130133 }
131134
132135 private void AutomapStatusMsg(string eventName, ref EnumHandling handling, IAttribute data)
133136 {
134- Logger.VerboseDebug("MsgBus RX: AutomapStatusMsg");
135- StatusData realData = data as StatusData;
136- totalShards = realData.TotalUpdates;
137- voidShards = realData.VoidChunks;
138- changesThisTick = realData.Delta;
139- lastState = realData.CurrentState;
137+ Logger.VerboseDebug("MsgBus RX: AutomapStatusMsg");
138+ StatusData realData = data as StatusData;
139+ totalShards = realData.TotalUpdates;
140+ voidShards = realData.VoidChunks;
141+ changesThisTick = realData.Delta;
142+ lastState = realData.CurrentState;
140143 }
141144
142- private void UpdateDashDisplay(float delay )
145+ private void UpdateDashDisplay(float delay)
143146 {
144- var statusText = this.SingleComposer.GetDynamicText(_statusTextKey);
145- statusText.SetNewText($"State: {lastState}, Total: {totalShards}, Delta: {changesThisTick} Nulls: {voidShards} ");
147+ var statusText = this.SingleComposer.GetDynamicText(_statusTextKey);
148+ statusText.SetNewText($"State: {lastState}, Total: {totalShards}, Delta: {changesThisTick} Nulls: {voidShards} ");
146149
147150
148151 }
--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -22,7 +22,7 @@ using Vintagestory.API.MathTools;
2222 using Vintagestory.Common;
2323
2424 namespace Automap
25-{
25+{
2626 public class AutomapSystem
2727 {
2828 private Thread cartographer_thread;
@@ -36,12 +36,12 @@ namespace Automap
3636 private const string chunkFile_filter = @"*_*.png";
3737 private static Regex chunkShardRegex = new Regex(@"(?<X>[\d]+)_(?<Z>[\d]+).png", RegexOptions.Singleline);
3838
39- private ConcurrentDictionary<Vec2i, uint> columnCounter = new ConcurrentDictionary<Vec2i, uint>(3, 150 );
39+ private ConcurrentDictionary<Vec2i, uint> columnCounter = new ConcurrentDictionary<Vec2i, uint>(3, 150);
4040 private ColumnsMetadata chunkTopMetadata;
4141 private PointsOfInterest POIs = new PointsOfInterest();
4242 private EntitiesOfInterest EOIs = new EntitiesOfInterest();
4343
44- internal Dictionary<int, BlockDesignator> BlockID_Designators { get; private set;}
44+ internal Dictionary<int, BlockDesignator> BlockID_Designators { get; private set; }
4545 internal Dictionary<AssetLocation, EntityDesignator> Entity_Designators { get; private set; }
4646 internal Dictionary<int, string> RockIdCodes { get; private set; }
4747
@@ -60,49 +60,49 @@ namespace Automap
6060
6161 public AutomapSystem(ICoreClientAPI clientAPI, ILogger logger)
6262 {
63- this.ClientAPI = clientAPI;
64- this.Logger = logger;
65- chunkSize = ClientAPI.World.BlockAccessor.ChunkSize;
66- ClientAPI.Event.LevelFinalize += EngageAutomap;
63+ this.ClientAPI = clientAPI;
64+ this.Logger = logger;
65+ chunkSize = ClientAPI.World.BlockAccessor.ChunkSize;
66+ ClientAPI.Event.LevelFinalize += EngageAutomap;
6767
68- //TODO:Choose which one from GUI
69- this.ChunkRenderer = new StandardRenderer(clientAPI, logger);
68+ //TODO:Choose which one from GUI
69+ this.ChunkRenderer = new StandardRenderer(clientAPI, logger);
7070
71- //Listen on bus for commands
72- ClientAPI.Event.RegisterEventBusListener(CommandListener, 1.0, AutomapSystem.AutomapCommandEventKey);
71+ //Listen on bus for commands
72+ ClientAPI.Event.RegisterEventBusListener(CommandListener, 1.0, AutomapSystem.AutomapCommandEventKey);
7373
7474 }
7575
7676
7777 #region Internals
78- private void EngageAutomap( )
78+ private void EngageAutomap()
7979 {
80- path = ClientAPI.GetOrCreateDataPath(_mapPath);
81- path = ClientAPI.GetOrCreateDataPath(Path.Combine(path, "World_" + ClientAPI.World.Seed));//Add name of World too...'ServerApi.WorldManager.CurrentWorldName'
80+ path = ClientAPI.GetOrCreateDataPath(_mapPath);
81+ path = ClientAPI.GetOrCreateDataPath(Path.Combine(path, "World_" + ClientAPI.World.Seed));//Add name of World too...'ServerApi.WorldManager.CurrentWorldName'
8282
83- stylesFile = ClientAPI.World.AssetManager.Get(new AssetLocation(_domain, "config/automap_format.css"));
84- Logger.VerboseDebug("CSS loaded: {0} size: {1}",stylesFile.IsLoaded() ,stylesFile.ToText( ).Length);
83+ stylesFile = ClientAPI.World.AssetManager.Get(new AssetLocation(_domain, "config/automap_format.css"));
84+ Logger.VerboseDebug("CSS loaded: {0} size: {1}", stylesFile.IsLoaded(), stylesFile.ToText().Length);
8585
86- Prefill_POI_Designators( );
87- startChunkColumn = new Vec2i((ClientAPI.World.Player.Entity.LocalPos.AsBlockPos.X / chunkSize), (ClientAPI.World.Player.Entity.LocalPos.AsBlockPos.Z / chunkSize));
88- chunkTopMetadata = new ColumnsMetadata(startChunkColumn);
86+ Prefill_POI_Designators();
87+ startChunkColumn = new Vec2i((ClientAPI.World.Player.Entity.LocalPos.AsBlockPos.X / chunkSize), (ClientAPI.World.Player.Entity.LocalPos.AsBlockPos.Z / chunkSize));
88+ chunkTopMetadata = new ColumnsMetadata(startChunkColumn);
8989
90- Logger.Notification("AUTOMAP Start {0}", startChunkColumn);
91- Reload_Metadata( );
90+ Logger.Notification("AUTOMAP Start {0}", startChunkColumn);
91+ Reload_Metadata();
9292
93- ClientAPI.Event.ChunkDirty += ChunkAChanging;
93+ ClientAPI.Event.ChunkDirty += ChunkAChanging;
9494
95- cartographer_thread = new Thread(Cartographer);
96- cartographer_thread.Name = "Cartographer";
97- cartographer_thread.Priority = ThreadPriority.Lowest;
98- cartographer_thread.IsBackground = true;
95+ cartographer_thread = new Thread(Cartographer);
96+ cartographer_thread.Name = "Cartographer";
97+ cartographer_thread.Priority = ThreadPriority.Lowest;
98+ cartographer_thread.IsBackground = true;
9999
100- ClientAPI.Event.RegisterGameTickListener(AwakenCartographer, 6000);
100+ ClientAPI.Event.RegisterGameTickListener(AwakenCartographer, 6000);
101101 }
102102
103103 private void ChunkAChanging(Vec3i chunkCoord, IWorldChunk chunk, EnumChunkDirtyReason reason)
104- {
105- Vec2i topPosition = new Vec2i(chunkCoord.X, chunkCoord.Z);
104+ {
105+ Vec2i topPosition = new Vec2i(chunkCoord.X, chunkCoord.Z);
106106
107107 columnCounter.AddOrUpdate(topPosition, 1, (key, colAct) => colAct + 1);
108108 }
@@ -110,490 +110,529 @@ namespace Automap
110110 private void AwakenCartographer(float delayed)
111111 {
112112
113- if (CurrentState == RunState.Run && (ClientAPI.IsGamePaused != false || ClientAPI.IsShuttingDown != true)) {
114- #if DEBUG
115- Logger.VerboseDebug("Cartographer re-trigger from [{0}]", cartographer_thread.ThreadState);
116- #endif
113+ if (CurrentState == RunState.Run && (ClientAPI.IsGamePaused != false || ClientAPI.IsShuttingDown != true))
114+ {
115+#if DEBUG
116+ Logger.VerboseDebug("Cartographer re-trigger from [{0}]", cartographer_thread.ThreadState);
117+#endif
117118
118- if (cartographer_thread.ThreadState.HasFlag(ThreadState.Unstarted)) {
119- cartographer_thread.Start( );
120- }
121- else if (cartographer_thread.ThreadState.HasFlag(ThreadState.WaitSleepJoin)) {
122- //Time to (re)write chunk shards
123- cartographer_thread.Interrupt( );
124- }
125- //#if DEBUG
126- //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})");
127- //#endif
128- }
129- else if (CurrentState == RunState.Snapshot) {
130- //TODO: Snapshot generator second thread...
131- }
119+ if (cartographer_thread.ThreadState.HasFlag(ThreadState.Unstarted))
120+ {
121+ cartographer_thread.Start();
122+ }
123+ else if (cartographer_thread.ThreadState.HasFlag(ThreadState.WaitSleepJoin))
124+ {
125+ //Time to (re)write chunk shards
126+ cartographer_thread.Interrupt();
127+ }
128+ //#if DEBUG
129+ //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})");
130+ //#endif
131+ }
132+ else if (CurrentState == RunState.Snapshot)
133+ {
134+ //TODO: Snapshot generator second thread...
135+ }
132136
133137 }
134138
135139
136- private void Cartographer( )
140+ private void Cartographer()
137141 {
138- wake:
139- Logger.VerboseDebug("Cartographer thread awoken");
140-
141- try {
142- uint ejectedItem = 0;
143- uint updatedChunks = 0;
142+ wake:
143+ Logger.VerboseDebug("Cartographer thread awoken");
144144
145- //-- Should dodge enumerator changing underfoot....at a cost.
146- if (!columnCounter.IsEmpty) {
147- var tempSet = columnCounter.ToArray( ).OrderByDescending(kvp => kvp.Value);
148- foreach (var mostActiveCol in tempSet) {
149-
150- var mapChunk = ClientAPI.World.BlockAccessor.GetMapChunk(mostActiveCol.Key);
151-
152- if (mapChunk == null) {
153- Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key);
154- nullChunkCount++;
155- columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem );
156- continue;
157- }
158-
159- ColumnMeta chunkMeta = CreateColumnMetadata(mostActiveCol,mapChunk);
160- PngWriter pngWriter = SetupPngImage(mostActiveCol.Key, chunkMeta);
161- UpdateEntityMetadata( );
162- ProcessChunkBlocks(mostActiveCol.Key, mapChunk, chunkMeta);
163-
164- uint updatedPixels = 0;
165-
166- ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, pngWriter , out updatedPixels);
167-
168- if (updatedPixels > 0) {
169-
170- #if DEBUG
171- Logger.VerboseDebug("Wrote chunk shard: ({0}) - Edits#:{1}, Pixels#:{2}", mostActiveCol.Key, mostActiveCol.Value, updatedPixels);
172- #endif
173- updatedChunks++;
174- chunkTopMetadata.Update(chunkMeta);
175- columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
176- }
177- else {
178- columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
179- Logger.VerboseDebug("Un-painted chunk: ({0}) ", mostActiveCol.Key);
180- }
145+ try
146+ {
147+ uint ejectedItem = 0;
148+ uint updatedChunks = 0;
181149
182- }
183- }
150+ //-- Should dodge enumerator changing underfoot....at a cost.
151+ if (!columnCounter.IsEmpty)
152+ {
153+ var tempSet = columnCounter.ToArray().OrderByDescending(kvp => kvp.Value);
154+ foreach (var mostActiveCol in tempSet)
155+ {
156+
157+ var mapChunk = ClientAPI.World.BlockAccessor.GetMapChunk(mostActiveCol.Key);
158+
159+ if (mapChunk == null)
160+ {
161+ Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key);
162+ nullChunkCount++;
163+ columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
164+ continue;
165+ }
166+
167+ ColumnMeta chunkMeta = CreateColumnMetadata(mostActiveCol, mapChunk);
168+ PngWriter pngWriter = SetupPngImage(mostActiveCol.Key, chunkMeta);
169+ UpdateEntityMetadata();
170+ ProcessChunkBlocks(mostActiveCol.Key, mapChunk, chunkMeta);
171+
172+ uint updatedPixels = 0;
173+
174+ ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, pngWriter, out updatedPixels);
175+
176+ if (updatedPixels > 0)
177+ {
178+
179+#if DEBUG
180+ Logger.VerboseDebug("Wrote chunk shard: ({0}) - Edits#:{1}, Pixels#:{2}", mostActiveCol.Key, mostActiveCol.Value, updatedPixels);
181+#endif
182+ updatedChunks++;
183+ chunkTopMetadata.Update(chunkMeta);
184+ columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
185+ }
186+ else
187+ {
188+ columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
189+ Logger.VerboseDebug("Un-painted chunk: ({0}) ", mostActiveCol.Key);
190+ }
191+
192+ }
193+ }
184194
185- UpdateStatus(this.updatedChunksTotal, this.nullChunkCount, updatedChunks);
195+ UpdateStatus(this.updatedChunksTotal, this.nullChunkCount, updatedChunks);
186196
187- if (updatedChunks > 0) {
188- //What about chunk updates themselves; a update bitmap isn't kept...
189- updatedChunksTotal += updatedChunks;
190- GenerateMapHTML( );
191- GenerateJSONMetadata( );
192- updatedChunks = 0;
193- }
197+ if (updatedChunks > 0)
198+ {
199+ //What about chunk updates themselves; a update bitmap isn't kept...
200+ updatedChunksTotal += updatedChunks;
201+ GenerateMapHTML();
202+ GenerateJSONMetadata();
203+ updatedChunks = 0;
204+ }
194205
195- //Then sleep until interupted again, and repeat
206+ //Then sleep until interupted again, and repeat
196207
197- Logger.VerboseDebug("Thread '{0}' about to sleep indefinitely.", Thread.CurrentThread.Name);
208+ Logger.VerboseDebug("Thread '{0}' about to sleep indefinitely.", Thread.CurrentThread.Name);
198209
199- Thread.Sleep(Timeout.Infinite);
210+ Thread.Sleep(Timeout.Infinite);
200211
201- } catch (ThreadInterruptedException) {
212+ }
213+ catch (ThreadInterruptedException)
214+ {
202215
203- Logger.VerboseDebug("Thread '{0}' interupted [awoken]", Thread.CurrentThread.Name);
204- goto wake;
216+ Logger.VerboseDebug("Thread '{0}' interupted [awoken]", Thread.CurrentThread.Name);
217+ goto wake;
205218
206- } catch (ThreadAbortException) {
207- Logger.VerboseDebug("Thread '{0}' aborted.", Thread.CurrentThread.Name);
219+ }
220+ catch (ThreadAbortException)
221+ {
222+ Logger.VerboseDebug("Thread '{0}' aborted.", Thread.CurrentThread.Name);
208223
209- } finally {
210- Logger.VerboseDebug("Thread '{0}' executing finally block.", Thread.CurrentThread.Name);
211- }
224+ }
225+ finally
226+ {
227+ Logger.VerboseDebug("Thread '{0}' executing finally block.", Thread.CurrentThread.Name);
228+ }
212229 }
213230
214- private void UpdateStatus( uint totalUpdates, uint voidChunks, uint delta)
231+ private void UpdateStatus(uint totalUpdates, uint voidChunks, uint delta)
215232 {
216- StatusData updateData = new StatusData(totalUpdates, voidChunks, delta, RunState.Run);
233+ StatusData updateData = new StatusData(totalUpdates, voidChunks, delta, RunState.Run);
217234
218- this.ClientAPI.Event.PushEvent(AutomapStatusEventKey, updateData);
235+ this.ClientAPI.Event.PushEvent(AutomapStatusEventKey, updateData);
219236 }
220237
221- private void Prefill_POI_Designators( )
238+ private void Prefill_POI_Designators()
222239 {
223240
224- this.BlockID_Designators = new Dictionary<int, BlockDesignator>( );
225- this.Entity_Designators = new Dictionary<AssetLocation, EntityDesignator>( );
226- this.RockIdCodes = Helpers.ArbitrarytBlockIdHunter(ClientAPI, new AssetLocation(GlobalConstants.DefaultDomain, "rock"), EnumBlockMaterial.Stone);
241+ this.BlockID_Designators = new Dictionary<int, BlockDesignator>();
242+ this.Entity_Designators = new Dictionary<AssetLocation, EntityDesignator>();
243+ this.RockIdCodes = Helpers.ArbitrarytBlockIdHunter(ClientAPI, new AssetLocation(GlobalConstants.DefaultDomain, "rock"), EnumBlockMaterial.Stone);
227244
228- //Add special marker types for BlockID's of "Interest", overwrite colour, and method
245+ //Add special marker types for BlockID's of "Interest", overwrite colour, and method
229246
230- Install_POI_Designators(DefaultDesignators.DefaultBlockDesignators(), DefaultDesignators.DefaultEntityDesignators());
247+ Install_POI_Designators(DefaultDesignators.DefaultBlockDesignators(), DefaultDesignators.DefaultEntityDesignators());
231248 }
232249
233250 private void Install_POI_Designators(ICollection<BlockDesignator> blockDesig, List<EntityDesignator> entDesig)
234251 {
235- Logger.VerboseDebug("Connecting {0} standard Block-Designators", blockDesig.Count);
236- foreach (var designator in blockDesig) {
237- var blockIDs = Helpers.ArbitrarytBlockIdHunter(ClientAPI, designator.Pattern, designator.Material);
238- if (blockIDs.Count > 0) { Logger.VerboseDebug("Designator {0} has {1} associated blockIDs", designator.ToString( ), blockIDs.Count); }
239- foreach (var entry in blockIDs) {
240- BlockID_Designators.Add(entry.Key, designator);
252+ Logger.VerboseDebug("Connecting {0} standard Block-Designators", blockDesig.Count);
253+ foreach (var designator in blockDesig)
254+ {
255+ var blockIDs = Helpers.ArbitrarytBlockIdHunter(ClientAPI, designator.Pattern, designator.Material);
256+ if (blockIDs.Count > 0) { Logger.VerboseDebug("Designator {0} has {1} associated blockIDs", designator.ToString(), blockIDs.Count); }
257+ foreach (var entry in blockIDs)
258+ {
259+ BlockID_Designators.Add(entry.Key, designator);
260+ }
241261 }
242- }
243- this.ChunkRenderer.BlockID_Designators = BlockID_Designators;
244-
245-
246- Logger.VerboseDebug("Connecting {0} standard Entity-Designators", entDesig.Count);
247- foreach (var designator in entDesig) {
248- //Get Variants first, from EntityTypes...better be populated!
249- var matched = ClientAPI.World.EntityTypes.FindAll(entp => entp.Code.BeginsWith(designator.Pattern.Domain, designator.Pattern.Path));
250-
251- foreach (var match in matched) {
252- Logger.VerboseDebug("Linked Entity: {0} Designator: {1}", match.Code, designator);
253- this.Entity_Designators.Add(match.Code, designator);
254- }
255-
256-
257-
258- //EntityProperties props = ClientAPI.World.GetEntityType(designator.Pattern);
259- }
260-
261-
262- }
263-
264-
265- private void GenerateMapHTML( )
266- {
267- string mapFilename = Path.Combine(path, "Automap.html");
268-
269- int TopNorth = chunkTopMetadata.North_mostChunk;
270- int TopSouth = chunkTopMetadata.South_mostChunk;
271- int TopEast = chunkTopMetadata.East_mostChunk;
272- int TopWest = chunkTopMetadata.West_mostChunk;
273-
274- using (StreamWriter outputText = new StreamWriter(File.Open(mapFilename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))) {
275- using (HtmlTextWriter tableWriter = new HtmlTextWriter(outputText)) {
276- tableWriter.BeginRender( );
277- tableWriter.RenderBeginTag(HtmlTextWriterTag.Html);
278-
279- tableWriter.RenderBeginTag(HtmlTextWriterTag.Head);
280- tableWriter.RenderBeginTag(HtmlTextWriterTag.Title);
281- tableWriter.WriteEncodedText("Generated Automap");
282- tableWriter.RenderEndTag( );
283- //CSS style here
284- tableWriter.RenderBeginTag(HtmlTextWriterTag.Style);
285- tableWriter.Write(stylesFile.ToText( ));
286- tableWriter.RenderEndTag( );//</style>
287-
288- //## JSON map-state data ######################
289- tableWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
290- tableWriter.RenderBeginTag(HtmlTextWriterTag.Script);
291-
292- tableWriter.Write("var available_images = [");
293-
294- foreach (var shard in this.chunkTopMetadata) {
295- tableWriter.Write("{{X:{0},Y:{1} }}, ", shard.Location.X, shard.Location.Y);
296- }
297-
298- tableWriter.Write(" ];\n");
299-
300- tableWriter.RenderEndTag( );
301-
302- tableWriter.RenderEndTag( );
303-
304- tableWriter.RenderBeginTag(HtmlTextWriterTag.Body);
305- tableWriter.RenderBeginTag(HtmlTextWriterTag.P);
306- tableWriter.WriteEncodedText($"Created {DateTimeOffset.UtcNow.ToString("u")}");
307- tableWriter.RenderEndTag( );
308- tableWriter.RenderBeginTag(HtmlTextWriterTag.P);
309- tableWriter.WriteEncodedText($"W:{TopWest}, E: {TopEast}, N:{TopNorth}, S:{TopSouth} ");
310- tableWriter.RenderEndTag( );
311- tableWriter.WriteLine( );
312- tableWriter.RenderBeginTag(HtmlTextWriterTag.Table);
313- tableWriter.RenderBeginTag(HtmlTextWriterTag.Caption);
314- tableWriter.WriteEncodedText($"Start: {startChunkColumn}, Seed: {ClientAPI.World.Seed}\n");
315- tableWriter.RenderEndTag( );
316-
317- //################ X-Axis <thead> #######################
318- tableWriter.RenderBeginTag(HtmlTextWriterTag.Thead);
319- tableWriter.RenderBeginTag(HtmlTextWriterTag.Tr);
320-
321- tableWriter.RenderBeginTag(HtmlTextWriterTag.Th);
322- tableWriter.Write("N, W");
323- tableWriter.RenderEndTag( );
324-
325- for (int xAxisT = TopWest; xAxisT <= TopEast; xAxisT++) {
326- tableWriter.RenderBeginTag(HtmlTextWriterTag.Th);
327- tableWriter.Write(xAxisT);
328- tableWriter.RenderEndTag( );
329- }
330-
331- tableWriter.RenderBeginTag(HtmlTextWriterTag.Th);
332- tableWriter.Write("N, E");
333- tableWriter.RenderEndTag( );
334-
335- tableWriter.RenderEndTag( );
336- tableWriter.RenderEndTag( );
337- //###### </thead> ################################
338-
339- //###### <tbody> - Chunk rows & Y-axis cols
340- tableWriter.RenderBeginTag(HtmlTextWriterTag.Tbody);
341-
342- //######## <tr> for every vertical row
343- for (int yAxis = TopNorth; yAxis <= TopSouth; yAxis++) {
344- tableWriter.RenderBeginTag(HtmlTextWriterTag.Tr);
345- tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
346- tableWriter.Write(yAxis);//legend: Y-axis
347- tableWriter.RenderEndTag( );
348-
349- for (int xAxis = TopWest; xAxis <= TopEast; xAxis++) {
350- //###### <td> #### for chunk shard
351- tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
352- var colLoc = new Vec2i(xAxis, yAxis);
353- if (chunkTopMetadata.Contains( colLoc)){
354- ColumnMeta meta = chunkTopMetadata[colLoc];
355- //Tooltip first
356- tableWriter.AddAttribute(HtmlTextWriterAttribute.Class, "tooltip");
357- tableWriter.RenderBeginTag(HtmlTextWriterTag.Div);
358-
359- tableWriter.AddAttribute(HtmlTextWriterAttribute.Src, $"{xAxis}_{yAxis}.png");
360- tableWriter.RenderBeginTag(HtmlTextWriterTag.Img);
361- tableWriter.RenderEndTag( );
362- // <span class="tooltiptext">Tooltip text
363- tableWriter.AddAttribute(HtmlTextWriterAttribute.Class, "tooltiptext");
364- tableWriter.RenderBeginTag(HtmlTextWriterTag.Span);
365-
366- StringBuilder tooltipText = new StringBuilder( );
367- tooltipText.Append($"{meta.Location.PrettyCoords(ClientAPI)} ");
368- tooltipText.Append($" Max-Height: {meta.YMax}, Temp: {meta.Temperature.ToString("F1")} " );
369- tooltipText.Append($" Rainfall: {meta.Rainfall.ToString("F1")}, ");
370- tooltipText.Append($" Shrubs: {meta.ShrubDensity.ToString("F1")}, ");
371- tooltipText.Append($" Forest: {meta.ForestDensity.ToString("F1")}, ");
372- tooltipText.Append($" Fertility: {meta.Fertility.ToString("F1")}, ");
373-
374- if (meta.RockRatio != null) {
375- foreach (KeyValuePair<int, uint> blockID in meta.RockRatio) {
376- var block = ClientAPI.World.GetBlock(blockID.Key);
377- tooltipText.AppendFormat(" {0} × {1},\t", block.Code.GetName( ), meta.RockRatio[blockID.Key]);
378- }
379- }
262+ this.ChunkRenderer.BlockID_Designators = BlockID_Designators;
380263
381- tableWriter.WriteEncodedText(tooltipText.ToString() );
382-
383- tableWriter.RenderEndTag( );//</span>
384-
385264
386- tableWriter.RenderEndTag( );//</div> --tooltip enclosure
387- }
388- else {
389- tableWriter.Write("?");
390- }
265+ Logger.VerboseDebug("Connecting {0} standard Entity-Designators", entDesig.Count);
266+ foreach (var designator in entDesig)
267+ {
268+ //Get Variants first, from EntityTypes...better be populated!
269+ var matched = ClientAPI.World.EntityTypes.FindAll(entp => entp.Code.BeginsWith(designator.Pattern.Domain, designator.Pattern.Path));
391270
392- tableWriter.RenderEndTag( );
393- }//############ </td> ###########
271+ foreach (var match in matched)
272+ {
273+ Logger.VerboseDebug("Linked Entity: {0} Designator: {1}", match.Code, designator);
274+ this.Entity_Designators.Add(match.Code, designator);
275+ }
394276
395- tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
396- tableWriter.Write(yAxis);//legend: Y-axis
397- tableWriter.RenderEndTag( );
398277
399- tableWriter.RenderEndTag( );
400-
401- }
402- tableWriter.RenderEndTag( );
403278
404- //################ X-Axis <tfoot> #######################
405- tableWriter.RenderBeginTag(HtmlTextWriterTag.Tfoot);
406- tableWriter.RenderBeginTag(HtmlTextWriterTag.Tr);
279+ //EntityProperties props = ClientAPI.World.GetEntityType(designator.Pattern);
280+ }
407281
408- tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
409- tableWriter.Write("S, W");
410- tableWriter.RenderEndTag( );
411282
412- for (int xAxisB = TopWest; xAxisB <= TopEast; xAxisB++) {
413- tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
414- tableWriter.Write(xAxisB);
415- tableWriter.RenderEndTag( );
416283 }
417284
418- tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
419- tableWriter.Write("S, E");
420- tableWriter.RenderEndTag( );
421-
422- tableWriter.RenderEndTag( );
423- tableWriter.RenderEndTag( );
424- //###### </tfoot> ################################
425-
426-
427- tableWriter.RenderEndTag( );//</table>
428285
429- //############## POI list #####################
430- tableWriter.RenderBeginTag(HtmlTextWriterTag.P);
431- tableWriter.WriteLine("Points of Interest");
432- tableWriter.RenderEndTag( );
433- tableWriter.RenderBeginTag(HtmlTextWriterTag.Ul);
434- foreach (var poi in this.POIs) {
435- tableWriter.RenderBeginTag(HtmlTextWriterTag.Li);
436- tableWriter.WriteEncodedText(poi.Location.PrettyCoords(this.ClientAPI)+"\t");
437- tableWriter.WriteEncodedText(poi.Notes+ "\t");
438- tableWriter.WriteEncodedText(poi.Timestamp.ToString("u"));
439- tableWriter.RenderEndTag( );
440- }
441-
442- foreach (var eoi in this.EOIs.PointsList) {
443- tableWriter.RenderBeginTag(HtmlTextWriterTag.Li);
444- tableWriter.WriteEncodedText(eoi.Location.PrettyCoords(this.ClientAPI)+ "\t");
445- tableWriter.WriteEncodedText(eoi.Notes+ "\t");
446- tableWriter.WriteEncodedText(eoi.Timestamp.ToString("u") );
447- tableWriter.RenderEndTag( );
448- }
286+ private void GenerateMapHTML()
287+ {
288+ string mapFilename = Path.Combine(path, "Automap.html");
449289
450- tableWriter.RenderEndTag( );
290+ int TopNorth = chunkTopMetadata.North_mostChunk;
291+ int TopSouth = chunkTopMetadata.South_mostChunk;
292+ int TopEast = chunkTopMetadata.East_mostChunk;
293+ int TopWest = chunkTopMetadata.West_mostChunk;
294+
295+ using (StreamWriter outputText = new StreamWriter(File.Open(mapFilename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)))
296+ {
297+ using (HtmlTextWriter tableWriter = new HtmlTextWriter(outputText))
298+ {
299+ tableWriter.BeginRender();
300+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Html);
301+
302+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Head);
303+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Title);
304+ tableWriter.WriteEncodedText("Generated Automap");
305+ tableWriter.RenderEndTag();
306+ //CSS style here
307+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Style);
308+ tableWriter.Write(stylesFile.ToText());
309+ tableWriter.RenderEndTag();//</style>
310+
311+ //## JSON map-state data ######################
312+ tableWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
313+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Script);
314+
315+ tableWriter.Write("var available_images = [");
316+
317+ foreach (var shard in this.chunkTopMetadata)
318+ {
319+ tableWriter.Write("{{X:{0},Y:{1} }}, ", shard.Location.X, shard.Location.Y);
320+ }
321+
322+ tableWriter.Write(" ];\n");
323+
324+ tableWriter.RenderEndTag();
325+
326+ tableWriter.RenderEndTag();
327+
328+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Body);
329+ tableWriter.RenderBeginTag(HtmlTextWriterTag.P);
330+ tableWriter.WriteEncodedText($"Created {DateTimeOffset.UtcNow.ToString("u")}");
331+ tableWriter.RenderEndTag();
332+ tableWriter.RenderBeginTag(HtmlTextWriterTag.P);
333+ tableWriter.WriteEncodedText($"W:{TopWest}, E: {TopEast}, N:{TopNorth}, S:{TopSouth} ");
334+ tableWriter.RenderEndTag();
335+ tableWriter.WriteLine();
336+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Table);
337+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Caption);
338+ tableWriter.WriteEncodedText($"Start: {startChunkColumn}, Seed: {ClientAPI.World.Seed}\n");
339+ tableWriter.RenderEndTag();
340+
341+ //################ X-Axis <thead> #######################
342+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Thead);
343+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Tr);
344+
345+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Th);
346+ tableWriter.Write("N, W");
347+ tableWriter.RenderEndTag();
348+
349+ for (int xAxisT = TopWest; xAxisT <= TopEast; xAxisT++)
350+ {
351+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Th);
352+ tableWriter.Write(xAxisT);
353+ tableWriter.RenderEndTag();
354+ }
355+
356+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Th);
357+ tableWriter.Write("N, E");
358+ tableWriter.RenderEndTag();
359+
360+ tableWriter.RenderEndTag();
361+ tableWriter.RenderEndTag();
362+ //###### </thead> ################################
363+
364+ //###### <tbody> - Chunk rows & Y-axis cols
365+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Tbody);
366+
367+ //######## <tr> for every vertical row
368+ for (int yAxis = TopNorth; yAxis <= TopSouth; yAxis++)
369+ {
370+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Tr);
371+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
372+ tableWriter.Write(yAxis);//legend: Y-axis
373+ tableWriter.RenderEndTag();
374+
375+ for (int xAxis = TopWest; xAxis <= TopEast; xAxis++)
376+ {
377+ //###### <td> #### for chunk shard
378+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
379+ var colLoc = new Vec2i(xAxis, yAxis);
380+ if (chunkTopMetadata.Contains(colLoc))
381+ {
382+ ColumnMeta meta = chunkTopMetadata[colLoc];
383+ //Tooltip first
384+ tableWriter.AddAttribute(HtmlTextWriterAttribute.Class, "tooltip");
385+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Div);
386+
387+ tableWriter.AddAttribute(HtmlTextWriterAttribute.Src, $"{xAxis}_{yAxis}.png");
388+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Img);
389+ tableWriter.RenderEndTag();
390+ // <span class="tooltiptext">Tooltip text
391+ tableWriter.AddAttribute(HtmlTextWriterAttribute.Class, "tooltiptext");
392+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Span);
393+
394+ StringBuilder tooltipText = new StringBuilder();
395+ tooltipText.Append($"{meta.Location.PrettyCoords(ClientAPI)} ");
396+ tooltipText.Append($" Max-Height: {meta.YMax}, Temp: {meta.Temperature.ToString("F1")} ");
397+ tooltipText.Append($" Rainfall: {meta.Rainfall.ToString("F1")}, ");
398+ tooltipText.Append($" Shrubs: {meta.ShrubDensity.ToString("F1")}, ");
399+ tooltipText.Append($" Forest: {meta.ForestDensity.ToString("F1")}, ");
400+ tooltipText.Append($" Fertility: {meta.Fertility.ToString("F1")}, ");
401+
402+ if (meta.RockRatio != null)
403+ {
404+ foreach (KeyValuePair<int, uint> blockID in meta.RockRatio)
405+ {
406+ var block = ClientAPI.World.GetBlock(blockID.Key);
407+ tooltipText.AppendFormat(" {0} × {1},\t", block.Code.GetName(), meta.RockRatio[blockID.Key]);
408+ }
409+ }
410+
411+ tableWriter.WriteEncodedText(tooltipText.ToString());
412+
413+ tableWriter.RenderEndTag();//</span>
414+
415+
416+ tableWriter.RenderEndTag();//</div> --tooltip enclosure
417+ }
418+ else
419+ {
420+ tableWriter.Write("?");
421+ }
422+
423+ tableWriter.RenderEndTag();
424+ }//############ </td> ###########
425+
426+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
427+ tableWriter.Write(yAxis);//legend: Y-axis
428+ tableWriter.RenderEndTag();
429+
430+ tableWriter.RenderEndTag();
431+
432+ }
433+ tableWriter.RenderEndTag();
434+
435+ //################ X-Axis <tfoot> #######################
436+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Tfoot);
437+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Tr);
438+
439+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
440+ tableWriter.Write("S, W");
441+ tableWriter.RenderEndTag();
442+
443+ for (int xAxisB = TopWest; xAxisB <= TopEast; xAxisB++)
444+ {
445+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
446+ tableWriter.Write(xAxisB);
447+ tableWriter.RenderEndTag();
448+ }
449+
450+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Td);
451+ tableWriter.Write("S, E");
452+ tableWriter.RenderEndTag();
453+
454+ tableWriter.RenderEndTag();
455+ tableWriter.RenderEndTag();
456+ //###### </tfoot> ################################
457+
458+
459+ tableWriter.RenderEndTag();//</table>
460+
461+ //############## POI list #####################
462+ tableWriter.RenderBeginTag(HtmlTextWriterTag.P);
463+ tableWriter.WriteLine("Points of Interest");
464+ tableWriter.RenderEndTag();
465+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Ul);
466+ foreach (var poi in this.POIs)
467+ {
468+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Li);
469+ tableWriter.WriteEncodedText(poi.Location.PrettyCoords(this.ClientAPI) + "\t");
470+ tableWriter.WriteEncodedText(poi.Notes + "\t");
471+ tableWriter.WriteEncodedText(poi.Timestamp.ToString("u"));
472+ tableWriter.RenderEndTag();
473+ }
474+
475+ foreach (var eoi in this.EOIs.PointsList)
476+ {
477+ tableWriter.RenderBeginTag(HtmlTextWriterTag.Li);
478+ tableWriter.WriteEncodedText(eoi.Location.PrettyCoords(this.ClientAPI) + "\t");
479+ tableWriter.WriteEncodedText(eoi.Notes + "\t");
480+ tableWriter.WriteEncodedText(eoi.Timestamp.ToString("u"));
481+ tableWriter.RenderEndTag();
482+ }
483+
484+ tableWriter.RenderEndTag();
451485
452-
453486
454487
455- tableWriter.RenderEndTag( );//### </BODY> ###
456-
457- tableWriter.EndRender( );
458- tableWriter.Flush( );
459- }
460- outputText.Flush( );
461- }
462488
463- Logger.VerboseDebug("Generated HTML map");
489+ tableWriter.RenderEndTag();//### </BODY> ###
490+
491+ tableWriter.EndRender();
492+ tableWriter.Flush();
493+ }
494+ outputText.Flush();
495+ }
496+
497+ Logger.VerboseDebug("Generated HTML map");
464498 }
465499
466500 /// <summary>
467501 /// Generates the JSON Metadata. (in MAP object format )
468502 /// </summary>
469- private void GenerateJSONMetadata( )
503+ private void GenerateJSONMetadata()
470504 {
471- string jsonFilename = Path.Combine(path, "Metadata.js");
505+ string jsonFilename = Path.Combine(path, "Metadata.js");
472506
473- StreamWriter jsonWriter = new StreamWriter(jsonFilename, false, Encoding.UTF8);
474- using (jsonWriter)
507+ StreamWriter jsonWriter = new StreamWriter(jsonFilename, false, Encoding.UTF8);
508+ using (jsonWriter)
475509 {
476- jsonWriter.WriteLine("var worldSeedNum = {0};", ClientAPI.World.Seed);
477- jsonWriter.WriteLine("var genTime = new Date('{0}');", DateTimeOffset.UtcNow.ToString("O"));
478- jsonWriter.WriteLine("var startCoords = {{X:{0},Y:{1}}};", startChunkColumn.X, startChunkColumn.Y);
479- jsonWriter.WriteLine("var chunkSize = {0};", chunkSize);
480- jsonWriter.WriteLine("var northMostChunk ={0};", chunkTopMetadata.North_mostChunk);
481- jsonWriter.WriteLine("var southMostChunk ={0};", chunkTopMetadata.South_mostChunk);
482- jsonWriter.WriteLine("var eastMostChunk ={0};", chunkTopMetadata.East_mostChunk);
483- jsonWriter.WriteLine("var westMostChunk ={0};", chunkTopMetadata.West_mostChunk);
484- //MAP object format - [key, value]: key is "x_y"
485- jsonWriter.Write("let shardsMetadata = new Map([");
486- foreach (var shard in chunkTopMetadata)
510+ jsonWriter.WriteLine("var worldSeedNum = {0};", ClientAPI.World.Seed);
511+ jsonWriter.WriteLine("var genTime = new Date('{0}');", DateTimeOffset.UtcNow.ToString("O"));
512+ jsonWriter.WriteLine("var startCoords = {{X:{0},Y:{1}}};", startChunkColumn.X, startChunkColumn.Y);
513+ jsonWriter.WriteLine("var chunkSize = {0};", chunkSize);
514+ jsonWriter.WriteLine("var northMostChunk ={0};", chunkTopMetadata.North_mostChunk);
515+ jsonWriter.WriteLine("var southMostChunk ={0};", chunkTopMetadata.South_mostChunk);
516+ jsonWriter.WriteLine("var eastMostChunk ={0};", chunkTopMetadata.East_mostChunk);
517+ jsonWriter.WriteLine("var westMostChunk ={0};", chunkTopMetadata.West_mostChunk);
518+ //MAP object format - [key, value]: key is "x_y"
519+ jsonWriter.Write("let shardsMetadata = new Map([");
520+ foreach (var shard in chunkTopMetadata)
487521 {
488- jsonWriter.Write("['{0}_{1}',", shard.Location.X, shard.Location.Y);
489- jsonWriter.Write("{");
490- jsonWriter.Write("ChunkAge: '{0}',", shard.ChunkAge);//World age - relative? or last edit ??
491- jsonWriter.Write("Temperature: {0},", shard.Temperature.ToString("F1"));
492- jsonWriter.Write("YMax: {0},", shard.YMax);
493- jsonWriter.Write("Fertility: {0},", shard.Fertility.ToString("F1"));
494- jsonWriter.Write("ForestDensity: {0},", shard.ForestDensity.ToString("F1"));
495- jsonWriter.Write("Rainfall: {0},", shard.Rainfall.ToString("F1"));
496- jsonWriter.Write("ShrubDensity: {0},", shard.ShrubDensity.ToString("F1"));
497- jsonWriter.Write("AirBlocks: {0},", shard.AirBlocks);
498- jsonWriter.Write("NonAirBlocks: {0},", shard.NonAirBlocks);
499- //TODO: Heightmap
500- //TODO: Rock-ratio
501- jsonWriter.Write("}],");
522+ jsonWriter.Write("['{0}_{1}',", shard.Location.X, shard.Location.Y);
523+ jsonWriter.Write("{");
524+ jsonWriter.Write("ChunkAge: '{0}',", shard.ChunkAge);//World age - relative? or last edit ??
525+ jsonWriter.Write("Temperature: {0},", shard.Temperature.ToString("F1"));
526+ jsonWriter.Write("YMax: {0},", shard.YMax);
527+ jsonWriter.Write("Fertility: {0},", shard.Fertility.ToString("F1"));
528+ jsonWriter.Write("ForestDensity: {0},", shard.ForestDensity.ToString("F1"));
529+ jsonWriter.Write("Rainfall: {0},", shard.Rainfall.ToString("F1"));
530+ jsonWriter.Write("ShrubDensity: {0},", shard.ShrubDensity.ToString("F1"));
531+ jsonWriter.Write("AirBlocks: {0},", shard.AirBlocks);
532+ jsonWriter.Write("NonAirBlocks: {0},", shard.NonAirBlocks);
533+ //TODO: Heightmap
534+ //TODO: Rock-ratio
535+ jsonWriter.Write("}],");
502536 }
503- jsonWriter.Write("]);\n\n");
537+ jsonWriter.Write("]);\n\n");
538+
504539
505-
506- jsonWriter.Write("let pointsOfInterest = new Map([");
507- foreach (var poi in POIs)
540+ jsonWriter.Write("let pointsOfInterest = new Map([");
541+ foreach (var poi in POIs)
508542 {
509543 jsonWriter.Write("['{0}_{1}',", poi.Location.X, poi.Location.Y);
510544 jsonWriter.Write("{");
511- jsonWriter.Write("notes: '{0}',", poi.Notes.Replace("'"," "));
545+ jsonWriter.Write("notes: '{0}',", poi.Notes.Replace("'", " "));
512546 jsonWriter.Write("timestamp : new Date('{0}'),", poi.Timestamp.ToString("O"));
513- jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X/chunkSize), (poi.Location.Y/chunkSize));
547+ jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X / chunkSize), (poi.Location.Y / chunkSize));
514548 jsonWriter.Write("}],");
515549 }
516550
517- foreach (var poi in EOIs.PointsList)
551+ foreach (var poi in EOIs.PointsList)
518552 {
519- jsonWriter.Write("['{0}_{1}',", poi.Location.X, poi.Location.Y);
520- jsonWriter.Write("{");
521- jsonWriter.Write("notes: '{0}',", poi.Notes.Replace("'", " "));
522- jsonWriter.Write("timestamp : new Date('{0}'),", poi.Timestamp.ToString("O"));
523- jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X / chunkSize), (poi.Location.Y / chunkSize));
524- jsonWriter.Write("}],");
553+ jsonWriter.Write("['{0}_{1}',", poi.Location.X, poi.Location.Y);
554+ jsonWriter.Write("{");
555+ jsonWriter.Write("notes: '{0}',", poi.Notes.Replace("'", " "));
556+ jsonWriter.Write("timestamp : new Date('{0}'),", poi.Timestamp.ToString("O"));
557+ jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X / chunkSize), (poi.Location.Y / chunkSize));
558+ jsonWriter.Write("}],");
525559 }
526- jsonWriter.Write("]);\n\n");
560+ jsonWriter.Write("]);\n\n");
527561
528- jsonWriter.Flush( );
529- }
562+ jsonWriter.Flush();
563+ }
530564
531565 }
532566
533567
534568 private ColumnMeta CreateColumnMetadata(KeyValuePair<Vec2i, uint> mostActiveCol, IMapChunk mapChunk)
535569 {
536- ColumnMeta data = new ColumnMeta(mostActiveCol.Key.Copy(), chunkSize);
537- BlockPos equivBP = new BlockPos(mostActiveCol.Key.X * chunkSize,
538- mapChunk.YMax,
539- mostActiveCol.Key.Y * chunkSize);
570+ ColumnMeta data = new ColumnMeta(mostActiveCol.Key.Copy(), chunkSize);
571+ BlockPos equivBP = new BlockPos(mostActiveCol.Key.X * chunkSize,
572+ mapChunk.YMax,
573+ mostActiveCol.Key.Y * chunkSize);
540574
541- var climate = ClientAPI.World.BlockAccessor.GetClimateAt(equivBP);
542- data.UpdateFieldsFrom(climate, mapChunk,TimeSpan.FromHours(ClientAPI.World.Calendar.TotalHours));
575+ var climate = ClientAPI.World.BlockAccessor.GetClimateAt(equivBP);
576+ data.UpdateFieldsFrom(climate, mapChunk, TimeSpan.FromHours(ClientAPI.World.Calendar.TotalHours));
543577
544- return data;
578+ return data;
545579 }
546580
547581 /// <summary>
548582 /// Reload chunk bounds from chunk shards
549583 /// </summary>
550584 /// <returns>The metadata.</returns>
551- private void Reload_Metadata( )
552- {
553- var worldmapDir = new DirectoryInfo(path);
585+ private void Reload_Metadata()
586+ {
587+ var worldmapDir = new DirectoryInfo(path);
554588
555- if (worldmapDir.Exists) {
589+ if (worldmapDir.Exists)
590+ {
556591
557- var files = worldmapDir.GetFiles(chunkFile_filter);
592+ var files = worldmapDir.GetFiles(chunkFile_filter);
558593
559- if (files.Length > 0) {
560- #if DEBUG
561- Logger.VerboseDebug("{0} Existing world chunk shards", files.Length);
562- #endif
594+ if (files.Length > 0)
595+ {
596+#if DEBUG
597+ Logger.VerboseDebug("{0} Existing world chunk shards", files.Length);
598+#endif
563599
564-
565600
566- foreach (var shardFile in files) {
567601
568- if (shardFile.Length < 512) continue;
569- var result = chunkShardRegex.Match(shardFile.Name);
570- if (result.Success) {
571- int X_chunk_pos = int.Parse(result.Groups["X"].Value );
572- int Z_chunk_pos = int.Parse(result.Groups["Z"].Value );
573-
574- //Parse PNG chunks for METADATA in shard
575- using (var fileStream = shardFile.OpenRead( ))
576- {
577- //TODO: Add corrupted PNG Exception handing HERE !
578- PngReader pngRead = new PngReader(fileStream );
579- pngRead.ReadSkippingAllRows( );
580- pngRead.End( );
602+ foreach (var shardFile in files)
603+ {
581604
582- PngMetadataChunk metadataFromPng = pngRead.GetChunksList( ).GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
605+ if (shardFile.Length < 512) continue;
606+ var result = chunkShardRegex.Match(shardFile.Name);
607+ if (result.Success)
608+ {
609+ int X_chunk_pos = int.Parse(result.Groups["X"].Value);
610+ int Z_chunk_pos = int.Parse(result.Groups["Z"].Value);
583611
584- chunkTopMetadata.Add(metadataFromPng.ChunkMetadata);
585- }
586-
587- }
588- }
612+ //Parse PNG chunks for METADATA in shard
613+ using (var fileStream = shardFile.OpenRead())
614+ {
615+ //TODO: Add corrupted PNG Exception handing HERE !
616+ PngReader pngRead = new PngReader(fileStream);
617+ pngRead.ReadSkippingAllRows();
618+ pngRead.End();
589619
590- }
591- }
592- else {
593- #if DEBUG
594- Logger.VerboseDebug("Could not open world map directory");
595- #endif
596- }
620+ PngMetadataChunk metadataFromPng = pngRead.GetChunksList().GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
621+
622+ chunkTopMetadata.Add(metadataFromPng.ChunkMetadata);
623+ }
624+
625+ }
626+ }
627+
628+ }
629+ }
630+ else
631+ {
632+#if DEBUG
633+ Logger.VerboseDebug("Could not open world map directory");
634+#endif
635+ }
597636
598637
599638
@@ -601,22 +640,22 @@ namespace Automap
601640
602641 private PngWriter SetupPngImage(Vec2i coord, ColumnMeta metadata)
603642 {
604- ImageInfo imageInf = new ImageInfo(chunkSize, chunkSize, 8, false);
605-
606- string filename = $"{coord.X}_{coord.Y}.png";
607- filename = Path.Combine(path, filename);
608-
609- PngWriter pngWriter = FileHelper.CreatePngWriter(filename, imageInf, true);
610- PngMetadata meta = pngWriter.GetMetadata( );
611- meta.SetTimeNow( );
612- meta.SetText("Chunk_X", coord.X.ToString("D"));
613- meta.SetText("Chunk_Y", coord.Y.ToString("D"));
614- //Setup specialized meta-data PNG chunks here...
615- PngMetadataChunk pngChunkMeta = new PngMetadataChunk(pngWriter.ImgInfo);
616- pngChunkMeta.ChunkMetadata = metadata;
617- pngWriter.GetChunksList( ).Queue(pngChunkMeta);
618-
619- return pngWriter;
643+ ImageInfo imageInf = new ImageInfo(chunkSize, chunkSize, 8, false);
644+
645+ string filename = $"{coord.X}_{coord.Y}.png";
646+ filename = Path.Combine(path, filename);
647+
648+ PngWriter pngWriter = FileHelper.CreatePngWriter(filename, imageInf, true);
649+ PngMetadata meta = pngWriter.GetMetadata();
650+ meta.SetTimeNow();
651+ meta.SetText("Chunk_X", coord.X.ToString("D"));
652+ meta.SetText("Chunk_Y", coord.Y.ToString("D"));
653+ //Setup specialized meta-data PNG chunks here...
654+ PngMetadataChunk pngChunkMeta = new PngMetadataChunk(pngWriter.ImgInfo);
655+ pngChunkMeta.ChunkMetadata = metadata;
656+ pngWriter.GetChunksList().Queue(pngChunkMeta);
657+
658+ return pngWriter;
620659 }
621660
622661 /// <summary>
@@ -628,149 +667,164 @@ namespace Automap
628667 private void ProcessChunkBlocks(Vec2i key, IMapChunk mapChunk, ColumnMeta chunkMeta)
629668 {
630669
631- int targetChunkY = mapChunk.YMax / chunkSize;//Surface ...
632- for (; targetChunkY > 0; targetChunkY--) {
633- WorldChunk chunkData = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
670+ int targetChunkY = mapChunk.YMax / chunkSize;//Surface ...
671+ for (; targetChunkY > 0; targetChunkY--)
672+ {
673+ WorldChunk chunkData = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
634674
635- if (chunkData == null || chunkData.BlockEntities == null) {
636- #if DEBUG
637- Logger.VerboseDebug("Chunk null or empty X{0} Y{1} Z{2}", key.X,targetChunkY,key.Y);
638- #endif
639- continue;
640- }
675+ if (chunkData == null || chunkData.BlockEntities == null)
676+ {
677+#if DEBUG
678+ Logger.VerboseDebug("Chunk null or empty X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);
679+#endif
680+ continue;
681+ }
641682
642- /*************** Chunk Entities Scanning *********************/
643- if (chunkData.BlockEntities != null && chunkData.BlockEntities.Length > 0) {
644- #if DEBUG
645- Logger.VerboseDebug("Surface@ {0} = BlockEntities: {1}", key, chunkData.BlockEntities.Length);
646- #endif
683+ /*************** Chunk Entities Scanning *********************/
684+ if (chunkData.BlockEntities != null && chunkData.BlockEntities.Length > 0)
685+ {
686+#if DEBUG
687+ Logger.VerboseDebug("Surface@ {0} = BlockEntities: {1}", key, chunkData.BlockEntities.Length);
688+#endif
647689
648- foreach (var blockEnt in chunkData.BlockEntities) {
649-
650- if (blockEnt != null && blockEnt.Block != null && BlockID_Designators.ContainsKey(blockEnt.Block.BlockId))
651- {
652- var designator = BlockID_Designators[blockEnt.Block.BlockId];
653- designator.SpecialAction(ClientAPI, POIs, blockEnt.Pos.Copy( ), blockEnt.Block);
654- }
655- }
656-
657- }
658- /********************* Chunk/Column BLOCKs scanning ****************/
659- //Heightmap, Stats, block tally
660- chunkData.Unpack( );
661-
662- int X_index, Y_index, Z_index;
663- X_index = Y_index = Z_index = 0;
664-
665- do {
666- do {
667- do {
668- /* Encode packed indicie
669- (y * chunksize + z) * chunksize + x
670- */
671- var indicie = Helpers.ChunkBlockIndicie16(X_index, Y_index, Z_index);
672- int aBlockId = chunkData.Blocks[indicie];
673-
674- if (aBlockId == 0) {//Air
675- chunkMeta.AirBlocks++;
676- continue;
677- }
690+ foreach (var blockEnt in chunkData.BlockEntities)
691+ {
678692
679- if (RockIdCodes.ContainsKey(aBlockId)) {
680- if (chunkMeta.RockRatio.ContainsKey(aBlockId)) { chunkMeta.RockRatio[aBlockId]++; } else { chunkMeta.RockRatio.Add(aBlockId, 1); }
681- }
682-
683- chunkMeta.NonAirBlocks++;
693+ if (blockEnt != null && blockEnt.Block != null && BlockID_Designators.ContainsKey(blockEnt.Block.BlockId))
694+ {
695+ var designator = BlockID_Designators[blockEnt.Block.BlockId];
696+ designator.SpecialAction(ClientAPI, POIs, blockEnt.Pos.Copy(), blockEnt.Block);
697+ }
698+ }
684699
685- //Heightmap
686- if (chunkMeta.HeightMap[X_index, Z_index] == 0)
687- { chunkMeta.HeightMap[X_index, Z_index] = ( ushort )(Y_index + (targetChunkY * chunkSize)); }
700+ }
701+ /********************* Chunk/Column BLOCKs scanning ****************/
702+ //Heightmap, Stats, block tally
703+ chunkData.Unpack();
688704
689- }
690- while (X_index++ < (chunkSize - 1));
691- X_index = 0;
692- }
693- while (Z_index++ < (chunkSize - 1));
694- Z_index = 0;
695- }
696- while (Y_index++ < (chunkSize - 1));
705+ int X_index, Y_index, Z_index;
706+ X_index = Y_index = Z_index = 0;
697707
698- }
708+ do
709+ {
710+ do
711+ {
712+ do
713+ {
714+ /* Encode packed indicie
715+ (y * chunksize + z) * chunksize + x
716+ */
717+ var indicie = Helpers.ChunkBlockIndicie16(X_index, Y_index, Z_index);
718+ int aBlockId = chunkData.Blocks[indicie];
719+
720+ if (aBlockId == 0)
721+ {//Air
722+ chunkMeta.AirBlocks++;
723+ continue;
724+ }
725+
726+ if (RockIdCodes.ContainsKey(aBlockId))
727+ {
728+ if (chunkMeta.RockRatio.ContainsKey(aBlockId)) { chunkMeta.RockRatio[aBlockId]++; } else { chunkMeta.RockRatio.Add(aBlockId, 1); }
729+ }
730+
731+ chunkMeta.NonAirBlocks++;
732+
733+ //Heightmap
734+ if (chunkMeta.HeightMap[X_index, Z_index] == 0)
735+ { chunkMeta.HeightMap[X_index, Z_index] = (ushort) (Y_index + (targetChunkY * chunkSize)); }
736+
737+ }
738+ while (X_index++ < (chunkSize - 1));
739+ X_index = 0;
740+ }
741+ while (Z_index++ < (chunkSize - 1));
742+ Z_index = 0;
743+ }
744+ while (Y_index++ < (chunkSize - 1));
745+
746+ }
699747 }
700748
701- private void UpdateEntityMetadata( )
749+ private void UpdateEntityMetadata()
702750 {
703- Logger.Debug("Presently {0} Entities", ClientAPI.World.LoadedEntities.Count);
704- //Mabey scan only for 'new' entities by tracking ID in set?
705- foreach (var loadedEntity in ClientAPI.World.LoadedEntities.ToList()) {
706-
707- #if DEBUG
708- //Logger.VerboseDebug($"ENTITY: ({loadedEntity.Value.Code}) = #{loadedEntity.Value.EntityId} {loadedEntity.Value.State} {loadedEntity.Value.LocalPos} <<<<<<<<<<<<");
709- #endif
710-
711- var dMatch = Entity_Designators.SingleOrDefault(se => se.Key.Equals(loadedEntity.Value.Code));
712- if (dMatch.Value != null) {
713- dMatch.Value.SpecialAction(ClientAPI, this.EOIs, loadedEntity.Value.LocalPos.AsBlockPos.Copy( ), loadedEntity.Value);
714- }
751+ Logger.Debug("Presently {0} Entities", ClientAPI.World.LoadedEntities.Count);
752+ //Mabey scan only for 'new' entities by tracking ID in set?
753+ foreach (var loadedEntity in ClientAPI.World.LoadedEntities.ToList())
754+ {
715755
716- }
756+#if DEBUG
757+ //Logger.VerboseDebug($"ENTITY: ({loadedEntity.Value.Code}) = #{loadedEntity.Value.EntityId} {loadedEntity.Value.State} {loadedEntity.Value.LocalPos} <<<<<<<<<<<<");
758+#endif
759+
760+ var dMatch = Entity_Designators.SingleOrDefault(se => se.Key.Equals(loadedEntity.Value.Code));
761+ if (dMatch.Value != null)
762+ {
763+ dMatch.Value.SpecialAction(ClientAPI, this.EOIs, loadedEntity.Value.LocalPos.AsBlockPos.Copy(), loadedEntity.Value);
764+ }
765+
766+ }
717767
718768
719769 }
720770
721771 private void AddNote(string notation)
722- {
723- var playerNodePoi = new PointOfInterest( ) {
724- Location = ClientAPI.World.Player.Entity.LocalPos.AsBlockPos.Copy(),
725- Notes = notation,
726- Timestamp = DateTimeOffset.UtcNow,
727- };
728-
729- this.POIs.AddReplace(playerNodePoi);
772+ {
773+ var playerNodePoi = new PointOfInterest()
774+ {
775+ Location = ClientAPI.World.Player.Entity.LocalPos.AsBlockPos.Copy(),
776+ Notes = notation,
777+ Timestamp = DateTimeOffset.UtcNow,
778+ };
779+
780+ this.POIs.AddReplace(playerNodePoi);
730781 }
731782
732783
733784
734785 private void CommandListener(string eventName, ref EnumHandling handling, IAttribute data)
735786 {
736- Logger.VerboseDebug("MsgBus RX: AutomapCommandMsg: {0}", data.ToJsonToken() );
787+ Logger.VerboseDebug("MsgBus RX: AutomapCommandMsg: {0}", data.ToJsonToken());
737788
738- CommandData cmdData = data as CommandData;
789+ CommandData cmdData = data as CommandData;
739790
740791
741- if (CurrentState != RunState.Snapshot) {
742- switch (cmdData.State) {
743- case RunState.Run:
744- CurrentState = cmdData.State;
745- AwakenCartographer(0.0f);
746- break;
792+ if (CurrentState != RunState.Snapshot)
793+ {
794+ switch (cmdData.State)
795+ {
796+ case RunState.Run:
797+ CurrentState = cmdData.State;
798+ AwakenCartographer(0.0f);
799+ break;
747800
748- case RunState.Stop:
749- CurrentState = cmdData.State;
750- break;
801+ case RunState.Stop:
802+ CurrentState = cmdData.State;
803+ break;
751804
752- case RunState.Snapshot:
753- CurrentState = RunState.Stop;
754- //Snapshot starts a second thread/process...
805+ case RunState.Snapshot:
806+ CurrentState = RunState.Stop;
807+ //Snapshot starts a second thread/process...
755808
756- break;
809+ break;
757810
758- case RunState.Notation:
759- //Add to POI list where player location
760- AddNote(cmdData.Notation);
761- break;
762- }
811+ case RunState.Notation:
812+ //Add to POI list where player location
813+ AddNote(cmdData.Notation);
814+ break;
815+ }
763816
764- }
817+ }
765818
766- if (CurrentState != cmdData.State) {
767- CurrentState = cmdData.State;
768- AwakenCartographer(0.0f);
769- }
819+ if (CurrentState != cmdData.State)
820+ {
821+ CurrentState = cmdData.State;
822+ AwakenCartographer(0.0f);
823+ }
770824
771- #if DEBUG
772- ClientAPI.TriggerChatMessage($"Automap commanded to: {cmdData.State} ");
773- #endif
825+#if DEBUG
826+ ClientAPI.TriggerChatMessage($"Automap commanded to: {cmdData.State} ");
827+#endif
774828
775829 }
776830