private void DetermineExits() { if (!Game1.IsMasterGame) { throw new ApplicationException("Illegal call to DeepWoods.DetermineExits() in client."); } this.exits.Clear(); List <ExitDirection> possibleExitDirs = AllExitDirsBut(CastEnterDirToExitDir(this.EnterDir)); int numExitDirs = Game1.random.Next(1, 4); if (numExitDirs < 3) { possibleExitDirs.RemoveAt(Game1.random.Next(0, possibleExitDirs.Count)); if (numExitDirs < 2) { possibleExitDirs.RemoveAt(Game1.random.Next(0, possibleExitDirs.Count)); } } foreach (ExitDirection exitDir in possibleExitDirs) { this.exits.Add( new DeepWoodsExit( this, exitDir, new DeepWoodsSpaceManager(this.mapWidth.Value, this.mapHeight.Value).GetRandomExitLocation(exitDir, new DeepWoodsRandom(this, this.seed ^ Game1.currentGameTime.TotalGameTime.Milliseconds ^ Game1.random.Next())) ) { TargetLocationName = "DeepWoods_" + DeepWoodsRandom.CalculateSeed(level + 1, ExitDirToEnterDir(exitDir), Seed) } ); } }
public DeepWoods(DeepWoods parent, int level, EnterDirection enterDir) : this() { base.isOutdoors.Value = true; base.ignoreDebrisWeather.Value = true; base.ignoreOutdoorLighting.Value = true; this.hasReceivedNetworkData.Value = true; this.uniqueMultiplayerID.Value = Game1.MasterPlayer.UniqueMultiplayerID; this.seed = DeepWoodsRandom.CalculateSeed(level, enterDir, parent?.Seed); if (level == 1) { base.name.Value = "DeepWoods"; } else { base.name.Value = "DeepWoods_" + this.seed; } this.parentName.Value = parent?.Name; this.ParentExitLocation = parent?.GetExit(EnterDirToExitDir(enterDir))?.Location ?? new Location(); this.level.Value = level; DeepWoodsState.LowestLevelReached = Math.Max(DeepWoodsState.LowestLevelReached, this.level.Value - 1); this.EnterDir = enterDir; this.spawnTime.Value = Game1.timeOfDay; this.spawnedFromObelisk.Value = parent?.spawnedFromObelisk?.Value ?? false; ModEntry.GetAPI().CallOnCreate(this); CreateSpace(); DetermineExits(); updateMap(); ModEntry.GetAPI().CallBeforeFill(this); if ((this.isLichtung.Value && this.lichtungHasLake.Value) || !ModEntry.GetAPI().CallOverrideFill(this)) { DeepWoodsStuffCreator.AddStuff(this, new DeepWoodsRandom(this, this.seed ^ Game1.currentGameTime.TotalGameTime.Milliseconds ^ Game1.random.Next())); } ModEntry.GetAPI().CallAfterFill(this); ModEntry.GetAPI().CallBeforeMonsterGeneration(this); if (!ModEntry.GetAPI().CallOverrideMonsterGeneration(this)) { DeepWoodsMonsters.AddMonsters(this, new DeepWoodsRandom(this, this.seed ^ Game1.currentGameTime.TotalGameTime.Milliseconds ^ Game1.random.Next())); } ModEntry.GetAPI().CallAfterMonsterGeneration(this); if (parent == null && level > 1 && !this.HasExit(CastEnterDirToExitDir(this.EnterDir))) { this.exits.Add(new DeepWoodsExit(this, CastEnterDirToExitDir(this.EnterDir), this.EnterLocation)); } if (parent != null) { ModEntry.Log($"Child spawned, time: {Game1.timeOfDay}, name: {this.Name}, level: {this.level}, parent: {this.parentName}, enterDir: {this.EnterDir}, enterLocation: {this.EnterLocation.X}, {this.EnterLocation.Y}", LogLevel.Trace); } }