Пример #1
0
        // replaces the method from RabbitHole class - identical except for new slot reassignment code
        public bool RouteNearEntranceAndEnterRabbitHole(Sim a, RabbitHole.IRabbitHoleFollowers inst, RabbitHole.BeforeEnteringRabbitHoleDelegate beforeEntering, bool canUseCar, Route.RouteMetaType routeMetaType, bool playRouteFailure)
        {
            if ((Target.RabbitHoleProxy.EnterSlots.Count == 0) || (Target.RabbitHoleProxy.ExitSlots.Count == 0))
            {
                return(false);
            }
            if (a.IsInRidingPosture && ((Target.RabbitHoleProxy.MountedEnterSlots.Count == 0) || (Target.RabbitHoleProxy.MountedExitSlots.Count == 0)))
            {
                return(false);
            }
            List <Sim>           list    = new List <Sim>();
            CarryingChildPosture posture = a.Posture as CarryingChildPosture;

            if (posture != null)
            {
                list.Add(posture.Child);
            }
            if (inst != null)
            {
                if (inst.SimFollowers != null)
                {
                    foreach (Sim sim in inst.SimFollowers)
                    {
                        posture = sim.Posture as CarryingChildPosture;
                        if (posture != null)
                        {
                            list.Add(posture.Child);
                        }
                    }
                    foreach (Sim sim2 in list)
                    {
                        inst.AddFollower(sim2);
                    }
                }
                else if (list.Count > 0)
                {
                    inst.AddFollower(list[0]);
                }
            }
            bool  flag   = false;
            Route item   = null;
            Sim   parent = null;

            if (a.IsInRidingPosture)
            {
                if (a.Parent is Sim)
                {
                    parent = a.Parent as Sim;
                }
                item = parent.CreateRoute();
                item.ExecutionFromNonSimTaskIsSafe = true;
            }
            else
            {
                item = a.CreateRoute();
            }
            bool flag2 = false;
            int  kRouteAttemptsToEnterRabbitHole = RabbitHole.kRouteAttemptsToEnterRabbitHole;
            Slot slotToUse = Slot.None;

            while ((kRouteAttemptsToEnterRabbitHole > 0) && !flag2)
            {
                kRouteAttemptsToEnterRabbitHole--;
                try
                {
                    Target.RabbitHoleProxy.ActiveEntryRoutes.Add(item);
                    if (playRouteFailure)
                    {
                        item.DoRouteFail = kRouteAttemptsToEnterRabbitHole == 0;
                    }
                    item.SetOption(Route.RouteOption.EnablePlanningAsCar, canUseCar);
                    if (Target.mGuid == RabbitHoleType.Subway)
                    {
                        item.SetOption(Route.RouteOption.EnableSubwayPlanning, false);
                    }
                    if (Target.mGuid == RabbitHoleType.HoverTrainStation)
                    {
                        item.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false);
                    }
                    item.SetRouteMetaType(routeMetaType);
                    foreach (Slot slot2 in Target.RabbitHoleProxy.EnterSlots)
                    {
                        item.AddObjectToIgnoreForRoute(Target.RabbitHoleProxy.SlotToSlotInfo[slot2].Footprint.ObjectId);
                    }
                    foreach (Slot slot3 in Target.RabbitHoleProxy.MountedEnterSlots)
                    {
                        item.AddObjectToIgnoreForRoute(Target.RabbitHoleProxy.SlotToSlotInfo[slot3].Footprint.ObjectId);
                    }
                    item.PlanToSlot(Target.RabbitHoleProxy, (a.IsInRidingPosture ? Target.RabbitHoleProxy.MountedEnterSlots : Target.RabbitHoleProxy.EnterSlots).ToArray());
                    if (!item.PlanResult.Succeeded())
                    {
                        item.DoRouteFail = playRouteFailure;
                        if (a.IsInRidingPosture)
                        {
                            return(parent.DoRoute(item));
                        }
                        return(a.DoRoute(item));
                    }
                    slotToUse = (Slot)item.PlanResult.mDestSlotNameHash;

                    // Slot Reassignment
                    if ((Target.RabbitHoleProxy.EnterSlots.Count > 1) && (Target.RabbitHoleProxy.EnterSlots.Count <= 5))
                    {
                        slotToUse = ReassignSlot(Target.RabbitHoleProxy.EnterSlots.Count);
                    }
                    List <Sim> followers = (inst == null) ? null : inst.SimFollowers;
                    if ((!flag && (followers != null)) && ((followers.Count > 1) || ((followers.Count == 1) && (followers[0].Posture.Container != a))))
                    {
                        //if (RouteOutside(a, followers, this.RabbitHoleProxy.EnterSlots[0x0], false, true, true, false))
                        if (Target.RouteOutside(a, followers, Target.RabbitHoleProxy.EnterSlots[0], false, true, true, false))
                        {
                            flag  = true;
                            flag2 = true;
                        }
                    }
                    else
                    {
                        //flag2 = RouteOutside(a, followers, none, false, true, false, false);
                        flag2 = Target.RouteOutside(a, followers, slotToUse, false, true, false, false);
                    }
                    if (!flag2 && (kRouteAttemptsToEnterRabbitHole > 0))
                    {
                        if (IntroTutorial.TutorialSim == a)
                        {
                            break;
                        }
                        a.RemoveExitReason(ExitReason.RouteFailed);
                        if (a.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)))
                        {
                            break;
                        }
                        a.LoopIdle();
                        Simulator.Sleep((uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(RabbitHole.kMinSimMinutesToSleepOnFailedRouteAttempt, RabbitHole.kMaxSimMinutesToSleepOnFailedRouteAttempt), TimeUnit.Minutes));
                    }
                    continue;
                }
                finally
                {
                    Target.RabbitHoleProxy.ActiveEntryRoutes.Remove(item);
                }
            }
            item = null;
            if (((a.ExitReason & ExitReason.HigherPriorityNext) == ExitReason.None) && ((a.ExitReason & ExitReason.UserCanceled) == ExitReason.None))
            {
                if (flag2)
                {
                    RabbitHole.NumSuccess++;
                }
                else
                {
                    RabbitHole.NumFail++;
                }
            }
            if (!flag2)
            {
                return(flag2);
            }
            if ((beforeEntering != null) && !beforeEntering())
            {
                List <Sim> simFollowers = null;
                if (inst != null)
                {
                    simFollowers = inst.SimFollowers;
                }
                //RouteOutside(a, simFollowers, RandomUtil.GetRandomObjectFromList<Slot>(a.IsInRidingPosture ? this.RabbitHoleProxy.MountedEnterSlots : this.RabbitHoleProxy.EnterSlots), false, false, true, true);
                Target.RouteOutside(a, simFollowers, RandomUtil.GetRandomObjectFromList <Slot>(a.IsInRidingPosture ? Target.RabbitHoleProxy.MountedEnterSlots : Target.RabbitHoleProxy.EnterSlots), false, false, true, true);
                return(false);
            }
            LeadingHorsePosture posture2 = a.Posture as LeadingHorsePosture;

            if (posture2 != null)
            {
                Sim container = posture2.Container as Sim;
                LeadingHorsePosture.ReleaseHorseFromLeadingPosture(a, container, false);
                Target.AnimateEnterRabbitHole(a, slotToUse, true, routeMetaType);
                Target.AnimateEnterRabbitHole(container, slotToUse, true, routeMetaType);
                return(flag2);
            }
            return(Target.AnimateEnterRabbitHole(a, slotToUse, true, routeMetaType));
        }
Пример #2
0
        public override bool RunFromInventory()
        {
            if (this.mResearchStation == null)
            {
                IResearchStation[]      objects = Sims3.Gameplay.Queries.GetObjects <IResearchStation>(base.Actor.LotCurrent);
                List <IResearchStation> list    = base.Actor.LotCurrent.GetObjects <IResearchStation>(p => !p.Repairable.Broken);
                if (objects.Length < 1)
                {
                    base.Actor.AddExitReason(ExitReason.FailedToStart);
                    return(false);
                }
                if (list.Count < 1)
                {
                    base.Actor.AddExitReason(ExitReason.FailedToStart);
                    return(false);
                }
                this.mResearchStation = objects[0];
            }
            if (!base.Actor.RouteToSlotAndCheckInUse(this.mResearchStation, Slot.RoutingSlot_0))
            {
                return(false);
            }
            GameObject mResearchStation = this.mResearchStation as GameObject;

            if (mResearchStation != null)
            {
                mResearchStation.EnableFootprintAndPushSims(ScientificSample.kScienceStationFootprintHash, base.Actor);
            }
            this.mVialsToUse = new List <ScientificSample>();
            base.Target.SetGeometryState(ScientificSample.kGeoStateInUse);
            base.Target.CreateClonesForInteraction(this.mVialsToUse, base.Actor);
            base.StandardEntry();
            base.BeginCommodityUpdates();
            if (base.Actor.TraitManager.HasElement(TraitNames.AntiTV))
            {
                base.Actor.BuffManager.AddElementPaused(BuffNames.AntiTV, Origin.FromScienceEquipment);
            }
            base.EnterStateMachine("ScienceStation", "EnterScienceStation", "x");
            base.AddOneShotScriptEventHandler(0x65, new SacsEventHandler(this.OnPlaceTargetOnTray));
            base.AddOneShotScriptEventHandler(0x66, new SacsEventHandler(this.OnRemoveTargetOnTray));
            base.AddOneShotScriptEventHandler(0x6f, new SacsEventHandler(this.OnStartStationLaser));
            base.AddOneShotScriptEventHandler(0xde, new SacsEventHandler(this.OnStopStationLaser));
            base.AddOneShotScriptEventHandler(0x20c, new SacsEventHandler(this.OnCloneSpawn));
            base.SetActor("researchStation", this.mResearchStation);
            base.Actor.Inventory.TryToRemove(base.Target);
            base.AnimateSim("PerformExperiment");
            bool succeeded = this.DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached | ExitReason.Canceled), new InteractionInstance.InsideLoopFunction(this.LoopDel), base.mCurrentStateMachine);

            if (base.Target.ScientificSampleType == ScientificSample.SampleType.Dna)
            {
                // custom
                this.DetermineHumanOutcomeEx(succeeded);
            }
            else
            {
                this.DetermineObjectOutcome(succeeded);
            }
            base.EndCommodityUpdates(succeeded);
            base.StandardExit();
            if (this.mCloneSim != null)
            {
                if (this.mCloneSim.Household != base.Actor.Household)
                {
                    this.mCloneSim.SimDescription.FirstName = StringInputDialog.Show(Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneTitle", new object[0]), Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneDesc", new object[0]), string.Empty, CASBasics.GetMaxNameLength(), StringInputDialog.Validation.SimNameText);
                    CarryingChildPosture posture = base.Actor.Posture as CarryingChildPosture;
                    if (posture != null)
                    {
                        base.Actor.InteractionQueue.AddNext(PutDownChild.Singleton.CreateInstance(posture.Child, base.Actor, new InteractionPriority(InteractionPriorityLevel.High), base.Autonomous, false));
                    }
                    SocialWorkerChildAbuse.Instance.MakeServiceRequest(base.Actor.LotCurrent, true, this.mCloneSim.ObjectId, true);
                }
                else
                {
                    this.mCloneSim.SimDescription.FirstName = StringInputDialog.Show(Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneTitle", new object[0]), Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneDesc", new object[0]), string.Empty, CASBasics.GetMaxNameLength(), StringInputDialog.Validation.SimNameText);
                    ScientificSample.DnaSampleSubject subject = base.Target.Subject as ScientificSample.DnaSampleSubject;
                    if (subject != null)
                    {
                        this.mCloneSim.SimDescription.LastName = subject.Subject.LastName;
                    }
                    else
                    {
                        this.mCloneSim.SimDescription.LastName = base.Actor.LastName;
                    }
                }
                ChildUtils.FinishObjectInteractionWithChild(this, this.mCloneSim);
            }
            return(succeeded);
        }
Пример #3
0
        public bool AllowSim(Common.IStatGenerator stats, Sim sim, Lot lot)
        {
            if (sim == null)
            {
                return(false);
            }

            if (!lot.IsOpenVenue())
            {
                stats.IncStat("Not Open Venue");
                return(false);
            }
            else if (UnchartedIslandMarker.IsUnchartedIsland(lot))
            {
                stats.IncStat("Uncharted");
                return(false);
            }

            LotOptions lotOptions = GetLotOptions(lot);

            if (!lotOptions.GetValue <AllowLotPushOption, bool>())
            {
                stats.IncStat("Lot Push Denied");
                return(false);
            }

            if (!lotOptions.AllowCastes(stats, sim.SimDescription))
            {
                return(false);
            }

            switch (lot.CommercialLotSubType)
            {
            case CommercialLotSubType.kEP2_JunkyardNoVisitors:
            case CommercialLotSubType.kMisc_NoVisitors:
                stats.IncStat("No Visitors");
                return(false);

            case CommercialLotSubType.kArtGallery:
            case CommercialLotSubType.kTheatre:
                if (sim.TraitManager.HasElement(TraitNames.CantStandArt))
                {
                    stats.IncStat("CantStandArt");
                    return(false);
                }
                break;

            case CommercialLotSubType.kBeach:
            case CommercialLotSubType.kEP3_DanceClubPool:
            case CommercialLotSubType.kPool:
            case CommercialLotSubType.kFishingSpot:
                if (sim.TraitManager.HasElement(TraitNames.CantStandArt))
                {
                    stats.IncStat("CantStandArt");
                    return(false);
                }
                break;

            case CommercialLotSubType.kGym:
                if (sim.TraitManager.HasElement(TraitNames.CouchPotato))
                {
                    stats.IncStat("CouchPotato");
                    return(false);
                }
                break;

            case CommercialLotSubType.kGraveyard:
                if (sim.TraitManager.HasElement(TraitNames.Coward))
                {
                    stats.IncStat("Coward");
                    return(false);
                }
                break;
            }

            CarryingChildPosture posture = sim.CarryingChildPosture;

            if (posture != null)
            {
                if (!AllowSim(stats, posture.Child, lot))
                {
                    stats.IncStat("Child Fail");
                    return(false);
                }
            }

            return(true);
        }
Пример #4
0
        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);
                    }
                }
            }
        }