def send_satisfaction_reward_list(self): msg = Sims_pb2.SatisfactionRewards() for (reward, data) in self.SATISFACTION_STORE_ITEMS.items(): reward_msg = Sims_pb2.SatisfactionReward() reward_msg.reward_id = reward.guid64 reward_msg.cost = data.cost reward_msg.affordable = True if data.cost <= self._sim_info.get_whim_bucks( ) else False reward_msg.available = reward.is_valid(self._sim_info) reward_msg.type = data.award_type msg.rewards.append(reward_msg) msg.sim_id = self._sim_info.id distributor = Distributor.instance() distributor.add_op_with_no_owner( GenericProtocolBufferOp(Operation.SIM_SATISFACTION_REWARDS, msg))
def send_reject_response(client, sim, context_handle, cancel_reason): reject_msg = protocols.ServerResponseFailed() reject_msg.handle = context_handle reject_msg.reason = cancel_reason distributor = Distributor.instance() distributor.add_op_with_no_owner(GenericProtocolBufferOp(Operation.SIM_SERVER_RESPONSE_FAILED, reject_msg)) logger.debug(' sending reject msg')
def write(self, msg): balloon_msg = Sims_pb2.AddBalloon() balloon_msg.sim_id = self.sim_id if self.balloon_request.icon is not None: balloon_msg.icon.type = self.balloon_request.icon.type balloon_msg.icon.group = self.balloon_request.icon.group balloon_msg.icon.instance = self.balloon_request.icon.instance if self.balloon_request.icon_object is None: balloon_msg.icon_object.manager_id = 0 balloon_msg.icon_object.object_id = 0 else: (balloon_msg.icon_object.object_id, balloon_msg.icon_object.manager_id ) = self.balloon_request.icon_object.icon_info if self.balloon_request.overlay is not None: balloon_msg.overlay.type = self.balloon_request.overlay.type balloon_msg.overlay.group = self.balloon_request.overlay.group balloon_msg.overlay.instance = self.balloon_request.overlay.instance balloon_msg.type = self.balloon_request.balloon_type balloon_msg.priority = self.balloon_request.priority balloon_msg.duration = self.balloon_request.duration if self.balloon_request.view_offset is not None: balloon_msg.view_offset_override.x = self.balloon_request.view_offset.x balloon_msg.view_offset_override.y = self.balloon_request.view_offset.y balloon_msg.view_offset_override.z = self.balloon_request.view_offset.z if self.balloon_request.category_icon is not None: balloon_msg.category_icon = self.balloon_request.category_icon self.serialize_op(msg, balloon_msg, protocols.Operation.ADD_BALLOON)
def _send_tracker_to_client(self, init=False): owner = self.owner_sim_info if owner is None or owner.is_npc or owner.manager is None: return msg_empty = True msg = Sims_pb2.AspirationTrackerUpdate() for guid in self._completed_milestones: while not self.milestone_sent(guid): self._sent_milestones.add(guid) msg.aspirations_completed.append(guid) if msg_empty: msg_empty = False for guid in self._completed_objectives: while not self.objective_sent(guid): self._sent_objectives.add(guid) msg.objectives_completed.append(guid) if msg_empty: msg_empty = False if not msg_empty: msg.sim_id = owner.id msg.init_message = init distributor = Distributor.instance() distributor.add_op( owner, GenericProtocolBufferOp( Operation.SIM_ASPIRATION_TRACKER_UPDATE, msg))
def send_selectable_sims_update(self): msg = Sims_pb2.UpdateSelectableSims() for sim_info in self._selectable_sims: with ProtocolBufferRollback(msg.sims) as new_sim: new_sim.id = sim_info.sim_id if sim_info.career_tracker is None: logger.error( 'CareerTracker is None for selectable Sim {}'.format( sim_info)) else: career = sim_info.career_tracker.get_currently_at_work_career( ) new_sim.at_work = career is not None and not career.is_at_active_event new_sim.is_selectable = sim_info.is_enabled_in_skewer (selector_visual_type, career_category) = self._get_selector_visual_type(sim_info) new_sim.selector_visual_type = selector_visual_type if career_category is not None: new_sim.career_category = career_category new_sim.can_care_for_toddler_at_home = sim_info.can_care_for_toddler_at_home if not sim_info.is_instanced( allow_hidden_flags=ALL_HIDDEN_REASONS): new_sim.instance_info.zone_id = sim_info.zone_id new_sim.instance_info.world_id = sim_info.world_id new_sim.firstname = sim_info.first_name new_sim.lastname = sim_info.last_name zone_data_proto = services.get_persistence_service( ).get_zone_proto_buff(sim_info.zone_id) if zone_data_proto is not None: new_sim.instance_info.zone_name = zone_data_proto.name distributor = Distributor.instance() distributor.add_op_with_no_owner( GenericProtocolBufferOp(Operation.SELECTABLE_SIMS_UPDATE, msg))
def _create_buff_update_msg(self, buff, equipped, change_rate=None): buff_msg = Sims_pb2.BuffUpdate() buff_msg.buff_id = buff.guid64 buff_msg.sim_id = self.owner.id buff_msg.equipped = equipped if buff.buff_reason is not None: buff_msg.reason = buff.buff_reason if equipped and buff.show_timeout: (timeout, rate_multiplier) = buff.get_timeout_time() buff_msg.timeout = timeout buff_msg.rate_multiplier = rate_multiplier if change_rate is not None: if change_rate == 0: progress_arrow = Sims_pb2.BUFF_PROGRESS_NONE elif change_rate > 0: progress_arrow = Sims_pb2.BUFF_PROGRESS_UP if not buff.flip_arrow_for_progress_update else Sims_pb2.BUFF_PROGRESS_DOWN else: progress_arrow = Sims_pb2.BUFF_PROGRESS_DOWN if not buff.flip_arrow_for_progress_update else Sims_pb2.BUFF_PROGRESS_UP buff_msg.buff_progress = progress_arrow buff_msg.is_mood_buff = buff.is_mood_buff buff_msg.commodity_guid = buff.commodity_guid or 0 if buff.mood_override is not None: buff_msg.mood_type_override = buff.mood_override.guid64 buff_msg.transition_into_buff_id = buff.transition_into_buff_id return buff_msg
def _send_tracker_to_client(self, init=False): owner = self.owner_sim_info if owner is None or owner.is_npc or owner.manager is None: return msg_empty = True msg = Sims_pb2.AspirationTrackerUpdate() for aspiration in self._completed_milestones: if not self.milestone_sent(aspiration): self._sent_milestones.add(aspiration) msg.aspirations_completed.append(aspiration.guid64) msg_empty = False for objective in self._completed_objectives: if not self.objective_sent(objective): self._sent_objectives.add(objective) msg.objectives_completed.append(objective.guid64) msg_empty = False for objective in self._reset_objectives: if not self.objective_sent(objective): self._sent_objectives.add(objective) msg.objectives_reset.append(objective.guid64) msg_empty = False for unlocked_hidden_aspiration_track in self._unlocked_hidden_aspiration_tracks: if not self.unlocked_hidden_aspiration_track_sent( unlocked_hidden_aspiration_track): msg.unlocked_hidden_aspiration_tracks.append( unlocked_hidden_aspiration_track.guid64) msg_empty = False if not msg_empty: msg.sim_id = owner.id msg.init_message = init distributor = Distributor.instance() distributor.add_op( owner, GenericProtocolBufferOp( Operation.SIM_ASPIRATION_TRACKER_UPDATE, msg))
def send_interactions_remove_msg(sim, interactions, immediate=False): logger.debug('send_interactions_remove_msg({}), immediate={}', sim.id, immediate) msg = Sims_pb2.InteractionsRemove() if _build_interactions_remove_msg(sim, msg, interactions): logger.debug(' SENDING') add_message_if_selectable(sim, MSG_SIM_INTERACTIONS_REMOVE, msg, immediate) else: logger.debug(' NOT_SENDING')
def send_interactions_update_msg(sim, super_interactions, immediate=False): logger.debug('send_interactions_update_msg({}), immediate={}', sim.id, immediate) msg = Sims_pb2.InteractionsUpdate() if _build_interactions_update_msg(sim, super_interactions, msg): logger.debug(' SENDING') add_message_if_selectable(sim, MSG_SIM_INTERACTIONS_UPDATE, msg, immediate) else: logger.debug(' NOT_SENDING')
def write(self, msg): reslot_msg = Sims_pb2.ReslotPlumbbob() reslot_msg.sim_id = self._sim_id reslot_msg.obj_id = self._obj_id reslot_msg.bone = self._bone_hash reslot_msg.offset.x = self._offset.x reslot_msg.offset.y = self._offset.y reslot_msg.offset.z = self._offset.z msg.type = protocols.Operation.RESLOT_PLUMBBOB msg.data = reslot_msg.SerializeToString()
def send_memory_trigger_update(sim, trigger_memory=False, timeout_time=0.0, memory_uid=0): memory_msg = Sims_pb2.MemoryTriggerUpdate() memory_msg.sim_id = sim.id if sim is not None else 0 memory_msg.trigger_memory = trigger_memory memory_msg.timeout = timeout_time memory_msg.memory_id = memory_uid add_message_if_selectable(sim, MSG_SIM_MEMORY_TRIGGER_UPDATE, memory_msg, False)
def send_interactions_removeall_msg(sim, immediate=False): if sim is None: return logger.debug('send_interactions_removeall_msg({}, immediate={})', sim.id, immediate) msg = Sims_pb2.InteractionsRemove() if _build_interactions_removeall_msg(sim, msg): logger.debug(' SENDING') add_message_if_selectable(sim, MSG_SIM_INTERACTIONS_REMOVE_ALL, msg, immediate) else: logger.debug(' NOT_SENDING')
def _send_objectives_update_to_client(self): owner = self.owner_sim_info if owner is None or owner.is_npc or owner.manager is None: return msg = Sims_pb2.GoalsStatusUpdate() if self._update_objectives_msg_for_client(msg): msg.sim_id = owner.id distributor = Distributor.instance() distributor.add_op( owner, GenericProtocolBufferOp(Operation.SIM_GOALS_STATUS_UPDATE, msg))
def send_interaction_queue_view_add_msg(sim, super_interactions, immediate=False): logger.debug('send_interaction_queue_view_add_msg({}, immediate={}', sim.id, immediate) msg = Sims_pb2.InteractionQueueViewAdd() if _build_interaction_queue_view_add_msg(sim, super_interactions, msg): logger.debug(' SENDING') add_message_if_selectable(sim, MSG_SIM_INTERACTION_QUEUE_VIEW_ADD, msg, immediate) else: logger.debug(' NOT_SENDING')
def write(self, msg): reslot_msg = Sims_pb2.ReslotPlumbbob() reslot_msg.sim_id = self._sim_id reslot_msg.obj_id = self._obj_id reslot_msg.bone = self._bone_hash reslot_msg.offset.x = self._offset.x reslot_msg.offset.y = self._offset.y reslot_msg.offset.z = self._offset.z if self._balloon_offset is not None: reslot_msg.balloon_view_offset.x = self._balloon_offset.x reslot_msg.balloon_view_offset.y = self._balloon_offset.y reslot_msg.balloon_view_offset.z = self._balloon_offset.z self.serialize_op(msg, reslot_msg, protocols.Operation.RESLOT_PLUMBBOB)
def send_interaction_replace_message(sim, old_interaction_id, new_interaction_info, immediate=False): logger.debug( 'send_interaction_replace_message({}), old_id={}, new_id={}, immediate={})', sim.id, old_interaction_id, new_interaction_info.interaction_id, immediate) msg = Sims_pb2.InteractionReplace() msg.sim_id = sim.id msg.old_interaction_id = old_interaction_id _build_interaction_msg(new_interaction_info, msg.new_interaction) logger.debug(' SENDING') add_message_if_selectable(sim, MSG_SIM_INTERACTION_REPLACE, msg, immediate)
def send_timed_aspiration_to_client(self, update_type): if services.current_zone().is_zone_shutting_down: return owner = self._tracker.owner_sim_info msg = Sims_pb2.TimedAspirationUpdate() msg.update_type = update_type msg.sim_id = owner.id msg.timed_aspiration_id = self._aspiration.guid64 if update_type == Sims_pb2.TimedAspirationUpdate.ADD: msg.timed_aspiration_end_time = self._end_time.absolute_ticks() distributor = Distributor.instance() distributor.add_op( owner, GenericProtocolBufferOp(Operation.TIMED_ASPIRATIONS_UPDATE, msg))
def _send_objectives_update_to_client(self): owner = self.owner_sim_info if owner is None or owner.is_npc or owner.manager is None: return msg = Sims_pb2.GoalsStatusUpdate() if self._update_objectives_msg_for_client(msg): msg.sim_id = owner.id cheat_service = services.get_cheat_service() msg.cheats_used = cheat_service.cheats_ever_enabled distributor = Distributor.instance() distributor.add_op( owner, GenericProtocolBufferOp(Operation.SIM_GOALS_STATUS_UPDATE, msg, block_on_task_owner=False))
def send_interaction_outcome_msg(sim, outcome_success, outcome_result_message, immediate=False): logger.debug('send_interaction_outcome_msg({})', sim.id) msg = Sims_pb2.InteractionOutcome() msg.sim_id = sim.id if outcome_success: msg.result = Sims_pb2.InteractionOutcome.POSITIVE else: msg.result = Sims_pb2.InteractionOutcome.NEGATIVE if outcome_result_message is not None: msg.display_message = outcome_result_message logger.debug(' SENDING') distributor = Distributor.instance() op = MessageOp(msg, MSG_SIM_INTERACTION_OUTCOME, immediate) distributor.add_op(sim, op)
def send_selectable_sims_update(self): msg = Sims_pb2.UpdateSelectableSims() for sim_info in self._selectable_sims: with ProtocolBufferRollback(msg.sims) as new_sim: new_sim.id = sim_info.sim_id new_sim.at_work = sim_info.career_tracker.currently_at_work new_sim.is_selectable = sim_info.is_enabled_in_skewer (selector_visual_type, career_category) = self._get_selector_visual_type(sim_info) new_sim.selector_visual_type = selector_visual_type if career_category is not None: new_sim.career_category = career_category while not sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS): new_sim.instance_info.zone_id = sim_info.zone_id new_sim.instance_info.world_id = sim_info.world_id new_sim.firstname = sim_info.first_name new_sim.lastname = sim_info.last_name zone_data_proto = services.get_persistence_service().get_zone_proto_buff(sim_info.zone_id) while zone_data_proto is not None: new_sim.instance_info.zone_name = zone_data_proto.name distributor = Distributor.instance() distributor.add_op_with_no_owner(GenericProtocolBufferOp(Operation.SELECTABLE_SIMS_UPDATE, msg))
def write(self, msg): balloon_msg = Sims_pb2.AddBalloon() balloon_msg.sim_id = self.sim_id if self.balloon_request.icon is not None: balloon_msg.icon.type = self.balloon_request.icon.type balloon_msg.icon.group = self.balloon_request.icon.group balloon_msg.icon.instance = self.balloon_request.icon.instance if self.balloon_request.icon_object is None: balloon_msg.icon_object.manager_id = 0 balloon_msg.icon_object.object_id = 0 else: (balloon_msg.icon_object.object_id, balloon_msg.icon_object.manager_id) = self.balloon_request.icon_object.icon_info if self.balloon_request.overlay is not None: balloon_msg.overlay.type = self.balloon_request.overlay.type balloon_msg.overlay.group = self.balloon_request.overlay.group balloon_msg.overlay.instance = self.balloon_request.overlay.instance balloon_msg.type = self.balloon_request.balloon_type balloon_msg.priority = self.balloon_request.priority balloon_msg.duration = self.balloon_request.duration msg.type = protocols.Operation.ADD_BALLOON msg.data = balloon_msg.SerializeToString()
def send_to_client(self, client): if hasattr(Sims_pb2, 'CheatStatusUpdate'): cheat_status_update = Sims_pb2.CheatStatusUpdate() cheat_status_update.cheats_enabled = self.cheats_enabled client.send_message(Consts_pb2.MSG_SET_CHEAT_STATUS, cheat_status_update)
def send_loan_op(sim_info, amount): msg = Sims_pb2.SetLoan() msg.amount = amount op = GenericProtocolBufferOp(Operation.SET_LOAN, msg) Distributor.instance().add_op(sim_info, op)