public void Clean(Game game) { foreach (var component in LevelComponents.Where(b => b.GameId == game.Id)) { LevelComponents.Remove(component); } foreach (var branch in Branches.Where(b => b.GameId == game.Id)) { Branches.Remove(branch); } foreach (var logEntry in LogEntries.Where(e => e.GameId == game.Id)) { LogEntries.Remove(logEntry); } foreach (var playerCommand in PlayerCommands.Where(b => b.GameId == game.Id)) { PlayerCommands.Remove(playerCommand); } foreach (var abilityComponent in AbilityComponents.Where(b => b.GameId == game.Id)) { AbilityComponents.Remove(abilityComponent); } foreach (var aiComponent in AIComponents.Where(b => b.GameId == game.Id)) { AIComponents.Remove(aiComponent); } foreach (var playerComponent in PlayerComponents.Where(b => b.GameId == game.Id)) { PlayerComponents.Remove(playerComponent); } foreach (var beingComponent in BeingComponents.Where(b => b.GameId == game.Id)) { BeingComponents.Remove(beingComponent); } foreach (var physicalComponent in PhysicalComponents.Where(b => b.GameId == game.Id)) { PhysicalComponents.Remove(physicalComponent); } foreach (var raceComponent in RaceComponents.Where(b => b.GameId == game.Id)) { RaceComponents.Remove(raceComponent); } foreach (var effectComponent in EffectComponents.Where(b => b.GameId == game.Id)) { EffectComponents.Remove(effectComponent); } foreach (var itemComponent in ItemComponents.Where(b => b.GameId == game.Id)) { ItemComponents.Remove(itemComponent); } foreach (var knowledgeComponent in KnowledgeComponents.Where(b => b.GameId == game.Id)) { KnowledgeComponents.Remove(knowledgeComponent); } foreach (var connectionComponent in ConnectionComponents.Where(b => b.GameId == game.Id)) { ConnectionComponents.Remove(connectionComponent); } foreach (var positionComponent in PositionComponents.Where(b => b.GameId == game.Id)) { PositionComponents.Remove(positionComponent); } foreach (var sensorComponent in SensorComponents.Where(b => b.GameId == game.Id)) { SensorComponents.Remove(sensorComponent); } game.ActingPlayerId = null; SaveChanges(); Games.Remove(game); SaveChanges(); }