From 8c8cf97e48592b57cde243555596fe3904091568 Mon Sep 17 00:00:00 2001 From: melchior Date: Mon, 18 Apr 2022 20:51:11 -0400 Subject: [PATCH] Fixes for some post *.4 issues Shapless block exclusion Entity scan fix --- Automap/Helpers.cs | 7 ++++- Automap/Subsystems/AutomapSystem.cs | 55 +++++++++++++++++++++---------------- Automap/modinfo.json | 4 +-- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/Automap/Helpers.cs b/Automap/Helpers.cs index 5dacf09..c217407 100644 --- a/Automap/Helpers.cs +++ b/Automap/Helpers.cs @@ -171,7 +171,12 @@ namespace Automap AutomapMod ownMod = ownApi.ModLoader.GetModSystem( ); return ownMod.Mod; } - + + + public static bool EndsWith(this AssetLocation asset, string domain, string endPath) + { + return asset.Domain.Equals(domain,StringComparison.InvariantCultureIgnoreCase) && asset.Path.EndsWith(endPath, StringComparison.InvariantCultureIgnoreCase); + } } } diff --git a/Automap/Subsystems/AutomapSystem.cs b/Automap/Subsystems/AutomapSystem.cs index 2997ec6..b7a554c 100644 --- a/Automap/Subsystems/AutomapSystem.cs +++ b/Automap/Subsystems/AutomapSystem.cs @@ -346,14 +346,24 @@ namespace Automap var airBlocksQuery = from airyBlock in ClientAPI.World.Blocks where airyBlock.MatterState == EnumMatterState.Solid - where airyBlock.BlockMaterial == EnumBlockMaterial.Plant || airyBlock.BlockMaterial == EnumBlockMaterial.Leaves - where airyBlock.CollisionBoxes == null || airyBlock.CollisionBoxes.Length == 0 ||airyBlock.RainPermeable == true - select airyBlock; - //^^ 'Solid' phase - 'Plant' Blocks without any boundg box ? Except water... - this.AiryIdCodes = airBlocksQuery.ToDictionary(aBlk => aBlk.BlockId, aBlk => aBlk.Code.Path); - - //Add special marker types for BlockID's of "Interest", overwrite colour, and method - Reload_POI_Designators(); + where airyBlock.BlockMaterial == EnumBlockMaterial.Plant || airyBlock.BlockMaterial == EnumBlockMaterial.Leaves + where airyBlock.CollisionBoxes == null || airyBlock.CollisionBoxes.Length == 0 || airyBlock.RainPermeable == true + select airyBlock; + //^^ 'Solid' phase - 'Plant' Blocks without any bounding-box; OR 'Invisible' shapes... + var invisibleBlocksQuery = from novisBlock in ClientAPI.World.Blocks + where novisBlock.Shape == null || novisBlock.Shape.Base.EndsWith(GlobalConstants.DefaultDomain, @"invisible") //Whaat! [ base: "block/basic/invisible" ] + select novisBlock; + this.AiryIdCodes = airBlocksQuery.Union(invisibleBlocksQuery).ToDictionary(aBlk => aBlk.BlockId, aBlk => aBlk.Code.Path); + + #if DEBUG + foreach (var fluffBlock in AiryIdCodes) { + Logger.VerboseDebug("ID#\t{0}:\t{1} IGNORED", fluffBlock.Key, fluffBlock.Value); + } + Logger.VerboseDebug("Ignoring {0} blocks", AiryIdCodes.Count); + #endif + + //Add special marker types for BlockID's of "Interest", overwrite colour, and method + Reload_POI_Designators(); } private void Reload_POI_Designators() @@ -714,26 +724,25 @@ namespace Automap private void UpdateEntityMetadata() { + #if DEBUG + Logger.Debug("Presently {0} Entities", ClientAPI.World.LoadedEntities.Count); + #endif + + //Handles mutations better than a plain Iterator + for (int entIndex = 0; entIndex < ClientAPI.World.LoadedEntities.Count; entIndex++ ) + { + var loadedEntity = ClientAPI.World.LoadedEntities.Values.ElementAt(entIndex); + #if DEBUG - Logger.Debug("Presently {0} Entities", ClientAPI.World.LoadedEntities.Count); + //Logger.VerboseDebug($"ENTITY: ({loadedEntity.Value.Code}) = #{loadedEntity.Value.EntityId} {loadedEntity.Value.State} {loadedEntity.Value.LocalPos} <<<<<<<<<<<<"); #endif - //Mabey scan only for 'new' entities by tracking ID in set? - foreach (var loadedEntity in ClientAPI.World.LoadedEntities.ToArray()) - { - - #if DEBUG - //Logger.VerboseDebug($"ENTITY: ({loadedEntity.Value.Code}) = #{loadedEntity.Value.EntityId} {loadedEntity.Value.State} {loadedEntity.Value.LocalPos} <<<<<<<<<<<<"); - #endif - var dMatch = Entity_Designators.SingleOrDefault(se => se.Key.Equals(loadedEntity.Value.Code)); - if (dMatch.Value != null) + var dMatch = Entity_Designators.SingleOrDefault(se => se.Key.Equals(loadedEntity.Code)); + if (dMatch.Value != null) { - dMatch.Value.SpecialAction(ClientAPI, this.EOIs, loadedEntity.Value.Pos.AsBlockPos.Copy(), loadedEntity.Value); + dMatch.Value.SpecialAction(ClientAPI, this.EOIs, loadedEntity.Pos.AsBlockPos.Copy( ), loadedEntity); } - - } - - + } } private void AddNote(string notation) diff --git a/Automap/modinfo.json b/Automap/modinfo.json index b135bac..8761044 100644 --- a/Automap/modinfo.json +++ b/Automap/modinfo.json @@ -3,11 +3,11 @@ "name": "Automap", "description" : "Automap; Generates a static HTML5 map dynamically, with P.O.I. Tracking & more.", "authors": ["Melchior","VeryGoodDog"], - "contributors":["VeryGoodDog"], + "contributors":["VeryGoodDog", "Drakker"], "version": "0.1.8", "side":"Client", "dependencies": { - "game": "1.16.0" + "game": "1.16.4" }, "website": "http://automap.osdn.io/" } \ No newline at end of file -- 2.11.0