Exemplo n.º 1
0
    def NotifyPregnancyEnded(self) -> None:
        """
		Notify this reproductive system that a pregnancy has ended. If we are not monitoring the pregnancy, or we detect the sim is still
		pregnant, nothing will happen.
		"""

        if self.IsPregnant:
            return

        if not self.MonitoringPregnancy:
            return

        self.MonitoringPregnancy = False
        eventArguments = CycleEvents.PregnancyEndedArguments()

        for pregnancyEndedCallback in self.PregnancyEndedEvent:
            try:
                pregnancyEndedCallback(self, eventArguments)
            except:
                Debug.Log("Failed to call pregnancy ended callback '" +
                          Types.GetFullName(pregnancyEndedCallback) + "'.\n" +
                          self.TrackingSystem.DebugInformation,
                          This.Mod.Namespace,
                          Debug.LogLevels.Exception,
                          group=This.Mod.Namespace,
                          owner=__name__,
                          lockIdentifier=__name__ + ":" +
                          str(Python.GetLineNumber()),
                          lockReference=pregnancyEndedCallback)

        self.ResetPregnancyVisualsIfAppropriate()
Exemplo n.º 2
0
def GenerateGenericSperm (source: typing.Optional[sim_info.SimInfo] = None, spermGuide: typing.Optional[CycleGuides.SpermGuide] = None) -> Sperm:
	"""
	Generate a generic sperm object. This is best used to generate sperm for sims who can't normally produce sperm.
	:param source: The sim that this sperm is supposed to be from. Let this be none to have no specific sim be the source.
	:type source: typing.Optional[sim_info.SimInfo]
	:param spermGuide: The sperm guide used to generate the sperm object. We will use the default sperm guide if this is left as None.
	:type spermGuide: typing.Optional[GuidesSperm.SpermGuide]
	"""

	if not isinstance(source, sim_info.SimInfo) and source is not None:
		raise Exceptions.IncorrectTypeException(source, "source", (sim_info.SimInfo, None))

	if not isinstance(spermGuide, CycleGuides.SpermGuide) and spermGuide is not None:
		raise Exceptions.IncorrectTypeException(spermGuide, "spermGuide", (CycleGuides.SpermGuide, None))

	if spermGuide is None:
		spermGuide = CycleGuides.SpermGuide.GetDefaultGuide()

	generatingSperm = Sperm()  # type: Sperm
	generationSeed = random.randint(-1000000000, 1000000000)

	generationArguments = CycleEvents.SpermGeneratingArguments(generationSeed, generatingSperm, spermGuide)
	generationArguments.Source = source
	generatingSperm.Generate(generationArguments)

	return generatingSperm
Exemplo n.º 3
0
	def GenerateSperm (self) -> Sperm.Sperm:
		"""
		Create an sperm object based off and made for this reproductive system.
		"""

		generationSeed = self.TrackingSystem.CurrentSeed  # type: int

		random.seed(self.SpermObjectsGenerated)
		generationSeed += random.randint(-1000000000, 1000000000)

		sperm = Sperm.Sperm()
		spermGuide = sperm.GetSpermGuide(self.TrackingSystem)  # type: CycleGuides.SpermGuide
		eventArguments = CycleEvents.SpermGeneratingArguments(generationSeed, sperm, spermGuide)

		for spermGeneratingCallback in self.SpermGeneratingEvent:
			try:
				spermGeneratingCallback(self, eventArguments)
			except:
				Debug.Log("Failed to call sperm generating callback '" + Types.GetFullName(spermGeneratingCallback) + "'.\n" + self.TrackingSystem.DebugInformation,
						  This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = __name__ + ":" + str(Python.GetLineNumber()), lockReference = spermGeneratingCallback)

		sperm.Generate(eventArguments)

		self._spermObjectsGenerated += 1

		return sperm
Exemplo n.º 4
0
	def CurrentCycle (self, value: typing.Optional[CycleBase.CycleBase]) -> None:
		if not isinstance(value, CycleBase.CycleBase) and value is not None:
			raise Exceptions.IncorrectTypeException(value, "CurrentCycle", (CycleBase.CycleBase, None))

		if hasattr(self, "_currentCycle"):
			previousValue = self._currentCycle

			if previousValue is value:
				return

			if previousValue is not None:
				self._UnsetCycleCallbacks(previousValue)
		else:
			previousValue = None  # type: typing.Optional[CycleBase.CycleBase]

		self._currentCycle = value

		if value is not None:
			self._SetCycleCallbacks(value)

		if self.TrackingSystem.Simulating:
			if value is None and previousValue is None:
				return

			self.TrackingSystem.Simulation.NeedToPlan = True

		cycleChangedEventArguments = CycleEvents.CycleAbortTestingArguments()  # type: CycleEvents.CycleAbortTestingArguments

		for cycleChangedCallback in self.CycleChangedEvent:
			try:
				cycleChangedCallback(self, cycleChangedEventArguments)
			except:
				Debug.Log("Failed to call cycle changed callback '" + Types.GetFullName(cycleChangedCallback) + "'.\n" + self.TrackingSystem.DebugInformation,
						  This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = __name__ + ":" + str(Python.GetLineNumber()), lockReference = cycleChangedCallback)
Exemplo n.º 5
0
	def _NotifyEffectRemoved (self, removedEffect: EffectsBase.EffectBase) -> None:
		eventArguments = CycleEvents.EffectRemovedArguments(removedEffect)  # type: CycleEvents.EffectRemovedArguments

		for effectRemovedCallback in self.EffectRemovedEvent:
			try:
				effectRemovedCallback(self, eventArguments)
			except:
				Debug.Log("Failed to call effect removed callback '" + Types.GetFullName(effectRemovedCallback) + "'.\n" + self.TrackingSystem.DebugInformation,
						  This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = __name__ + ":" + str(Python.GetLineNumber()), lockReference = effectRemovedCallback)
Exemplo n.º 6
0
	def DoBuffSelectionTesting (self) -> CycleEvents.MenstrualEffectBuffSelectionTestingArguments:
		eventArguments = CycleEvents.MenstrualEffectBuffSelectionTestingArguments(self.AffectingSystem.CurrentSeed, self.AffectingSystem.SimInfo)  # type: CycleEvents.MenstrualEffectBuffSelectionTestingArguments

		for buffSelectionTestingCallback in self.BuffSelectionTestingEvent:
			try:
				buffSelectionTestingCallback(self, eventArguments)
			except:
				Debug.Log("Failed to call buff selection testing callback '" + Types.GetFullName(buffSelectionTestingCallback) + "'.\n" + self.AffectingSystem.DebugInformation,
						  This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = __name__ + ":" + str(Python.GetLineNumber()), lockReference = buffSelectionTestingCallback)

		return eventArguments
Exemplo n.º 7
0
	def NotifyBuffRemoved (self, removedBuff: BuffsMenstrual.MenstrualBuffBase) -> None:
		"""
		Notify the effect that a new buff was just added.
		"""

		if not isinstance(removedBuff, BuffsMenstrual.MenstrualBuffBase):
			raise Exceptions.IncorrectTypeException(removedBuff, "removedBuff", (BuffsMenstrual.MenstrualBuffBase,))

		eventArguments = CycleEvents.MenstrualEffectBuffRemovedArguments(removedBuff)  # type: CycleEvents.MenstrualEffectBuffRemovedArguments

		for buffRemovedCallback in self.BuffRemovedEvent:
			try:
				buffRemovedCallback(self, eventArguments)
			except:
				Debug.Log("Failed to call buff removed callback '" + Types.GetFullName(buffRemovedCallback) + "'.\n" + self.AffectingSystem.DebugInformation,
						  This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = __name__ + ":" + str(Python.GetLineNumber()), lockReference = buffRemovedCallback)
Exemplo n.º 8
0
	def DoCycleAbortTesting (self) -> CycleEvents.CycleAbortTestingArguments:
		"""
		Test if the currently active cycle should abort.
		:return: Testing event arguments that carry information on whether or not the current cycle should abort.
		:rtype: EventsCycles.CycleAbortTestingArguments
		"""

		eventArguments = CycleEvents.CycleAbortTestingArguments()  # type: CycleEvents.CycleAbortTestingArguments

		for cycleAbortTestingCallback in self.CycleAbortTestingEvent:
			try:
				cycleAbortTestingCallback(self, eventArguments)
			except:
				Debug.Log("Failed to call cycle abort testing callback '" + Types.GetFullName(cycleAbortTestingCallback) + "'.\n" + self.TrackingSystem.DebugInformation,
						  This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = __name__ + ":" + str(Python.GetLineNumber()), lockReference = cycleAbortTestingCallback)

		return eventArguments
Exemplo n.º 9
0
    def _NotifyHandlerAdded(self,
                            addedHandler: HandlersBase.HandlerBase) -> None:
        eventArguments = CycleEvents.HandlerAddedArguments(
            addedHandler)  # type: CycleEvents.HandlerAddedArguments

        for handlerAddedCallback in self.HandlerAddedEvent:
            try:
                handlerAddedCallback(self, eventArguments)
            except:
                Debug.Log("Failed to call handler added callback '" +
                          Types.GetFullName(handlerAddedCallback) + "'.\n" +
                          self.TrackingSystem.DebugInformation,
                          This.Mod.Namespace,
                          Debug.LogLevels.Exception,
                          group=This.Mod.Namespace,
                          owner=__name__,
                          lockIdentifier=__name__ + ":" +
                          str(Python.GetLineNumber()),
                          lockReference=handlerAddedCallback)
Exemplo n.º 10
0
	def DoCycleReleaseOvumTesting (self, ovumRelease: CycleOvumRelease.OvumRelease) -> CycleEvents.CycleReleaseOvumTestingArguments:
		"""
		Test if the a cycle should release an ovum.
		:param ovumRelease: The object that has indicated to the cycle that an ovum should release.
		:type ovumRelease: CycleOvumRelease.OvumRelease
		:return: Testing event arguments that carry information on whether or not a cycle should release an ovum.
		:rtype: EventsCycles.CycleReleaseOvumTestingArguments
		"""

		eventArguments = CycleEvents.CycleReleaseOvumTestingArguments(ovumRelease)  # type: CycleEvents.CycleReleaseOvumTestingArguments

		for cycleReleaseOvumTestingCallback in self.CycleReleaseOvumTestingEvent:
			try:
				cycleReleaseOvumTestingCallback(self, eventArguments)
			except:
				Debug.Log("Failed to call cycle release ovum testing callback '" + Types.GetFullName(cycleReleaseOvumTestingCallback) + "'.\n" + self.TrackingSystem.DebugInformation,
						  This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = __name__ + ":" + str(Python.GetLineNumber()), lockReference = cycleReleaseOvumTestingCallback)

		return eventArguments
Exemplo n.º 11
0
	def _CurrentCycleCompletedCallback (self, completionReason: CycleShared.CompletionReasons) -> None:
		eventArguments = CycleEvents.CycleCompletedArguments(completionReason)  # type: CycleEvents.CycleCompletedArguments

		for cycleCompletedCallback in self.CycleCompletedEvent:
			try:
				cycleCompletedCallback(self, eventArguments)
			except:
				Debug.Log("Failed to call cycle completed callback '" + Types.GetFullName(cycleCompletedCallback) + "'.\n" + self.TrackingSystem.DebugInformation,
						  This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = __name__ + ":" + str(Python.GetLineNumber()), lockReference = cycleCompletedCallback)

		self.CurrentCycle = None

		self.CompletedInitialCycle = True
		self.CompletedFirstCycle = True

		self.TimeSinceLastCycle = None
		self.LastCycleCompletionReason = completionReason

		if completionReason == CycleShared.CompletionReasons.Finished:
			self.TimeSinceLastCycle = 0  # TODO this should be set only if the sim experiences any symptoms instead.
Exemplo n.º 12
0
	def DoCycleStartTesting (self) -> CycleEvents.CycleStartTestingArguments:
		"""
		Test for when the next cycle is to start and of what type it will be.
		:return: Testing event arguments that carry information on whether or not a cycle should start.
		:rtype: EventsCycles.CycleStartTestingArguments
		"""

		if self.CycleStartTestingSeed is None:
			self.CycleStartTestingSeed = self.TrackingSystem.CurrentSeed

		eventArguments = CycleEvents.CycleStartTestingArguments(self.CycleStartTestingSeed, self.TimeSinceLastCycle)  # type: CycleEvents.CycleStartTestingArguments
		self.CycleStartTestingEvent.Invoke(self, eventArguments)

		for cycleStartTestingCallback in self.CycleStartTestingEvent:
			try:
				cycleStartTestingCallback(self, eventArguments)
			except:
				Debug.Log("Failed to call cycle start testing callback '" + Types.GetFullName(cycleStartTestingCallback) + "'.\n" + self.TrackingSystem.DebugInformation,
						  This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, lockIdentifier = __name__ + ":" + str(Python.GetLineNumber()), lockReference = cycleStartTestingCallback)

		return eventArguments