本文整理汇总了Python中services.time_service函数的典型用法代码示例。如果您正苦于以下问题:Python time_service函数的具体用法?Python time_service怎么用?Python time_service使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了time_service函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, tracker, initial_value):
super().__init__(tracker, initial_value)
self._decay_enabled = False
self._decay_rate_override = UNSET
self._callbacks = []
self._suppress_update_active_callbacks = False
self._alarm_handle = None
self._active_callback = None
if self.max_simulate_time_on_load is not None:
now = services.time_service().sim_now
if services.current_zone().is_zone_loading:
world_game_time = services.game_clock_service().zone_init_world_game_time()
neg_max_update_time = create_time_span(minutes=-self.max_simulate_time_on_load)
diff = world_game_time + neg_max_update_time
if diff > now:
update_time = diff
else:
update_time = now
self._last_update = update_time
else:
self._last_update = now
else:
self._last_update = services.time_service().sim_now
self._decay_rate_modifier = 1
self._decay_rate_modifiers = []
self._convergence_value = self._default_convergence_value
self._recalculate_modified_decay_rate()
示例2: __init__
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._walker = None
self._flavor_cooldown_until = services.time_service().sim_now + clock.interval_in_sim_minutes(10)
self._social_cooldown_until = services.time_service().sim_now + clock.interval_in_sim_minutes(10)
self._other_social_situation = None
self._social_interaction = None
示例3: advance_game_time
def advance_game_time(hours:int=0, minutes:int=0, seconds:int=0, _connection=None):
previous_time = services.time_service().sim_now
services.game_clock_service().advance_game_time(hours=hours, minutes=minutes, seconds=seconds)
new_time = services.time_service().sim_now
services.sim_info_manager().auto_satisfy_sim_motives()
output = sims4.commands.Output(_connection)
output('previous time = {}'.format(previous_time))
output('new time = {}'.format(new_time))
示例4: create_sim_timeline_data
def create_sim_timeline_data(zone_id:int=None):
time_service = services.time_service()
if time_service is None:
return
sim_timeline = time_service.sim_timeline
if sim_timeline is None:
return
return _create_timeline_fields(services.time_service().sim_timeline)
示例5: now
def now(_connection=None):
output = sims4.commands.Output(_connection)
game_clock_ticks = services.time_service().sim_now.absolute_ticks()
server_ticks = services.server_clock_service().ticks()
output('Gameclock ticks: {} Server Ticks: {}'.format(game_clock_ticks, server_ticks))
timeline_now = services.time_service().sim_now
game_clock_now = services.game_clock_service().now()
output('Sim timeline now: {}'.format(timeline_now))
output('Game clock now: {}'.format(game_clock_now))
示例6: _trigger_idle_animation
def _trigger_idle_animation(self, state, new_value):
if new_value in self._idle_animation_map:
new_animation = self._idle_animation_map[new_value]
self._hard_stop_animation_element()
self._current_idle_state_value = new_value
if new_animation is not None:
animation_element = new_animation(self.owner)
self._idle_animation_element = build_element((animation_element, flush_all_animations))
services.time_service().sim_timeline.schedule(self._idle_animation_element)
return True
return False
示例7: _set_up_bill_timer
def _set_up_bill_timer(self):
day = self.TIME_TO_PLACE_BILL_IN_HIDDEN_INVENTORY.day
hour = self.TIME_TO_PLACE_BILL_IN_HIDDEN_INVENTORY.hour
minute = self.TIME_TO_PLACE_BILL_IN_HIDDEN_INVENTORY.minute
time = create_date_and_time(days=day, hours=hour, minutes=minute)
time_until_bill_delivery = services.time_service().sim_now.time_to_week_time(time)
bill_delivery_time = services.time_service().sim_now + time_until_bill_delivery
end_of_first_week = DateAndTime(0) + interval_in_sim_weeks(1)
if bill_delivery_time < end_of_first_week:
time_until_bill_delivery += interval_in_sim_weeks(1)
if time_until_bill_delivery.in_ticks() <= 0:
time_until_bill_delivery = TimeSpan(1)
self._bill_timer_handle = alarms.add_alarm(self, time_until_bill_delivery, lambda _: self.allow_bill_delivery())
示例8: on_response
def on_response(dialog):
if not dialog.accepted:
return
name = dialog.text_input_responses.get(self.TEXT_INPUT_NEW_NAME)
description = dialog.text_input_responses.get(self.TEXT_INPUT_NEW_DESCRIPTION)
target = self.target
if target is not None:
if name is not None:
target.set_custom_name(name)
if description is not None:
target.set_custom_description(description)
self._update_ui_metadata(target)
sequence = self._build_outcome_sequence()
services.time_service().sim_timeline.schedule(element_utils.build_element(sequence))
示例9: save
def save(self, persistence_master_message):
persistable_data = persistence_protocols.PersistenceMaster.PersistableData()
persistable_data.type = persistence_protocols.PersistenceMaster.PersistableData.ObjectAgeComponent
obj_age_data = persistable_data.Extensions[persistence_protocols.PersistableObjectAgeComponent.persistable_data]
obj_age_data.age = self.get_current_age()
obj_age_data.saved_tick = services.time_service().sim_now.absolute_ticks()
persistence_master_message.data.extend([persistable_data])
示例10: execute_interaction
def execute_interaction(interaction) -> ExecuteResult:
if interaction:
if interaction.affordance.cheat:
with telemetry_helper.begin_hook(sims4.commands.cheats_writer, sims4.commands.TELEMETRY_HOOK_INTERACTION) as hook:
hook.write_string(sims4.commands.TELEMETRY_FIELD_NAME, interaction.__str__())
hook.write_string(sims4.commands.TELEMETRY_FIELD_TARGET, str(interaction.target))
if interaction.affordance.immediate:
interaction._trigger_interaction_start_event()
immediate_timeline = services.time_service().sim_timeline.get_sub_timeline()
result_element = elements.ResultElement(elements.GeneratorElement(interaction._run_gen))
immediate_timeline.schedule(result_element)
immediate_timeline.simulate(immediate_timeline.now)
if immediate_timeline.heap:
logger.error('On immediate execute_interaction, immediate timeline is not empty')
immediate_timeline.heap.clear()
run_result = result_element.result
interaction._trigger_interaction_complete_test_event()
if run_result:
exit_behavior = interaction._exit(None, False)
try:
next(exit_behavior)
logger.error('Running immediate exit_behavior yielded despite allow_yield=False')
except StopIteration:
pass
execute_result = ExecuteResult(run_result, interaction, None)
log_interaction('Immediate', interaction, '{}'.format(execute_result))
return execute_result
context = interaction.context
return ExecuteResult(context.sim.queue.append(interaction), interaction, None)
return ExecuteResult(False, None, 'Trying to execute a None interaction.')
示例11: save_data
def save_data(self, household_msg):
for utility in Utilities:
while self.is_utility_delinquent(utility):
household_msg.gameplay_data.delinquent_utilities.append(utility)
for (bill_source, cost) in self._additional_bill_costs.items():
with ProtocolBufferRollback(household_msg.gameplay_data.additional_bill_costs) as additional_bill_cost:
additional_bill_cost.bill_source = bill_source
additional_bill_cost.cost = cost
household_msg.gameplay_data.can_deliver_bill = self._can_deliver_bill
household_msg.gameplay_data.put_bill_in_hidden_inventory = self._put_bill_in_hidden_inventory
if self.current_payment_owed is not None:
household_msg.gameplay_data.current_payment_owed = self.current_payment_owed
current_time = services.time_service().sim_now
if self._bill_timer_handle is not None:
time = max((self._bill_timer_handle.finishing_time - current_time).in_ticks(), 0)
household_msg.gameplay_data.bill_timer = time
elif self._bill_timer is not None:
household_msg.gameplay_data.bill_timer = self._bill_timer
if self._shutoff_handle is not None:
time = max((self._shutoff_handle.finishing_time - current_time).in_ticks(), 0)
household_msg.gameplay_data.shutoff_timer = time
elif self._shutoff_timer is not None:
household_msg.gameplay_data.shutoff_timer = self._shutoff_timer
if self._warning_handle is not None:
time = max((self._warning_handle.finishing_time - current_time).in_ticks(), 0)
household_msg.gameplay_data.warning_timer = time
elif self._warning_timer is not None:
household_msg.gameplay_data.warning_timer = self._warning_timer
示例12: debugvis_test
def debugvis_test(name, _connection=None):
client = services.client_manager().get(_connection)
sim = client.active_sim
time = services.time_service().sim_now
hour = time.hour() % 12*sims4.math.TWO_PI/12
minute = time.minute()*sims4.math.TWO_PI/60
a = sim.position + sims4.math.Vector3(0, 1, 0)
b = a + sims4.math.Vector3(math.cos(hour), 0, math.sin(hour))*3
c = a + sims4.math.Vector3(math.cos(minute), 0, math.sin(minute))*4
with Context(name, routing_surface=sim.routing_surface) as layer:
layer.set_color(Color.YELLOW)
layer.add_segment(a, b, color=Color.CYAN)
layer.add_segment(a, c, color=Color.RED)
layer.add_point(a, size=0.2)
layer.add_point(b, size=0.1, color=Color.BLUE)
layer.add_point(c, size=0.1, color=Color.MAGENTA)
layer.add_circle(a, 5, color=Color.GREEN)
for i in range(12):
theta = i*sims4.math.TWO_PI/12
x = sims4.math.Vector3(4.75*math.cos(theta), 0, 4.75*math.sin(theta))
color = sims4.color.interpolate(Color.YELLOW, Color.BLUE, i/11)
layer.add_arrow(a + x, 0.5*sims4.math.PI - theta, end_arrow=False, color=color)
layer.add_text_world(a + x, str(i), color_foreground=pseudo_random_color(i))
layer.add_text_screen(sims4.math.Vector2(4, 32), 'Displaying debug visualization tests.')
for i in range(200):
layer.add_text_object(sim, sims4.math.Vector3.ZERO(), str(i), bone_index=i)
return 1
示例13: get_sims_for_job
def get_sims_for_job(session_id, sim_id, situation_type, job_type, *job_assignments, _connection=None):
sim = get_optional_target(sim_id, _connection)
situation_start_time = services.time_service().sim_now
duration = situation_type.duration
if duration > 0:
situation_end_time = situation_start_time + date_and_time.create_time_span(0, 0, duration)
else:
situation_start_time = date_and_time.INVALID_DATE_AND_TIME
situation_end_time = date_and_time.INVALID_DATE_AND_TIME
results = services.sim_filter_service().submit_filter(job_type.filter, None, requesting_sim_info=sim.sim_info, start_time=situation_start_time, end_time=situation_end_time, allow_yielding=False)
if job_type.additional_filter_for_user_selection:
sim_constraints = {result.sim_info.id for result in results}
results = services.sim_filter_service().submit_filter(job_type.additional_filter_for_user_selection, None, requesting_sim_info=sim.sim_info, start_time=situation_start_time, end_time=situation_end_time, sim_constraints=sim_constraints, allow_yielding=False)
msg = Situations_pb2.SituationJobSims()
msg.situation_session_id = session_id
msg.job_resource_id = job_type.guid
msg.requirements = job_type.requirement_text
results.sort(key=lambda x: (x.sim_info.is_npc, x.sim_info.last_name))
for result in results:
msg.sim_ids.append(result.sim_info.id)
with ProtocolBufferRollback(msg.sims) as situation_job_sim:
situation_job_sim.sim_id = result.sim_info.id
if result.sim_info.household.id == services.active_household_id():
situation_job_sim.account_id = result.sim_info.account_id
while result.conflicting_career_track_id:
situation_job_sim.career_track_id = result.conflicting_career_track_id
shared_messages.add_message_if_selectable(services.object_manager().get(sim.id), Consts_pb2.MSG_SITUATION_JOB_SIMS, msg, True)
示例14: set_last_autonomous_action_time
def set_last_autonomous_action_time(self, to_reschedule_autonomy=True):
now = services.time_service().sim_now
logger.debug('Setting last autonomous action time for {} to {}', self.owner, now)
self._last_autonomous_action_time = now
self._last_autonomy_result_was_none = False
if to_reschedule_autonomy:
self._schedule_next_full_autonomy_update()
示例15: _create_work_session_alarms
def _create_work_session_alarms(self):
self._end_work_handle = alarms.add_alarm(self, self.time_until_end_of_work() + TimeSpan.ONE, self._end_work_callback)
if not self.attended_work:
now = services.time_service().sim_now
late_time = self.get_late_time()
if now < late_time:
self._late_for_work_handle = alarms.add_alarm(self, late_time - now + TimeSpan.ONE, self._late_for_work_callback)