@@ -1220,12 +1220,40 @@ public static bool IsHere(this AddressBookEntry entry)
12201220 }
12211221 if ( entry . PropertyType == PropertyType . Apartment )
12221222 {
1223- if ( entry . ApartmentSubdivision && h ->GetCurrentDivision ( ) != 2 ) return false ;
1223+ // Better logic for subdivision detection
1224+ if ( ! ( entry . ApartmentSubdivision == ( ( h ->IsInside ( ) ? h ->GetCurrentHouseId ( ) . Unit . ApartmentDivision : h ->GetCurrentDivision ( ) - 1 ) == 1 ) ) ) return false ;
12241225 return entry . Apartment == h ->GetCurrentRoom ( ) ;
12251226 }
12261227 return false ;
12271228 }
12281229
1230+ // A version of IsHere that is not strict about if we are indoors or not for apartments.
1231+ public static bool IsAtAddress ( this AddressBookEntry entry )
1232+ {
1233+ var h = HousingManager . Instance ( ) ;
1234+ if ( h == null ) return false ;
1235+ if ( h ->GetCurrentWard ( ) != entry . Ward - 1 ) return false ;
1236+ if ( GetResidentialAetheryteByTerritoryType ( P . Territory ) != entry . City ) return false ;
1237+ if ( entry . PropertyType is PropertyType . House )
1238+ {
1239+ return h ->GetCurrentPlot ( ) == entry . Plot - 1 ;
1240+ }
1241+ else
1242+ {
1243+ return entry . ApartmentSubdivision == ( ( h ->IsInside ( ) ? h ->GetCurrentHouseId ( ) . Unit . ApartmentDivision : h ->GetCurrentDivision ( ) - 1 ) == 1 ) ;
1244+ }
1245+ }
1246+
1247+ // Determines the other half of IsHere that IsAtAddress doesnt check.
1248+ // Can determine if it does the full IsHere logic or not with checkAddress.
1249+ public static bool IsInsideApartment ( this AddressBookEntry entry , bool checkAddress )
1250+ {
1251+ if ( entry . PropertyType == PropertyType . House ) return false ;
1252+ if ( checkAddress && ! IsAtAddress ( entry ) ) return false ;
1253+ var h = HousingManager . Instance ( ) ;
1254+ return h != null && h ->IsInside ( ) && h ->GetCurrentRoom ( ) == entry . Apartment ;
1255+ }
1256+
12291257 public static bool IsQuickTravelAvailable ( this AddressBookEntry entry )
12301258 {
12311259 if ( S . Data . ResidentialAethernet . HousingData . Data . SafeSelect ( entry . City . GetResidentialTerritory ( ) ) ? . SafeSelect ( entry . Ward - 1 ) ? . AethernetID . EqualsAny ( ResidentialAethernet . StartingAetherytes ) != false ) return false ;
@@ -1245,7 +1273,34 @@ public static void GoTo(this AddressBookEntry entry)
12451273 Notify . Error ( $ "Can not travel to { ExcelWorldHelper . GetName ( entry . World ) } ") ;
12461274 return ;
12471275 }
1248- if ( entry . IsQuickTravelAvailable ( ) )
1276+ // Check first if already at our destination.
1277+ if ( IsAtAddress ( entry ) )
1278+ {
1279+ // We dont need to do anything if at our house, but if at our address we do.
1280+ if ( entry . PropertyType == PropertyType . House )
1281+ {
1282+ return ;
1283+ }
1284+ else if ( entry . PropertyType == PropertyType . Apartment )
1285+ {
1286+ if ( IsInsideApartment ( entry , false ) )
1287+ {
1288+ return ;
1289+ }
1290+ // We were infront of the apartment, so attempt the automation from the door. If it fails, fallback
1291+ else if ( TaskApproachAndInteractWithApartmentEntrance . TargetApartmentEntrance ( ) )
1292+ {
1293+ TaskApproachAndInteractWithApartmentEntrance . Enqueue ( false ) ;
1294+ P . TaskManager . Enqueue ( TaskTpAndGoToWard . SelectGoToSpecifiedApartment ) ;
1295+ P . TaskManager . Enqueue ( ( ) => TaskTpAndGoToWard . SelectApartment ( entry . Apartment - 1 ) , $ "SelectApartment { entry . Apartment - 1 } ") ;
1296+ if ( ! C . AddressApartmentNoEntry ) P . TaskManager . Enqueue ( TaskTpAndGoToWard . ConfirmApartmentEnterYesno ) ;
1297+ return ;
1298+ }
1299+ }
1300+ }
1301+
1302+ // Do not else if this as the above may need to flow down to these logic.
1303+ if ( entry . IsQuickTravelAvailable ( ) )
12491304 {
12501305 if ( entry . PropertyType == PropertyType . House )
12511306 {
0 commit comments