public static void Update() { var addedScenes = new List <WorldScene>(); List <Scene> newScenes; try { newScenes = ZetaDia.Scenes.Where( s => s.IsAlmostValid() && !CurrentWorldSceneIds.Contains(s.GetSceneNameString())).ToList(); } catch (NullReferenceException) { return; } catch (Exception ex) { if (ex.Message.Contains("ReadProcessMemory")) { return; } throw; } foreach (var scene in newScenes) { try { if (!scene.IsAlmostValid()) { continue; } if (scene.IsAlmostValid() && scene.Mesh.ParentSceneId <= 0 && scene.Mesh.DynamicWorldId == ZetaDia.CurrentWorldDynamicId && !scene.Name.ToLowerInvariant().Contains("fill")) { var adventurerScene = new WorldScene(scene); if (adventurerScene.Cells.Count > 0) { CurrentWorldScenes.Add(adventurerScene); addedScenes.Add(adventurerScene); } } CurrentWorldSceneIds.Add(scene.GetSceneNameString()); } catch (NullReferenceException) { } } if (addedScenes.Count > 0) { //Logger.Debug("[ScenesStorage] Found {0} new scenes", addedScenes.Count); var nodes = addedScenes.SelectMany(s => s.Nodes).ToList(); TrinityGrid.Instance.Update(nodes); } }
public IEnumerable <ExplorationNode> SceneNodes(Scene scene) { if (scene.IsAlmostValid()) { var sceneNameHash = scene.GetSceneNameString(); if (CurrentWorldSceneIds.Contains(sceneNameHash)) { var adventurerScene = CurrentWorldScenes.FirstOrDefault(s => s.HashName == sceneNameHash); if (adventurerScene != null) { return(adventurerScene.Nodes); } } } return(new List <ExplorationNode>()); }
public void Update() { var currentWorldId = ZetaDia.Globals.WorldId; if (currentWorldId <= 0) { return; } if (_currentWorld != currentWorldId) { if (!ZetaDia.IsInGame) { s_logger.Debug($"[{nameof(Update)}] Left Game..."); Reset(); return; } if (ZetaDia.Globals.IsLoadingWorld) { s_logger.Debug($"[{nameof(Update)}] World loading..."); return; } s_logger.Information($"[{nameof(Update)}] World has changed from {_currentWorld} to {currentWorldId}."); _currentWorld = currentWorldId; Reset(); } var addedScenes = new List <WorldScene>(); List <Scene> newScenes; try { newScenes = ZetaDia.Scenes .Where(s => s.IsAlmostValid() && !CurrentWorldSceneIds.Contains(s.GetSceneNameString())).ToList(); } catch (NullReferenceException) { return; } catch (PartialReadWriteException) { return; } SNOWorld worldId = 0; foreach (var scene in newScenes) { try { if (!scene.IsAlmostValid()) { continue; } var sceneHashName = scene.GetSceneNameString(); worldId = scene.Mesh.WorldId; var subScene = scene.Mesh.SubScene; if (scene.IsAlmostValid() && scene.Mesh.ParentSceneId <= 0 && worldId == currentWorldId) { if (scene.Mesh.Zone.GridSquares.Length <= 1 && (subScene != null && !subScene.HasGridSquares())) { continue; } var adventurerScene = new WorldScene(scene, ExplorationData.ExplorationNodeBoxSize, ExplorationData.ExplorationNodeBoxTolerance); if (adventurerScene.Cells.Count > 0) { CurrentWorldScenes.Add(adventurerScene); addedScenes.Add(adventurerScene); } } CurrentWorldSceneIds.Add(sceneHashName); } catch (NullReferenceException) { } } if (addedScenes.Count <= 0) { return; } s_logger.Information($"[{nameof(Update)}] Found {addedScenes.Count} new scenes."); var sceneData = CreateSceneData(addedScenes, worldId); foreach (var grid in GridStore.GetCurrentGrids()) { grid.Update(sceneData); } if (CurrentScene != null) { foreach (var scene in CurrentWorldScenes.Where(s => !s.HasPlayerConnection)) { if (scene == CurrentScene || CurrentScene.IsConnected(scene)) { scene.HasPlayerConnection = true; } } } ScenesAdded?.Invoke(addedScenes); s_logger.Information($"[{nameof(Update)}] Updates Finished."); }
public void Update() { var currentWorldId = ZetaDia.Globals.WorldId; if (currentWorldId <= 0) { return; } if (_currentWorld != currentWorldId) { //if (GameData.MenuWorldSnoIds.Contains(ZetaDia.Globals.WorldSnoId)) //{ // Core.Logger.Debug("[SceneStorage] Left Game...."); // Reset(); // return; //} //if (ZetaDia.Globals.IsLoadingWorld) //{ // Core.Logger.Debug("[SceneStorage] World loading...."); // return; //} Core.Logger.Debug("[SceneStorage] World has changed from {0} to {1}", _currentWorld, currentWorldId); _currentWorld = currentWorldId; Reset(); } var addedScenes = new List <WorldScene>(); List <Scene> newScenes; try { newScenes = ZetaDia.Scenes.Where(s => s.IsAlmostValid() && !CurrentWorldSceneIds.Contains(s.GetSceneNameString())).ToList(); } catch (NullReferenceException) { return; } catch (Exception ex) { if (ex.Message.Contains("ReadProcessMemory")) { return; } throw; } var worldId = 0; foreach (var scene in newScenes) { try { if (!scene.IsAlmostValid()) { continue; } var sceneHashName = scene.GetSceneNameString(); worldId = scene.Mesh.WorldId; Scene subScene = scene.Mesh.SubScene; if (scene.IsAlmostValid() && scene.Mesh.ParentSceneId <= 0 && worldId == currentWorldId) { if (scene.Mesh.Zone.GridSquares.Length <= 1 && (subScene != null && !subScene.HasGridSquares())) { continue; } var adventurerScene = new WorldScene(scene, ExplorationData.ExplorationNodeBoxSize, ExplorationData.ExplorationNodeBoxTolerance); if (adventurerScene.Cells.Count > 0) { CurrentWorldScenes.Add(adventurerScene); addedScenes.Add(adventurerScene); } } CurrentWorldSceneIds.Add(sceneHashName); } catch (NullReferenceException) { } } if (addedScenes.Count > 0) { Core.Logger.Debug("[ScenesStorage] Found {0} new scenes", addedScenes.Count); var sceneData = CreateSceneData(addedScenes, worldId); foreach (var grid in GridStore.GetCurrentGrids()) { grid.Update(sceneData); } ScenesAdded?.Invoke(addedScenes); Core.Logger.Debug("[ScenesStorage] Updates Finished", addedScenes.Count); } }
public static void Update() { using (new PerformanceLogger("[ScenesStorage] Update Scenes", true)) { var addedScenes = new List <WorldScene>(); List <Scene> newScenes; try { newScenes = ZetaDia.Scenes.Where(s => s.IsAlmostValid() && !CurrentWorldSceneIds.Contains(s.GetSceneNameString())).ToList(); } catch (NullReferenceException) { return; } catch (Exception ex) { if (ex.Message.Contains("ReadProcessMemory")) { return; } throw; } foreach (var scene in newScenes) { try { if (!scene.IsAlmostValid()) { continue; } var sceneHashName = scene.GetSceneNameString(); if (scene.IsAlmostValid() && scene.Mesh.ParentSceneId <= 0 && scene.Mesh.WorldId == AdvDia.CurrentWorldDynamicId && !scene.Name.ToLowerInvariant().Contains("fill")) { var adventurerScene = new WorldScene(scene, ExplorationData.ExplorationNodeBoxSize, ExplorationData.ExplorationNodeBoxTolerance); if (adventurerScene.Cells.Count > 0) { CurrentWorldScenes.Add(adventurerScene); addedScenes.Add(adventurerScene); } } CurrentWorldSceneIds.Add(sceneHashName); } catch (NullReferenceException) { } } if (addedScenes.Count > 0) { Logger.Debug("[ScenesStorage] Found {0} new scenes", addedScenes.Count); var nodes = addedScenes.SelectMany(s => s.Nodes).ToList(); //foreach (var explorationNode in nodes) //{ // if (ZetaDia.Minimap.IsExplored(explorationNode.NavigableCenter, explorationNode.WorldId)) // { // explorationNode.IsVisited = true; // } //} ExplorationGrid.Instance.Update(nodes.Cast <INode>().ToList()); NavigationGrid.Instance.Update(nodes.SelectMany(n => n.Nodes).Cast <INode>().ToList()); } } }