/// <summary> /// Constructs a new zone instances with the given properties. /// </summary> /// <param name="id">Numeric ID of zone.</param> /// <param name="parent_id">Numeric ID of parent zone.</param> /// <param name="child_zone_1_id">Numeric ID of child zone 1.</param> /// <param name="child_zone_2_id">Numeric ID of child zone 2.</param> /// <param name="split_orientation">Orientation of split for this zone.</param> public Zone(int id, int parent_id, int child_zone_1_id, int child_zone_2_id, ZoneSplitOrientation split_orientation) { m_id = id; m_parent_id = parent_id; m_child_zone_1_id = child_zone_1_id; m_child_zone_2_id = child_zone_2_id; m_split_orientation = split_orientation; }
/// <summary> /// Adds a new zone to the grid with the given settings. The zone /// is not propogated until SaveZones() is called. /// </summary> /// <param name="child_1_zone">Child zone one if split, null if not split.</param> /// <param name="child_2_zone">Child zone two if split, null if not split.</param> /// <param name="split">Split type of zone.</param> /// <returns>Returns the zone that was added.</returns> private Zone AddZone(Zone parentZone, Zone child_1_zone, Zone child_2_zone, ZoneSplitOrientation split) { Zone zone = new Zone(0, 0, 0, 0, split); zone.ChildZone1 = child_1_zone; zone.ChildZone2 = child_2_zone; zone.Parent = parentZone; if (zone.ChildZone1 != null) { zone.ChildZone1ID = zone.ChildZone1.ID; } if (zone.ChildZone2 != null) { zone.ChildZone2ID = zone.ChildZone2.ID; } if (zone.Parent != null) { zone.ParentID = zone.Parent.ID; } // We need to generate a unique ID for this zone. // This will get overriden when we commit to the database, but it allows us // to differentiate until then. int id = int.MinValue; while (true) { if (m_zoneGrid.GetZoneByID(id) == null) { break; } id++; } zone.ID = id; m_zoneGrid.AddZone(zone); return zone; }