public static List <InteractionObjectPair> GetAllInteractionsForActor(Sim ths, IActor actor) { List <InteractionObjectPair> allInteractionsForActor; InteractionInstance currentInteraction = ths.CurrentInteraction; Sim sim = actor as Sim; if (ths.DisablePieMenuOnSim) { sMsg += Common.NewLine + "Disabled"; return(new List <InteractionObjectPair>()); } if (ths.BuffManager.HasElement(BuffNames.BabyIsComing)) { sMsg += Common.NewLine + "Pregnant"; allInteractionsForActor = new List <InteractionObjectPair>(); allInteractionsForActor.Add(new InteractionObjectPair(Pregnancy.TakeToHospital.Singleton, ths)); return(allInteractionsForActor); } allInteractionsForActor = new List <InteractionObjectPair>(); //base.GetAllInteractionsForActor(actor); if (actor != ths) { List <InteractionObjectPair> list2; DaycareSituation daycareSituationForSim = DaycareSituation.GetDaycareSituationForSim(ths); if ((daycareSituationForSim != null) && daycareSituationForSim.OverrideActorInteractions) { sMsg += Common.NewLine + "Daycare"; return(daycareSituationForSim.GetAllInteractionsForActor(sim, ths)); } if (FirefighterEmergencySituation.FindFirefighterEmergencySituationInvolvingSim(ths) != null) { sMsg += Common.NewLine + "Firefighter"; allInteractionsForActor.Clear(); } else { if (actor.Posture.GetType() != ths.Posture.GetType()) { sMsg += Common.NewLine + "Posture Socials " + actor.Posture.GetType().ToString() + " " + ths.Posture.GetType().ToString(); actor.Posture.AddSocialInteractions(ths, allInteractionsForActor); } if (actor.Posture.AllowsNormalSocials() && ths.Posture.AllowsNormalSocials()) { int count = 0; foreach (InteractionObjectPair pair in GetAllInteractionsForSim(ths.SocialComponent, sim, false)) { pair.AddInteractions(actor, allInteractionsForActor); count++; } sMsg += Common.NewLine + "Socials " + count; } if (currentInteraction != null) { InteractionTuning tuning = currentInteraction.InteractionObjectPair.Tuning; if (((tuning != null) && tuning.mTradeoff.JoinableInteraction) && (!(currentInteraction.InteractionDefinition is IDoNotAddJoinInteraction) && !Sim.HaveSameCurrentInteraction(sim, ths))) { Sim.Join.Definition interaction = new Sim.Join.Definition(); new InteractionObjectPair(interaction, ths).AddInteractions(actor, allInteractionsForActor); } } if ((sim.CurrentInteraction != null) && (sim.CurrentInteraction != currentInteraction)) { InteractionObjectPair interactionObjectPair = sim.CurrentInteraction.InteractionObjectPair; if (((interactionObjectPair.Tuning != null) && interactionObjectPair.Tuning.mTradeoff.JoinableInteraction) && !Sim.HaveSameCurrentInteraction(sim, ths)) { Sim.AskToJoin.Definition definition2 = new Sim.AskToJoin.Definition(); new InteractionObjectPair(definition2, ths).AddInteractions(actor, allInteractionsForActor); } } } if (ths.mSituationSpecificInteractions.TryGetValue(sim, out list2) && (list2.Count > 0x0)) { foreach (InteractionObjectPair pair5 in list2) { bool flag = false; foreach (InteractionObjectPair pair6 in allInteractionsForActor) { SocialInteractionA.Definition interactionDefinition = pair6.InteractionDefinition as SocialInteractionA.Definition; SocialInteractionA.Definition definition4 = pair5.InteractionDefinition as SocialInteractionA.Definition; if (((definition4 != null) && (interactionDefinition != null)) && (interactionDefinition.ActionKey == definition4.ActionKey)) { string[] path = interactionDefinition.GetPath(actor.IsFemale); string[] strArray2 = definition4.GetPath(actor.IsFemale); if (strArray2.Length == path.Length) { bool flag2 = true; for (int i = 0x0; i < strArray2.Length; i++) { if (strArray2[i] != path[i]) { flag2 = false; break; } } if (flag2) { flag = true; break; } } } } if (!flag) { allInteractionsForActor.Add(pair5); } } } } else { foreach (InteractionObjectPair pair7 in ths.SoloInteractions) { pair7.AddInteractions(actor, allInteractionsForActor); } } foreach (Sim.IAddsSimInteractions interactions in Inventories.QuickDuoFind <Sim.IAddsSimInteractions, GameObject>(actor.Inventory)) { interactions.GetAllInteractions(actor as Sim, ths, allInteractionsForActor); } allInteractionsForActor.Sort(); return(allInteractionsForActor); }
public static void ShouldBabyOrToddler(Sims3.Gameplay.ActorSystems.InteractionQueue simIQ) { if (simIQ.mBabyOrToddlerTransitionTargetInteraction != null) { return; } DaycareTransportSituation daycareTransportSituation = DaycareSituation.GetDaycareSituationForSim(simIQ.mActor) as DaycareTransportSituation; if (daycareTransportSituation != null) { return; } Sim sim = simIQ.mActor; InteractionInstance interactionInstance = simIQ.mInteractionList._items[0]; if (interactionInstance == null) { return; } Lot targetLot = interactionInstance.GetTargetLot(); LotLocation location = LotLocation.Invalid; World.GetLotLocation(GetGameObjectInForInteractionPosition(interactionInstance), ref location); int mRoom = location.mRoom; int mLevel = location.mLevel; if (interactionInstance.Target == simIQ.mActor || interactionInstance.Target == simIQ.mActor.Posture.Container) { return; } ItemComponent itemComp = interactionInstance.Target.ItemComp; if ((itemComp != null && itemComp.InventoryParent != null && itemComp.InventoryParent.Owner == sim) || simIQ.TryLocalToddlerCareRules(sim, interactionInstance, targetLot, mLevel, mRoom) || interactionInstance is Terrain.GoHereWith || (interactionInstance is Terrain.TeleportMeHere && !(interactionInstance is Terrain.TeleporterTeleportMe))) { return; } PreconditionOptions posturePreconditions = interactionInstance.PosturePreconditions; bool flag = posturePreconditions != null && posturePreconditions.ContainsPosture(CommodityKind.CarryingChild); Lot lotHome = sim.LotHome; bool flag2 = lotHome == sim.LotCurrent; if (flag2 && lotHome != null && lotHome.HasVirtualResidentialSlots) { flag2 = !sim.IsInPublicResidentialRoom; } CarryingChildPosture carryingChildPosture = sim.CarryingChildPosture; if (carryingChildPosture != null && carryingChildPosture.Child.Household == sim.Household && !flag2 && !flag) { if (simIQ.ShouldTakeBabyOrToddlerWithUsTo(interactionInstance)) { float num = (sim.Position - GetGameObjectInForInteractionPosition(interactionInstance)).LengthSqr(); float num2 = 0.99f / num; float num3 = 9.01f + num2 % num; if (!(num < num2) && !(num > num3)) { return; } Route route = sim.CreateRoute(); int[] validRooms = new int[1] { interactionInstance.Target.RoomId }; route.PlanToPointRadialRange(GetGameObjectInForInteractionPosition(interactionInstance), 1f, 3f, RouteDistancePreference.NoPreference, RouteOrientationPreference.NoPreference, targetLot.LotId, validRooms); if (route.PlanResult.Succeeded()) { float num4 = (route.GetDestPoint() - sim.Position).LengthSqr(); if (num4 >= 0.00250000018f) { Terrain.GoHere goHere = Terrain.GoHere.OtherLotWithCarriedChildSingleton.CreateInstance(Terrain.Singleton, sim, interactionInstance.GetPriority(), interactionInstance.Autonomous, true) as Terrain.GoHere; goHere.SetDestination(route.PlanResult.mDestination, false); simIQ.InsertBabyOrToddlerTransition(goHere); } } return; } if (targetLot != lotHome || (lotHome.HasVirtualResidentialSlots && sim.IsInPublicResidentialRoom && !targetLot.IsRoomPublic(mRoom))) { simIQ.InsertTakeBabyOrToddlerHome(sim, interactionInstance); return; } } if ((interactionInstance.Autonomous || CaregiverRoutingMonitor.TreatPlayerSimsLikeNPCs) && sim.SimDescription.TeenOrAbove && sim.Household != null && sim.Household.LotHome != null && sim.InheritedPriority().Level < InteractionPriorityLevel.ESRB) { bool flag3 = false; bool flag4 = false; if (targetLot == null || targetLot.IsResidentialLot) { flag4 = true; } else { MetaAutonomyTuning tuning = MetaAutonomyManager.GetTuning(interactionInstance.GetTargetLot().GetMetaAutonomyVenueType()); if (tuning != null) { flag3 = tuning.BabiesCanVisit; flag4 = tuning.ToddlersCanVisit; } } if (flag3 || flag4) { foreach (Sim sim2 in sim.Household.Sims) { if ((!sim2.SimDescription.Baby || sim2.LotCurrent != sim2.LotHome) && (!sim2.SimDescription.Baby || flag3) && (!sim2.SimDescription.Toddler || flag4) && sim2.SimDescription.ToddlerOrBelow && sim2.LotCurrent == sim.LotCurrent) { if (CaregiverRoutingMonitor.EnoughCaregiversRemain(sim.Household, sim.LotCurrent, false) || (carryingChildPosture != null && carryingChildPosture.Child.Household == sim.Household) || (!flag && flag2)) { break; } simIQ.InsertPickUpBabyOrToddler(sim, sim2, sim2.LotCurrent.IsActive || sim2.Posture.Container != sim2); return; } } } } if (carryingChildPosture != null && carryingChildPosture.Child.Household != sim.Household) { simIQ.InsertPutDownBabyOrToddler(sim); return; } if (carryingChildPosture != null) { DaycareSituation daycareSituationForChild = DaycareSituation.GetDaycareSituationForChild(carryingChildPosture.Child); if (daycareSituationForChild != null && daycareSituationForChild.Lot != interactionInstance.GetTargetLot()) { simIQ.InsertPutDownBabyOrToddler(sim); return; } } if ((interactionInstance.Autonomous || CaregiverRoutingMonitor.TreatPlayerSimsLikeNPCs) && carryingChildPosture != null && carryingChildPosture.Child.SimDescription.Baby && flag2 && targetLot != sim.LotCurrent) { simIQ.InsertPutDownBabyOrToddler(sim); } else if (sim.Household != null && sim.Household.LotHome != null) { foreach (Sim sim3 in sim.Household.Sims) { if (sim3.SimDescription.ToddlerOrBelow) { CaregiverRoutingMonitor.StartMonitoring(sim3); } } } }