public Dungeon(long instanceId, string dungeonName, int itemId, int seed, int floorPlan, Creature creature)
{
dungeonName = dungeonName.ToLower();
Log.Debug("Dungeon: Creating '{0}', item id: {1}, seed: {2}, floorPlan: {3}", dungeonName, itemId, seed, floorPlan);
// Get data
this.Data = AuraData.DungeonDb.Find(dungeonName);
if (this.Data == null)
throw new ArgumentException("Dungeon '" + dungeonName + "' doesn't exist.");
_treasureChests = new List<Prop>();
_treasurePlacementProvider = new PlacementProvider(Placement.Treasure8, 750);
this.Regions = new List<DungeonRegion>();
_clearedSections = new HashSet<int>();
this.InstanceId = instanceId;
this.Name = dungeonName;
this.ItemId = itemId;
this.Seed = seed;
this.FloorPlan = floorPlan;
this.Options = XElement.Parse("<option />");
this.Creators = new List<long>();
this.RpCharacters = new List<long>();
this.PartyLeader = creature;
// Only creatures who actually ENTER the dungeon at creation are considered "dungeon founders".
this.Creators.AddRange(creature.Party.GetCreaturesOnAltar(creature.RegionId).Select(a => a.EntityId));
// Add the creator to the list if something went wrong on the altar check.
if (this.Creators.Count == 0)
this.Creators.Add(creature.EntityId);
// Get script
this.Script = ChannelServer.Instance.ScriptManager.DungeonScripts.Get(this.Name);
if (this.Script == null)
Log.Warning("Dungeon: No script found for '{0}'.", this.Name);
// Generate floors
this.Generator = new DungeonGenerator(this.Name, this.ItemId, this.Seed, this.FloorPlan, this.Options.ToString());
// Prepare puzzles
for (int iFloor = 0; iFloor < this.Generator.Floors.Count; ++iFloor)
this.GeneratePuzzles(iFloor);
this.GenerateRegions();
}