Пример #1
0
 def _set_exterior_house_description(self, house_descriptions):
     if not house_descriptions:
         return
     zone_ids = get_zone_ids_from_street(self._street)
     if not zone_ids:
         return
     distributor = Distributor.instance()
     persistence_service = services.get_persistence_service()
     for zone_id in zone_ids:
         zone_data = persistence_service.get_zone_proto_buff(zone_id)
         zone_world_description_id = services.get_world_description_id(
             zone_data.world_id)
         zone_lot_description_id = services.get_lot_description_id(
             zone_data.lot_id, zone_world_description_id)
         for (lot_description_id,
              house_description_id) in house_descriptions.items():
             if lot_description_id == zone_lot_description_id:
                 zone_data.pending_plex_exterior_house_desc_id = house_description_id
                 plex_update_msg = Lot_pb2.LotPlexExteriorUpdate()
                 plex_update_msg.zone_id = zone_id
                 plex_update_msg.plex_exterior_house_desc_id = house_description_id
                 distributor.add_event(
                     Consts_pb2.MSG_SET_PLEX_EXTERIOR_HOUSE_DESC,
                     plex_update_msg)
                 break
def print_venues(_connection=None):
    current_zone = services.current_zone()
    lot = current_zone.lot
    neighborhood_id = current_zone.neighborhood_id
    lot_description_id = services.get_lot_description_id(lot.lot_id)
    world_description_id = services.get_world_description_id(
        current_zone.world_id)
    neighborhood_description_id = services.get_persistence_service(
    ).get_neighborhood_proto_buff(neighborhood_id).region_id

    def print_line():
        sims4.commands.output('-' * 150, _connection)

    print_line()
    sims4.commands.output(
        'Current Game Stats: \nLot: {}\nWorld/Street: {}\nRegion/Neighborhood: {}'
        .format(lot_description_id, world_description_id,
                neighborhood_description_id), _connection)
    print_line()
    venue_manager = services.get_instance_manager(sims4.resources.Types.VENUE)
    venues = []
    for neighborhood_proto in services.get_persistence_service(
    ).get_neighborhoods_proto_buf_gen():
        for lot_owner_info in neighborhood_proto.lots:
            zone_id = lot_owner_info.zone_instance_id
            while zone_id is not None:
                venue_type_id = build_buy.get_current_venue(zone_id)
                venue_type = venue_manager.get(venue_type_id)
                if venue_type is not None:
                    log = PrintVenueLog._make(
                        (neighborhood_proto.name, neighborhood_proto.region_id,
                         lot_owner_info.lot_description_id, zone_id,
                         venue_type.__name__, lot_owner_info.lot_name))
                    venues.append(log)
    str_format = '{:20} ({:{center}15}) {:{center}20} {:15} ({:{center}20}) {:20}'

    def print_columns():
        sims4.commands.output(
            str_format.format('Neighborhood_Name',
                              'Neighborhood_ID',
                              'Lot_Description_ID',
                              'Zone_Instance_ID',
                              'Venue_Tuning_Name',
                              'Lot_Name',
                              center='^'), _connection)

    print_columns()
    print_line()
    for venue in sorted(venues):
        sims4.commands.output(
            str_format.format(venue.Neighborhood_Name,
                              venue.Neighborhood_ID,
                              venue.Lot_Description_ID,
                              venue.Zone_Instance_ID,
                              venue.Venue_Tuning_Name,
                              venue.Lot_Name,
                              center='^'), _connection)
    print_line()
    print_columns()
Пример #3
0
def generate_lot_info_data(*args, zone_id:int=None, filter=None, **kwargs):
    lot_infos = []
    current_zone = services.current_zone()
    lot = current_zone.lot
    neighborhood_id = current_zone.neighborhood_id
    lot_description_id = services.get_lot_description_id(lot.lot_id)
    world_description_id = services.get_world_description_id(current_zone.world_id)
    neighborhood_description_id = services.get_persistence_service().get_neighborhood_proto_buff(neighborhood_id).region_id
    venue_manager = services.get_instance_manager(sims4.resources.Types.VENUE)
    for neighborhood_proto in services.get_persistence_service().get_neighborhoods_proto_buf_gen():
        for lot_owner_info in neighborhood_proto.lots:
            zone_id = lot_owner_info.zone_instance_id
            while zone_id is not None:
                venue_type_id = build_buy.get_current_venue(zone_id)
                venue_type = venue_manager.get(venue_type_id)
                if venue_type is not None:
                    cur_info = {'neighborhood': neighborhood_proto.name, 'region_id': neighborhood_proto.region_id, 'lot_desc_id': lot_owner_info.lot_description_id, 'zone_id': zone_id, 'venue_type': venue_type.__name__, 'lot_name': lot_owner_info.lot_name, 'cur_lot': 'X' if lot_owner_info.zone_instance_id == lot.zone_id else ''}
                    lot_infos.append(cur_info)
    return lot_infos
Пример #4
0
 def get_plex_door_infos(self, force_refresh=False):
     if self._plex_door_infos and not force_refresh:
         return self._plex_door_infos
     plex_service = services.get_plex_service()
     doors = self._get_doors()
     plex_door_infos = set()
     for door in doors:
         (front_position, back_position) = door.get_door_positions()
         if front_position is None or back_position is None:
             logger.error("Door '{}' has broken portals.", door)
         else:
             front_zone_id = plex_service.get_plex_zone_at_position(
                 front_position, door.level)
             back_zone_id = plex_service.get_plex_zone_at_position(
                 back_position, door.level)
             if front_zone_id is None and back_zone_id is None:
                 current_zone = services.current_zone()
                 lot = current_zone.lot
                 world_description_id = services.get_world_description_id(
                     current_zone.world_id)
                 lot_description_id = services.get_lot_description_id(
                     lot.lot_id, world_description_id)
                 neighborhood_id = current_zone.neighborhood_id
                 neighborhood_data = services.get_persistence_service(
                 ).get_neighborhood_proto_buff(neighborhood_id)
                 if False and EXEMPT_DOOR_WORLD_DESCRIPTION_ID == world_description_id and EXEMPT_DOOR_LOT_DESCRIPTION_ID == lot_description_id:
                     continue
                 logger.error(
                     "Door isn't part of any plex. This will require WB fix. Door: {}, Lot desc id: {}, World desc id: {}. Neighborhood id: {}, Neighborhood Name: {}",
                     door, lot_description_id, world_description_id,
                     neighborhood_id, neighborhood_data.name)
             else:
                 if front_zone_id == back_zone_id:
                     continue
                 zone_id = front_zone_id or back_zone_id
                 is_backwards = front_zone_id is not None
                 info = PlexDoorInfo(door_id=door.id,
                                     zone_id=zone_id,
                                     is_backwards=is_backwards)
                 plex_door_infos.add(info)
     self._plex_door_infos = frozenset(plex_door_infos)
     return self._plex_door_infos
Пример #5
0
def print_venues(_connection=None):
    current_zone = services.current_zone()
    lot = current_zone.lot
    neighborhood_id = current_zone.neighborhood_id
    lot_description_id = services.get_lot_description_id(lot.lot_id)
    world_description_id = services.get_world_description_id(current_zone.world_id)
    neighborhood_description_id = services.get_persistence_service().get_neighborhood_proto_buff(neighborhood_id).region_id

    def print_line():
        sims4.commands.output('-'*150, _connection)

    print_line()
    sims4.commands.output('Current Game Stats: \nLot: {}\nWorld/Street: {}\nRegion/Neighborhood: {}'.format(lot_description_id, world_description_id, neighborhood_description_id), _connection)
    print_line()
    venue_manager = services.get_instance_manager(sims4.resources.Types.VENUE)
    venues = []
    for neighborhood_proto in services.get_persistence_service().get_neighborhoods_proto_buf_gen():
        for lot_owner_info in neighborhood_proto.lots:
            zone_id = lot_owner_info.zone_instance_id
            while zone_id is not None:
                venue_type_id = build_buy.get_current_venue(zone_id)
                venue_type = venue_manager.get(venue_type_id)
                if venue_type is not None:
                    log = PrintVenueLog._make((neighborhood_proto.name, neighborhood_proto.region_id, lot_owner_info.lot_description_id, zone_id, venue_type.__name__, lot_owner_info.lot_name))
                    venues.append(log)
    str_format = '{:20} ({:{center}15}) {:{center}20} {:15} ({:{center}20}) {:20}'

    def print_columns():
        sims4.commands.output(str_format.format('Neighborhood_Name', 'Neighborhood_ID', 'Lot_Description_ID', 'Zone_Instance_ID', 'Venue_Tuning_Name', 'Lot_Name', center='^'), _connection)

    print_columns()
    print_line()
    for venue in sorted(venues):
        sims4.commands.output(str_format.format(venue.Neighborhood_Name, venue.Neighborhood_ID, venue.Lot_Description_ID, venue.Zone_Instance_ID, venue.Venue_Tuning_Name, venue.Lot_Name, center='^'), _connection)
    print_line()
    print_columns()
Пример #6
0
 def _fix_up_for_apartments(self):
     plex_door_infos = self.get_plex_door_infos(force_refresh=True)
     backward_doors = set()
     active_zone_id = services.current_zone_id()
     object_manager = services.object_manager()
     plex_doors = []
     for info in plex_door_infos:
         household_id = services.get_persistence_service(
         ).get_household_id_from_zone_id(info.zone_id)
         door = object_manager.get(info.door_id)
         if door is None:
             logger.error('Plex Door {} does not exist.',
                          info.door_id,
                          owner='rmccord')
         else:
             if info.is_backwards:
                 backward_doors.add(door)
                 current_zone = services.current_zone()
                 lot = current_zone.lot
                 world_description_id = services.get_world_description_id(
                     current_zone.world_id)
                 lot_description_id = services.get_lot_description_id(
                     lot.lot_id, world_description_id)
                 neighborhood_id = current_zone.neighborhood_id
                 neighborhood_data = services.get_persistence_service(
                 ).get_neighborhood_proto_buff(neighborhood_id)
                 logger.error(
                     'For WB: An apartment door facing the common area needs to be flipped. Lot desc id: {}, World desc id: {}. Neighborhood id: {}, Neighborhood Name: {}',
                     lot_description_id, world_description_id,
                     neighborhood_id, neighborhood_data.name)
             door.set_household_owner_id(household_id)
             if info.zone_id == active_zone_id:
                 plex_doors.append(door)
             else:
                 door.set_inactive_apartment_door_status(True)
     self._flip_backward_doors(backward_doors)
     if not plex_doors:
         return
     if len(plex_doors) == 1:
         self.set_as_front_door(plex_doors[0])
         return
     logger.warn(
         "plex zone_id: {} has multiple potential front doors: {}, can lead to sims able to access areas they shouldn't",
         active_zone_id, plex_doors)
     best_door = None
     best_distance = None
     connections = self._get_door_connections_from_arrival(
         plex_doors, is_apartment=True)
     for (_, handle, distance) in connections:
         if not best_distance is None:
             if best_distance < distance:
                 best_door = handle.door
                 best_distance = distance
         best_door = handle.door
         best_distance = distance
     if best_door is None:
         logger.error(
             'Unable to route to plex doors in zone_id: {} potential doors: {}',
             active_zone_id, plex_doors)
         self.set_as_front_door(plex_doors[0])
         return
     self.set_as_front_door(best_door)