本文整理汇总了Python中services.time_service函数的典型用法代码示例。如果您正苦于以下问题:Python time_service函数的具体用法?Python time_service怎么用?Python time_service使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了time_service函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:27,代码来源:continuous_statistic.py
示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:walkby_ambient_situation.py
示例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))
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:clock_commands.py
示例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)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:elements_handlers.py
示例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))
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:clock_commands.py
示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:11,代码来源:idle_component.py
示例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())
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:13,代码来源:bills.py
示例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))
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:14,代码来源:base_interactions.py
示例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])
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:object_age.py
示例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.')
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:30,代码来源:aop.py
示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:28,代码来源:bills.py
示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:27,代码来源:visualization_commands.py
示例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)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:27,代码来源:situation_commands.py
示例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()
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:autonomy.py
示例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)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:career_base.py
示例16: join_career
def join_career(self, career_history=None):
resolver = SingleSimResolver(self._sim_info)
(new_level, new_user_level, current_track) = self.get_career_entry_level(career_history=career_history, resolver=resolver)
self._level = new_level
self._user_level = new_user_level
if self._company_name is None:
self._company_name = self.get_random_company_name_hash()
if current_track is None:
self._current_track = self.start_track
else:
self._current_track = current_track
self._join_time = services.time_service().sim_now
self._reset_career_objectives(self._current_track, new_level)
self.career_start()
loot = self.current_level_tuning.loot_on_join
if loot is not None:
resolver = SingleSimResolver(self._sim_info)
loot.apply_to_resolver(resolver)
self._give_rewards_for_skipped_levels()
with telemetry_helper.begin_hook(career_telemetry_writer, TELEMETRY_HOOK_CAREER_START, sim=self._sim_info) as hook:
hook.write_int(TELEMETRY_CAREER_ID, self.guid64)
hook.write_int(TELEMETRY_CAREER_LEVEL, self._user_level)
hook.write_guid(TELEMETRY_TRACK_ID, self._current_track.guid64)
hook.write_int(TELEMETRY_TRACK_LEVEL, new_level)
if not self.get_is_school():
(_, first_work_time, _) = self.get_next_work_time()
self.send_career_message(self.career_messages.join_career_notification, first_work_time)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:27,代码来源:career_base.py
示例17: _on_leaving_situation
def _on_leaving_situation(self, end_work_reason):
service_npc_type = self._service_npc_type
household = self._hiring_household
try:
now = services.time_service().sim_now
time_worked = now - self._service_start_time
time_worked_in_hours = time_worked.in_hours()
if self._had_preroll_work:
cost = service_npc_type.get_cost(time_worked_in_hours)
else:
cost = 0
if cost > 0:
(paid_amount, billed_amount) = service_npc_type.try_charge_for_service(household, cost)
end_work_reason = ServiceNpcEndWorkReason.NOT_PAID
else:
paid_amount = 0
billed_amount = 0
self._send_end_work_notification(end_work_reason, paid_amount, billed_amount)
service_record = household.get_service_npc_record(service_npc_type.guid64)
service_record.time_last_finished_service = now
if end_work_reason == ServiceNpcEndWorkReason.FIRED:
service_sim = self.service_sim()
if service_record is not None:
service_record.add_fired_sim(service_sim.id)
service_record.remove_preferred_sim(service_sim.id)
while end_work_reason in ServiceNpcSituation.CANCEL_SERVICE_LEAVING_REASONS:
services.current_zone().service_npc_service.cancel_service(household, service_npc_type)
except Exception as e:
logger.exception('Exception while executing _on_leaving_situation for situation {}', self, exc=e)
finally:
if not self._is_recurring:
services.current_zone().service_npc_service.cancel_service(household, service_npc_type)
return end_work_reason
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:33,代码来源:service_npc_situation.py
示例18: is_work_time
def is_work_time(self):
if self._current_work_start is None:
return False
current_time = services.time_service().sim_now
if current_time.time_between_week_times(self._current_work_start, self._current_work_end):
return True
return False
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:career_base.py
示例19: get_career_entry_level
def get_career_entry_level(self, career_history=None, resolver=None):
if career_history is None or self.guid64 not in career_history:
level = int(self.start_level_modifiers.get_max_modifier(resolver))
max_level = len(self.start_track.career_levels)
level = sims4.math.clamp(0, level, max_level - 1)
return (level, level + 1, None)
history = career_history[self.guid64]
new_level = history.career_level
new_user_level = history.user_level
time_left = history.time_left
current_track_uid = history.track_uid
current_track = services.get_instance_manager(sims4.resources.Types.CAREER_TRACK).get(current_track_uid)
new_level -= self.levels_lost_on_leave
new_user_level -= self.levels_lost_on_leave
current_time = services.time_service().sim_now
time_gone_from_career = current_time - time_left
days_gone_from_career = time_gone_from_career.in_days()
if self.days_to_level_loss > 0:
levels_to_lose = int(days_gone_from_career/self.days_to_level_loss)
new_level -= levels_to_lose
new_user_level -= levels_to_lose
if new_level < 0:
new_level = 0
if new_user_level < 1:
new_user_level = 1
return (new_level, new_user_level, current_track)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:26,代码来源:career_base.py
示例20: _write_common_data
def _write_common_data(hook, sim=None, household=None, session_id=None):
if sim is not None:
if not hook.valid_for_npc and sim.is_npc:
hook.disabled_hook = True
sim_id = sim.id
if household is None:
household = sim.household
mood = sim.get_mood()
if mood is not None:
sim_mood = mood.guid64
else:
sim_mood = 0
else:
sim_id = 0
sim_mood = 0
sim_classification = 0
if household is not None:
household_id = household.id
account = household.account
if sim is not None:
sim_classification = _classify_sim(sim, household)
if session_id is None:
zone_id = sims4.zone_utils.get_zone_id(can_be_none=True)
if zone_id is not None:
client = account.get_client(zone_id)
if client is not None:
session_id = client.id
else:
household_id = 0
if session_id is None:
session_id = 0
time_service = services.time_service()
sim_time = int(time_service.sim_now.absolute_seconds())
sims4.telemetry._write_common_data(hook, sim_id, household_id, session_id,
sim_time, sim_mood, sim_classification)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:35,代码来源:telemetry_helper.py
注:本文中的services.time_service函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论