Esempio n. 1
0
        public WorldScene(Scene scene, float boxSize, float boxTolerance)
        {
            using (new PerformanceLogger("[WorldScene] ctor", false))
            {
                //                Core.Logger.Debug("[WorldScene] Scene GridSquare Size: {0} X:{1} Y:{2}", scene.Mesh.Zone.NavZoneDef.GridSquareSize,scene.Mesh.Zone.NavZoneDef.NavGridSquareCountX, scene.Mesh.Zone.NavZoneDef.NavGridSquareCountY);
                _boxSize      = boxSize;
                _boxTolerance = boxTolerance;
                //Scene = scene;
                var mesh = scene.Mesh;
                Name        = scene.Name;
                HashName    = scene.GetSceneNameString();
                SnoId       = scene.SceneInfo.SNOId;
                LevelAreaId = mesh.LevelAreaSnoId;
                Min         = mesh.Zone.ZoneMin;
                Max         = mesh.Zone.ZoneMax;
                Size        = Max - Min;
                Center      = (Max + Min) / 2;
                //Rect = new Rect(new Point(Center.X, Center.Y), new Size(_boxSize, _boxSize));
                HasChild       = mesh.SubSceneId > 0;
                HasParent      = mesh.ParentSceneId > 0;
                IsIgnored      = ExplorationData.IgnoreScenes.Contains(Name);
                DynamicWorldId = mesh.WorldId;

                NorthWest = Min;
                NorthEast = new Vector2(Min.X, Max.Y);
                SouthEast = Max;
                SouthWest = new Vector2(Max.X, Min.Y);

                if (ExplorationHelpers.BlacklistedPositionsBySceneSnoId.ContainsKey(SnoId))
                {
                    BlacklistedPositions = ExplorationHelpers.BlacklistedPositionsBySceneSnoId[SnoId];
                }

                SceneId = scene.Mesh.SceneId;
                if (HasChild)
                {
                    SubScene = new WorldScene(mesh.SubScene, boxSize, boxTolerance);
                }
                Core.Logger.Verbose("[WorldScene] Created a new world scene. Name: {0} LevelArea: {1} ({2})", Name, (SNOLevelArea)LevelAreaId, LevelAreaId);
                if (LevelAreaId != AdvDia.CurrentLevelAreaId && !ExplorationData.OpenWorldIds.Contains(AdvDia.CurrentWorldId))
                {
                    Core.Logger.Verbose("[WorldScene] The scene LevelAreaID is different than the CurrentLevelAreaID");
                    Core.Logger.Verbose("[WorldScene] Scene Name: {0}", Name);
                    Core.Logger.Verbose("[WorldScene] Scene: {0} ({1})", (SNOLevelArea)LevelAreaId, LevelAreaId);
                    Core.Logger.Verbose("[WorldScene] Current: {0} ({1})", (SNOLevelArea)AdvDia.CurrentLevelAreaId, AdvDia.CurrentLevelAreaId);
                }

                CreateGrid(mesh);

                if (!ExitPositions.Any())
                {
                    ScanExitDirection(SceneExitDirections.North);
                    ScanExitDirection(SceneExitDirections.South);
                    ScanExitDirection(SceneExitDirections.East);
                    ScanExitDirection(SceneExitDirections.West);
                }
            }
        }
Esempio n. 2
0
        private void ScanExitDirection(SceneExitDirections dir)
        {
            var n = GetNavigableConnection(dir);

            if (n != Vector3.Zero)
            {
                ExitPositions.Add(dir, n);
                ExitDirections |= dir;
            }
        }
Esempio n. 3
0
        public bool IsConnected(WorldScene to)
        {
            var results = TryConnectScenes(this, to);

            if (results == null || !results.Any())
            {
                return(false);
            }

            results.ForEach(r => s_logger.Verbose($"> {r.Scene.Name} {r.Direction} {(ExitPositions.ContainsKey(r.Direction) ? ExitPositions[r.Direction].ToString() : "")}"));
            return(true);
        }
Esempio n. 4
0
        public WorldScene(Scene scene, float boxSize, float boxTolerance)
        {
            using (new PerformanceLogger("[WorldScene] ctor", false))
            {
                _boxSize      = boxSize;
                _boxTolerance = boxTolerance;
                //Scene = scene;
                var mesh = scene.Mesh;
                Name        = scene.Name;
                HashName    = scene.GetSceneNameString();
                SnoId       = scene.SceneInfo.SNOId;
                LevelAreaId = mesh.LevelAreaSnoId;
                Min         = mesh.Zone.ZoneMin;
                Max         = mesh.Zone.ZoneMax;
                Size        = Max - Min;
                Center      = (Max + Min) / 2;
                //Rect = new Rect(new Point(Center.X, Center.Y), new Size(_boxSize, _boxSize));
                HasChild       = mesh.SubSceneId > 0;
                HasParent      = mesh.ParentSceneId > 0;
                IsIgnored      = ExplorationData.IgnoreScenes.Contains(Name);
                DynamicWorldId = mesh.WorldId;

                NorthWest = Min;
                NorthEast = new Vector2(Min.X, Max.Y);
                SouthEast = Max;
                SouthWest = new Vector2(Max.X, Min.Y);

                CornerPositions = new HashSet <Vector2>
                {
                    NorthWest,
                    NorthEast,
                    SouthEast,
                    SouthWest
                };

                if (ExplorationHelpers.BlacklistedPositionsBySceneSnoId.ContainsKey(SnoId))
                {
                    BlacklistedPositions = ExplorationHelpers.BlacklistedPositionsBySceneSnoId[SnoId];
                }

                SceneId = scene.Mesh.SceneId;
                if (HasChild)
                {
                    SubScene = new WorldScene(mesh.SubScene, boxSize, boxTolerance);
                }
                s_logger.Debug($"[{nameof(WorldScene)}] Created a new world scene. Name: {Name} LevelArea: {LevelAreaId}");
                if (LevelAreaId != AdvDia.CurrentLevelAreaId && !ExplorationData.OpenWorldIds.Contains(AdvDia.CurrentWorldId))
                {
                    s_logger.Debug($"[{nameof(WorldScene)}] The scene LevelAreaID is different than the CurrentLevelAreaID");
                    s_logger.Debug($"[{nameof(WorldScene)}] Scene Name: {Name}");
                    s_logger.Debug($"[{nameof(WorldScene)}] Scene: {LevelAreaId}");
                    s_logger.Debug($"[{nameof(WorldScene)}] Current: {AdvDia.CurrentLevelAreaId}");
                }

                CreateGrid(mesh);

                if (!ExitPositions.Any())
                {
                    ScanExitDirection(SceneExitDirections.North);
                    ScanExitDirection(SceneExitDirections.South);
                    ScanExitDirection(SceneExitDirections.East);
                    ScanExitDirection(SceneExitDirections.West);
                }
            }
        }