public void ConnectPortalsToTargetZonesByLocation()
{
// go through every zone to find portals
bool foundMatch;
foreach ( PCZone zone in zones )
{
// go through all the portals in the zone
foreach ( Portal portal in zone.mPortals )
{
//portal->updateDerivedValues();
if ( null == portal.getTargetZone() )
{
// this is a portal without a connected zone - look for
// a matching portal in another zone
PCZone zone2;
foundMatch = false;
int j = 0;
while ( !foundMatch && j != zones.Count )
{
zone2 = zones[ j++ ];
if ( zone2 != zone ) // make sure we don't look in the same zone
{
Portal portal2 = zone2.FindMatchingPortal( portal );
if ( null != portal2 )
{
// found a match!
LogManager.Instance.Write( "Connecting portal " + portal.getName() + " to portal " + portal2.getName() );
foundMatch = true;
portal.setTargetZone( zone2 );
portal.setTargetPortal( portal2 );
portal2.setTargetZone( zone );
portal2.setTargetPortal( portal );
}
}
}
if ( foundMatch == false )
{
// error, didn't find a matching portal!
throw new AxiomException( "Could not find matching portal for portal " + portal.getName() +
"PCZSceneManager.connectPortalsToTargetZonesByLocation" );
}
}
}
}
}