예제 #1
0
 def load_zone(self):
     zone_data_proto = self._get_zone_proto()
     self.neighborhood_id = zone_data_proto.neighborhood_id
     self.open_street_id = zone_data_proto.world_id
     self.service_manager.load_all_services(zone_data=zone_data_proto)
     self._first_visit_to_zone = not protocol_buffer_utils.has_field(
         zone_data_proto.gameplay_zone_data, 'venue_type_id_on_save')
     open_street_data = services.get_persistence_service(
     ).get_open_street_proto_buff(self.open_street_id)
     if open_street_data is not None:
         self._time_of_last_open_street_save = DateAndTime(
             open_street_data.sim_time_on_save)
     spawn_points = {}
     if zone_data_proto.spawn_point_ids:
         for (index,
              spawn_point_id) in enumerate(zone_data_proto.spawn_point_ids):
             spawn_point = self._spawner_data[index]
             spawn_point.spawn_point_id = spawn_point_id
             spawn_points[spawn_point_id] = spawn_point
     else:
         for (index, spawn_point) in enumerate(self._spawner_data.values()):
             spawn_point_id = id_generator.generate_object_id()
             spawn_point.spawn_point_id = spawn_point_id
             spawn_points[spawn_point_id] = spawn_point
     self._spawner_data = spawn_points
     self.lot.load(zone_data_proto.gameplay_zone_data)
     for spawn_point in self._spawner_data.values():
         while spawn_point.has_tag(
                 SpawnPoint.
                 ARRIVAL_SPAWN_POINT_TAG) and spawn_point.lot_id == self.lot.lot_id:
             self._active_lot_arrival_spawn_point = spawn_point
     return True
예제 #2
0
 def load(self, **_):
     if self.RELGRAPH_ENABLED:
         save_slot_data_msg = services.get_persistence_service(
         ).get_save_slot_proto_buff()
         relgraph_service_data = save_slot_data_msg.gameplay_data.relgraph_service
         if protocol_buffer_utils.has_field(relgraph_service_data,
                                            'relgraph_data'):
             self.relgraph_set(relgraph_service_data.relgraph_data)
예제 #3
0
 def is_relgraph_initialized(cls):
     if cls.RELGRAPH_ENABLED:
         save_slot_data_msg = services.get_persistence_service(
         ).get_save_slot_proto_buff()
         relgraph_service_data = save_slot_data_msg.gameplay_data.relgraph_service
         return protocol_buffer_utils.has_field(relgraph_service_data,
                                                'relgraph_data')
     else:
         return False
예제 #4
0
 def venue_type_changed_between_save_and_load(self):
     zone_data_proto = self._get_zone_proto()
     if zone_data_proto is None or self.venue_service.venue is None:
         return False
     gameplay_zone_data = zone_data_proto.gameplay_zone_data
     if not protocol_buffer_utils.has_field(gameplay_zone_data,
                                            'venue_type_id_on_save'):
         return False
     return False
예제 #5
0
 def lot_owner_household_changed_between_save_and_load(self):
     zone_data_proto = self._get_zone_proto()
     if zone_data_proto is None or self.lot is None:
         return False
     gameplay_zone_data = zone_data_proto.gameplay_zone_data
     if not protocol_buffer_utils.has_field(
             gameplay_zone_data, 'lot_owner_household_id_on_save'):
         return False
     return gameplay_zone_data.lot_owner_household_id_on_save != self.lot.owner_household_id
예제 #6
0
 def active_household_changed_between_save_and_load(self):
     zone_data_proto = self._get_zone_proto()
     if zone_data_proto is None:
         return False
     gameplay_zone_data = zone_data_proto.gameplay_zone_data
     if not protocol_buffer_utils.has_field(gameplay_zone_data,
                                            'active_household_id_on_save'):
         return False
     return gameplay_zone_data.active_household_id_on_save != services.active_household_id(
     )
예제 #7
0
def recommend_order_for_table(sim_orders: str, _connection=None):
    zone_director = get_restaurant_zone_director()
    if zone_director is None:
        sims4.commands.output('Current venue is not restaurant', _connection)
        return False
    proto = Restaurant_pb2.SimOrders()
    text_format.Merge(sim_orders, proto)
    orders = [(order.sim_id, order.recipe_id) for order in proto.sim_orders]
    sims_in_order = set([
        services.object_manager().get(order_sim_id)
        for order_sim_id in [order[0] for order in orders]
    ])
    for sim in sims_in_order:
        if sim is None:
            sims4.commands.output(
                "Trying to target order for a Sim that isn't on the lot",
                _connection)
            return False
        active_group_order = _get_active_group_order_for_dining_group(sim)
    if active_group_order:
        recipe_manager = services.get_instance_manager(
            sims4.resources.Types.RECIPE)
        for order in orders:
            recipe = recipe_manager.get(order[1])
            recipes = GroupOrder.get_food_drink_recipe_id_tuple(recipe)
            active_group_order.add_sim_order(
                order[0],
                food_recipe_id=recipes[0],
                drink_recipe_id=recipes[1],
                recommendation_state=OrderRecommendationState.
                RECOMMENDATION_PROPOSAL,
                order_status=OrderStatus.ORDER_INIT)
    else:
        zone_director.order_for_table(
            orders,
            send_order=False,
            recommendation_state=OrderRecommendationState.
            RECOMMENDATION_PROPOSAL,
            order_status=OrderStatus.ORDER_INIT)
    groups = zone_director.get_dining_groups_by_sim(sim)
    group = groups.pop()
    group.hold_ordered_cost(
        proto.meal_cost if has_field(proto, 'meal_cost') else 0)
    for sim in sims_in_order:
        zone_director.trigger_recommendation_interaction(
            services.get_active_sim(), sim)
    return True
예제 #8
0
 def update_household_objects_ownership(self):
     zone_data_proto = self._get_zone_proto()
     if zone_data_proto is None:
         return
     venue_instance = self.venue_service.venue
     if venue_instance is None or not venue_instance.venue_requires_front_door:
         return
     if self.lot.owner_household_id == 0:
         self._set_zone_objects_household_owner_id(None)
     elif self.lot.owner_household_id == services.active_household_id():
         gameplay_zone_data = zone_data_proto.gameplay_zone_data
         if not protocol_buffer_utils.has_field(
                 gameplay_zone_data,
                 'active_household_id_on_save') or gameplay_zone_data.lot_owner_household_id_on_save != services.active_household_id(
                 ):
             self._set_zone_objects_household_owner_id(
                 services.active_household_id())
예제 #9
0
def order_for_table(sim_orders: str, _connection=None):
    zone_director = get_restaurant_zone_director()
    if zone_director is None:
        sims4.commands.output('Current venue is not restaurant', _connection)
        return False
    proto = Restaurant_pb2.SimOrders()
    text_format.Merge(sim_orders, proto)
    orders = [(order.sim_id, order.recipe_id) for order in proto.sim_orders]
    sim = services.object_manager().get(orders[0][0])
    if sim is None:
        sims4.commands.output(
            "Trying to order for a Sim that isn't on the lot", _connection)
        return False
    zone_director.order_for_table(orders)
    groups = zone_director.get_dining_groups_by_sim(sim)
    group = groups.pop()
    group.hold_ordered_cost(
        proto.meal_cost if has_field(proto, 'meal_cost') else 0)
    return True
예제 #10
0
 def load_from_career_event_data_proto(self, proto):
     self._event_situation_id = proto.event_situation_id
     if has_field(proto, 'required_zone_id'):
         self._required_zone_id = proto.required_zone_id
     self._state = CareerEventState(proto.state)