public void TriggerSocialWorker(Sim sim, CommodityKind commodity) { Household household = sim.Household; if (household.IsPetHousehold) { return; } if (sim.IsHuman) { DaycareWorkdaySituation daycareWorkdaySituation = DaycareSituation.GetDaycareSituationForChild(sim) as DaycareWorkdaySituation; if (daycareWorkdaySituation != null) { SimDescription ownerDescription = daycareWorkdaySituation.Daycare.OwnerDescription; if (daycareWorkdaySituation.Daycare.OwnerDescription == null) { return; } household = daycareWorkdaySituation.Daycare.OwnerDescription.Household; } } household.SetSocialWorkerTrigger(sim, commodity); }
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); } } } }