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) } ); } }
private void CreateSpace() { if (!Game1.IsMasterGame) { throw new ApplicationException("Illegal call to DeepWoods.CreateSpace in client."); } var random = new DeepWoodsRandom(this, this.Seed ^ Game1.currentGameTime.TotalGameTime.Milliseconds ^ Game1.random.Next()); if (!this.isLichtungSetByAPI.Value) { this.isLichtung.Value = this.level.Value >= Settings.Level.MinLevelForClearing && !(this.Parent?.isLichtung ?? true) && random.CheckChance(Settings.Luck.Clearings.ChanceForClearing); } if (!this.isMapSizeSetByAPI.Value) { if (this.isLichtung.Value) { this.mapWidth.Value = Game1.random.Next(Settings.Map.MinMapWidth, Settings.Map.MaxMapWidthForClearing); this.mapHeight.Value = Game1.random.Next(Settings.Map.MinMapWidth, Settings.Map.MaxMapWidthForClearing); this.lichtungHasLake.Value = random.GetRandomValue(Settings.Luck.Clearings.Perks) == LichtungStuff.Lake; } else { this.mapWidth.Value = Game1.random.Next(Settings.Map.MinMapWidth, Settings.Map.MaxMapWidth); this.mapHeight.Value = Game1.random.Next(Settings.Map.MinMapHeight, Settings.Map.MaxMapHeight); } } this.EnterLocation = this.level.Value == 1 ? Settings.Map.RootLevelEnterLocation : new DeepWoodsSpaceManager(this.mapWidth.Value, this.mapHeight.Value).GetRandomEnterLocation(this.EnterDir, random); }
public Location GetRandomEnterLocation(EnterDirection enterDir, DeepWoodsRandom random) { int x, y; if (enterDir == EnterDirection.FROM_BOTTOM || enterDir == EnterDirection.FROM_TOP) { x = random.GetRandomValue(Settings.Map.MinCornerDistanceForEnterLocation, this.mapWidth - Settings.Map.MinCornerDistanceForEnterLocation); if (enterDir == EnterDirection.FROM_BOTTOM) { y = this.mapHeight - 1; } else { y = 0; } } else { y = random.GetRandomValue(Settings.Map.MinCornerDistanceForEnterLocation, this.mapHeight - Settings.Map.MinCornerDistanceForEnterLocation); if (enterDir == EnterDirection.FROM_RIGHT) { x = this.mapWidth - 1; } else { x = 0; } } return(new Location(x, y)); }
private int GetRandomFoodType(DeepWoods deepWoods) { if (random == null) { random = new DeepWoodsRandom(deepWoods, (deepWoods?.Seed ?? Game1.random.Next()) ^ Game1.currentGameTime.TotalGameTime.Milliseconds ^ (int)this.tile.X ^ (int)this.tile.Y); } return(random.GetRandomValue(Settings.Objects.GingerBreadHouse.FootItems)); }
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); } }
public Location GetRandomExitLocation(ExitDirection exitDir, DeepWoodsRandom random) { if (exitDir == ExitDirection.BOTTOM) { return(GetRandomEnterLocation(EnterDirection.FROM_BOTTOM, random)); } else if (exitDir == ExitDirection.LEFT) { return(GetRandomEnterLocation(EnterDirection.FROM_LEFT, random)); } else if (exitDir == ExitDirection.RIGHT) { return(GetRandomEnterLocation(EnterDirection.FROM_RIGHT, random)); } else { return(GetRandomEnterLocation(EnterDirection.FROM_TOP, random)); } }
public static void AddMonsters(DeepWoods deepWoods, DeepWoodsRandom random) { new DeepWoodsMonsters(deepWoods, random).AddMonsters(); }
private DeepWoodsMonsters(DeepWoods deepWoods, DeepWoodsRandom random) { this.deepWoods = deepWoods; this.random = random; }
public static void AddStuff(DeepWoods deepWoods, DeepWoodsRandom random) { DeepWoodsSpaceManager spaceManager = new DeepWoodsSpaceManager(deepWoods.mapWidth.Value, deepWoods.mapHeight.Value); new DeepWoodsStuffCreator(deepWoods, random, spaceManager).ClearAndAddStuff(); }
private DeepWoodsStuffCreator(DeepWoods deepWoods, DeepWoodsRandom random, DeepWoodsSpaceManager spaceManager) { this.deepWoods = deepWoods; this.random = random; this.spaceManager = spaceManager; }