OSDN Git Service

Fixes for some post *.4 issues
authormelchior <melchior@users.osdn.me>
Tue, 19 Apr 2022 00:51:11 +0000 (20:51 -0400)
committermelchior <melchior@users.osdn.me>
Tue, 19 Apr 2022 00:51:11 +0000 (20:51 -0400)
Shapless block exclusion
Entity scan fix

Automap/Helpers.cs
Automap/Subsystems/AutomapSystem.cs
Automap/modinfo.json

index 5dacf09..c217407 100644 (file)
@@ -171,7 +171,12 @@ namespace Automap
                AutomapMod ownMod = ownApi.ModLoader.GetModSystem<AutomapMod>( );
                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);
+               }
     }
 }
 
index 2997ec6..b7a554c 100644 (file)
@@ -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)
index b135bac..8761044 100644 (file)
@@ -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