def _add_fish_effect(self, fish): if None in self._fish_vfx_handles: index = self._fish_vfx_handles.index(None) else: index = len(self._fish_vfx_handles) self._fish_vfx_handles.append(None) vfx_data = fish.inventory_to_fish_vfx.get( self.inventory_component.inventory_type, None) if vfx_data is not None: vfx_index = index + 1 if self.fish_vfx_prefix is not None: vfx_name = '{}_{}_{}'.format(self.fish_vfx_prefix, vfx_data.vfx_name, vfx_index) else: vfx_name = '{}_{}'.format(vfx_data.vfx_name, vfx_index) vfx_slot_name = '{}{}'.format(vfx_data.vfx_base_bone_name, vfx_index) else: vfx_name = fish.fishbowl_vfx vfx_slot_name = self.VFX_SLOT_NAME vfx_slot = hash_util.hash32(vfx_slot_name) play_effect_handle = vfx.PlayEffect(self, vfx_name, joint_name=vfx_slot) play_effect_handle.start() self._fish_vfx_handles[index] = (fish.id, play_effect_handle)
def fish_added(self, fish): current_fish = self.get_fish() if not current_fish or current_fish is not fish: logger.error("The fish_added function was called but there is\n either no fish in this fish bowl or the fish in it doesn't match\n the fish making the function called.") return self._fish_vfx = vfx.PlayEffect(self, current_fish.fishbowl_vfx, self.VFX_SLOT_HASH) self._fish_vfx.start() self._enable_tooltip() self.add_dynamic_component(objects.components.types.ENVIRONMENT_SCORE_COMPONENT.instance_attr)
def on_add(self, *_, **__): for fish in self._fishing_data.get_possible_fish_gen(): if self._is_fishing_hole: location_vfx = fish.fish.cls.fishing_hole_vfx else: location_vfx = fish.fish.cls.fishing_spot_vfx while location_vfx is not None: fish_vfx = vfx.PlayEffect(self.owner, location_vfx, self.VFX_SLOT_HASH) fish_vfx.start() self._fish_vfx.append(fish_vfx)
def _on_add(self): for effect_name in self._fishing_vfx.get_effects( self.fishing_data, self._is_fishing_hole): fish_vfx = vfx.PlayEffect(self.owner, effect_name, self.VFX_SLOT_HASH) fish_vfx.start() self._fish_vfx.append(fish_vfx) if self.safe_to_fish_test_in_use: if self.owner.routing_component is not None: self.owner.routing_component.register_routing_stage_event( RoutingStageEvent.ROUTE_START, self._on_routing_stage_event_start) self.owner.routing_component.register_routing_stage_event( RoutingStageEvent.ROUTE_END, self._on_routing_stage_event_end) self.owner.register_on_location_changed(self._on_location_changed)
def start_baby_neglect(baby): baby._started_neglect_moment = True sim_info = baby.sim_info dialog = Baby.NEGLECT_NOTIFICATION(sim_info, SingleSimResolver(sim_info)) dialog.show_dialog() neglect_effect = vfx.PlayEffect(sim_info, 's40_Sims_neglected', sims4.hash_util.hash32('_FX_')) neglect_effect.start() camera.focus_on_sim(sim_info, follow=False) sim_info_manager = services.sim_info_manager() with genealogy_caching(): for member_id in sim_info.genealogy.get_immediate_family_sim_ids_gen(): member_info = sim_info_manager.get(member_id) member_info.add_buff_from_op( Baby.NEGLECT_BUFF_IMMEDIATE_FAMILY.buff_type, Baby.NEGLECT_BUFF_IMMEDIATE_FAMILY.buff_reason) empty_bassinet = _replace_bassinet(sim_info) empty_bassinet.set_state(Baby.NEGLECT_EMPTY_BASSINET_STATE.state, Baby.NEGLECT_EMPTY_BASSINET_STATE) services.client_manager().get_first_client( ).selectable_sims.remove_selectable_sim_info(sim_info) services.get_persistence_service().del_sim_proto_buff(sim_info.id) sim_info_manager.remove_permanently(sim_info)
def _event_handler_effect_start(self, event_data): request_id = event_data.event_data['request_id'] if request_id != self.request_id: return (early_out, effect_parent_obj) = get_animation_object_for_event( event_data, 'effect_parent_id', 'parent', asms=self._asms) if early_out is not None: return target_parent_id = event_data.event_data['effect_target_parent_id'] if target_parent_id == 0: target_parent_obj = None else: (early_out, target_parent_obj) = get_animation_object_for_event( event_data, 'effect_target_parent_id', 'parent', asms=self._asms) if early_out is not None: return event_actor_id = event_data.event_data['event_actor_id'] effect_actor_id = event_data.event_data['effect_actor_id'] effect_name = None target_joint_name_hash = event_data.event_data[ 'effect_target_joint_name_hash'] if self._vfx_overrides and effect_actor_id in self._vfx_overrides: effect_overrides = self._vfx_overrides[effect_actor_id] if effect_overrides.effect is not None: if not effect_overrides.effect: return effect_name = effect_overrides.effect target_joint_name_hash = effect_overrides.target_joint else: effect_name = event_data.event_data['effect_name'] effect_joint_name_hash = event_data.event_data[ 'effect_joint_name_hash'] key = UserDataKey(ClipEventType.Effect, event_actor_id, effect_actor_id) if key in self._user_data: self._user_data[key].stop() del self._user_data[key] if effect_name is None: return mirrored = event_data.event_data['clip_is_mirrored'] if mirrored: try: if effect_parent_obj is not None: effect_joint_name_hash = get_mirrored_joint_name_hash( effect_parent_obj.rig, effect_joint_name_hash) while target_parent_obj is not None: target_joint_name_hash = get_mirrored_joint_name_hash( target_parent_obj.rig, target_joint_name_hash) except Exception as e: logger.error( 'Failed to look up mirrored joint name...\nException: {}\nEventData: {}', e, event_data.event_data) effect = vfx.PlayEffect(effect_parent_obj, effect_name, effect_joint_name_hash, target_parent_id, target_joint_name_hash, mirror_effect=mirrored) self._user_data[key] = effect effect.start()