diff --git a/src/DiIiS-NA/Core/MPQ/Dicts.cs b/src/DiIiS-NA/Core/MPQ/Dicts.cs index 8523022..c954fa5 100644 --- a/src/DiIiS-NA/Core/MPQ/Dicts.cs +++ b/src/DiIiS-NA/Core/MPQ/Dicts.cs @@ -24830,10 +24830,12 @@ namespace DiIiS_NA.Core.MPQ #endregion return DictSNOConversation; } + public static Dictionary DictSNOEffectGroup = new Dictionary(); + public static Dictionary LoadEffectGroup() { - Dictionary DictSNOEffectGroup = new Dictionary(); #region EffectGroup + DictSNOEffectGroup.Clear(); DictSNOEffectGroup.Add("A1C4HouseFireSmall", 1111); DictSNOEffectGroup.Add("a1dun_Leor_Barrel_Torture_A_01_guts", 87589); DictSNOEffectGroup.Add("a1dun_leor_BigFireGrate", 108018); diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs index 65f194c..1525943 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs @@ -51,6 +51,8 @@ using System.Collections.Generic; using System.Drawing; //Blizzless Project 2022 using System.Linq; +using DiIiS_NA.Core.MPQ; +using Player = DiIiS_NA.GameServer.GSSystem.PlayerSystem.Player; namespace DiIiS_NA.GameServer.GSSystem.ActorSystem { @@ -63,15 +65,9 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem /// public SNOHandle ActorSNO { get; private set; } - public ActorSno SNO - { - get { return (ActorSno)ActorSNO.Id; } - } + public ActorSno SNO => (ActorSno)ActorSNO.Id; - public string Name - { - get { return ActorSNO.Name; } - } + public string Name => ActorSNO.Name; /// /// Gets or sets the sno of the actor used to identify the actor to the player @@ -201,7 +197,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem { get { - return (DiIiS_NA.Core.MPQ.FileFormats.Actor)DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.Actor][(int)SNO].Data; + return (DiIiS_NA.Core.MPQ.FileFormats.Actor)MPQStorage.Data.Assets[SNOGroup.Actor][(int)SNO].Data; } } @@ -213,7 +209,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem get { if (ActorData.AnimSetSNO != -1) - return (DiIiS_NA.Core.MPQ.FileFormats.AnimSet)DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.AnimSet][ActorData.AnimSetSNO].Data; + return (DiIiS_NA.Core.MPQ.FileFormats.AnimSet)MPQStorage.Data.Assets[SNOGroup.AnimSet][ActorData.AnimSetSNO].Data; else return null; } @@ -310,12 +306,14 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem Logger.WarnException(e, "quest_OnQuestProgress exception: "); } } - + private bool _isDestroyed = false; + /// /// Unregister from quest events when object is destroyed /// public override void Destroy() { + if (_isDestroyed) return; if (SNO == ActorSno._p6_necro_corpse_flesh) if (World != null) foreach (var plr in World.Game.Players.Values) @@ -338,7 +336,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem public virtual void EnterWorld(Vector3D position) { - var Quest = DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.Quest][74128]; + var Quest = MPQStorage.Data.Assets[SNOGroup.Quest][74128]; if (World != null) { @@ -363,16 +361,9 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem } } - public virtual void BeforeChangeWorld() - { - - } - - public virtual void AfterChangeWorld() - { - - } + public virtual void BeforeChangeWorld() {} + public virtual void AfterChangeWorld() {} public void ChangeWorld(World world, Vector3D position) { @@ -403,37 +394,37 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem CheckPointPosition = position; if (this is Player) - world.BroadcastIfRevealed((plr => ACDWorldPositionMessage(plr)), this); + world.BroadcastIfRevealed((ACDWorldPositionMessage), this); AfterChangeWorld(); - if (this is Player) + if (this is Player plr) { - Hireling hireling = (this as Player).ActiveHireling; + Hireling hireling = plr.ActiveHireling; if (hireling != null) { - (hireling as Hireling).Brain.DeActivate(); + hireling.Brain.DeActivate(); hireling.ChangeWorld(world, position); - (hireling as Hireling).Brain.Activate(); - (this as Player).ActiveHireling = hireling; + hireling.Brain.Activate(); + plr.ActiveHireling = hireling; } - Hireling questhireling = (this as Player).SetQuestHireling; - if (questhireling != null) + Hireling questHireling = plr.QuestHireling; + if (questHireling != null) { - (questhireling as Hireling).Brain.DeActivate(); - questhireling.ChangeWorld(world, position); - (questhireling as Hireling).Brain.Activate(); - (this as Player).SetQuestHireling = questhireling; + questHireling.Brain.DeActivate(); + questHireling.ChangeWorld(world, position); + questHireling.Brain.Activate(); + plr.QuestHireling = questHireling; } - foreach (var fol in (this as Player).Followers.Keys.ToList()) + foreach (var fol in plr.Followers.Keys.ToList()) { var minion = prevWorld.GetActorByGlobalId(fol); - if (minion != null) + if (minion is Minion m) { - (minion as Minion).Brain.DeActivate(); - (this as Player).Followers.Remove(fol); + m.Brain.DeActivate(); + plr.Followers.Remove(fol); minion.ChangeWorld(world, position); - (this as Player).Followers.Add(minion.GlobalID, minion.SNO); - (minion as Minion).Brain.Activate(); + plr.Followers.Add(minion.GlobalID, minion.SNO); + m.Brain.Activate(); } } @@ -455,10 +446,10 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem public void Teleport(Vector3D position) { Position = position; - if (this is Player) + if (this is Player player) { - (this as Player).BetweenWorlds = true; - (this as Player).InGameClient.SendMessage(new ACDTranslateSyncMessage() + player.BetweenWorlds = true; + player.InGameClient.SendMessage(new ACDTranslateSyncMessage() { ActorId = DynamicID(this as Player), Position = Position @@ -476,46 +467,40 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem OnTeleport(); - World.BroadcastIfRevealed(plr => ACDWorldPositionMessage(plr), this); - if (this is Player) + World.BroadcastIfRevealed(ACDWorldPositionMessage, this); + if (this is Player plr) { - (this as Player).BetweenWorlds = false; - } - - if (this is Player) - { - var hireling = (this as Player).ActiveHireling; + var hireling = plr.ActiveHireling; if (hireling != null) { (hireling as Hireling).Brain.DeActivate(); hireling.Position = position; (hireling as Hireling).Brain.Activate(); } - var questhireling = (this as Player).SetQuestHireling; - if (questhireling != null) + var questHireling = plr.QuestHireling; + if (questHireling != null) { - (questhireling as Hireling).Brain.DeActivate(); - questhireling.Position = position; - (questhireling as Hireling).Brain.Activate(); + questHireling.Brain.DeActivate(); + questHireling.Position = position; + questHireling.Brain.Activate(); } - foreach (var fol in (this as Player).Followers) + foreach (var fol in plr.Followers) { - var minion = World.GetActorByGlobalId(fol.Key); - if (minion != null) + if (World.GetActorByGlobalId(fol.Key) is Minion minion) { - (minion as Minion).Brain.DeActivate(); + minion.Brain.DeActivate(); World.GetActorByGlobalId(fol.Key).Position = position; - (minion as Minion).Brain.Activate(); + minion.Brain.Activate(); } } - (this as Player).RevealActorsToPlayer(); - (this as Player).ReRevealPlayersToPlayer(); + plr.RevealActorsToPlayer(); + plr.ReRevealPlayersToPlayer(); Attributes[GameAttribute.Looping_Animation_Start_Time] = -1; Attributes[GameAttribute.Looping_Animation_End_Time] = -1; Attributes.BroadcastChangedIfRevealed(); //Refresh Inventory - (this as Player).Inventory.RefreshInventoryToClient(); + plr.Inventory.RefreshInventoryToClient(); } } @@ -541,18 +526,17 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem public void Unstuck() { if (World == null) return; - Vector3D correctPosition = null; for (int i = 1; i <= 8; i++) { int radius = (int)Math.Pow(2, i); for (int a = 0; a < 8; a++) { float angle = (float)((0.125f * a) * (Math.PI * 2)); - correctPosition = Position + new Vector3D((float)Math.Cos(angle) * radius, (float)Math.Sin(angle) * radius, 0); + Vector3D correctPosition = Position + new Vector3D((float)Math.Cos(angle) * radius, (float)Math.Sin(angle) * radius, 0); if (World.CheckLocationForFlag(correctPosition, DiIiS_NA.Core.MPQ.FileFormats.Scene.NavCellFlags.AllowWalk)) { Position = correctPosition; - World.BroadcastIfRevealed(plr => ACDWorldPositionMessage(plr), this); + World.BroadcastIfRevealed(ACDWorldPositionMessage, this); return; } } @@ -565,6 +549,17 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem public void PlayEffectGroup(int effectGroupSNO) { + #if DEBUG + if (Dicts.DictSNOEffectGroup.ContainsValue(effectGroupSNO)) + { + var effectGroupKey = Dicts.DictSNOEffectGroup.FirstOrDefault(x => x.Value == effectGroupSNO).Key; + Logger.Warn($"PlayEffectGroup {effectGroupSNO} on {GetType().Name}. Type: {effectGroupKey}"); + } + else + { + Logger.Warn($"PlayEffectGroup {effectGroupSNO} on {GetType().Name}. Type: Unknown"); + } + #endif PlayEffect(Effect.PlayEffectGroup, effectGroupSNO); } @@ -612,7 +607,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem ActorId = DynamicID(this as Player), Effect = effect, OptionalParameter = param, - PlayerId = this is Player ? (this as Player).PlayerIndex : null + PlayerId = (this as Player)?.PlayerIndex }); } } @@ -676,21 +671,10 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem { if (this is Monster) { - var Anim = - (DiIiS_NA.Core.MPQ.FileFormats.Anim)DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.Anim][ + var anim = + (DiIiS_NA.Core.MPQ.FileFormats.Anim)MPQStorage.Data.Assets[SNOGroup.Anim][ animationSNO].Data; - if ((this as Monster).Brain != null) - { - //(this as Monster).Brain.DeActivate(); - /* - System.Threading.Tasks.Task.Delay(1200).ContinueWith(delegate - { - (this as Monster).Brain.Activate(); - }); - //*/ - } - World.BroadcastIfRevealed(plr => new PlayAnimationMessage { ActorID = DynamicID(plr), @@ -724,7 +708,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem { new() { - Duration = ticksToPlay.HasValue ? ticksToPlay.Value : -2, // -2 = play animation once through + Duration = ticksToPlay ?? -2, // -2 = play animation once through AnimationSNO = animationSNO, PermutationIndex = 0x0, // TODO: implement variations? AnimationTag = 0, @@ -1135,112 +1119,86 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem #region circurlar region queries - public List GetPlayersInRange(float radius = -1) + public List GetPlayersInRange(float? radius = null) { - if (radius == -1) radius = DefaultQueryProximityRadius; + radius ??= DefaultQueryProximityRadius; return GetObjectsInRange(radius); } - public List GetItemsInRange(float radius = -1) + public List GetItemsInRange(float? radius = null) { - if (radius == -1) radius = DefaultQueryProximityRadius; + radius ??= DefaultQueryProximityRadius; return GetObjectsInRange(radius); } - public List GetMonstersInRange(float radius = -1) + public List GetMonstersInRange(float? radius = null) { - if (radius == -1) radius = DefaultQueryProximityRadius; + radius ??= DefaultQueryProximityRadius; return GetObjectsInRange(radius); } - public List GetActorsInRange(float radius = -1) + public List GetActorsInRange(float? radius = null) { - if (radius == -1) radius = DefaultQueryProximityRadius; + radius ??= DefaultQueryProximityRadius; if (World == null || Position == null) return new List(); return GetObjectsInRange(radius); } - public List GetActorsInRange(Vector3D TPosition, float radius = -1) + public List GetActorsInRange(Vector3D TPosition, float? radius = null) { - if (radius == -1) radius = DefaultQueryProximityRadius; + radius ??= DefaultQueryProximityRadius; return GetObjectsInRange(TPosition, radius); } - public List GetObjectsInRange(Vector3D TPosition, float radius) where T : WorldObject + public List GetObjectsInRange(Vector3D TPosition, float? radius = null) where T : WorldObject { - var proximityCircle = new Circle(TPosition.X, TPosition.Y, radius); + var proximityCircle = new Circle(TPosition.X, TPosition.Y, radius ?? DefaultQueryProximityRadius); return World.QuadTree.Query(proximityCircle); } - public List GetActorsInRange(float radius = -1) where T : Actor + public List GetActorsInRange(float? radius = null) where T : Actor { - if (radius == -1) radius = DefaultQueryProximityRadius; + radius ??= DefaultQueryProximityRadius; return GetObjectsInRange(radius); } - public List GetScenesInRange(float radius = -1) + public List GetScenesInRange(float? radius = null) { - if (radius == -1) radius = DefaultQueryProximityRadius; + radius ??= DefaultQueryProximityRadius; return GetObjectsInRange(radius); } - public List GetObjectsInRange(float radius = -1) + public List GetObjectsInRange(float? radius = null) { - if (radius == -1) radius = DefaultQueryProximityRadius; + radius ??= DefaultQueryProximityRadius; return GetObjectsInRange(radius); } - public List GetObjectsInRange(float radius = -1, bool includeHierarchy = false) where T : WorldObject + public List GetObjectsInRange(float? radius = null, bool includeHierarchy = false) where T : WorldObject { if (World == null || Position == null) return new List(); - if (radius == -1) radius = DefaultQueryProximityRadius; - var proximityCircle = new Circle(Position.X, Position.Y, radius); + radius ??= DefaultQueryProximityRadius; + var proximityCircle = new Circle(Position.X, Position.Y, radius.Value); return World.QuadTree.Query(proximityCircle, includeHierarchy); } #endregion #region rectangluar region queries - - public List GetPlayersInRegion(int lenght = DefaultQueryProximityLenght) - { - return GetObjectsInRegion(lenght); - } - - public List GetItemsInRegion(int lenght = DefaultQueryProximityLenght) - { - return GetObjectsInRegion(lenght); - } - - public List GetMonstersInRegion(int lenght = DefaultQueryProximityLenght) - { - return GetObjectsInRegion(lenght); - } - - public List GetActorsInRegion(int lenght = DefaultQueryProximityLenght) - { - return GetObjectsInRegion(lenght); - } - - public List GetActorsInRegion(int lenght = DefaultQueryProximityLenght) where T : Actor - { - return GetObjectsInRegion(lenght); - } - - public List GetScenesInRegion(int lenght = DefaultQueryProximityLenght) - { - return GetObjectsInRegion(lenght); - } - - public List GetObjectsInRegion(int lenght = DefaultQueryProximityLenght) - { - return GetObjectsInRegion(lenght); - } + public List GetPlayersInRegion(int lenght = DefaultQueryProximityLenght) => GetObjectsInRegion(lenght); + public List GetItemsInRegion(int lenght = DefaultQueryProximityLenght) => GetObjectsInRegion(lenght); + public List GetMonstersInRegion(int lenght = DefaultQueryProximityLenght) => GetObjectsInRegion(lenght); + public List GetActorsInRegion(int lenght = DefaultQueryProximityLenght) => GetObjectsInRegion(lenght); + public List GetActorsInRegion(int lenght = DefaultQueryProximityLenght) where T : Actor => GetObjectsInRegion(lenght); + public List GetScenesInRegion(int lenght = DefaultQueryProximityLenght) => GetObjectsInRegion(lenght); + public List GetObjectsInRegion(int lenght = DefaultQueryProximityLenght) => GetObjectsInRegion(lenght); public List GetObjectsInRegion(int lenght = DefaultQueryProximityLenght) where T : WorldObject { + // ReSharper disable PossibleLossOfFraction var proximityRectangle = new RectangleF(Position.X - lenght / 2, Position.Y - lenght / 2, lenght, lenght); + // ReSharper enable PossibleLossOfFraction return World.QuadTree.Query(proximityRectangle); } @@ -1332,8 +1290,8 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem if (Tags.ContainsKey(MarkerKeys.QuestRange)) { int snoQuestRange = Tags[MarkerKeys.QuestRange].Id; - if (DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.QuestRange].ContainsKey(snoQuestRange)) - _questRange = DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.QuestRange][snoQuestRange].Data as DiIiS_NA.Core.MPQ.FileFormats.QuestRange; + if (MPQStorage.Data.Assets[SNOGroup.QuestRange].ContainsKey(snoQuestRange)) + _questRange = MPQStorage.Data.Assets[SNOGroup.QuestRange][snoQuestRange].Data as DiIiS_NA.Core.MPQ.FileFormats.QuestRange; else Logger.Debug("Actor {0} GlobalID {1} is tagged with unknown QuestRange {2}", NameSNO, GlobalID, snoQuestRange); } @@ -1343,8 +1301,8 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem Logger.Trace(" (ReadTags) actor {0} GlobalID {2} has a conversation list {1}", NameSNO, snoConversationList, GlobalID); - if (DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.ConversationList].ContainsKey(snoConversationList)) - ConversationList = DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.ConversationList][snoConversationList].Data as DiIiS_NA.Core.MPQ.FileFormats.ConversationList; + if (MPQStorage.Data.Assets[SNOGroup.ConversationList].ContainsKey(snoConversationList)) + ConversationList = MPQStorage.Data.Assets[SNOGroup.ConversationList][snoConversationList].Data as DiIiS_NA.Core.MPQ.FileFormats.ConversationList; else if (snoConversationList != -1) Logger.Warn("Actor {0} - Conversation list {1} not found!", NameSNO, snoConversationList); @@ -1406,7 +1364,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem public override string ToString() { - return string.Format("[Actor] [Type: {0}] SNOId:{1} GlobalId: {2} Position: {3} Name: {4}", ActorType, SNO, GlobalID, Position, Name); + return $"[Actor] [Type: {ActorType}] SNOId:{SNO} GlobalId: {GlobalID} Position: {Position} Name: {Name}"; } } diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/GeneratorsSystem/WorldGenerator.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/GeneratorsSystem/WorldGenerator.cs index 9658b96..6b42c7c 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/GeneratorsSystem/WorldGenerator.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/GeneratorsSystem/WorldGenerator.cs @@ -91,19 +91,19 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem Game = game; } - public static Dictionary DefaultConversationLists = new Dictionary(); + public static Dictionary DefaultConversationLists = new(); - private List LoadedLevelAreas = new List(); + private readonly List LoadedLevelAreas = new(); public void CheckLevelArea(World world, int levelAreaSNO) { - if (SpawnGenerator.Spawns.ContainsKey(levelAreaSNO) && SpawnGenerator.Spawns[levelAreaSNO].lazy_load == true) + if (SpawnGenerator.Spawns.ContainsKey(levelAreaSNO) && SpawnGenerator.Spawns[levelAreaSNO].lazy_load) if (!LoadedLevelAreas.Contains(levelAreaSNO)) { LoadedLevelAreas.Add(levelAreaSNO); // Load monsters for level area - foreach (var scene in LazyLevelAreas[levelAreaSNO]) + foreach (var scene in _lazyLevelAreas[levelAreaSNO]) { LoadMonstersLayout(world, levelAreaSNO, scene); } @@ -130,22 +130,22 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem if (world.worldData.DynamicWorld && !worldSNO.IsNotDynamicWorld()) //Gardens of Hope - 2 lvl is NOT random { if (!Config.Instance.DRLGemu) - Logger.Warn("DRLG-Emu деактивирован."); + Logger.Warn("DRLG-Emu is Disabled."); string DRLGVersion = "1.8"; var WorldContainer = DBSessions.WorldSession.Query().Where(dbt => dbt.WorldSNO == (int)worldSNO).ToList(); if (WorldContainer.Count > 0 && worldSNO != WorldSno.a1trdun_level05_templar && Config.Instance.DRLGemu) { DRLGEmuActive = true; - Logger.Warn("Мир - {0} [{1}] динамический! Найден контейнер, DRLG-Emu v{2} Активирован!", worldAsset.Name, worldAsset.SNOId, DRLGVersion); + Logger.Warn("World - {0} [{1}] is dynamic! Found container, DRLG-Emu v{2} Activated!", worldAsset.Name, worldAsset.SNOId, DRLGVersion); } else if (!GenerateRandomDungeon(worldSNO, world.worldData)) { - Logger.Error("DRLG-Emu v{2} - World - {0} [{1}] динамический! DRLG Engine не нашёл контейнер! Шаблонная система не настроена для этого мира.", worldAsset.Name, worldAsset.SNOId, DRLGVersion); + Logger.Error("DRLG-Emu v{2} - World - {0} [{1}] is dynamic! DRLG Engine can't find container! Template system is not configured for this world.", worldAsset.Name, worldAsset.SNOId, DRLGVersion); return null; } else { - Logger.Warn("DRLG-Emu v{2} - Мир - {0} [{1}] динамический! DRLG Engine не нашёл контейнер! Запуск шаблонной системы генерации.", worldAsset.Name, worldAsset.SNOId, DRLGVersion); + Logger.Warn("DRLG-Emu v{2} - World - {0} [{1}] is dynamic! DRLG Engine can't find container! Template system is started.", worldAsset.Name, worldAsset.SNOId, DRLGVersion); if (world.worldData.DRLGParams != null) { world.NextLocation = new MessageSystem.Message.Fields.ResolvedPortalDestination @@ -163,7 +163,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem } else { - Logger.Warn("DRLG-Emu v{2} - Мир - {0} [{1}] динамический! DRLG Engine не нашёл контейнер! Сбой шаблона генерации, не установлена обратная связь.", worldAsset.Name, worldAsset.SNOId, DRLGVersion); + Logger.Warn("DRLG-Emu v{2} - World - {0} [{1}] is dynamic! DRLG Engine can't find container! Template system is not configured for this world.", worldAsset.Name, worldAsset.SNOId, DRLGVersion); return null; } } @@ -180,53 +180,53 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem }; } - if (DRLGEmuActive == true) + if (DRLGEmuActive) { - List> DRLGContainers = new List> { }; - List EnterChuncks = new List { }; - List ExitChuncks = new List { }; - List WayChuncks = new List { }; - List EndChuncks = new List { }; - List FillerChuncks = new List { }; + List> containers = new List> { }; + List enterChunks = new List { }; + List exitChunks = new List { }; + List wayChunks = new List { }; + List endChunks = new List { }; + List fillerChunks = new List { }; var WorldContainer = DBSessions.WorldSession.Query().Where(dbt => dbt.WorldSNO == (int)world.SNO).First(); - var DRLGTiles = DBSessions.WorldSession.Query().Where(dbt => dbt.Head_Container == (int)WorldContainer.Id).ToList(); + var tiles = DBSessions.WorldSession.Query().Where(dbt => dbt.Head_Container == (int)WorldContainer.Id).ToList(); REP: - DRLGTiles = DBSessions.WorldSession.Query().Where(dbt => dbt.Head_Container == (int)WorldContainer.Id).ToList(); + tiles = DBSessions.WorldSession.Query().Where(dbt => dbt.Head_Container == (int)WorldContainer.Id).ToList(); //All Scenes - foreach (var Tile in DRLGTiles) + foreach (var Tile in tiles) { switch (Tile.Type) { - case 0: //Входы - EnterChuncks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); + case 0: //enter + enterChunks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); break; - case 1: //Выходы - ExitChuncks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); + case 1: //exits + exitChunks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); break; - case 2: //Пути - WayChuncks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); + case 2: //way + wayChunks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); break; - case 3: //Тупики - EndChuncks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); + case 3: //dead ends + endChunks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); break; - case 4: //Филлеры - FillerChuncks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); + case 4: //fillers + fillerChunks.Add(new DRLGEmuScene(Tile.SNOHandle_Id, Tile.SNOWeather, Tile.SNOMusic, Tile.SNOLevelArea)); break; } } - DRLGContainers.Add(EnterChuncks); - DRLGContainers.Add(ExitChuncks); - DRLGContainers.Add(WayChuncks); - DRLGContainers.Add(EndChuncks); - DRLGContainers.Add(FillerChuncks); + containers.Add(enterChunks); + containers.Add(exitChunks); + containers.Add(wayChunks); + containers.Add(endChunks); + containers.Add(fillerChunks); if (world.SNO.IsGenerated()) while (true) { - DRLGGenerateProcess(world, DRLGContainers, FillerChuncks, WorldContainer.RangeofScenes); + DRLGGenerateProcess(world, containers, fillerChunks, WorldContainer.RangeofScenes); if (world.worldData.SceneParams.ChunkCount > 15) break; @@ -235,11 +235,11 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem { try { - DRLGGenerateProcess(world, DRLGContainers, FillerChuncks, WorldContainer.RangeofScenes); + DRLGGenerateProcess(world, containers, fillerChunks, WorldContainer.RangeofScenes); } catch { - Logger.Info("DRLG генератор нашёл ошибку в расчёте, повтор."); + Logger.Info("DRLG generator found an error in the calculation, repeat."); goto REP; } } @@ -394,14 +394,14 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem try { if (!world.IsPvP) - loadLevelAreas(levelAreas, world); + LoadLevelAreas(levelAreas, world); } catch (Exception e) { Logger.WarnException(e, "loadLevelAreas exception: "); } - #region Патчи + #region patches switch (worldSNO) { case WorldSno.x1_pand_ext_2_battlefields: //x1_pand_ext_2_battlefields @@ -413,7 +413,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem RandomSpawnInWorldWithLevelArea(world, ActorSno._x1_deathmaiden_unique_fire_a); RandomSpawnInWorldWithLevelArea(world, ActorSno._x1_deathmaiden_unique_fire_a); break; - case WorldSno.trdun_leoric_level03: //Установка портала на третий этаж Залов Агонии рядом с входом к Мяснику. + case WorldSno.trdun_leoric_level03: //Setting portal to the third floor of the Agony's Halls near the entrance to the Butcher. Vector3D Scene0Pos = world.GetSceneBySnoId(78824).Position; world.SpawnMonster(ActorSno._waypoint, new Vector3D(Scene0Pos.X + 149.0907f, Scene0Pos.Y + 106.7075f, Scene0Pos.Z)); break; @@ -428,16 +428,21 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem ActorSno._x1_pand_hexmaze_en_enchantress )) actor.Destroy(); break; - case WorldSno.trout_town: //Упоротый наёмник =) - var Templar = world.GetActorBySNO(ActorSno._templar); + case WorldSno.trout_town: //mercenary + var templar = world.GetActorBySNO(ActorSno._templar); var hasmalth = world.GetActorBySNO(ActorSno._x1_malthael_npc); if (hasmalth == null) { - ActorSystem.Implementations.Hirelings.MalthaelHireling malthaelHire = new ActorSystem.Implementations.Hirelings.MalthaelHireling(world, ActorSno._x1_malthael_npc_nocollision, Templar.Tags); - malthaelHire.RotationAxis = new Vector3D(0f, 0f, 0.4313562f); - malthaelHire.RotationW = 0.9021817f; - malthaelHire.Attributes[GameAttribute.Team_Override] = 2; + ActorSystem.Implementations.Hirelings.MalthaelHireling malthaelHire = new ActorSystem.Implementations.Hirelings.MalthaelHireling(world, ActorSno._x1_malthael_npc_nocollision, templar.Tags) + { + RotationAxis = new Vector3D(0f, 0f, 0.4313562f), + RotationW = 0.9021817f, + Attributes = + { + [GameAttribute.Team_Override] = 2 + } + }; malthaelHire.EnterWorld(new Vector3D(3017.266f, 2851.986f, 24.04533f)); } foreach (var door in world.GetActorsBySNO(ActorSno._house_door_trout_newtristram)) @@ -455,21 +460,21 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem TownDoor.Attributes.BroadcastChangedIfRevealed(); } break; - case WorldSno.a1trdun_level04: //2 уровень собора + case WorldSno.a1trdun_level04: //Cathedral Level 2 foreach (var actor in world.GetActorsBySNO(ActorSno._g_portal_townportal_red)) { foreach (var sp in actor.GetActorsInRange(20f)) sp.Destroy(); actor.Destroy(); //g_Portal_TownPortal_Red } break; - case WorldSno.a1trdun_level06: //4 уровень собора + case WorldSno.a1trdun_level06: //Cathedral Level 4 foreach (var actor in world.GetActorsBySNO(ActorSno._g_portal_townportal_red)) { foreach (var sp in actor.GetActorsInRange(20f)) sp.Destroy(); actor.Destroy(); //g_Portal_TownPortal_Red } break; - case WorldSno.a1trdun_level05_templar: //Лишние NPC в соборе (3 уровень) + case WorldSno.a1trdun_level05_templar: //Cathedral Level 3 foreach (var actor in world.GetActorsBySNO( ActorSno._x1_mysticintro_npc, ActorSno._tristramfemale, @@ -484,59 +489,59 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem } break; - case WorldSno.a2dun_swr_swr_to_oasis_level01: //Убиваем ненужный портал в локации если игра не в режиме приключений + case WorldSno.a2dun_swr_swr_to_oasis_level01: //kill useless portal in location if game not in adventure mode if (Game.CurrentAct != 3000) - foreach (var wayp in world.GetActorsBySNO(ActorSno._waypoint)) wayp.Destroy(); + foreach (var waypoint in world.GetActorsBySNO(ActorSno._waypoint)) waypoint.Destroy(); break; - case WorldSno.a2dun_zolt_head_random01: //Убираем кровь кула + case WorldSno.a2dun_zolt_head_random01: //remove blood pool foreach (var act in world.GetActorsBySNO(ActorSno._a2dun_zolt_blood_container_02)) act.Destroy(); break; - case WorldSno.a2dun_aqd_special_01: //Главный водосток. Убираем лишние порталы. + case WorldSno.a2dun_aqd_special_01: //Main Drain. Remove useless portals. foreach (var port in world.Actors.Values) - if (port is Portal) - if ((port as Portal).Destination.WorldSNO == (int)WorldSno.a2dun_aqd_special_b_level01) - port.Destroy(); + if (port is Portal portal) + if (portal.Destination.WorldSNO == (int)WorldSno.a2dun_aqd_special_b_level01) + portal.Destroy(); break; - case WorldSno.a3dun_keep_level04: //Убиваем ненужный портал в локации если игра не в режиме приключений + case WorldSno.a3dun_keep_level04: //kill useless portal in location if game not in adventure mode if (Game.CurrentAct != 3000) - foreach (var wayp in world.GetActorsBySNO(ActorSno._waypoint)) wayp.Destroy(); + foreach (var waypoint in world.GetActorsBySNO(ActorSno._waypoint)) waypoint.Destroy(); break; - #region Убиваем все порталы в демонические разломы на первом этаже садов(теперь и на втором этаже), а то чет дохера их), создавать будет скрипт уничтожения скверны. Добалвяем голос Дьябло на несколько участков - case WorldSno.a4dun_garden_of_hope_01: //1 Этаж садов - foreach (var HellPortal in world.GetActorsBySNO(ActorSno._a4_heaven_gardens_hellportal)) - HellPortal.Destroy(); + #region kill all portals in demonic rifts on the first floor of the gardens (now and on the second floor), because there are a lot of them), the script will create a script to destroy the demon. Add the voice of Diablo to several areas; + case WorldSno.a4dun_garden_of_hope_01: //1st floor of the gardens + foreach (var hellPortal in world.GetActorsBySNO(ActorSno._a4_heaven_gardens_hellportal)) + hellPortal.Destroy(); break; - case WorldSno.a4dun_garden_of_hope_random: //2 Этаж садов - foreach (var HellPortal in world.GetActorsBySNO(ActorSno._a4_heaven_gardens_hellportal)) - HellPortal.Destroy(); + case WorldSno.a4dun_garden_of_hope_random: //2nd floor of the gardens + foreach (var hellPortal in world.GetActorsBySNO(ActorSno._a4_heaven_gardens_hellportal)) + hellPortal.Destroy(); break; #endregion case WorldSno.a4dun_spire_level_00: - var LeahGhost = world.SpawnMonster(ActorSno._a4dun_aspect_ghost_07, new Vector3D(570f, 570f, 0.1f)) as InteractiveNPC; - LeahGhost.Conversations.Clear(); - LeahGhost.Conversations.Add(new ConversationInteraction(198600)); - LeahGhost.Attributes[GameAttribute.Conversation_Icon, 0] = 6; - LeahGhost.Attributes.BroadcastChangedIfRevealed(); + var leahGhost = world.SpawnMonster(ActorSno._a4dun_aspect_ghost_07, new Vector3D(570f, 570f, 0.1f)) as InteractiveNPC; + leahGhost.Conversations.Clear(); + leahGhost.Conversations.Add(new ConversationInteraction(198600)); + leahGhost.Attributes[GameAttribute.Conversation_Icon, 0] = 6; + leahGhost.Attributes.BroadcastChangedIfRevealed(); break; //428f, 836f, -20.3f case WorldSno.a4dun_spire_level_01: - var ZoltunGhost = world.SpawnMonster(ActorSno._a4dun_aspect_ghost_02, new Vector3D(428f, 836f, -2f)) as InteractiveNPC; - ZoltunGhost.Conversations.Clear(); - ZoltunGhost.Conversations.Add(new ConversationInteraction(198402)); - ZoltunGhost.Attributes[GameAttribute.Conversation_Icon, 0] = 6; - ZoltunGhost.Attributes.BroadcastChangedIfRevealed(); + var zoltunGhost = world.SpawnMonster(ActorSno._a4dun_aspect_ghost_02, new Vector3D(428f, 836f, -2f)) as InteractiveNPC; + zoltunGhost.Conversations.Clear(); + zoltunGhost.Conversations.Add(new ConversationInteraction(198402)); + zoltunGhost.Attributes[GameAttribute.Conversation_Icon, 0] = 6; + zoltunGhost.Attributes.BroadcastChangedIfRevealed(); break; case WorldSno.a3dun_ruins_frost_city_a_02: - foreach (var wayp in world.GetActorsBySNO(ActorSno._waypoint)) wayp.Destroy(); + foreach (var waypoint in world.GetActorsBySNO(ActorSno._waypoint)) waypoint.Destroy(); break; case WorldSno.p43_ad_oldtristram: - foreach (var wayp in world.GetActorsBySNO(ActorSno._trout_oldtristram_exit_gate)) wayp.Destroy(); + foreach (var waypoint in world.GetActorsBySNO(ActorSno._trout_oldtristram_exit_gate)) waypoint.Destroy(); break; case WorldSno.x1_tristram_adventure_mode_hub: - //Отображаем только одного продавца + //Display only one seller world.ShowOnlyNumNPC(ActorSno._a1_uniquevendor_miner_intown_01, 0); - //Отображаем только одного мистика + //Display only one mystic world.ShowOnlyNumNPC(ActorSno._pt_mystic, 1); var Door = world.GetActorBySNO(ActorSno._trout_newtristram_gate_town); Door.Attributes[GameAttribute.Team_Override] = 2; @@ -548,64 +553,61 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem Door.Attributes[GameAttribute.Immunity] = true; Door.Attributes.BroadcastChangedIfRevealed(); break; - case WorldSno.p43_ad_cathedral_level_01: //1 этаж собора (Режим D1) - case WorldSno.p43_ad_cathedral_level_02: //2 этаж собора (Режим D1) - case WorldSno.p43_ad_cathedral_level_03: //3 этаж собора (Режим D1) - case WorldSno.p43_ad_cathedral_level_04: //4 этаж собора (Режим D1) - case WorldSno.p43_ad_catacombs_level_05: //5 этаж собора (Режим D1) - case WorldSno.p43_ad_catacombs_level_06: //6 этаж собора (Режим D1) - case WorldSno.p43_ad_catacombs_level_07: //7 этаж собора (Режим D1) - case WorldSno.p43_ad_catacombs_level_08: //8 этаж собора (Режим D1) - foreach (var actor in world.GetActorsBySNO(d1ModeHiddenActors)) actor.Destroy(); + case WorldSno.p43_ad_cathedral_level_01: //1st floor of the cathedral (D1 mode) + case WorldSno.p43_ad_cathedral_level_02: //2nd floor of the cathedral (D1 mode) + case WorldSno.p43_ad_cathedral_level_03: //3rd floor of the cathedral (D1 mode) + case WorldSno.p43_ad_cathedral_level_04: //4th floor of the cathedral (D1 mode) + case WorldSno.p43_ad_catacombs_level_05: //5th floor of the cathedral (D1 mode) + case WorldSno.p43_ad_catacombs_level_06: //6th floor of the cathedral (D1 mode) + case WorldSno.p43_ad_catacombs_level_07: //7th floor of the cathedral (D1 mode) + case WorldSno.p43_ad_catacombs_level_08: //8th floor of the cathedral (D1 mode) + foreach (var actor in world.GetActorsBySNO(d1ModeHiddenActors)) + actor.Destroy(); foreach (var actor in world.GetActorsBySNO(ActorSno._g_portal_townportal_red)) { - foreach (var sp in actor.GetActorsInRange(20f)) sp.Destroy(); + foreach (var startingPoint in actor.GetActorsInRange(20f)) startingPoint.Destroy(); actor.Destroy(); //g_Portal_TownPortal_Red } break; } #endregion - #region Глобал патч при генерации - foreach (var oldp in world.GetActorsBySNO( - ActorSno._x1_openworld_lootrunportal, - ActorSno._x1_openworld_tiered_rifts_portal, - ActorSno._x1_openworld_tiered_rifts_challenge_portal, - ActorSno._x1_westm_bridge_scoundrel - )) + #region Global patch when generating + foreach (var oldPoint in world.GetActorsBySNO(ActorSno._x1_openworld_lootrunportal, ActorSno._x1_openworld_tiered_rifts_portal, + ActorSno._x1_openworld_tiered_rifts_challenge_portal, ActorSno._x1_westm_bridge_scoundrel)) { - oldp.Destroy(); + oldPoint.Destroy(); } - foreach (var oldp in world.GetActorsBySNO(ActorSno._placedgold)) { foreach(var plr in world.Game.Players.Values) world.SpawnGold(oldp, plr); oldp.Destroy(); } + foreach (var oldPoint in world.GetActorsBySNO(ActorSno._placedgold)) { foreach(var plr in world.Game.Players.Values) world.SpawnGold(oldPoint, plr); oldPoint.Destroy(); } if(world.SNO != WorldSno.a1trdun_level05_templar) - foreach (var oldp in world.GetActorsBySNO(ActorSno._x1_openworld_tiered_rifts_challenge_portal)) { oldp.Destroy(); }//109209 - Костяные стены из собора + foreach (var oldPoint in world.GetActorsBySNO(ActorSno._x1_openworld_tiered_rifts_challenge_portal)) { oldPoint.Destroy(); }//109209 - Bone Walls from the Cathedral #endregion return world; } - public void RandomSpawnInWorldWithLevelArea(World world, ActorSno monsterSno, int LevelArea = -1) + public void RandomSpawnInWorldWithLevelArea(World world, ActorSno monsterSno, int levelArea = -1) { - List Scenes = world.Scenes.Values.ToList(); - if (LevelArea != -1) Scenes = Scenes.Where(sc => sc.Specification.SNOLevelAreas[0] == LevelArea && !sc.SceneSNO.Name.ToLower().Contains("filler")).ToList(); - else Scenes = Scenes.Where(sc => !sc.SceneSNO.Name.ToLower().Contains("filler")).ToList(); - int RandomScene = RandomHelper.Next(0, Scenes.Count - 1); - Vector3D SSV = Scenes[RandomScene].Position; - Vector3D SP = null; + List scenes = world.Scenes.Values.ToList(); + if (levelArea != -1) scenes = scenes.Where(sc => sc.Specification.SNOLevelAreas[0] == levelArea && !sc.SceneSNO.Name.ToLower().Contains("filler")).ToList(); + else scenes = scenes.Where(sc => !sc.SceneSNO.Name.ToLower().Contains("filler")).ToList(); + int randomScene = RandomHelper.Next(0, scenes.Count - 1); + Vector3D SSV = scenes[randomScene].Position; + Vector3D startingPoint = null; while (true) { - SP = new Vector3D(SSV.X + RandomHelper.Next(0, 240), SSV.Y + RandomHelper.Next(0, 240), SSV.Z); - if (world.CheckLocationForFlag(SP, DiIiS_NA.Core.MPQ.FileFormats.Scene.NavCellFlags.AllowWalk)) + startingPoint = new Vector3D(SSV.X + RandomHelper.Next(0, 240), SSV.Y + RandomHelper.Next(0, 240), SSV.Z); + if (world.CheckLocationForFlag(startingPoint, DiIiS_NA.Core.MPQ.FileFormats.Scene.NavCellFlags.AllowWalk)) break; } - world.SpawnMonster(monsterSno, SP); + world.SpawnMonster(monsterSno, startingPoint); } - public void FilterWaypoints(World world, int SceneSNO = -1) + public void FilterWaypoints(World world, int sceneSno = -1) { var waypoints = world.GetActorsBySNO(ActorSno._waypoint); - if (SceneSNO != -1) waypoints = waypoints.Where(wp => wp.CurrentScene.SceneSNO.Id == SceneSNO).ToList(); + if (sceneSno != -1) waypoints = waypoints.Where(wp => wp.CurrentScene.SceneSNO.Id == sceneSno).ToList(); if (waypoints.Count > 1) { @@ -628,25 +630,25 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem Blocked, //"wall" in that direction Open //"path" in that direction } - public static void DRLGGenerateProcess(World world, List> Cont, List Fillers, long RangofSc) + public static void DRLGGenerateProcess(World world, List> container, List fillers, long range) { if (world.worldData.SceneParams == null) world.worldData.CreateNewSceneParams(); world.worldData.SceneParams.SceneChunks.Clear(); - List BusyChunks = new List { }; - List ReservedChunks = new List { }; - Dictionary WaitChunks = new Dictionary { }; - Dictionary NextWaitChunks = new Dictionary { }; + List busyChunks = new List { }; + List reservedChunks = new List { }; + Dictionary waitChunks = new Dictionary { }; + Dictionary nextWaitChunks = new Dictionary { }; - bool HasExit = false; + bool hasExit = false; - List> DRLGContainers = Cont; - List FillerChuncks = Fillers; + List> DRLGContainers = container; + List FillerChuncks = fillers; - char CurrentNav = '.'; + char currentNav = '.'; - DRLGEmuScene CurrentScene = null; + DRLGEmuScene currentScene = null; foreach (var Container in DRLGContainers) foreach (var Scene in Container) @@ -658,55 +660,55 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem { Logger.Error("Scene {0}, not added on DRLG", Scene.SnoID); } - bool Rift = world.SNO.IsGenerated(); + bool rift = world.SNO.IsGenerated(); //Getting Enter - var loadedscene = new SceneChunk(); - CurrentScene = DRLGContainers[0][RandomHelper.Next(0, DRLGContainers[0].Count)]; - loadedscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - loadedscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), new Vector3D(0, 0, 0)); - loadedscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + var loadedScene = new SceneChunk(); + currentScene = DRLGContainers[0][RandomHelper.Next(0, DRLGContainers[0].Count)]; + loadedScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + loadedScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), new Vector3D(0, 0, 0)); + loadedScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(loadedscene); //Add Chunk - BusyChunks.Add(loadedscene.PRTransform.Vector3D); //Cords Busy + world.worldData.SceneParams.SceneChunks.Add(loadedScene); //Add Chunk + busyChunks.Add(loadedScene.PRTransform.Vector3D); //Cords Busy - SceneChunk PrestScene = loadedscene; - Vector3D PlaceToNewScene = new Vector3D(); + SceneChunk prestScene = loadedScene; + Vector3D placeToNewScene = new Vector3D(); - var nextscene = new SceneChunk(); - char[] ToWaitChunks; - var splits = PrestScene.SNOHandle.Name.Split('_'); - int PosOfNav = 2; + var nextScene = new SceneChunk(); + char[] toWaitChunks; + var splits = prestScene.SNOHandle.Name.Split('_'); + int positionOfNav = 2; if (splits[0].ToLower().StartsWith("p43") || splits[2].ToLower().Contains("random") || splits[2].ToLower().Contains("corrupt")) - PosOfNav = 3; - else if (PrestScene.SNOHandle.Name.StartsWith("x1_Pand")) - PosOfNav = 4; + positionOfNav = 3; + else if (prestScene.SNOHandle.Name.StartsWith("x1_Pand")) + positionOfNav = 4; - int RangetoNext = (int)RangofSc; + int RangetoNext = (int)range; //First Switch - switch (PrestScene.SNOHandle.Name.Split('_')[PosOfNav]) + switch (prestScene.SNOHandle.Name.Split('_')[positionOfNav]) { case "S": - CurrentNav = 'N'; + currentNav = 'N'; while (true) { - if (PrestScene.SNOHandle.Name.StartsWith("x1_Pand")) - PosOfNav = 3; - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + if (prestScene.SNOHandle.Name.StartsWith("x1_Pand")) + positionOfNav = 3; + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way break; } - PlaceToNewScene = new Vector3D(PrestScene.PRTransform.Vector3D.X + RangetoNext, PrestScene.PRTransform.Vector3D.Y, PrestScene.PRTransform.Vector3D.Z); - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) + placeToNewScene = new Vector3D(prestScene.PRTransform.Vector3D.X + RangetoNext, prestScene.PRTransform.Vector3D.Y, prestScene.PRTransform.Vector3D.Z); + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); + foreach (var Point in toWaitChunks) + if (Point != currentNav) switch (Point) { //Куда застраивать в названии @@ -714,77 +716,76 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem //N - Строить налево -240:0 //E - Строить вверх 0:+240 //W - Строить вниз 0:-240 - case 'S': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + case 'S': waitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'N': waitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'E': waitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + case 'W': waitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - nextscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - nextscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); - nextscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + nextScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + nextScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); + nextScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(nextscene); //Добавить сцену - BusyChunks.Add(nextscene.PRTransform.Vector3D); //Занять клетку - PrestScene = nextscene; + world.worldData.SceneParams.SceneChunks.Add(nextScene); //Add scene + busyChunks.Add(nextScene.PRTransform.Vector3D); //Occupy cell + prestScene = nextScene; break; case "N": - CurrentNav = 'S'; + currentNav = 'S'; while (true) { - if (PrestScene.SNOHandle.Name.StartsWith("x1_Pand")) - PosOfNav = 3; + if (prestScene.SNOHandle.Name.StartsWith("x1_Pand")) + positionOfNav = 3; - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way break; } - PlaceToNewScene = new Vector3D(PrestScene.PRTransform.Vector3D.X - RangetoNext, PrestScene.PRTransform.Vector3D.Y, PrestScene.PRTransform.Vector3D.Z); - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) - switch (Point) + placeToNewScene = new Vector3D(prestScene.PRTransform.Vector3D.X - RangetoNext, prestScene.PRTransform.Vector3D.Y, prestScene.PRTransform.Vector3D.Z); + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); + foreach (var point in toWaitChunks) + if (point != currentNav) + switch (point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 - case 'S': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + //S - build to the right +240:0 + case 'S': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //N - build to the left -240:0 + case 'N': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //E - build up 0:+240 + case 'E': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + //W - build down 0:-240 + case 'W': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - nextscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - nextscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); - nextscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + nextScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + nextScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); + nextScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(nextscene); //Добавить сцену - BusyChunks.Add(nextscene.PRTransform.Vector3D); //Занять клетку - PrestScene = nextscene; + world.worldData.SceneParams.SceneChunks.Add(nextScene); //Добавить сцену + busyChunks.Add(nextScene.PRTransform.Vector3D); //Занять клетку + prestScene = nextScene; break; case "E": - CurrentNav = 'W'; + currentNav = 'W'; while (true) { - if (PrestScene.SNOHandle.Name.StartsWith("x1_Pand")) - PosOfNav = 3; + if (prestScene.SNOHandle.Name.StartsWith("x1_Pand")) + positionOfNav = 3; - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way break; } - PlaceToNewScene = new Vector3D(PrestScene.PRTransform.Vector3D.X, PrestScene.PRTransform.Vector3D.Y + RangetoNext, PrestScene.PRTransform.Vector3D.Z); - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) + placeToNewScene = new Vector3D(prestScene.PRTransform.Vector3D.X, prestScene.PRTransform.Vector3D.Y + RangetoNext, prestScene.PRTransform.Vector3D.Z); + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); + foreach (var Point in toWaitChunks) + if (Point != currentNav) switch (Point) { //Куда застраивать в названии @@ -792,871 +793,864 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem //N - Строить налево -240:0 //E - Строить вверх 0:+240 //W - Строить вниз 0:-240 - case 'S': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + case 'S': waitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'N': waitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'E': waitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + case 'W': waitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - nextscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - nextscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); - nextscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + nextScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + nextScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); + nextScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(nextscene); //Добавить сцену - BusyChunks.Add(nextscene.PRTransform.Vector3D); //Занять клетку - PrestScene = nextscene; + world.worldData.SceneParams.SceneChunks.Add(nextScene); //Добавить сцену + busyChunks.Add(nextScene.PRTransform.Vector3D); //Занять клетку + prestScene = nextScene; break; case "W": - CurrentNav = 'E'; + currentNav = 'E'; while (true) { - if (PrestScene.SNOHandle.Name.StartsWith("x1_Pand")) - PosOfNav = 3; + if (prestScene.SNOHandle.Name.StartsWith("x1_Pand")) + positionOfNav = 3; - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way break; } - PlaceToNewScene = new Vector3D(PrestScene.PRTransform.Vector3D.X, PrestScene.PRTransform.Vector3D.Y - RangetoNext, PrestScene.PRTransform.Vector3D.Z); - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) - switch (Point) + placeToNewScene = new Vector3D(prestScene.PRTransform.Vector3D.X, prestScene.PRTransform.Vector3D.Y - RangetoNext, prestScene.PRTransform.Vector3D.Z); + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); + foreach (var point in toWaitChunks) + if (point != currentNav) + switch (point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 - case 'S': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + //S - Build to the right +240:0 + case 'S': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //N - Build to the left -240:0 + case 'N': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //E - Build up 0:+240 + case 'E': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + //W - Build down 0:-240 + case 'W': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - nextscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - nextscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); - nextscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + nextScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + nextScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); + nextScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(nextscene); //Добавить сцену - BusyChunks.Add(nextscene.PRTransform.Vector3D); //Занять клетку - PrestScene = nextscene; + world.worldData.SceneParams.SceneChunks.Add(nextScene); // add scene + busyChunks.Add(nextScene.PRTransform.Vector3D); //occupy cell + prestScene = nextScene; break; case "EW": var nextscene1 = new SceneChunk(); - CurrentNav = 'E'; + currentNav = 'E'; while (true) { - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way break; } - PlaceToNewScene = new Vector3D(PrestScene.PRTransform.Vector3D.X, PrestScene.PRTransform.Vector3D.Y - RangetoNext, PrestScene.PRTransform.Vector3D.Z); - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) - switch (Point) + placeToNewScene = new Vector3D(prestScene.PRTransform.Vector3D.X, prestScene.PRTransform.Vector3D.Y - RangetoNext, prestScene.PRTransform.Vector3D.Z); + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); + foreach (var point in toWaitChunks) + if (point != currentNav) + switch (point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 - case 'S': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + //S - Build to the right +240:0 + case 'S': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //N - Build to the left -240:0 + case 'N': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //E - Build up 0:+240 + case 'E': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + //W - Build down 0:-240 + case 'W': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - nextscene1.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - nextscene1.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); + nextscene1.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + nextscene1.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); nextscene1.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); world.worldData.SceneParams.SceneChunks.Add(nextscene1); //Добавить сцену - BusyChunks.Add(nextscene1.PRTransform.Vector3D); //Занять клетку + busyChunks.Add(nextscene1.PRTransform.Vector3D); //Занять клетку - CurrentNav = 'W'; + currentNav = 'W'; while (true) { - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way break; } - PlaceToNewScene = new Vector3D(PrestScene.PRTransform.Vector3D.X, PrestScene.PRTransform.Vector3D.Y + RangetoNext, PrestScene.PRTransform.Vector3D.Z); - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) - switch (Point) + placeToNewScene = new Vector3D(prestScene.PRTransform.Vector3D.X, prestScene.PRTransform.Vector3D.Y + RangetoNext, prestScene.PRTransform.Vector3D.Z); + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); + foreach (var point in toWaitChunks) + if (point != currentNav) + switch (point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 - case 'S': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': WaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + //S - Build to the right +240:0 + case 'S': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //N - Build to the left -240:0 + case 'N': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //E - Build up 0:+240 + case 'E': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + //W - Build down 0:-240 + case 'W': waitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - nextscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - nextscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); - nextscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + nextScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + nextScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); + nextScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(nextscene); //Добавить сцену - BusyChunks.Add(nextscene.PRTransform.Vector3D); //Занять клетку - PrestScene = nextscene; + world.worldData.SceneParams.SceneChunks.Add(nextScene); //Добавить сцену + busyChunks.Add(nextScene.PRTransform.Vector3D); //Занять клетку + prestScene = nextScene; break; } int DRLGDeep = 5; - if (Rift) + if (rift) DRLGDeep = 20; //Deep and exits for (int i = 0; i <= DRLGDeep; i++) { - foreach (var waitedScene in WaitChunks) + foreach (var waitedScene in waitChunks) { - var newscene = new SceneChunk(); + var newScene = new SceneChunk(); switch (waitedScene.Key[0]) { case 'S': - CurrentNav = 'N'; + currentNav = 'N'; while (true) { if (i > DRLGDeep - 1) { - if (HasExit) + if (hasExit) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)]; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //Way + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)]; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //Way { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } else { - CurrentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav)) //Exit + currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav)) //Exit { - HasExit = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + hasExit = true; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } } else { - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; #region проверка на будущее - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); bool ForceStop = false; - foreach (var Point in ToWaitChunks) - if (Point != waitedScene.Key[0]) - switch (Point) + foreach (var point in toWaitChunks) + if (point != waitedScene.Key[0]) + switch (point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 - + //S - Build to the right case 'S': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; + + //N - Build to the left case 'N': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; + + //E - Build up case 'E': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; + + //W - Build down case 'W': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; } #endregion - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } else if (ForceStop) { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } } - PlaceToNewScene = waitedScene.Value; - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); + placeToNewScene = waitedScene.Value; + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) - switch (Point) + foreach (var point in toWaitChunks) + if (point != currentNav) + switch (point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 - - case 'S': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + //S - Build right +240:0 + case 'S': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z))) nextWaitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //N - Build left -240:0 + case 'N': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z))) nextWaitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + //E - Build up 0:+240 + case 'E': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z))) nextWaitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + //W - Build down 0:-240 + case 'W': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z))) nextWaitChunks.Add(point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - newscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - newscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); - newscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + newScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + newScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); + newScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(newscene); //Добавить сцену - BusyChunks.Add(newscene.PRTransform.Vector3D); //Занять клетку - PrestScene = newscene; + world.worldData.SceneParams.SceneChunks.Add(newScene); //Добавить сцену + busyChunks.Add(newScene.PRTransform.Vector3D); //Занять клетку + prestScene = newScene; break; case 'N': - CurrentNav = 'S'; + currentNav = 'S'; while (true) { if (i > DRLGDeep - 1) { - if (HasExit) + if (hasExit) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)]; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //Way + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)]; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //Way { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } else { - CurrentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav)) //Exit + currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav)) //Exit { - HasExit = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + hasExit = true; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } } else { - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; #region проверка на будущее - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); - bool ForceStop = false; - foreach (var Point in ToWaitChunks) - if (Point != waitedScene.Key[0]) - switch (Point) + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); + bool forceStop = false; + foreach (var point in toWaitChunks) + if (point != waitedScene.Key[0]) + switch (point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 - + //S - Build to the right +240:0 case 'S': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { - ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + forceStop = true; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; + //N - Build to the left -240:0 case 'N': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { - ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + forceStop = true; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; + //E - Build up 0:+240 case 'E': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { - ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + forceStop = true; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; + //W - Build down 0:-240 case 'W': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4;// else PosOfNav = 3; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;// else PosOfNav = 3; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { - ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + forceStop = true; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; } #endregion - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } - else if (ForceStop) + else if (forceStop) { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } } - PlaceToNewScene = waitedScene.Value; - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); + placeToNewScene = waitedScene.Value; + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) + foreach (var Point in toWaitChunks) + if (Point != currentNav) switch (Point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 + //S - Build to the right +240:0 + //N - Build to the left -240:0 + //E - Build up 0:+240 + //W - Build down 0:-240 - case 'S': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + case 'S': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'N': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'E': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + case 'W': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - newscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - newscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); - newscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + newScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + newScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); + newScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(newscene); //Добавить сцену - BusyChunks.Add(newscene.PRTransform.Vector3D); //Занять клетку - PrestScene = newscene; + world.worldData.SceneParams.SceneChunks.Add(newScene); //Добавить сцену + busyChunks.Add(newScene.PRTransform.Vector3D); //Занять клетку + prestScene = newScene; break; case 'E': - CurrentNav = 'W'; + currentNav = 'W'; while (true) { if (i > DRLGDeep - 1) { - if (HasExit) + if (hasExit) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)]; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //Way + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)]; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //Way { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } else { - CurrentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav)) //Exit + currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav)) //Exit { - HasExit = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + hasExit = true; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } } else { - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; #region проверка на будущее - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); bool ForceStop = false; - foreach (var Point in ToWaitChunks) + foreach (var Point in toWaitChunks) if (Point != waitedScene.Key[0]) switch (Point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 + //S - Build to the right +240:0 + //N - Build to the left -240:0 + //E - Build up 0:+240 + //W - Build down 0:-240 case 'S': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; case 'N': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; case 'E': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; case 'W': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; } #endregion - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } else if (ForceStop) { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } } - PlaceToNewScene = waitedScene.Value; - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); + placeToNewScene = waitedScene.Value; + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) + foreach (var Point in toWaitChunks) + if (Point != currentNav) switch (Point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 + //S - Build to the right +240:0 + //N - Build to the left -240:0 + //E - Build up 0:+240 + //W - Build down 0:-240 - case 'S': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + case 'S': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'N': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'E': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + case 'W': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - newscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - newscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); - newscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + newScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + newScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); + newScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(newscene); //Добавить сцену - BusyChunks.Add(newscene.PRTransform.Vector3D); //Занять клетку - PrestScene = newscene; + world.worldData.SceneParams.SceneChunks.Add(newScene); //Add scene + busyChunks.Add(newScene.PRTransform.Vector3D); //occupy the cell + prestScene = newScene; break; case 'W': - CurrentNav = 'E'; + currentNav = 'E'; while (true) { if (i > DRLGDeep - 1) { - if (HasExit) + if (hasExit) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)]; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //Way + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)]; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //Way { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } else { - CurrentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav)) //Exit + currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav)) //Exit { - HasExit = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + hasExit = true; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } } else { - CurrentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; + currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)]; #region проверка на будущее - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); bool ForceStop = false; - foreach (var Point in ToWaitChunks) + foreach (var Point in toWaitChunks) if (Point != waitedScene.Key[0]) switch (Point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 + //S - Build to the right +240:0 + //N - Build to the left -240:0 + //E - Build up 0:+240 + //W - Build down 0:-240 case 'S': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; case 'N': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; case 'E': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; case 'W': - if (BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)) || - (ReservedChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)))) + if (busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)) || + (reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)))) while (true) { - CurrentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //End + currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End { ForceStop = true; - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } break; } #endregion - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 4; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length > 1) //Way + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4; + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } else if (ForceStop) { - if (CurrentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || CurrentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) PosOfNav = 3; + if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 3; break; } } } - PlaceToNewScene = waitedScene.Value; - ToWaitChunks = CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray(); + placeToNewScene = waitedScene.Value; + toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray(); - foreach (var Point in ToWaitChunks) - if (Point != CurrentNav) + foreach (var Point in toWaitChunks) + if (Point != currentNav) switch (Point) { - //Куда застраивать в названии - //S - Строить направо +240:0 - //N - Строить налево -240:0 - //E - Строить вверх 0:+240 - //W - Строить вниз 0:-240 + //S - Build to the right +240:0 + //N - Build to the left -240:0 + //E - Build up 0:+240 + //W - Build down 0:-240 - case 'S': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X + RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'N': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X - RangetoNext, PlaceToNewScene.Y, PlaceToNewScene.Z)); break; - case 'E': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y + RangetoNext, PlaceToNewScene.Z)); break; - case 'W': if (!BusyChunks.Contains(new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z))) NextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(PlaceToNewScene.X, PlaceToNewScene.Y - RangetoNext, PlaceToNewScene.Z)); break; + case 'S': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'N': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z)); break; + case 'E': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z)); break; + case 'W': if (!busyChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z))) nextWaitChunks.Add(Point.ToString().ToArray(), new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z)); break; } - newscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - newscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), PlaceToNewScene); - newscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + newScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + newScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), placeToNewScene); + newScene.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - world.worldData.SceneParams.SceneChunks.Add(newscene); //Добавить сцену - BusyChunks.Add(newscene.PRTransform.Vector3D); //Занять клетку - PrestScene = newscene; + world.worldData.SceneParams.SceneChunks.Add(newScene); //Add scene + busyChunks.Add(newScene.PRTransform.Vector3D); //occupy the cell + prestScene = newScene; break; } } - WaitChunks.Clear(); + waitChunks.Clear(); - foreach (var NC in NextWaitChunks) + foreach (var nextChunk in nextWaitChunks) { - bool Unique = true; - //Не накладываем сцену на сцену! - foreach (var EC in BusyChunks) //Проверяем уже созданные. - if (NC.Value == EC) - Unique = false; - foreach (var RC in ReservedChunks) - if (NC.Value == RC) //Проверяем резерв! - Unique = false; - if (Unique) + bool unique = true; + //we don't put scene on scene! + foreach (var busyChunk in busyChunks) //check already created + if (nextChunk.Value == busyChunk) + unique = false; + foreach (var reservedChunk in reservedChunks) + if (nextChunk.Value == reservedChunk) //check reserve + unique = false; + if (unique) { - ReservedChunks.Add(NC.Value); - WaitChunks.Add(NC.Key, NC.Value); + reservedChunks.Add(nextChunk.Value); + waitChunks.Add(nextChunk.Key, nextChunk.Value); } - } - NextWaitChunks.Clear(); - ReservedChunks.Clear(); + nextWaitChunks.Clear(); + reservedChunks.Clear(); } //Force Check Exit - if (!HasExit) + if (!hasExit) { - bool First = false; - bool Finish = false; - var newscene = new SceneChunk(); - foreach (var Chunck in world.worldData.SceneParams.SceneChunks) + bool first = false; + bool finish = false; + var newSceneChunk = new SceneChunk(); + foreach (var chunk in world.worldData.SceneParams.SceneChunks) { - if (!HasExit) + if (!hasExit) { - //Пропускаем первый чанк - if (!First) { First = true; continue; } - //Начинаем искать тупики + //skip first chunk + if (!first) { first = true; continue; } + //we start to find dead ends //if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(CurrentNav) & CurrentScene.Asset.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) //Way - if (Chunck.SNOHandle.Name.Split('_')[PosOfNav].ToCharArray().Length == 1) + if (chunk.SNOHandle.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) { - char Nav = Chunck.SNOHandle.Name.Split('_')[PosOfNav].ToCharArray()[0]; + char Nav = chunk.SNOHandle.Name.Split('_')[positionOfNav].ToCharArray()[0]; while (true) { - CurrentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; + currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)]; - if (CurrentScene.Asset.Name.Split('_')[PosOfNav].Contains(Nav)) //Exit + if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(Nav)) //Exit { - HasExit = true; + hasExit = true; break; } } - newscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - newscene.PRTransform = Chunck.PRTransform; - newscene.SceneSpecification = new SceneSpecification( - 0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, + newSceneChunk.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID); + newSceneChunk.PRTransform = chunk.PRTransform; + newSceneChunk.SceneSpecification = new SceneSpecification( + 0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); - Finish = true; + finish = true; } } - if (Finish) + if (finish) { - //Преждевременное завершение и добавление выхода - world.worldData.SceneParams.SceneChunks.Add(newscene); //Добавить сцену - world.worldData.SceneParams.SceneChunks.Remove(Chunck); + //premature completion and adding an exit + world.worldData.SceneParams.SceneChunks.Add(newSceneChunk); //Add scene + world.worldData.SceneParams.SceneChunks.Remove(chunk); break; } } } //Forming Range - float ChunkminX = -480; - float ChunkmaxX = 0; - float ChunkminY = -480; - float ChunkmaxY = 0; + float chunkMinX = -480; + float chunkMaxX = 0; + float chunkMinY = -480; + float chunkMaxY = 0; foreach (var chunk in world.worldData.SceneParams.SceneChunks) { - if (chunk.PRTransform.Vector3D.X > ChunkmaxX) ChunkmaxX = chunk.PRTransform.Vector3D.X; - if (chunk.PRTransform.Vector3D.Y > ChunkmaxY) ChunkmaxY = chunk.PRTransform.Vector3D.Y; + if (chunk.PRTransform.Vector3D.X > chunkMaxX) chunkMaxX = chunk.PRTransform.Vector3D.X; + if (chunk.PRTransform.Vector3D.Y > chunkMaxY) chunkMaxY = chunk.PRTransform.Vector3D.Y; } - ChunkmaxX += RangetoNext; - ChunkmaxY += RangetoNext; + chunkMaxX += RangetoNext; + chunkMaxY += RangetoNext; //Fillers List FillerChunks = new List(); if (FillerChuncks.Count > 0) { - float X = ChunkminX; - float Y = ChunkminY; - while (X < ChunkmaxX) + float x = chunkMinX; + float y = chunkMinY; + while (x < chunkMaxX) { - float ReturnToMinY = ChunkminY; - while (Y < ChunkmaxY) + float returnToMinY = chunkMinY; + while (y < chunkMaxY) { - bool Busy = false; + bool busy = false; foreach (var chunk in world.worldData.SceneParams.SceneChunks) - if (chunk.PRTransform.Vector3D.X == X & chunk.PRTransform.Vector3D.Y == Y) - { Busy = true; break; } + if (Math.Abs(chunk.PRTransform.Vector3D.X - x) < 0.001 & Math.Abs(chunk.PRTransform.Vector3D.Y - y) < 0.001) + { + busy = true; + break; + } - if (!Busy) + if (!busy) { - CurrentScene = DRLGContainers[4][RandomHelper.Next(0, DRLGContainers[4].Count)]; + currentScene = DRLGContainers[4][RandomHelper.Next(0, DRLGContainers[4].Count)]; - var newscene = new SceneChunk(); - newscene.SNOHandle = new SNOHandle(SNOGroup.Scene, CurrentScene.SnoID); - newscene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), new Vector3D(X, Y, 0)); - newscene.SceneSpecification = new SceneSpecification(0, new Vector2D(0, 0), new int[4] { Rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : CurrentScene.LevelArea, Rift ? CurrentScene.LevelArea : -1, -1, -1 }, - -1, -1, -1, -1, -1, -1, CurrentScene.Music, -1, -1, -1, CurrentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)); + var newscene = new SceneChunk + { + SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID), + PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), new Vector3D(x, y, 0)), + SceneSpecification = new SceneSpecification(0, new Vector2D(0, 0), new int[4] { rift ? world.SNO != world.Game.WorldOfPortalNephalem ? 288684 : 288482 : currentScene.LevelArea, rift ? currentScene.LevelArea : -1, -1, -1 }, + -1, -1, -1, -1, -1, -1, currentScene.Music, -1, -1, -1, currentScene.Weather, -1, -1, -1, -1, -1, new SceneCachedValues(-1, -1, -1, new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new AABB(new Vector3D(-1, -1, -1), new Vector3D(-1, -1, -1)), new int[4] { 0, 0, 0, 0 }, 0)) + }; FillerChunks.Add(newscene); } - Busy = false; - Y += RangetoNext; + busy = false; + y += RangetoNext; } - Y = ReturnToMinY; - X += RangetoNext; + y = returnToMinY; + x += RangetoNext; } } world.worldData.SceneParams.ChunkCount = world.worldData.SceneParams.SceneChunks.Count; foreach (var fil in FillerChunks) { - world.worldData.SceneParams.SceneChunks.Add(fil); //Добавить сцену + world.worldData.SceneParams.SceneChunks.Add(fil); //Add scene } world.DRLGEmuActive = true; @@ -1796,7 +1790,6 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem /// private void AddFillers(Dictionary worldTiles, Dictionary tiles, int chunkSize) { - Dictionary fillersToAdd = new Dictionary(); foreach (var tile in worldTiles) { @@ -1860,7 +1853,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem //add adjacent tiles for each randomized direction foreach (var exit in randomizedExitTypes) { - if (GetTileInfo(tiles, (int)TileTypes.Normal, GetadjacentExitStatus(worldTiles, exit.Value, chunkSize), true) == null) return false; + if (GetTileInfo(tiles, (int)TileTypes.Normal, GetAdjacentExitStatus(worldTiles, exit.Value, chunkSize), true) == null) return false; } return true; } @@ -1884,7 +1877,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem } if (lookingForCork) incCounter = false; - Dictionary exitStatus = GetadjacentExitStatus(worldTiles, position, chunkSize); + Dictionary exitStatus = GetAdjacentExitStatus(worldTiles, position, chunkSize); if (counter > 5) //TODO: this value must be set according to difficulty { if (!ContainsTileType(worldTiles, TileTypes.Exit)) @@ -1952,7 +1945,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem /// /// Tiles already added to world /// Position - private Dictionary GetadjacentExitStatus(Dictionary worldTiles, Vector3D position, int chunkSize) + private Dictionary GetAdjacentExitStatus(Dictionary worldTiles, Vector3D position, int chunkSize) { Dictionary exitStatusDict = new Dictionary(); //Compute East adjacent Location @@ -1988,11 +1981,13 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem Vector3D positionSouth = new Vector3D(position.X, position.Y + chunkSize, 0); //get a random direction - Dictionary exitTypes = new Dictionary(); - exitTypes.Add(TileExits.East, positionEast); - exitTypes.Add(TileExits.West, positionWest); - exitTypes.Add(TileExits.North, positionNorth); - exitTypes.Add(TileExits.South, positionSouth); + Dictionary exitTypes = new Dictionary + { + { TileExits.East, positionEast }, + { TileExits.West, positionWest }, + { TileExits.North, positionNorth }, + { TileExits.South, positionSouth } + }; if (!isRandom) return exitTypes; @@ -2072,9 +2067,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem { //get all exits that need to be in the new tile int mustHaveExits = 0; - Dictionary acceptedTiles = new Dictionary(); - //By default use all tiles - acceptedTiles = tiles; + Dictionary acceptedTiles = tiles; foreach (TileExits exit in Enum.GetValues(typeof(TileExits))) { if (exitStatus[exit] == ExitStatus.Open) mustHaveExits += (int)exit; @@ -2087,15 +2080,12 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem } Logger.Trace("Looking for tile with Exits: {0}", mustHaveExits); if (isCork) - return GetTileInfo(acceptedTiles.Where( - pair => pair.Value.TileType == tileType //&& - //System.Enum.IsDefined(typeof(TileExits), pair.Value.ExitDirectionBits) - ).ToDictionary(pair => pair.Key, pair => pair.Value), mustHaveExits); - else - return GetTileInfo(acceptedTiles.Where( - pair => pair.Value.TileType == tileType && - !Enum.IsDefined(typeof(TileExits), pair.Value.ExitDirectionBits) - ).ToDictionary(pair => pair.Key, pair => pair.Value), mustHaveExits); + return GetTileInfo(acceptedTiles + .Where(pair => pair.Value.TileType == tileType) + .ToDictionary(pair => pair.Key, pair => pair.Value), mustHaveExits); + return GetTileInfo(acceptedTiles + .Where(pair => pair.Value.TileType == tileType && !Enum.IsDefined(typeof(TileExits), pair.Value.ExitDirectionBits)) + .ToDictionary(pair => pair.Key, pair => pair.Value), mustHaveExits); } /// @@ -2128,7 +2118,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem private TileInfo GetTile(Dictionary tiles, int snoId) { if (!tiles.ContainsKey(snoId)) return null; - return tiles.Where(x => x.Key == snoId).First().Value; + return tiles.First(x => x.Key == snoId).Value; } /// @@ -2150,56 +2140,65 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem //return filler return GetTileInfo(tiles, TileTypes.Filler); } - List tilesWithRightTypeAndDirection = new List(); + List tilesWithRightTypeAndDirection; if (tileType == TileTypes.Normal) - tilesWithRightTypeAndDirection = (from pair in tiles where ((pair.Value.TileType == 100 || pair.Value.TileType == 101 || pair.Value.TileType == 102) && pair.Value.ExitDirectionBits == exitDirectionBits) select pair.Value).ToList(); + tilesWithRightTypeAndDirection = (from pair in tiles where (pair.Value.TileType is 100 or 101 or 102 && pair.Value.ExitDirectionBits == exitDirectionBits) select pair.Value).ToList(); else tilesWithRightTypeAndDirection = (from pair in tiles where (pair.Value.TileType == (int)tileType && pair.Value.ExitDirectionBits == exitDirectionBits) select pair.Value).ToList(); - if (tilesWithRightTypeAndDirection.Count == 0) - { - Logger.Error("Did not find matching tile for template! Type: {0}, Direction: {1}", tileType, exitDirectionBits); - return null; - } + if (tilesWithRightTypeAndDirection.Any()) + return RandomHelper.RandomItem(tilesWithRightTypeAndDirection, entry => entry.Probability); + + Logger.Error("Did not find matching tile for template! Type: {0}, Direction: {1}", tileType, exitDirectionBits); + return null; - return RandomHelper.RandomItem(tilesWithRightTypeAndDirection, entry => entry.Probability); } private void AddTile(DiIiS_NA.Core.MPQ.FileFormats.World worldData, TileInfo tileInfo, Vector3D location) { - var sceneChunk = new SceneChunk(); - sceneChunk.SNOHandle = new SNOHandle(tileInfo.SNOScene); - sceneChunk.PRTransform = new PRTransform(); - sceneChunk.PRTransform.Quaternion = new Quaternion(); - sceneChunk.PRTransform.Quaternion.W = 1.0f; - sceneChunk.PRTransform.Quaternion.Vector3D = new Vector3D(0, 0, 0); - sceneChunk.PRTransform.Vector3D = new Vector3D(); + var sceneChunk = new SceneChunk + { + SNOHandle = new SNOHandle(tileInfo.SNOScene), + PRTransform = new PRTransform + { + Quaternion = new Quaternion + { + W = 1.0f, + Vector3D = new Vector3D(0, 0, 0) + }, + Vector3D = new Vector3D() + } + }; sceneChunk.PRTransform.Vector3D = location; - var spec = new SceneSpecification(); - //scene.Specification = spec; - spec.Cell = new Vector2D() { X = 0, Y = 0 }; - spec.CellZ = 0; - spec.SNOLevelAreas = new int[] { -1, -1, -1, -1 }; - spec.SNOMusic = -1; - spec.SNONextLevelArea = -1; - spec.SNONextWorld = -1; - spec.SNOPresetWorld = -1; - spec.SNOPrevLevelArea = -1; - spec.SNOPrevWorld = -1; - spec.SNOReverb = -1; - spec.SNOWeather = 50542; - spec.SNOCombatMusic = -1; - spec.SNOAmbient = -1; - spec.ClusterID = -1; - spec.PrevEntranceGUID = 14; - spec.DRLGIndex = 5; - spec.SceneChunk = -1; - spec.OnPathBits = tileInfo.TileType; //we can make it TileType value - spec.SceneCachedValues = new SceneCachedValues(); - spec.SceneCachedValues.CachedValuesValid = 63; - spec.SceneCachedValues.NavMeshSizeX = 96; - spec.SceneCachedValues.NavMeshSizeY = 96; + var spec = new SceneSpecification + { + //scene.Specification = spec; + Cell = new Vector2D() { X = 0, Y = 0 }, + CellZ = 0, + SNOLevelAreas = new[] { -1, -1, -1, -1 }, + SNOMusic = -1, + SNONextLevelArea = -1, + SNONextWorld = -1, + SNOPresetWorld = -1, + SNOPrevLevelArea = -1, + SNOPrevWorld = -1, + SNOReverb = -1, + SNOWeather = 50542, + SNOCombatMusic = -1, + SNOAmbient = -1, + ClusterID = -1, + PrevEntranceGUID = 14, + DRLGIndex = 5, + SceneChunk = -1, + OnPathBits = tileInfo.TileType, //we can make it TileType value + SceneCachedValues = new SceneCachedValues + { + CachedValuesValid = 63, + NavMeshSizeX = 96, + NavMeshSizeY = 96 + } + }; //Logger.Trace("Adding Tile: SNOscene {0}", tileInfo.SNOScene); var sceneFile = MPQStorage.Data.Assets[SNOGroup.Scene][tileInfo.SNOScene]; var sceneData = (DiIiS_NA.Core.MPQ.FileFormats.Scene)sceneFile.Data; @@ -2214,7 +2213,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem //System.Threading.Thread.Sleep(3); } - private static readonly Dictionary GizmosToSpawn = new Dictionary{ + private static readonly Dictionary GizmosToSpawn = new() + { {51300, 0.3f}, //chest common {138989, 0.3f}, //healthwell_global {176074, 0.06f}, //blessed @@ -2227,34 +2227,34 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem //135384, //shrine_global }; - private static readonly List Goblins = new List{ + private static readonly List Goblins = new() + { {5984}, {5985}, {5987}, {5988} }; - private Dictionary> LazyLevelAreas = new Dictionary>(); + private readonly Dictionary> _lazyLevelAreas = new(); /// /// Loads content for level areas. Call this after scenes have been generated and after scenes have their GizmoLocations /// set (this is done in Scene.LoadActors right now) + /// + /// Each Scene has one to four level areas assigned to it. I dont know if that means + /// the scene belongs to both level areas or if the scene is split + /// Scenes marker tags have generic GizmoLocationA to Z that are used + /// to provide random spawning possibilities. + /// For each of these 26 LocationGroups, the LevelArea has a entry in its SpawnType array that defines + /// what type of actor/encounter/adventure could spawn there + /// + /// It could for example define, that for a level area X, out of the four spawning options + /// two are randomly picked and have barrels placed there /// /// Dictionary that for every level area has the scenes it consists of /// The world to which to add loaded actors - private void loadLevelAreas(Dictionary> levelAreas, World world) + private void LoadLevelAreas(Dictionary> levelAreas, World world) { - /// Each Scene has one to four level areas assigned to it. I dont know if that means - /// the scene belongs to both level areas or if the scene is split - /// Scenes marker tags have generic GizmoLocationA to Z that are used - /// to provide random spawning possibilities. - /// For each of these 26 LocationGroups, the LevelArea has a entry in its SpawnType array that defines - /// what type of actor/encounter/adventure could spawn there - /// - /// It could for example define, that for a level area X, out of the four spawning options - /// two are randomly picked and have barrels placed there - - Dictionary dict = new Dictionary(); foreach (int la in levelAreas.Keys) { @@ -2339,9 +2339,9 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem foreach (var scene in levelAreas.First().Value) { if (!SpawnGenerator.Spawns.ContainsKey(wid)) break; - if (SpawnGenerator.Spawns[wid].lazy_load == true) + if (SpawnGenerator.Spawns[wid].lazy_load) { - LazyLevelAreas.Add(wid, levelAreas.First().Value); + _lazyLevelAreas.Add(wid, levelAreas.First().Value); break; } else @@ -2436,9 +2436,9 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem foreach (var scene in levelAreas[la]) { if (!SpawnGenerator.Spawns.ContainsKey(la)) break; - if (SpawnGenerator.Spawns[la].lazy_load == true) + if (SpawnGenerator.Spawns[la].lazy_load) { - LazyLevelAreas.Add(la, levelAreas[la]); + _lazyLevelAreas.Add(la, levelAreas[la]); break; } else diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/WorldObject.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/WorldObject.cs index c8c37dc..455da14 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/WorldObject.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/WorldObject.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem { - public abstract class WorldObject : DynamicObject, IRevealable + public abstract class WorldObject : DynamicObject, IRevealable, IDisposable { /// /// The world object belongs to. @@ -35,7 +35,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem /// public Vector3D Position { - get { return _position; } + get => _position; set { _position = value; @@ -108,14 +108,20 @@ namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem { try { - if (this is Actor) + if (this is Actor actor) if (World != null) - World.Leave(this as Actor); + World.Leave(actor); //this.World.EndTracking(this); } catch { } World = null; } + + + public void Dispose() + { + Destroy(); + } } } diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs index ce0c28f..b966555 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs @@ -316,7 +316,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem _activeHireling = value; } } - public Hireling SetQuestHireling + public Hireling QuestHireling { get { return _questHireling; } set