public override void UpdatePortalsZoneData()
{
List<Portal> transferPortalList = new List<Portal>();
// check each portal to see if it's intersecting another portal of greater size
foreach ( Portal p in mPortals )
{
Real pRadius = p.getRadius();
// First we check against portals in the SAME zone (and only if they have a
// target zone different from the home zone)
foreach ( Portal p2 in mPortals )
{
// only check against bigger portals (this will also prevent checking against self)
// and only against portals which point to another zone
if ( pRadius < p2.getRadius() && p2.getTargetZone() != this )
{
// Portal#2 is bigger than Portal1, check for crossing
if ( p.crossedPortal( p2 ) && p.getCurrentHomeZone() != p2.getTargetZone() )
{
// portal#1 crossed portal#2 - flag portal#1 to be moved to portal#2's target zone
p.setNewHomeZone( p2.getTargetZone() );
transferPortalList.Add( p );
break;
}
}
}
// Second we check against portals in the target zone (and only if that target
// zone is different from the home zone)
PCZone tzone = p.getTargetZone();
if ( tzone != this )
{
foreach ( Portal p3 in mPortals )
{
// only check against bigger portals
if ( pRadius < p3.getRadius() )
{
// Portal#3 is bigger than Portal#1, check for crossing
if ( p.crossedPortal( p3 ) &&
p.getCurrentHomeZone() != p3.getTargetZone() )
{
// Portal#1 crossed Portal#3 - switch target zones for Portal#1
p.setTargetZone( p3.getTargetZone() );
break;
}
}
}
}
}
// transfer any portals to new zones that have been flagged
foreach ( Portal p in transferPortalList )
{
if ( null != p.getNewHomeZone() )
{
RemovePortal( p );
p.getNewHomeZone().AddPortal( p );
p.setNewHomeZone( null );
}
}
transferPortalList.Clear();
}