public override bool Run() { try { if (Actor.LotCurrent != Target) { Vector3 point = World.LotGetPtInside(Target.LotId); if (point == Vector3.Invalid) { return(false); } if (!Actor.RouteToPointRadius(point, 3f) && (!GlobalFunctions.PlaceAtGoodLocation(Actor, new World.FindGoodLocationParams(point), false) || !SimEx.IsPointInLotSafelyRoutable(Actor, Target, Actor.Position))) { Actor.AttemptToPutInSafeLocation(true); } } Sim destObj = null; float negativeInfinity = float.NegativeInfinity; foreach (Sim sim2 in Actor.Household.Sims) { if ((sim2.IsHuman && sim2.IsAtHome) && !sim2.IsSleeping) { Relationship relationship = Relationship.Get(Actor, sim2, false); if ((relationship != null) && (relationship.LTR.Liking > negativeInfinity)) { destObj = sim2; negativeInfinity = relationship.LTR.Liking; } } } if (destObj != null) { Actor.RouteToDynamicObjectRadius(destObj, kRouteToHighRelSimRange[0x0], kRouteToHighRelSimRange[0x1], null, new Route.RouteOption[] { Route.RouteOption.DoLineOfSightCheckUserOverride }); } string instanceName = null; switch (Actor.SimDescription.Species) { case CASAgeGenderFlags.Dog: instanceName = "dogPregnantJig"; break; case CASAgeGenderFlags.LittleDog: instanceName = "smallDogPregnantJig"; break; case CASAgeGenderFlags.Horse: instanceName = "horsePregnantJig"; break; case CASAgeGenderFlags.Cat: instanceName = "catPregnantJig"; break; } if (instanceName != null) { mPetPregnancyJig = GlobalFunctions.CreateObjectOutOfWorld(instanceName, ProductVersion.EP5) as SocialJigOnePerson; if (mPetPregnancyJig != null) { mPetPregnancyJig.RegisterParticipants(Actor, null); Vector3 position = Actor.Position; Vector3 forwardVector = Actor.ForwardVector; if (GlobalFunctions.FindGoodLocationNearby(mPetPregnancyJig, ref position, ref forwardVector)) { mPetPregnancyJig.SetPosition(position); mPetPregnancyJig.SetForward(forwardVector); mPetPregnancyJig.AddToWorld(); Route r = mPetPregnancyJig.RouteToJigA(Actor); if (!Actor.DoRoute(r)) { mPetPregnancyJig.Destroy(); mPetPregnancyJig = null; } } else { mPetPregnancyJig.Destroy(); mPetPregnancyJig = null; } } } StandardEntry(); BeginCommodityUpdates(); EnterStateMachine("GiveBirth", "Enter", "x"); AnimateSim("LieDown"); if (Actor.IsSelectable) { try { Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/PetPregnancy:DisableSave"); // Custom HaveBabyHomeEx.EnsureForeignFather(Actor.SimDescription.Pregnancy); mOffspring = new Proxies.PetPregnancyProxy(Actor.SimDescription.Pregnancy).CreateNewborns(0f, true, true); int num2 = 0x0; foreach (Sim sim3 in mOffspring) { sim3.SimDescription.IsNeverSelectable = true; if (mPetPregnancyJig != null) { Slot slotName = kPregnancyJigContainmentSlots[num2++]; sim3.SetPosition(mPetPregnancyJig.GetPositionOfSlot(slotName)); sim3.SetForward(mPetPregnancyJig.GetForwardOfSlot(slotName)); InteractionInstance entry = Pregnancy.BabyPetLieDown.Singleton.CreateInstance(sim3, sim3, new InteractionPriority(InteractionPriorityLevel.Autonomous), true, true); entry.Hidden = true; sim3.InteractionQueue.AddNext(entry); } else { World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Actor.Position); fglParams.RequiredRoomID = Actor.RoomId; if ((!GlobalFunctions.PlaceAtGoodLocation(sim3, fglParams, false) || !sim3.IsPointInLotSafelyRoutable(sim3.LotCurrent, sim3.Position)) && !sim3.AttemptToPutInSafeLocation(true)) { sim3.SetPosition(Actor.Position); } } } } finally { Sims3.Gameplay.Gameflow.Singleton.EnableSave(this); } } // Custom call bool flag = DoLoop(ExitReason.Finished, GiveBirthLoopFunc, mCurrentStateMachine); AnimateSim("Exit"); StandardExit(); return(flag); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public override bool Run() { try { if (Actor.LotCurrent != Target) { Vector3 point = World.LotGetPtInside(Target.LotId); if (point == Vector3.Invalid) { return(false); } if (!Actor.RouteToPointRadius(point, 3f) && (!GlobalFunctions.PlaceAtGoodLocation(Actor, new World.FindGoodLocationParams(point), false) || !SimEx.IsPointInLotSafelyRoutable(Actor, Target, Actor.Position))) { Actor.AttemptToPutInSafeLocation(true); } } if (Actor.Posture is SwimmingInPool) { SwimmingInPool posture = Actor.Posture as SwimmingInPool; if (!posture.ContainerPool.RouteToEdge(Actor)) { if (Actor.BridgeOrigin != null) { Actor.BridgeOrigin.MakeRequest(); } Actor.PopPosture(); IGameObject reservedTile = null; Actor.FindRoutablePointInsideNearFrontDoor(Actor.Household.LotHome, out reservedTile); Vector3 position = reservedTile.Position; Terrain.TeleportMeHere here = Terrain.TeleportMeHere.Singleton.CreateInstance(Terrain.Singleton, Actor, new InteractionPriority(InteractionPriorityLevel.Pregnancy), false, false) as Terrain.TeleportMeHere; here.SetAndReserveDestination(reservedTile); try { here.RunInteractionWithoutCleanup(); } catch { Actor.SetPosition(position); } finally { here.Cleanup(); } Actor.LoopIdle(); } } Pregnancy pregnancy = Actor.SimDescription.Pregnancy; GetNewBorns(); AcquirePregnancyStateMachine(); mCurrentStateMachine.SetActor("x", Actor); for (int i = 0; i < mNewborns.Count; i++) { Sim baby = mNewborns[i]; Relationship.Get(Actor, baby, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend); if (baby.BridgeOrigin != null) { baby.BridgeOrigin.MakeRequest(); baby.BridgeOrigin = null; } InternalHaveAlienBabyHome instance = InternalHaveAlienBabyHome.Singleton.CreateInstance(baby, Actor, GetPriority(), Autonomous, CancellableByPlayer) as InternalHaveAlienBabyHome; instance.TotalCount = mNewborns.Count; instance.BabyIndex = i + 1; instance.mCurrentStateMachine = mCurrentStateMachine; Actor.InteractionQueue.PushAsContinuation(instance, true); } TryDeliverImaginaryFriend(); return(true); } catch (ResetException) { throw; } catch (Exception e) { Logger.WriteExceptionLog(e, this, "HaveAlienBabyHome.Run() Error"); return(false); } }
public static bool Run(Pregnancy.HaveBabyHome ths) { try { if (ths.Actor.LotCurrent != ths.Target) { Vector3 point = World.LotGetPtInside(ths.Target.LotId); if (point == Vector3.Invalid) { return(false); } if (!ths.Actor.RouteToPointRadius(point, 3f) && (!GlobalFunctions.PlaceAtGoodLocation(ths.Actor, new World.FindGoodLocationParams(point), false) || !SimEx.IsPointInLotSafelyRoutable(ths.Actor, ths.Target, ths.Actor.Position))) { ths.Actor.AttemptToPutInSafeLocation(true); } } if (ths.Actor.Posture is SwimmingInPool) { SwimmingInPool posture = ths.Actor.Posture as SwimmingInPool; if (!posture.ContainerPool.RouteToEdge(ths.Actor)) { if (ths.Actor.BridgeOrigin != null) { ths.Actor.BridgeOrigin.MakeRequest(); } ths.Actor.PopPosture(); IGameObject reservedTile = null; ths.Actor.FindRoutablePointInsideNearFrontDoor(ths.Actor.Household.LotHome, out reservedTile); Vector3 position = reservedTile.Position; Terrain.TeleportMeHere here = Terrain.TeleportMeHere.Singleton.CreateInstance(Terrain.Singleton, ths.Actor, new InteractionPriority(InteractionPriorityLevel.Pregnancy), false, false) as Terrain.TeleportMeHere; here.SetAndReserveDestination(reservedTile); try { here.RunInteractionWithoutCleanup(); } catch { ths.Actor.SetPosition(position); } finally { here.Cleanup(); } ths.Actor.LoopIdle(); } } Pregnancy pregnancy = ths.Actor.SimDescription.Pregnancy; if (pregnancy != null) { // Custom EnsureForeignFather(pregnancy); } ths.GetNewBorns(); ths.AcquirePregnancyStateMachine(); ths.mCurrentStateMachine.SetActor("x", ths.Actor); for (int i = 0x0; i < ths.mNewborns.Count; i++) { Sim sim = ths.mNewborns[i]; Relationship.Get(ths.Actor, sim, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend); if (sim.BridgeOrigin != null) { sim.BridgeOrigin.MakeRequest(); sim.BridgeOrigin = null; } Pregnancy.InternalHaveBabyHome instance = Pregnancy.InternalHaveBabyHome.Singleton.CreateInstance(sim, ths.Actor, ths.GetPriority(), ths.Autonomous, ths.CancellableByPlayer) as Pregnancy.InternalHaveBabyHome; instance.TotalCount = ths.mNewborns.Count; instance.BabyIndex = i + 0x1; instance.mCurrentStateMachine = ths.mCurrentStateMachine; ths.Actor.InteractionQueue.PushAsContinuation(instance, true); } ths.TryDeliverImaginaryFriend(); return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(ths.Actor, ths.Target, e); return(false); } }
protected override void PrivatePerformAction(bool prompt) { Overwatch.Log(Name); foreach (Sim createdSim in new List <Sim> (LotManager.Actors)) { StuckSimData other; if (!sData.TryGetValue(createdSim.SimDescription.SimDescriptionId, out other)) { other = new StuckSimData(); sData.Add(createdSim.SimDescription.SimDescriptionId, other); } try { bool wasReset = false; if ((createdSim != null) && (createdSim.InWorld) && (createdSim.Proxy != null) && (!SimTypes.IsSelectable(createdSim))) { bool check = true; if (createdSim.Parent is IBed) { check = false; } if (createdSim.OccultManager != null) { OccultRobot bot = createdSim.OccultManager.GetOccultType(Sims3.UI.Hud.OccultTypes.Robot) as OccultRobot; if (bot != null && bot.IsShutdown) { check = false; } } if (check) { InteractionInstance interaction = createdSim.CurrentInteraction; bool sameInteraction = (object.ReferenceEquals(other.mLastInteraction, interaction)); other.mLastInteraction = interaction; if (createdSim.LotCurrent.IsRoomHidden(createdSim.RoomId)) { ResetTask.Perform(createdSim, Vector3.Invalid, "Unroutable"); wasReset = true; } if ((!wasReset) && (other.mLastPosition != Vector3.Invalid) && (other.mLastPosition == createdSim.Position)) { if ((interaction == null) || (sameInteraction)) { bool success = false; try { success = SimEx.IsPointInLotSafelyRoutable(createdSim, createdSim.LotCurrent, createdSim.PositionOnFloor); } catch (Exception e) { Common.DebugException(createdSim, e); success = false; } if (!success) { ResetTask.Perform(createdSim, Vector3.Invalid, "Unroutable"); wasReset = true; } } } if (other.mLastPosition != createdSim.Position) { other.mLastPosition = createdSim.Position; other.mLastPositionTicks = SimClock.CurrentTicks; } else if ((prompt) || ((other.mLastPositionTicks + SimClock.kSimulatorTicksPerSimDay) < SimClock.CurrentTicks)) { if (!wasReset) { bool reset = false; if (sameInteraction) { reset = true; } if (reset) { ResetTask.Perform(createdSim, Vector3.Invalid, "Stationary"); wasReset = true; } } } } } else { wasReset = true; } if (wasReset) { sData.Remove(createdSim.SimDescription.SimDescriptionId); } } catch (Exception e) { Common.Exception(createdSim, e); } } }
public override bool Run() { bool result; try { if (Actor.LotCurrent != Target) { Vector3 point = World.LotGetPtInside(Target.LotId); if (point == Vector3.Invalid) { return(false); } if (!Actor.RouteToPointRadius(point, 3f) && (!GlobalFunctions.PlaceAtGoodLocation(Actor, new World.FindGoodLocationParams(point), false) || !SimEx.IsPointInLotSafelyRoutable(Actor, Target, Actor.Position))) { Actor.AttemptToPutInSafeLocation(true); } } if (Actor.Posture is SwimmingInPool && !(Actor.Posture as SwimmingInPool).ContainerPool.RouteToEdge(Actor)) { if (Actor.BridgeOrigin != null) { Actor.BridgeOrigin.MakeRequest(); } Actor.PopPosture(); IGameObject reservedTile = null; Actor.FindRoutablePointInsideNearFrontDoor(Actor.Household.LotHome, out reservedTile); Vector3 position = reservedTile.Position; Terrain.TeleportMeHere here = Terrain.TeleportMeHere.Singleton.CreateInstance(Terrain.Singleton, Actor, new InteractionPriority(InteractionPriorityLevel.Pregnancy), false, false) as Terrain.TeleportMeHere; here.SetAndReserveDestination(reservedTile); try { here.RunInteractionWithoutCleanup(); } catch { Actor.SetPosition(position); } finally { here.Cleanup(); } Actor.LoopIdle(); } AlienPregnancyProxy pregnancy = new AlienPregnancyProxy(Actor.SimDescription.Pregnancy); Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave"); mNewborns = pregnancy.CreateNewborns(0f, Actor.IsSelectable, true); mCurrentStateMachine = StateMachineClient.Acquire(Actor, "Pregnancy"); mCurrentStateMachine.SetActor("x", Actor); for (int i = 0; i < mNewborns.Count; i++) { Sim baby = mNewborns[i]; Relationship.Get(Actor, baby, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend); if (baby.BridgeOrigin != null) { baby.BridgeOrigin.MakeRequest(); baby.BridgeOrigin = null; } HaveAlienBabyHomeInternal instance = HaveAlienBabyHomeInternal.Singleton.CreateInstance(baby, Actor, GetPriority(), Autonomous, CancellableByPlayer) as HaveAlienBabyHomeInternal; instance.TotalCount = mNewborns.Count; instance.BabyIndex = i + 1; instance.mCurrentStateMachine = mCurrentStateMachine; Actor.InteractionQueue.PushAsContinuation(instance, true); } if (Actor.IsSelectable) { OccultImaginaryFriend.DeliverDollToHousehold(mNewborns); } result = true; } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); result = false; } return(result); }