Esempio n. 1
0
	def _plannedUpdateCallback (alarmHandle: alarms.AlarmHandle) -> None:
		if not This.Mod.IsLoaded():
			return

		reportLockIdentifier = __name__ + ":UpdateCallback"  # type: str

		try:
			Reproduction.UpdateSystems(plannedSystems)  # TODO log the time taken?
		except:
			Debug.Log("Reproduction planned update callback failed.", This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = reportLockIdentifier)
		else:
			Debug.Unlock(reportLockIdentifier)

		try:
			_plannedUpdateAlarms.remove(alarmHandle)
		except ValueError:
			pass
Esempio n. 2
0
def _StandardUpdateCallback (alarmHandle: alarms.AlarmHandle) -> None:
	if not This.Mod.IsLoaded():
		return

	reportLockIdentifier = __name__ + ":UpdateCallback"  # type: str

	try:
		Reproduction.UpdateSystems()  # TODO log the time taken?

		updateTicks = Reproduction.GetUpdateTicks(_standardUpdateInterval)  # type: typing.Dict[int, typing.List[ReproductionShared.ReproductiveSystem]]

		for plannedTick, plannedSystems in updateTicks.items():  # type: int, typing.List[ReproductionShared.ReproductiveSystem]
			if plannedTick >= _standardUpdateInterval:
				continue

			alarmTimeSpan = date_and_time.TimeSpan(plannedTick)
			plannedUpdateAlarm = alarms.add_alarm(sys.modules[__name__], alarmTimeSpan, _CreatePlannedUpdateCallback(plannedSystems))

			_plannedUpdateAlarms.append(plannedUpdateAlarm)
	except:
		Debug.Log("Reproduction standard update callback failed.", This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = reportLockIdentifier)
	else:
		Debug.Unlock(reportLockIdentifier)