def _on_sim_spawned(self, sim_info: SimInfo, *_, **__): from sims4communitylib.events.zone_spin.common_zone_spin_event_dispatcher import CommonZoneSpinEventDispatcher if CommonZoneSpinEventDispatcher.get().game_loading: return False from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils return CommonEventRegistry.get().dispatch( S4CLSimSpawnedEvent(CommonSimUtils.get_sim_info(sim_info)))
def _notify_exception_occurred(file_path: str): from ui.ui_dialog_notification import UiDialogNotification from sims4communitylib.notifications.common_basic_notification import CommonBasicNotification from sims4communitylib.enums.strings_enum import CommonStringId from sims4communitylib.events.zone_spin.common_zone_spin_event_dispatcher import CommonZoneSpinEventDispatcher if not CommonZoneSpinEventDispatcher.get().game_loaded: return basic_notification = CommonBasicNotification( CommonStringId.EXCEPTION_OCCURRED_TITLE, CommonStringId.EXCEPTION_OCCURRED_TEXT, description_tokens=(file_path,), urgency=UiDialogNotification.UiDialogNotificationUrgency.URGENT ) basic_notification.show()
def _time_to_save(*_) -> bool: try: if CommonZoneSpinEventDispatcher().game_loading or not CommonZoneSpinEventDispatcher().game_loaded: return False CommonBasicNotification( 'S4ASM Autosaving', 0 ).show() import sims4.commands save_game_data = SaveGameData(CommonSaveUtils.get_save_slot_id(), 'S4ASMAutosave', True, 500001) persistence_service = services.get_persistence_service() persistence_service.save_using(persistence_service.save_game_gen, save_game_data, send_save_message=True, check_cooldown=False) CommonBasicNotification( 'S4ASM Finished Autosaving', 0 ).show() return True except Exception as ex: CommonBasicNotification( 'Problem Occurred While S4ASM Autosaving', 0 ).show() CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'An exception occurred while autosaving.', exception=ex) return False
def _notify_exception_occurred(file_path: str, mod_identifier: Union[str, CommonModIdentity]=None): from ui.ui_dialog_notification import UiDialogNotification from sims4communitylib.notifications.common_basic_notification import CommonBasicNotification from sims4communitylib.enums.strings_enum import CommonStringId from sims4communitylib.events.zone_spin.common_zone_spin_event_dispatcher import CommonZoneSpinEventDispatcher if not CommonZoneSpinEventDispatcher.get().game_loaded: return mod_identifier = CommonModIdentity._get_mod_name(mod_identifier) basic_notification = CommonBasicNotification( CommonStringId.EXCEPTION_OCCURRED_TITLE_FOR_MOD, CommonStringId.EXCEPTION_OCCURRED_TEXT, title_tokens=(mod_identifier,), description_tokens=(file_path,), urgency=UiDialogNotification.UiDialogNotificationUrgency.URGENT ) basic_notification.show()
def _on_sim_load(self, sim_info: SimInfo, *_, **__) -> bool: from sims4communitylib.events.zone_spin.common_zone_spin_event_dispatcher import CommonZoneSpinEventDispatcher if CommonZoneSpinEventDispatcher.get().game_loading: return False return CommonEventRegistry.get().dispatch(S4CLSimLoadedEvent(sim_info))
def _nqm_block_quick_meal_interactions( event_data: S4CLInteractionQueuedEvent) -> bool: if not CommonZoneSpinEventDispatcher().game_loaded: return True return NQMInteractionBlocker().should_allow_interaction( event_data.interaction)