Ejemplo n.º 1
0
 def _event_handler_visibility(self, event_data):
     from objects import VisibilityState
     asms = self._get_asms_from_arb_request_info()
     (early_out,
      target_object) = get_animation_object_for_event(event_data,
                                                      'target_actor_id',
                                                      'target',
                                                      asms=asms,
                                                      allow_obj=False)
     if early_out is not None:
         (early_out,
          target_object) = get_animation_object_for_event(event_data,
                                                          'target_actor_id',
                                                          'target',
                                                          asms=asms,
                                                          allow_prop=False)
         if early_out is not None:
             return
     visible = event_data.event_data['visibility_state']
     if visible is not None:
         curr_visibility = target_object.visibility or VisibilityState(
             True, False, False)
         target_object.visibility = VisibilityState(
             visible, curr_visibility.inherits,
             curr_visibility.enable_drop_shadow)
 def _do_behavior(self, *args, **kwargs):
     subject = self.interaction.get_participant(self.subject)
     if subject is not None:
         if self.fade:
             if self.visibility:
                 subject.fade_in()
             else:
                 subject.fade_out()
                 subject.visibility = VisibilityState(self.visibility)
         else:
             subject.visibility = VisibilityState(self.visibility)
Ejemplo n.º 3
0
            def run_age_up(kid):
                def age_up_exit_behavior():
                    new_bassinet = create_object(
                        Baby.get_corresponding_definition(
                            middle_bassinet.definition))
                    new_bassinet.location = middle_bassinet.location
                    middle_bassinet.make_transient()

                kid.fade_opacity(1, 0)
                kid.visibility = VisibilityState(False)
                affordance = Baby.BABY_AGE_UP.age_up_affordance
                aop = AffordanceObjectPair(
                    affordance,
                    middle_bassinet,
                    affordance,
                    None,
                    exit_functions=(age_up_exit_behavior, ))
                context = InteractionContext(
                    kid,
                    InteractionSource.SCRIPT,
                    interactions.priority.Priority.Critical,
                    insert_strategy=QueueInsertStrategy.NEXT)
                result = aop.test_and_execute(context)
                if result:
                    result.interaction.add_liability(
                        AGING_LIABILITY, AgingLiability(sim_info, Age.BABY))
                else:
                    logger.error('Failed to run baby age up interaction.',
                                 owner='jjacobson')
                return True
Ejemplo n.º 4
0
 def set_location_without_distribution(self, new_location):
     if not isinstance(new_location, sims4.math.Location):
         raise TypeError()
     if new_location == self._location:
         return
     old_location = self._location
     events = [(self, old_location)]
     for child in self.children_recursive_gen():
         events.append((child, child._location))
     if new_location.parent != old_location.parent:
         self.pre_parent_change(new_location.parent)
         if old_location.parent is not None:
             old_location.parent._remove_child(self)
         if new_location.parent is not None:
             new_location.parent._add_child(self)
         visibility_state = self.visibility or VisibilityState()
         if new_location.parent is not None and new_location.parent._disable_child_footprint_and_shadow:
             visibility_state.enable_drop_shadow = False
         else:
             visibility_state.enable_drop_shadow = True
         self.visibility = visibility_state
     if new_location.parent is not None:
         current_inventory = self.get_inventory()
         if current_inventory is not None:
             if not current_inventory.try_remove_object_by_id(self.id):
                 raise RuntimeError(
                     'Unable to remove object: {} from the inventory: {}, parenting request will be ignored.'
                     .format(self, current_inventory))
     posture_graph_service = services.current_zone().posture_graph_service
     with posture_graph_service.object_moving(self):
         self._location = new_location
     if new_location.parent != old_location.parent:
         self.on_parent_change(new_location.parent)
     for (obj, old_value) in events:
         obj.on_location_changed(old_value)
 def snap_to_good_location_on_floor(target,
                                    starting_transform=None,
                                    starting_routing_surface=None):
     target.visibility = VisibilityState(True, True, True)
     parent = target.get_parenting_root()
     if starting_transform is None:
         starting_transform = parent.transform
         starting_transform = sims4.math.Transform(
             parent.position + parent.forward * parent.object_radius,
             starting_transform.orientation)
     if starting_routing_surface is None:
         starting_routing_surface = parent.routing_surface
     search_flags = CarryingObject.SNAP_TO_GOOD_LOCATION_SEARCH_FLAGS
     (trans, orient) = placement.find_good_location(
         placement.FindGoodLocationContext(
             starting_transform=starting_transform,
             starting_routing_surface=starting_routing_surface,
             object_footprints=(target.footprint, ),
             object_id=target.id,
             search_flags=search_flags))
     if starting_transform is not None and (
             starting_transform.translation != trans
             or starting_transform.orientation != orient):
         logger.debug(
             "snap_to_good_location_on_floor's FGL couldn't use the exact suggested starting transform."
         )
     if trans is not None:
         target.clear_parent(sims4.math.Transform(trans, orient),
                             starting_routing_surface)
         return True
     logger.warn(
         'snap_to_good_location_on_floor could not find good location for {}.',
         target)
     target.clear_parent(starting_transform, starting_routing_surface)
     return False
Ejemplo n.º 6
0
 def snap_to_good_location_on_floor(target,
                                    *args,
                                    starting_transform=None,
                                    starting_routing_surface=None,
                                    **kwargs):
     target.visibility = VisibilityState(True, True, True)
     parent = target.get_parenting_root()
     if starting_transform is None:
         starting_transform = parent.transform
         starting_transform = sims4.math.Transform(
             parent.position + parent.forward * parent.object_radius,
             starting_transform.orientation)
     if starting_routing_surface is None:
         starting_routing_surface = parent.routing_surface
     translation = None
     orientation = None
     is_lot_clearing = services.current_zone().is_active_lot_clearing
     if not is_lot_clearing:
         (translation,
          orientation) = CarryingObject.get_good_location_on_floor(
              target,
              *args,
              starting_transform=starting_transform,
              starting_routing_surface=starting_routing_surface,
              **kwargs)
     if translation is not None:
         target.clear_parent(sims4.math.Transform(translation, orientation),
                             starting_routing_surface)
         return True
     logger.debug(
         'snap_to_good_location_on_floor could not find good location for {}.',
         target)
     clear_transform = starting_transform
     clear_routing_surface = starting_routing_surface
     if not (is_lot_clearing or not build_buy.has_floor_at_location(
             starting_transform.translation,
             starting_routing_surface.secondary_id)):
         clear_routing_surface = routing.SurfaceIdentifier(
             services.current_zone_id(), 0,
             routing.SurfaceType.SURFACETYPE_WORLD)
         ground_position = sims4.math.Vector3(
             starting_transform.translation.x,
             starting_transform.translation.y,
             starting_transform.translation.z)
         ground_position.y = services.terrain_service.terrain_object(
         ).get_routing_surface_height_at(starting_transform.translation.x,
                                         starting_transform.translation.z,
                                         clear_routing_surface)
         clear_transform = sims4.math.Transform(
             ground_position, starting_transform.orientation)
     target.clear_parent(clear_transform, clear_routing_surface)
     return False
Ejemplo n.º 7
0
 def fade_in(self,
             fade_duration=None,
             immediate=False,
             additional_channels=None):
     if self.allow_opacity_change:
         if fade_duration is None:
             fade_duration = ClientObjectMixin.FADE_DURATION
         if self.visibility is not None:
             if not self.visibility.visibility:
                 self.visibility = VisibilityState()
                 self.opacity = 0
         self.fade_opacity(1,
                           fade_duration,
                           immediate=immediate,
                           additional_channels=additional_channels)
Ejemplo n.º 8
0
def set_visibility(obj_id,
                   visibility: bool = True,
                   inherits: bool = False,
                   enable_drop_shadow: bool = False,
                   _connection=None):
    manager = services.object_manager()
    obj = None
    if obj_id in manager:
        obj = manager.get(obj_id)
    else:
        sims4.commands.output(
            'SET_VISIBILITY: Object ID not in the object manager.',
            _connection)
    if obj is not None:
        obj.visibility = VisibilityState(visibility, inherits,
                                         enable_drop_shadow)
Ejemplo n.º 9
0
 def create_object_in_sequence(self):
     self._place_object(self._object_helper.object)
     if self._placement_failed:
         if self.cancel_on_destroy:
             self.interaction.cancel(
                 FinishingType.FAILED_TESTS,
                 cancel_reason_msg='Cannot place object')
             return False
         return True
     if not self.transient:
         self._object_helper.claim()
     if self.set_to_invisible:
         self._object_helper.object.visibility = VisibilityState(False)
     with telemetry_helper.begin_hook(
             writer, TELEMETRY_HOOK_OBJECT_CREATE_BSCEXTRA) as hook:
         hook.write_enum(TELEMETRY_FIELD_OBJECT_INTERACTION,
                         self.interaction.guid64)
         hook.write_guid(TELEMETRY_FIELD_OBJECT_DEFINITION,
                         self._object_helper.object.definition.id)
     return True
Ejemplo n.º 10
0
 def hide_carry_object(_):
     asm.set_current_state('entry')
     carry_object.visibility = VisibilityState(False, False, False)
     hide_carry_handle.release()
Ejemplo n.º 11
0
 def show_carry_object(_):
     carry_object.location = old_location
     carry_object.visibility = VisibilityState(True, True, False)
     carry_posture._event_handler_start_pose()
     show_carry_handle.release()
Ejemplo n.º 12
0
 def on_removed_from_inventory(self):
     super().on_removed_from_inventory()
     self._add_to_world()
     self.visibility = VisibilityState(True)
Ejemplo n.º 13
0
 def on_added_to_inventory(self):
     super().on_added_to_inventory()
     self._remove_from_world()
     self.visibility = VisibilityState(False)
Ejemplo n.º 14
0
 def fade_in(self):
     if self.visibility is not None and not self.visibility.visibility:
         self.visibility = VisibilityState()
         self.opacity = 0
     self.fade_opacity(1, ClientObjectMixin.FADE_DURATION)
Ejemplo n.º 15
0
 def post_add(obj):
     obj.transient = True
     obj.visibility = VisibilityState(visibility=False,
                                      inherits=False,
                                      enable_drop_shadow=False)
Ejemplo n.º 16
0
 def set_all_prop_visibility(self, visible, held_only=False):
     for name in self._all_props_gen(held_only):
         self._props[name].visibility = VisibilityState(visible)
Ejemplo n.º 17
0
 def init_placeholder_obj(obj):
     obj.visibility = VisibilityState(False)
Ejemplo n.º 18
0
 def _pre_add(obj):
     obj.opacity = 1
     obj.visibility = VisibilityState(False)