private bool MakeValid() { bool madeChanges = false; int maxLevels = Level.INIT_LID_FOR_WORLD.Last(); this.CurrentLevel = (int)MathHelper.Clamp(this.CurrentLevel, 0, maxLevels); if (LevelStatistics == null) { this.LevelStatistics = new Statistics[maxLevels]; madeChanges = true; } if (LevelStatistics.Length < maxLevels) { var stats = LevelStatistics.ToList(); stats.AddRange(new Statistics[maxLevels - LevelStatistics.Length]); LevelStatistics = stats.ToArray(); madeChanges = true; } else if (LevelStatistics.Length > maxLevels) { this.LevelStatistics = LevelStatistics.Take(maxLevels).ToArray(); madeChanges = true; } if (Name == null || this.Name.Length <= 0) { this.Name = "No Namer"; madeChanges = true; } if (this.Audio == null) { this.Audio = new AudioSettings(); madeChanges = true; } if (this.Graphics == null) { this.Graphics = new GraphicsSettings(); madeChanges = true; } if (this.KeyBindings == null) { this.KeyBindings = new Keybindings(); madeChanges = true; } return !madeChanges; }
private bool MakeValid() { bool madeChanges = false; this.CurrentLevel = (int)MathHelper.Clamp(this.CurrentLevel, 0, Level.MAX_LEVELS - 1); if (LevelStatistics == null) { this.LevelStatistics = new Statistics[Level.MAX_LEVELS]; madeChanges = true; } if (LevelStatistics.Length < Level.MAX_LEVELS) { this.LevelStatistics = LevelStatistics.Union(new Statistics[Level.MAX_LEVELS - LevelStatistics.Length]).ToArray(); madeChanges = true; } else if (LevelStatistics.Length > Level.MAX_LEVELS) { this.LevelStatistics = LevelStatistics.Take(Level.MAX_LEVELS).ToArray(); madeChanges = true; } if (Name == null || this.Name.Length <= 0) { this.Name = " "; madeChanges = true; } if (this.Audio == null) { this.Audio = new AudioSettings(); madeChanges = true; } if (this.Graphics == null) { this.Graphics = new GraphicsSettings(); madeChanges = true; } if (this.KeyBindings == null) { this.KeyBindings = new Keybindings(); madeChanges = true; } return !madeChanges; }