Exemple #1
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            Common.StringBuilder msg = new Common.StringBuilder("Run");

            try
            {
                Terrain terrain = parameters.mTarget as Terrain;
                if (terrain != null)
                {
                    foreach (Sim sim in LotManager.Actors)
                    {
                        Common.TestSpan span = Common.TestSpan.CreateSimple();

                        Route r = null;

                        uint simFlags = sim.SimDescription.SimFlags;

                        try
                        {
                            r = Route.Create(sim.Proxy, simFlags);
                        }
                        finally
                        {
                            msg += Common.NewLine + sim.FullName;
                            msg += Common.NewLine + " " + sim.SimDescription.mSimFlags;
                            msg += Common.NewLine + " " + span.Duration;
                        }

                        SimDescription simDescription  = sim.SimDescription;
                        Posture        previousPosture = sim.Posture;

                        SimRoutingComponent routingComponent = sim.RoutingComponent as SimRoutingComponent;

                        bool flag = false;

                        span = Common.TestSpan.CreateSimple();
                        try
                        {
                            //routingComponent.SetRouteOptions(route, simFlags);

                            if (!(sim.CurrentInteraction is IHasCustomRouteOptions))
                            {
                                r.SetOption(Route.RouteOption.BeginAsCar, (sim.Parent is Vehicle) && !(sim.Parent is IBoat));
                                r.SetOption(Route.RouteOption.EnablePlanningAsCar, simDescription.ChildOrAbove);
                                r.SetOption(Route.RouteOption.DisablePlanningAsPedestrian, false);
                                r.SetOption(Route.RouteOption.PushSimsAtDestination, true);
                                r.SetOption(Route.RouteOption.UseAutoSlotFootprintLocking, true);
                                r.SetOption(Route.RouteOption.ReplanToFindObstacleWhenPathPlanFails, true);
                                r.SetOption(Route.RouteOption.IgnoreParent, false);
                                r.SetOption(Route.RouteOption.IgnoreChildren, false);
                                r.SetOption(Route.RouteOption.CreateSubPaths, true);
                                r.SetOption(Route.RouteOption.CheckForFootprintsNearGoals, true);
                                r.SetOption(Route.RouteOption.PenalizeGoalsOnDifferentLevels, true);
                                if (GameUtils.IsInstalled(ProductVersion.EP10))
                                {
                                    IBoat parent = sim.Parent as IBoat;
                                    if (parent != null)
                                    {
                                        flag       = true;
                                        r.Follower = parent.Proxy;
                                        r.FollowerAgeGenderSpecies = (uint)parent.GetBoatSpecies();
                                        r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, true);
                                        r.SetOption2(Route.RouteOption2.BeginAsBoat, true);
                                        r.SetOption2(Route.RouteOption2.UseFollowerStartOrientation, true);
                                        r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true);
                                        r.AddObjectToIgnoreForRoute(sim.ObjectId);
                                    }
                                    bool flag2 = OccultMermaid.IsEveryOneGroupedWithMeATeenOrAboveMermaid(sim);
                                    bool flag3 = false;
                                    if (!flag2)
                                    {
                                        flag3 = ((previousPosture is CarryingChildPosture) || (previousPosture is CarryingPetPosture)) || sim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation));
                                    }
                                    bool flag4 = simDescription.ChildOrAbove & !(previousPosture is ScubaDiving);
                                    flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.GiveCPR);
                                    flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.FakeInjury);
                                    flag4 &= !(simDescription.CreatedByService is GrimReaper);
                                    flag4 &= !flag2 || flag3;
                                    flag4 &= !(previousPosture is BeingRiddenPosture) && !(previousPosture is RidingPosture);
                                    bool flag5 = simDescription.ChildOrAbove && simDescription.IsHuman;
                                    flag5 &= !(previousPosture is CarryingChildPosture) && !(previousPosture is CarryingPetPosture);
                                    r.SetOption(Route.RouteOption.EnableWaterPlanning, flag5);
                                    r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, !flag5);
                                    r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, (parent != null) || flag4);
                                    if (flag2 && flag5)
                                    {
                                        r.SetOption2(Route.RouteOption2.RouteAsMermaid, true);
                                    }
                                    else
                                    {
                                        r.SetOption2(Route.RouteOption2.RouteAsLifeguard, Lifeguard.ShouldUseRescueSwimWade(sim));
                                    }
                                }

                                // Cut

                                if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP3))
                                {
                                    r.SetOption(Route.RouteOption.EnableSubwayPlanning, true);
                                }
                                if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP5) && ((sim.IsWildAnimal || sim.IsStray) || (sim.IsUnicorn || WildHorses.IsWildHorse(sim))))
                                {
                                    r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, false);
                                    r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, true);
                                }
                                if (routingComponent.SimSatisfiesSpecialConditions())
                                {
                                    r.SetOption(Route.RouteOption.PassThroughObjects, true);
                                    r.SetOption(Route.RouteOption.PassThroughWalls, true);
                                }
                                if (sim.HasGhostBuff && !flag)
                                {
                                    r.SetOption(Route.RouteOption.RouteAsGhost, true);
                                }
                                if ((GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP4) && (sim.CarryingChildPosture != null)) && (Stroller.GetStroller(sim, sim.LotCurrent) != null))
                                {
                                    r.SetOption(Route.RouteOption.PlanUsingStroller, true);
                                }
                                if (sim.IsHuman)
                                {
                                    SwimmingInPool pool = previousPosture as SwimmingInPool;
                                    if (pool != null)
                                    {
                                        if (pool.ContainerIsOcean)
                                        {
                                            r.SetOption(Route.RouteOption.EnableWaterPlanning, true);
                                        }
                                    }
                                    else
                                    {
                                        Ocean.PondAndOceanRoutingPosture posture2 = previousPosture as Ocean.PondAndOceanRoutingPosture;
                                        if ((posture2 != null) && (posture2.WalkStyleToUse == Sim.WalkStyle.Wade))
                                        {
                                            r.SetOption(Route.RouteOption.EnableWaterPlanning, true);
                                        }
                                    }
                                }

                                // Cut

                                if (GameUtils.IsInstalled(ProductVersion.EP8))
                                {
                                    if (SimEx.GetOwnedAndUsableVehicle(sim, sim.LotHome, false, false, false, true) is CarUFO)
                                    {
                                        r.SetOption(Route.RouteOption.EnableUFOPlanning, true);
                                    }

                                    if ((sim.IsHuman && sim.SimDescription.ChildOrAbove) && PondManager.ArePondsFrozen())
                                    {
                                        bool flag6 = true;
                                        while (previousPosture != null)
                                        {
                                            if (previousPosture.Satisfaction(CommodityKind.Standing, null) <= 0f)
                                            {
                                                flag6 = false;
                                                break;
                                            }
                                            previousPosture = previousPosture.PreviousPosture;
                                        }
                                        if (flag6)
                                        {
                                            r.SetOption(Route.RouteOption.EnablePondPlanning, true);
                                        }
                                    }
                                }
                            }
                        }
                        finally
                        {
                            msg += Common.NewLine + " B " + span.Duration;
                        }

                        span = Common.TestSpan.CreateSimple();
                        try
                        {
                            if (!(sim.CurrentInteraction is IHasCustomRouteOptions))
                            {
                                r.ExitReasonsInterrupt = unchecked ((int)0xffa9bfff);
                                if ((0x0 != (simFlags & 0x3)) && !sim.LotCurrent.IsWorldLot)
                                {
                                    r.SetValidRooms(sim.LotCurrent.LotId, null);
                                }
                                if ((sim.IsHorse && sim.SimDescription.AdultOrAbove) && !sim.SimDescription.IsGhost)
                                {
                                    r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true);
                                }
                                if (((sim.IsHorse || sim.IsDeer) || (sim.IsFullSizeDog && sim.SimDescription.AdultOrAbove)) && !sim.SimDescription.IsGhost)
                                {
                                    r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true);
                                }
                                if (sim.IsHorse && sim.IsInBeingRiddenPosture)
                                {
                                    r.SetOption(Route.RouteOption.RouteWhileMounted, true);
                                }
                                if (previousPosture is LeadingHorsePosture)
                                {
                                    r.SetOption(Route.RouteOption.EnablePlanningAsCar, false);
                                    r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true);
                                    r.SetOption(Route.RouteOption.RouteAsSimLeadingHorse, true);
                                }
                                if (sim.IsPet && !sim.IsInBeingRiddenPosture)
                                {
                                    r.SetOption(Route.RouteOption.IgnoreSidewalkAndLotRestrictions, true);
                                }
                            }

                            //route = sim.CreateRoute();
                        }
                        finally
                        {
                            msg += Common.NewLine + " C " + span.Duration;
                        }
                    }
                }

                AcademicTextBook book = parameters.mTarget as AcademicTextBook;
                if (book != null)
                {
                    Sim a = parameters.mActor as Sim;

                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                    if ((a.OccupationAsAcademicCareer != null) || !book.mRequireAcademics)
                    {
                        if (book.TestRockAndRead(a, false, ref greyedOutTooltipCallback))
                        {
                            msg += Common.NewLine + "A";
                        }
                        if (a.Inventory.Contains(parameters.mTarget) && !(a.Posture is Sim.StandingPosture))
                        {
                            if (book.TestReadBook(a, false, ref greyedOutTooltipCallback))
                            {
                                msg += Common.NewLine + "B";
                            }
                        }
                        if (a.GetObjectInRightHand() == parameters.mTarget)
                        {
                            if (book.TestReadBook(a, false, ref greyedOutTooltipCallback))
                            {
                                msg += Common.NewLine + "C";
                            }
                        }

                        msg += Common.NewLine + "D";
                    }

                    msg += Common.NewLine + "E";
                }

                CommonDoor door = parameters.mTarget as CommonDoor;
                if (door != null)
                {
                    if (door.mObjComponents != null)
                    {
                        msg += Common.NewLine + "Count: " + door.mObjComponents.Count;

                        for (int i = 0x0; i < door.mObjComponents.Count; i++)
                        {
                            msg += Common.NewLine + door.mObjComponents[i].BaseType;

                            if (door.mObjComponents[i].BaseType == typeof(PortalComponent))
                            {
                                msg += Common.NewLine + " Found";

                                door.mObjComponents[i].Dispose();
                                door.mObjComponents.RemoveAt(i);
                                break;
                            }
                        }
                        if (door.mObjComponents.Count == 0x0)
                        {
                            door.mObjComponents = null;
                        }
                    }
                }

                HarvestPlant plant = parameters.mTarget as HarvestPlant;
                if (plant != null)
                {
                    msg += Common.NewLine + "mBarren: " + plant.mBarren;
                    msg += Common.NewLine + "mGrowthState: " + plant.mGrowthState;
                    msg += Common.NewLine + "mDormant: " + plant.mDormant;
                    msg += Common.NewLine + "mLeaflessState: " + plant.mLeaflessState;
                    msg += Common.NewLine + "mLifetimeHarvestablesYielded: " + plant.mLifetimeHarvestablesYielded;
                    msg += Common.NewLine + "NumLifetimeHarvestables: " + plant.PlantDef.NumLifetimeHarvestables;
                    msg += Common.NewLine + "Yield: " + plant.GetYield();
                }
            }
            catch (Exception e)
            {
                GameHitParameters <GameObject> .Exception(parameters, msg, e);
            }
            finally
            {
                Common.DebugWriteLog(msg);
            }

            return(OptionResult.SuccessClose);
        }
Exemple #2
0
        public static void   FixInvisibleSim(SimDescription sim, bool force = false, bool reset = false)
        {
            try{
                OutfitCategories[] categoriesArray = null;
                switch (sim.Species)
                {
                case CASAgeGenderFlags.Human:
                    categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday,
                                                               OutfitCategories.Naked,
                                                               OutfitCategories.Athletic,
                                                               OutfitCategories.Formalwear,
                                                               OutfitCategories.Sleepwear,
                                                               OutfitCategories.Swimwear };
                    break;

                case CASAgeGenderFlags.Horse:
                    categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday,
                                                               OutfitCategories.Naked,
                                                               OutfitCategories.Racing,
                                                               OutfitCategories.Bridle,
                                                               OutfitCategories.Jumping };
                    break;

                default:
                    categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday,
                                                               OutfitCategories.Naked };
                    break;
                }
                bool necessary = force;
                if (!necessary)
                {
                    foreach (OutfitCategories category in categoriesArray)
                    {
                        if (sim.IsHuman)
                        {
                            if (category == OutfitCategories.Naked)
                            {
                                continue;
                            }
                        }
                        SimOutfit outfit2 = sim.GetOutfit(category, 0);
                        if ((outfit2 == null) || (!outfit2.IsValid))
                        {
                            necessary = true;
                        }
                    }
                }
                if (!necessary)
                {
                    return;
                }
                SimOutfit sourceOutfit = null;
                for (int i = 0; i < 2; i++)
                {
                    OutfitCategoryMap map = null;
                    if (i == 0)
                    {
                        map = sim.mOutfits;
                    }
                    else
                    {
                        map = sim.mMaternityOutfits;
                    }
                    if (map == null)
                    {
                        continue;
                    }
                    foreach (OutfitCategories category in Enum.GetValues(typeof(OutfitCategories)))
                    {
                        if (category == OutfitCategories.Supernatural)
                        {
                            continue;
                        }
                        ArrayList outfits = map[category] as ArrayList;
                        if (outfits == null)
                        {
                            continue;
                        }
                        foreach (SimOutfit anyOutfit in outfits)
                        {
                            if ((anyOutfit != null) && (anyOutfit.IsValid))
                            {
                                sourceOutfit = anyOutfit;
                                break;
                            }
                        }
                    }
                }
                SimBuilder builder = new SimBuilder();
                builder.UseCompression = true;
                var simTone = sim.SkinToneKey;
                List <ResourceKey> choiceTones = new List <ResourceKey>();
                KeySearch          tones       = new KeySearch(0x0354796a);
                foreach (ResourceKey tone in tones)
                {
                    choiceTones.Add(tone);
                }
                tones.Reset();
                if ((simTone.InstanceId == 0) || (!choiceTones.Contains(simTone)))
                {
                    simTone = RandomUtil.GetRandomObjectFromList(choiceTones);
                }
                ResourceKey newTone = simTone;

                builder.Age           = sim.Age;
                builder.Gender        = sim.Gender;
                builder.Species       = sim.Species;
                builder.SkinTone      = newTone;
                builder.SkinToneIndex = sim.SkinToneIndex;
                builder.MorphFat      = sim.mCurrentShape.Fat;
                builder.MorphFit      = sim.mCurrentShape.Fit;
                builder.MorphThin     = sim.mCurrentShape.Thin;
                GeneticsPet.SpeciesSpecificData speciesData = OutfitUtils.GetSpeciesSpecificData(sim);
                try{
                    if (sourceOutfit != null)
                    {
                        foreach (SimOutfit.BlendInfo blend in sourceOutfit.Blends)
                        {
                            builder.SetFacialBlend(blend.key, blend.amount);
                        }
                        CASParts.OutfitBuilder.CopyGeneticParts(builder, sourceOutfit);
                    }
                    else
                    {
                        if (sim.Genealogy != null)
                        {
                            List <SimDescription> parents      = new List <SimDescription>();
                            List <SimDescription> grandParents = new List <SimDescription>();
                            if (sim.Genealogy.Parents != null)
                            {
                                foreach (Genealogy gene in sim.Genealogy.Parents)
                                {
                                    SimDescription relative = gene.SimDescription;
                                    if (relative == null)
                                    {
                                        continue;
                                    }
                                    parents.Add(relative);
                                    if (relative.Genealogy != null)
                                    {
                                        if (relative.Genealogy.Parents != null)
                                        {
                                            foreach (Genealogy grandGene in relative.Genealogy.Parents)
                                            {
                                                var grandRelative = grandGene.SimDescription;
                                                if (grandRelative == null)
                                                {
                                                    continue;
                                                }
                                                grandParents.Add(grandRelative);
                                            }
                                        }
                                    }
                                }
                            }
                            if (parents.Count > 0)
                            {
                                if (sim.IsHuman)
                                {
                                    Genetics.InheritFacialBlends(builder, parents.ToArray(), new Random());
                                }
                                else
                                {
                                    GeneticsPet.InheritBodyShape(builder, parents, grandParents, new Random());
                                    GeneticsPet.InheritBasePeltLayer(builder, parents, grandParents, new Random());
                                    GeneticsPet.InheritPeltLayers(builder, parents, grandParents, new Random());
                                }
                            }
                        }
                    }
                }catch (Exception exception) {
                    Alive.WriteLog(exception.Message + "\n\n" +
                                   exception.StackTrace + "\n\n" +
                                   exception.Source);
                }
                if (sim.IsRobot)
                {
                    OutfitUtils.AddMissingPartsBots(builder, (OutfitCategories)0x200002, true, sim);
                    Sleep();
                    OutfitUtils.AddMissingPartsBots(builder, OutfitCategories.Everyday, true, sim);
                    Sleep();
                }
                else
                if (sim.IsHuman)
                {
                    OutfitUtils.AddMissingParts(builder, (OutfitCategories)0x200002, true, sim, sim.IsAlien);
                    Sleep();
                    OutfitUtils.AddMissingParts(builder, OutfitCategories.Everyday, true, sim, sim.IsAlien);
                    Sleep();
                }
                else
                {
                    OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday | (OutfitCategories)0x200000, true, sim, speciesData);
                    Sleep();
                    OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday, true, sim, speciesData);
                    Sleep();
                }
                ResourceKey uniformKey = new ResourceKey();
                if (sim.IsHuman)
                {
                    if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, OutfitCategories.Everyday))
                    {
                        OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim);
                    }
                }
                OutfitUtils.SetAutomaticModifiers(builder);
                sim.ClearOutfits(OutfitCategories.Career, false);
                sim.ClearOutfits(OutfitCategories.MartialArts, false);
                sim.ClearOutfits(OutfitCategories.Special, false);
                foreach (OutfitCategories category in categoriesArray)
                {
                    ArrayList outfits = null;
                    if (!force)
                    {
                        outfits = sim.Outfits[category] as ArrayList;
                        if (outfits != null)
                        {
                            int index = 0;
                            while (index < outfits.Count)
                            {
                                SimOutfit anyOutfit = outfits[index] as SimOutfit;
                                if (anyOutfit == null)
                                {
                                    outfits.RemoveAt(index);
                                }
                                else
                                if (!anyOutfit.IsValid)
                                {
                                    outfits.RemoveAt(index);
                                }
                                else
                                {
                                    index++;
                                }
                            }
                        }
                    }

                    if ((outfits == null) || (outfits.Count == 0))
                    {
                        OutfitUtils.MakeCategoryAppropriate(builder, category, sim);
                        if (sim.IsHuman)
                        {
                            if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, category))
                            {
                                OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim);
                            }
                        }
                        sim.RemoveOutfits(category, false);
                        CASParts.AddOutfit(sim, category, builder, true);
                    }
                    if (sim.IsUsingMaternityOutfits)
                    {
                        sim.BuildPregnantOutfit(category);
                    }
                }
                if (sim.IsMummy)
                {
                    OccultMummy
                    .OnMerge(sim);
                }
                else
                if (sim.IsFrankenstein)
                {
                    OccultFrankenstein
                    .OnMerge(sim, sim.OccultManager.mIsLifetimeReward);
                }
                else
                if (sim.IsGenie)
                {
                    OccultGenie
                    .OverlayUniform(sim, OccultGenie.CreateUniformName(sim.Age, sim.Gender), ProductVersion.EP6, OutfitCategories.Everyday, CASSkinTones.BlueSkinTone, 0.68f);
                }
                else
                if (sim.IsImaginaryFriend)
                {
                    OccultImaginaryFriend friend = sim.OccultManager.GetOccultType(Sims3.UI.Hud.OccultTypes.ImaginaryFriend) as OccultImaginaryFriend;
                    OccultBaseClass
                    .OverlayUniform(sim, OccultImaginaryFriend.CreateUniformName(sim.Age, friend.Pattern), ProductVersion.EP4, OutfitCategories.Special, CASSkinTones.NoSkinTone, 0f);
                }
                if (sim.IsMermaid)
                {
                    OccultMermaid
                    .AddOutfits(sim, null);
                }
                if (sim.IsWerewolf)
                {
                    if (sim.ChildOrAbove)
                    {
                        SimOutfit newWerewolfOutfit =
                            OccultWerewolf
                            .GetNewWerewolfOutfit(sim.Age, sim.Gender);
                        if (newWerewolfOutfit != null)
                        {
                            sim.AddOutfit(newWerewolfOutfit, OutfitCategories.Supernatural, 0x0);
                        }
                    }
                }
                SimOutfit currentOutfit = null;
                if (sim.CreatedSim != null)
                {
                    if (reset)
                    {
                        StuckSimData stuckSim;
                        if (!StuckSims.TryGetValue(sim.SimDescriptionId, out stuckSim))
                        {
                            stuckSim = new StuckSimData();
                            StuckSims.Add(sim.SimDescriptionId, stuckSim);
                        }
                        if (!stuckSim.Resetting)
                        {
                            stuckSim.Detections++;
                            Vector3 destination = Vector3.Invalid;
                            if (sim.CreatedSim.RoutingComponent != null)
                            {
                                sim.CreatedSim.RoutingComponent.GetDestination(out destination);
                            }
                            if (stuckSim.resetTask == null)
                            {
                                stuckSim.resetTask = new ResetStuckSimTask(sim.CreatedSim, destination, "Invisible");
                            }
                            else
                            {
                                stuckSim.resetTask.Renew();
                            }
                        }
                    }
                    try{
                        sim.CreatedSim.SwitchToOutfitWithoutSpin(Sim.ClothesChangeReason.GoingOutside, OutfitCategories.Everyday, true);
                    }catch (Exception exception) {
                        Alive.WriteLog(exception.Message + "\n\n" +
                                       exception.StackTrace + "\n\n" +
                                       exception.Source);
                    }
                    currentOutfit = sim.CreatedSim.CurrentOutfit;
                }
                else
                {
                    currentOutfit = sim.GetOutfit(OutfitCategories.Everyday, 0);
                }
                if (currentOutfit != null)
                {
                    ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, sim.AgeGenderSpecies);
                }
            }catch (Exception exception) {
                Alive.WriteLog(exception.Message + "\n\n" +
                               exception.StackTrace + "\n\n" +
                               exception.Source + "\n\n" +
                               "FixInvisibleSim");
            }finally{
            }
        }
Exemple #3
0
        public static bool DoRoute(RoutingComponent ths, Route r)
        {
            Sim owner = ths.Owner as Sim;

            if ((!r.ExecutionFromNonSimTaskIsSafe && (owner != null)) && (Simulator.CurrentTask != ths.Owner.ObjectId))
            {
                Simulator.CurrentTask.ObjectFromId <GameObject>();
                return(false);
            }

            IBoat boat = ths.Owner as IBoat;

            if (ths.RoutingParent != null)
            {
                if (!(ths.RoutingParent is IBoat) || (r.GetOption2(Route.RouteOption2.EndAsBoat) && (!r.PlanResult.Succeeded() || !RoutingComponent.PlannedRouteHasNonBoatSubpath(r))))
                {
                    // Custom
                    if (ths.RoutingParent.RoutingComponent is CarRoutingComponent)
                    {
                        return(CarRoutingComponentEx.DoRoute(ths.RoutingParent.RoutingComponent as CarRoutingComponent, r));
                    }
                    else
                    {
                        return(ths.RoutingParent.RoutingComponent.DoRoute(r));
                    }
                }
            }
            else if (((boat != null) && r.PlanResult.Succeeded()) && (!r.GetOption2(Route.RouteOption2.EndAsBoat) || RoutingComponent.PlannedRouteHasNonBoatSubpath(r)))
            {
                Sim driver = boat.GetDriver();
                if (driver != null)
                {
                    return(driver.RoutingComponent.DoRoute(r));
                }
            }

            Common.StringBuilder msg = new Common.StringBuilder("RoutingComponentEx:DoRoute" + Common.NewLine);
            if (owner != null)
            {
                msg += Common.NewLine + owner.FullName + Common.NewLine;
            }

            ths.mRouteActions.Clear();
            bool routeSuccess = true;

            try
            {
                RouteAction.FailureExplanation explanation = RouteAction.FailureExplanation.None;
                RoutingComponent.mnNumDoRouteCalls += (ulong)0x1L;
                if (r.PlanResult.Succeeded())
                {
                    ths.OnAboutToStartFollowingRoute(r);
                    if (r.PlanResult.Succeeded())
                    {
                        ths.PushActionsForRoute(r, r);
                        if (owner != null)
                        {
                            owner.PushBackpackPostureIfNecessary();
                            owner.PushCanePostureIfNecessary();
                            owner.PushJetpackPostureIfNecessary();
                        }
                    }
                    else
                    {
                        routeSuccess = false;
                    }
                }
                else
                {
                    routeSuccess = false;
                }

                msg.Append("A");

                if (!routeSuccess)
                {
                    explanation |= RouteAction.FailureExplanation.InitialPlanFailure;
                    LogFailure(ths.Owner, RouteAction.FailureExplanation.InitialPlanFailure, r.PlanResult, "Initial Path Plan Failure (WILL NOT play route fail)");
                    r.SetRouteActionResult(0x2);
                    return(false);
                }

                msg.Append("B");

                int failures = 0;

                if ((ths.RoutingParent != null) && (ths.RoutingParent is IBoat))
                {
                    ths.UpdateDynamicFootprint(ths.RoutingParent as GameObject, false);
                }
                else
                {
                    ths.UpdateDynamicFootprint(ths.Owner, false);
                }

                Vector3 originalPosition = ths.Owner.Position;
                int     loops            = 0;

                bool  success       = true;
                Route processedPath = r;
                bool  isOutside     = ths.Owner.IsOutside;
                ths.mNumWaterEntriesThisRoute = 0;
                while (ths.mRouteActions.Count != 0x0)
                {
                    // Custom
                    if (ths.Owner.Position == originalPosition)
                    {
                        loops++;
                    }

                    if ((loops > 30) || (ths.mRouteActions.Count > 30))
                    {
                        success = false;
                        ths.mRouteActions.Clear();
                        break;
                    }

                    if (ths.mRouteActions[0] is GetInBoatRouteAction)
                    {
                        ths.mNumWaterEntriesThisRoute++;
                        if (ths.mNumWaterEntriesThisRoute > 10)
                        {
                            if (owner != null)
                            {
                                owner.SetToResetAndSendHome();
                            }
                            else
                            {
                                ths.Owner.SetObjectToReset();
                            }
                            return(false);
                        }
                    }

                    if ((owner != null) && owner.IsOutside)
                    {
                        owner.PushHoverboardPostureIfNecessary();
                    }

                    // Custom
                    RouteAction routeAction = ths.mRouteActions[0x0];

                    msg.Append(Common.NewLine + routeAction.GetType());

                    RouteAction.ActionResult actionResult = RouteAction.ActionResult.Continue;

                    //using (BuffsChangedProxy buffsProxy = new BuffsChangedProxy(owner))
                    {
                        try
                        {
                            if (routeAction is ObstacleEncounteredRouteInterruptAction)
                            {
                                actionResult = ObstacleEncounteredRouteInterruptActionEx.PerformAction(routeAction as ObstacleEncounteredRouteInterruptAction);
                            }
                            else
                            {
                                actionResult = routeAction.PerformAction();
                            }
                        }
                        catch (ResetException)
                        {
                            throw;
                        }
                        catch (SacsErrorException e)
                        {
                            Common.DebugException(owner, null, msg, e);

                            failures++;

                            if (failures > 10)
                            {
                                actionResult = RouteAction.ActionResult.Terminate;
                            }
                            else
                            {
                                actionResult = RouteAction.ActionResult.ContinueAndPopPathAndReplan;
                            }

                            routeAction.OnReset();
                        }
                        catch (Exception e)
                        {
                            Common.Exception(owner, null, msg.ToString(), e);

                            string stackTrace = e.StackTrace.ToString();

                            if (stackTrace.Contains("OccultManager:DisallowClothesChange"))
                            {
                                OccultTypeHelper.ValidateOccult(owner.SimDescription, null);

                                actionResult = RouteAction.ActionResult.Terminate;
                            }
                            else if (stackTrace.Contains("CommonDoor:IsAllowedThrough"))
                            {
                                Corrections.CleanupCommonDoors(null);
                                actionResult = RouteAction.ActionResult.Terminate;
                            }
                            else if (stackTrace.Contains("SimRoutingComponent:RequestWalkStyle"))
                            {
                                actionResult = RouteAction.ActionResult.Terminate;
                            }
                            else
                            {
                                failures++;

                                if (failures > 10)
                                {
                                    actionResult = RouteAction.ActionResult.Terminate;
                                }
                                else
                                {
                                    actionResult = RouteAction.ActionResult.ContinueAndPopPathAndReplan;
                                }
                            }

                            routeAction.OnReset();
                        }
                    }

                    msg.Append(Common.NewLine + "C");

                    // Custom
                    if ((ths.mRouteActions.Count > 0) && (ths.mRouteActions[0x0].ForciblyReplanned) && (actionResult == RouteAction.ActionResult.ContinueAndPopPath))
                    {
                        actionResult = RouteAction.ActionResult.ContinueAndFollowPath;
                    }

                    msg.Append(Common.NewLine + actionResult + Common.NewLine);

                    if (GoHere.Settings.mDetailedRouting)
                    {
                        if (Sim.ActiveActor == owner)
                        {
                            Common.DebugNotify(msg);
                        }
                    }

                    if (ths.mRouteActions.Count == 0x0)
                    {
                        explanation |= RouteAction.FailureExplanation.InternalPlanFailure;
                        success      = false;
                        break;
                    }

                    msg.Append("D");

                    ths.mPreviousRouteAction = ths.mRouteActions[0x0];
                    switch (actionResult)
                    {
                    case RouteAction.ActionResult.Continue:
                    case RouteAction.ActionResult.ContinueAndPopPath:
                    case RouteAction.ActionResult.ContinueAndPopPathAndReplan:
                    case RouteAction.ActionResult.ContinueAndPopPathAndRestart:
                    case RouteAction.ActionResult.ContinueAndFollowPath:
                        msg.Append("E");

                        ths.mRouteActions.RemoveAt(0x0);
                        bool flag3 = (processedPath.GetNumPaths() > 0x1) || (processedPath.IsLoop());
                        if (((actionResult == RouteAction.ActionResult.ContinueAndPopPath) && flag3) || ((actionResult == RouteAction.ActionResult.ContinueAndPopPathAndRestart) || (actionResult == RouteAction.ActionResult.ContinueAndPopPathAndReplan)))
                        {
                            if (flag3)
                            {
                                processedPath.PopPath();
                            }

                            msg.Append("F");

                            if (actionResult == RouteAction.ActionResult.ContinueAndPopPathAndReplan)
                            {
                                Vector3 outPosition = new Vector3();
                                if ((ths.RoutingParent != null) && (ths.RoutingParent is IBoat))
                                {
                                    outPosition = ths.RoutingParent.PositionOnFloor;
                                }
                                else if (ths.Owner != null)
                                {
                                    if ((owner != null) && (owner.Posture is SwimmingInPool))
                                    {
                                        outPosition = ths.Owner.Position;
                                    }
                                    else
                                    {
                                        outPosition = ths.Owner.PositionOnFloor;
                                    }
                                }
                                else
                                {
                                    processedPath.GetPathStartPoint(0x0, ref outPosition);
                                }
                                processedPath.ReplanFromPoint(outPosition);
                            }

                            msg.Append("G");

                            if (actionResult == RouteAction.ActionResult.ContinueAndPopPathAndRestart)
                            {
                                Vector3 positionOnFloor = new Vector3();
                                if (ths.Owner != null)
                                {
                                    positionOnFloor = ths.Owner.PositionOnFloor;
                                }
                                else
                                {
                                    processedPath.GetPathStartPoint(0x0, ref positionOnFloor);
                                }
                                processedPath.SetOption(Route.RouteOption.EnablePlanningAsCar, false);
                                processedPath.SetOption(Route.RouteOption.EnableSubwayPlanning, false);
                                processedPath.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false);
                                processedPath.ReplanFromPoint(positionOnFloor);
                                explanation |= RouteAction.FailureExplanation.CancelledByScript;
                                success      = false;
                                ths.mRouteActions.Clear();
                            }
                            else if (processedPath.PlanResult.Succeeded())
                            {
                                ths.PushActionsForRoute(r, processedPath);
                            }
                            else
                            {
                                explanation |= RouteAction.FailureExplanation.ReplanFailure;
                                success      = false;
                                ths.mRouteActions.Clear();
                            }
                        }
                        else if ((actionResult == RouteAction.ActionResult.ContinueAndFollowPath) && (r.GetNumPaths() > 0x0))
                        {
                            msg.Append("H");

                            if (r.PlanResult.Succeeded())
                            {
                                ths.PushActionsForRoute(r, processedPath);
                            }
                            else
                            {
                                explanation |= RouteAction.FailureExplanation.InternalPlanFailure;
                                success      = false;
                                ths.mRouteActions.Clear();
                            }
                        }
                        break;

                    default:
                        msg.Append("I");

                        explanation |= ths.mPreviousRouteAction.FailureExplanations;
                        success      = false;
                        ths.mRouteActions.Clear();
                        break;
                    }
                }

                msg.Append("J");

                ths.mRouteActions.Clear();
                r.SetRouteActionResult((uint)explanation);
                if (!success)
                {
                    if (ths.mPreviousRouteAction == null)
                    {
                        LogFailure(ths.Owner, explanation, r.PlanResult, "(Null mPreviousRouteAction failure)");
                    }
                    else
                    {
                        LogFailure(ths.Owner, explanation, r.PlanResult, "(failure in " + ths.mPreviousRouteAction.ToString() + ")");
                    }
                }

                msg.Append("K");

                if ((ths.RoutingParent != null) && (ths.RoutingParent is IBoat))
                {
                    ths.UpdateDynamicFootprint(ths.RoutingParent as GameObject, true);
                }
                else
                {
                    ths.UpdateDynamicFootprint(ths.Owner, true);
                }

                routeSuccess             = (success && (processedPath == r)) && r.PlanResult.Succeeded();
                ths.mPreviousRouteAction = null;
                if (ths.OnRouteActionsFinished != null)
                {
                    ths.OnRouteActionsFinished(ths.Owner, routeSuccess);
                }

                if (((SeasonsManager.Enabled && routeSuccess) && (isOutside && (owner != null))) && ((owner.IsHuman && owner.SimDescription.ChildOrAbove) && (!owner.IsOutside && (owner.CurrentOutfitCategory == OutfitCategories.Outerwear))))
                {
                    owner.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.RemovingOuterwear);
                }

                if (owner != null)
                {
                    SwimmingInPool posture = owner.Posture as SwimmingInPool;
                    if ((posture != null) && posture.UsedShortEntryAnimation)
                    {
                        posture.UsedShortEntryAnimation = false;
                        if (owner.SimDescription.IsMatureMermaid)
                        {
                            OccultMermaid.PutOnTailWithSpin(owner.SimDescription);
                        }
                    }
                }
            }
            catch (ResetException)
            {
                routeSuccess = false;
                if (ths.mRouteActions.Count > 0x0)
                {
                    RouteAction action = ths.mRouteActions[0x0];
                    if (action != null)
                    {
                        action.OnReset();
                    }
                }
                ths.mRouteActions.Clear();
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(owner, null, msg.ToString(), e);
                routeSuccess = false;

                if (ths.mRouteActions.Count > 0x0)
                {
                    RouteAction action = ths.mRouteActions[0x0];
                    if (action != null)
                    {
                        action.OnReset();
                    }
                }
                ths.mRouteActions.Clear();
            }
            finally
            {
                ths.mRouteActions.Clear();
                if (owner != null)
                {
                    owner.RestoreUsedHoverboard();
                }

                if ((owner != null) && (owner.FirstName == "Roberto"))
                {
                    Common.DebugStackLog(msg);
                }
            }

            return(routeSuccess);
        }
Exemple #4
0
        public void motive_motive_distress(Sim sim, CommodityKind commodity)
        {
            if (commodity == (CommodityKind)0x44440444)
            {
                return;
            }

            SimDescription simd        = sim.SimDescription;
            BuffManager    buffManager = sim.BuffManager;
            Motives        moves       = sim.Motives;

            switch (commodity)
            {
            case CommodityKind.Bladder:
            {
                bool flag = true;
                InteractionDefinition interactionDefinition;
                switch (simd.Species)
                {
                case CASAgeGenderFlags.Horse:
                    interactionDefinition = Sim.HorsePee.Singleton;
                    break;

                case CASAgeGenderFlags.Dog:
                case CASAgeGenderFlags.LittleDog:
                    interactionDefinition = (InteractionDefinition)Sim.DogPeeStart.Singleton;
                    break;

                case CASAgeGenderFlags.Cat:
                    interactionDefinition = (InteractionDefinition)Sim.CatPeeStart.Singleton;
                    break;

                default:
                    interactionDefinition = Sim.BladderFailure.Singleton;
                    break;
                }

                foreach (InteractionInstance interaction in sim.InteractionQueue.InteractionList)
                {
                    if (interaction is Sim.DogPee || interaction is Sim.CatPee || interaction.InteractionDefinition == interactionDefinition)
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag)
                {
                    SwimmingInPool swimmingInPool = sim.Posture as SwimmingInPool;
                    if (swimmingInPool == null)
                    {
                        InteractionInstance interactionInstance = interactionDefinition.CreateInstance(sim, sim, new InteractionPriority(InteractionPriorityLevel.High), false, false);
                        Sim.DogPeeStart     dogPeeStart         = interactionInstance as Sim.DogPeeStart;
                        if (dogPeeStart != null)
                        {
                            dogPeeStart.DoNotRoute = true;
                        }
                        else
                        {
                            Sim.CatPeeStart catPeeStart = interactionInstance as Sim.CatPeeStart;
                            if (catPeeStart != null)
                            {
                                catPeeStart.DoNotRoute = true;
                            }
                        }
                        if (sim.InteractionQueue.AddNext(interactionInstance) && simd.IsRaccoon)
                        {
                            sim.AddExitReason(ExitReason.BuffFailureState);
                        }
                        else
                        {
                            BuffInstance buffOfSolveCommodity = buffManager.GetBuffOfSolveCommodity(commodity);
                            if (buffOfSolveCommodity != null && buffOfSolveCommodity.EffectValue <= 0)
                            {
                                ThoughtBalloonManager.BalloonData balloonData = new ThoughtBalloonManager.BalloonData(buffOfSolveCommodity.ThumbString);
                                if (balloonData.IsValid)
                                {
                                    balloonData.BalloonType = ThoughtBalloonTypes.kScreamBalloon;
                                    balloonData.mCoolDown   = ThoughtBalloonCooldown.None;
                                    sim.ThoughtBalloonManager.ShowBalloon(balloonData);
                                }
                            }

                            moves.SetMax(CommodityKind.Bladder);

                            if (!simd.IsPet)
                            {
                                PuddleManager.AddPuddle(sim.Position);
                                moves.SetValue(CommodityKind.Hygiene, -100f);
                                if (GlobalFunctions.AreOtherSimsNearby(sim, BuffEmbarrassed.DistanceForEmbarrassedBuff))
                                {
                                    buffManager.AddElement(BuffNames.Embarrassed, Origin.FromPeeingSelf);
                                }
                                ActiveTopic.AddToSim(sim, "Embarrassment");
                            }
                            else
                            {
                                MetaAutonomyVenueType metaAutonomyVenueType = sim.LotCurrent.GetMetaAutonomyVenueType();
                                if ((!simd.IsADogSpecies || metaAutonomyVenueType != MetaAutonomyVenueType.DogPark) && World.GetTerrainType(sim.Position) == TerrainType.LotFloor)
                                {
                                    PuddleManager.AddPuddle(sim.Position);
                                }
                            }
                            EventTracker.SendEvent(EventTypeId.kBladderFailure, sim);
                        }
                        Motive motive = moves.GetMotive(CommodityKind.Bladder);
                        if (motive != null)
                        {
                            motive.PotionBladderDecayOverride = false;
                        }
                    }
                    else
                    {
                        swimmingInPool.ContainerPool.PeeInPool(sim);
                    }
                }
                break;
            }

            case CommodityKind.Hunger:
            case CommodityKind.VampireThirst:

                if (simd.IsFrankenstein)
                {
                    OccultFrankenstein.PushFrankensteinShortOut(sim);
                }
                else if (!simd.IsGhost && !simd.IsDead && !IsCheckKillSimInteraction(sim))
                {
                    if (sim.Posture.Satisfies(CommodityKind.ScubaDiving, null) && !simd.IsMermaid)
                    {
                        sim.Kill(SimDescription.DeathType.ScubaDrown);
                    }
                    else if (sim.Posture.Satisfies(CommodityKind.SwimmingInPool, null) && !simd.IsMermaid)
                    {
                        sim.Kill(SimDescription.DeathType.Drown);
                    }
                    else if (SimTemperature.HasFrozenSolidInteraction(sim))
                    {
                        sim.Kill(SimDescription.DeathType.Freeze, null, false);
                    }
                    else if (OccultMermaid.IsDehydrated(sim))
                    {
                        sim.Kill(SimDescription.DeathType.MermaidDehydrated, null, false);
                    }
                    else
                    {
                        sim.Kill(sim.SimDescription.IsVampire ? SimDescription.DeathType.Thirst : SimDescription.DeathType.Starve);
                    }
                }
                break;

            case CommodityKind.Temperature:
            {
                float value = moves.GetValue(CommodityKind.Temperature);
                if (value > 0f)
                {
                    SimTemperature.PushSpontaneouslyCombustInteraction(sim);
                }
                else
                {
                    SimTemperature.PushFreezeInteraction(sim);
                }
                break;
            }

            case CommodityKind.MermaidDermalHydration:
                OccultMermaid.CollapseFromDehydration(sim);
                break;
            }
        }
Exemple #5
0
        // From OccultManager
        protected static bool AddOccultType(OccultManager ths, OccultTypes type, bool addOutfit, bool isReward, bool fromRestore, OccultBaseClass overrideOccultToAdd)
        {            
            OccultBaseClass newOccult = null;
            OccultBaseClass oldOccult = ths.VerifyOccultList(type);
            if (overrideOccultToAdd != null)
            {
                newOccult = overrideOccultToAdd;
            }
            else
            {
                switch (type)
                {
                    case OccultTypes.Mummy:
                        newOccult = new OccultMummy();
                        break;
                    case OccultTypes.Frankenstein:
                        newOccult = new OccultFrankenstein();
                        break;
                    case OccultTypes.Vampire:
                        newOccult = new OccultVampire();
                        break;
                    case OccultTypes.ImaginaryFriend:
                        OccultImaginaryFriend oldImFr = oldOccult as OccultImaginaryFriend;
                        if (oldImFr == null)
                        {
                            newOccult = new OccultImaginaryFriend();
                        }
                        else
                        {
                            newOccult = new OccultImaginaryFriend(oldImFr);
                        }
                        break;
                    case OccultTypes.Unicorn:
                        newOccult = new OccultUnicorn();
                        break;
                    case OccultTypes.Fairy:
                        newOccult = new OccultFairy();
                        break;
                    case OccultTypes.Witch:
                        newOccult = new OccultWitch();
                        break;
                    case OccultTypes.Genie:
                        newOccult = new OccultGenie();
                        break;
                    case OccultTypes.Werewolf:
                        newOccult = new OccultWerewolf();
                        break;
                    case OccultTypes.PlantSim:
                        newOccult = new OccultPlantSim();
                        break;
                    case OccultTypes.Mermaid:
                        newOccult = new OccultMermaid();
                        break;
                    case OccultTypes.TimeTraveler:
                        newOccult = new OccultTimeTraveler();
                        break;
                    case OccultTypes.Robot:
                        newOccult = new OccultRobot();
                        break;
                }
            }

            if (newOccult == null)
            {
                return false;
            }

            OccultTypes originalTypes = ths.mCurrentOccultTypes;
            Role assignedRole = ths.mOwnerDescription.AssignedRole;
            float alienDNAPercentage = ths.mOwnerDescription.AlienDNAPercentage;

            try
            {
                ths.mCurrentOccultTypes = OccultTypes.None;
                ths.mOwnerDescription.AssignedRole = null;
                ths.mOwnerDescription.mAlienDNAPercentage = 0f;

                if (!newOccult.CanAdd(ths.mOwnerDescription, fromRestore))
                {
                    return false;
                }
            }
            finally
            {
                ths.mCurrentOccultTypes = originalTypes;
                ths.mOwnerDescription.AssignedRole = assignedRole;
                ths.mOwnerDescription.mAlienDNAPercentage = alienDNAPercentage;
            }

            if ((ths.mOwnerDescription.SupernaturalData == null) ||
                ((type == OccultTypes.Fairy) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Fairy)) ||
                ((type == OccultTypes.Robot) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Robot)) ||
                ((type == OccultTypes.PlantSim) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.PlantSim)))
            {
                ths.mOwnerDescription.AddSupernaturalData(type);
            }

            ths.mIsLifetimeReward = isReward;

            if (type == OccultTypes.Genie)
            {
                // Corrections for improper handling of the special outfits by OccultGenie
                if (ths.mOwnerDescription.mSpecialOutfitIndices == null)
                {
                    ths.mOwnerDescription.mSpecialOutfitIndices = new Dictionary<uint, int>();
                }

                addOutfit = false;
            }

            if (type == OccultTypes.Unicorn)
            {
                OccultUnicornEx.OnAddition(newOccult as OccultUnicorn, ths.mOwnerDescription, addOutfit);
            }

            ApplyTrait(ths.mOwnerDescription, type);

            MidlifeCrisisManager midlifeCrisisManager = ths.mOwnerDescription.MidlifeCrisisManager;

            try
            {
                // Inactive mummies don't agree with mid-life crisis managers
                ths.mOwnerDescription.MidlifeCrisisManager = null;

                newOccult.OnAddition(ths.mOwnerDescription, addOutfit, ths.mIsLifetimeReward, fromRestore);
            }
            finally
            {
                ths.mOwnerDescription.MidlifeCrisisManager = midlifeCrisisManager;
            }

            ths.mOccultList.Add(newOccult);
            ths.mCurrentOccultTypes |= type;
            EventTracker.SendEvent(new BeAnOccultEvent(EventTypeId.kBeAnOccult, ths.mOwnerDescription.CreatedSim, (uint)type));
            if (ths.mOwnerDescription.CreatedSim != null)
            {
                if (!Cane.IsAllowedToUseCane(ths.mOwnerDescription.CreatedSim))
                {
                    Cane.StopUsingAnyActiveCanes(ths.mOwnerDescription.CreatedSim);
                }
                if (!Backpack.IsAllowedToUseBackpack(ths.mOwnerDescription.CreatedSim))
                {
                    Backpack.StopUsingAnyActiveBackpacks(ths.mOwnerDescription.CreatedSim);
                }
                if (!Jetpack.IsAllowedToUseJetpack(ths.mOwnerDescription.CreatedSim))
                {
                    Jetpack.StopUsingAnyActiveJetpacks(ths.mOwnerDescription.CreatedSim);
                }
            }

            (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();
            ths.ClearOneShot();
            ths.UpdateOccultUI();            
            if (!fromRestore)
            {
                EventTracker.SendEvent(EventTypeId.kBecameOccult, ths.mOwnerDescription.CreatedSim);                
            }

            if (oldOccult != null)
            {
                newOccult.MergeOccultData(oldOccult);
            }

            if (ths.mOwnerDescription.CreatedSim != null)
            {
                Sim.StandingPosture standing = ths.mOwnerDescription.CreatedSim.Standing as Sim.StandingPosture;
                if (standing != null)
                {
                    standing.SetDefaultIdleAnim();
                }
            }

            return true;
        }
Exemple #6
0
        // From OccultManager
        protected static bool AddOccultType(OccultManager ths, OccultTypes type, bool addOutfit, bool isReward, bool fromRestore, OccultBaseClass overrideOccultToAdd)
        {
            OccultBaseClass newOccult = null;
            OccultBaseClass oldOccult = ths.VerifyOccultList(type);

            if (overrideOccultToAdd != null)
            {
                newOccult = overrideOccultToAdd;
            }
            else
            {
                switch (type)
                {
                case OccultTypes.Mummy:
                    newOccult = new OccultMummy();
                    break;

                case OccultTypes.Frankenstein:
                    newOccult = new OccultFrankenstein();
                    break;

                case OccultTypes.Vampire:
                    newOccult = new OccultVampire();
                    break;

                case OccultTypes.ImaginaryFriend:
                    OccultImaginaryFriend oldImFr = oldOccult as OccultImaginaryFriend;
                    if (oldImFr == null)
                    {
                        newOccult = new OccultImaginaryFriend();
                    }
                    else
                    {
                        newOccult = new OccultImaginaryFriend(oldImFr);
                    }
                    break;

                case OccultTypes.Unicorn:
                    newOccult = new OccultUnicorn();
                    break;

                case OccultTypes.Fairy:
                    newOccult = new OccultFairy();
                    break;

                case OccultTypes.Witch:
                    newOccult = new OccultWitch();
                    break;

                case OccultTypes.Genie:
                    newOccult = new OccultGenie();
                    break;

                case OccultTypes.Werewolf:
                    newOccult = new OccultWerewolf();
                    break;

                case OccultTypes.PlantSim:
                    newOccult = new OccultPlantSim();
                    break;

                case OccultTypes.Mermaid:
                    newOccult = new OccultMermaid();
                    break;

                case OccultTypes.TimeTraveler:
                    newOccult = new OccultTimeTraveler();
                    break;

                case OccultTypes.Robot:
                    newOccult = new OccultRobot();
                    break;
                }
            }

            if (newOccult == null)
            {
                return(false);
            }

            OccultTypes originalTypes      = ths.mCurrentOccultTypes;
            Role        assignedRole       = ths.mOwnerDescription.AssignedRole;
            float       alienDNAPercentage = ths.mOwnerDescription.AlienDNAPercentage;

            try
            {
                ths.mCurrentOccultTypes                   = OccultTypes.None;
                ths.mOwnerDescription.AssignedRole        = null;
                ths.mOwnerDescription.mAlienDNAPercentage = 0f;

                if (!newOccult.CanAdd(ths.mOwnerDescription, fromRestore))
                {
                    return(false);
                }
            }
            finally
            {
                ths.mCurrentOccultTypes                   = originalTypes;
                ths.mOwnerDescription.AssignedRole        = assignedRole;
                ths.mOwnerDescription.mAlienDNAPercentage = alienDNAPercentage;
            }

            if ((ths.mOwnerDescription.SupernaturalData == null) ||
                ((type == OccultTypes.Fairy) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Fairy)) ||
                ((type == OccultTypes.Robot) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Robot)) ||
                ((type == OccultTypes.PlantSim) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.PlantSim)))
            {
                ths.mOwnerDescription.AddSupernaturalData(type);
            }

            ths.mIsLifetimeReward = isReward;

            if (type == OccultTypes.Genie)
            {
                // Corrections for improper handling of the special outfits by OccultGenie
                if (ths.mOwnerDescription.mSpecialOutfitIndices == null)
                {
                    ths.mOwnerDescription.mSpecialOutfitIndices = new Dictionary <uint, int>();
                }

                addOutfit = false;
            }

            if (type == OccultTypes.Unicorn)
            {
                OccultUnicornEx.OnAddition(newOccult as OccultUnicorn, ths.mOwnerDescription, addOutfit);
            }

            ApplyTrait(ths.mOwnerDescription, type);

            MidlifeCrisisManager midlifeCrisisManager = ths.mOwnerDescription.MidlifeCrisisManager;

            try
            {
                // Inactive mummies don't agree with mid-life crisis managers
                ths.mOwnerDescription.MidlifeCrisisManager = null;

                newOccult.OnAddition(ths.mOwnerDescription, addOutfit, ths.mIsLifetimeReward, fromRestore);
            }
            finally
            {
                ths.mOwnerDescription.MidlifeCrisisManager = midlifeCrisisManager;
            }

            ths.mOccultList.Add(newOccult);
            ths.mCurrentOccultTypes |= type;
            EventTracker.SendEvent(new BeAnOccultEvent(EventTypeId.kBeAnOccult, ths.mOwnerDescription.CreatedSim, (uint)type));
            if (ths.mOwnerDescription.CreatedSim != null)
            {
                if (!Cane.IsAllowedToUseCane(ths.mOwnerDescription.CreatedSim))
                {
                    Cane.StopUsingAnyActiveCanes(ths.mOwnerDescription.CreatedSim);
                }
                if (!Backpack.IsAllowedToUseBackpack(ths.mOwnerDescription.CreatedSim))
                {
                    Backpack.StopUsingAnyActiveBackpacks(ths.mOwnerDescription.CreatedSim);
                }
                if (!Jetpack.IsAllowedToUseJetpack(ths.mOwnerDescription.CreatedSim))
                {
                    Jetpack.StopUsingAnyActiveJetpacks(ths.mOwnerDescription.CreatedSim);
                }
            }

            (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();
            ths.ClearOneShot();
            ths.UpdateOccultUI();
            if (!fromRestore)
            {
                EventTracker.SendEvent(EventTypeId.kBecameOccult, ths.mOwnerDescription.CreatedSim);
            }

            if (oldOccult != null)
            {
                newOccult.MergeOccultData(oldOccult);
            }

            if (ths.mOwnerDescription.CreatedSim != null)
            {
                Sim.StandingPosture standing = ths.mOwnerDescription.CreatedSim.Standing as Sim.StandingPosture;
                if (standing != null)
                {
                    standing.SetDefaultIdleAnim();
                }
            }

            return(true);
        }
Exemple #7
0
        public static Approach Perform(SimDescription sim, bool force, bool reset)
        {
            try
            {
                OutfitCategories[] categoriesArray = null;

                switch (sim.Species)
                {
                case CASAgeGenderFlags.Human:
                    categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked, OutfitCategories.Athletic, OutfitCategories.Formalwear, OutfitCategories.Sleepwear, OutfitCategories.Swimwear };
                    break;

                case CASAgeGenderFlags.Horse:
                    categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked, OutfitCategories.Racing, OutfitCategories.Bridle, OutfitCategories.Jumping };
                    break;

                default:
                    categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked };
                    break;
                }

                bool necessary = force;

                if (!necessary)
                {
                    foreach (OutfitCategories category in categoriesArray)
                    {
                        if (sim.IsHuman)
                        {
                            if (category == OutfitCategories.Naked)
                            {
                                continue;
                            }
                        }

                        SimOutfit outfit2 = sim.GetOutfit(category, 0);
                        if ((outfit2 == null) || (!outfit2.IsValid))
                        {
                            necessary = true;
                        }
                    }
                }

                if (!necessary)
                {
                    return(Approach.None);
                }

                SimOutfit sourceOutfit = null;

                for (int i = 0; i < 2; i++)
                {
                    OutfitCategoryMap map = null;
                    if (i == 0)
                    {
                        map = sim.mOutfits;
                    }
                    else
                    {
                        map = sim.mMaternityOutfits;
                    }

                    if (map == null)
                    {
                        continue;
                    }

                    foreach (OutfitCategories category in Enum.GetValues(typeof(OutfitCategories)))
                    {
                        if (category == OutfitCategories.Supernatural)
                        {
                            continue;
                        }

                        ArrayList outfits = map[category] as ArrayList;
                        if (outfits == null)
                        {
                            continue;
                        }

                        foreach (SimOutfit anyOutfit in outfits)
                        {
                            if ((anyOutfit != null) && (anyOutfit.IsValid))
                            {
                                sourceOutfit = anyOutfit;
                                break;
                            }
                        }
                    }
                }

                SimBuilder builder = new SimBuilder();
                builder.UseCompression = true;

                ResourceKey newTone = ValidateSkinTone(sim.SkinToneKey);

                builder.Age           = sim.Age;
                builder.Gender        = sim.Gender;
                builder.Species       = sim.Species;
                builder.SkinTone      = newTone;
                builder.SkinToneIndex = sim.SkinToneIndex;
                builder.MorphFat      = sim.mCurrentShape.Fat;
                builder.MorphFit      = sim.mCurrentShape.Fit;
                builder.MorphThin     = sim.mCurrentShape.Thin;

                Approach approach = Approach.Rerolled;

                GeneticsPet.SpeciesSpecificData speciesData = OutfitUtils.GetSpeciesSpecificData(sim);

                try
                {
                    if (sourceOutfit != null)
                    {
                        foreach (SimOutfit.BlendInfo blend in sourceOutfit.Blends)
                        {
                            builder.SetFacialBlend(blend.key, blend.amount);
                        }

                        CASParts.OutfitBuilder.CopyGeneticParts(builder, sourceOutfit);

                        approach = Approach.Recovered;
                    }
                    else
                    {
                        if (sim.Genealogy != null)
                        {
                            List <SimDescription> parents      = new List <SimDescription>();
                            List <SimDescription> grandParents = new List <SimDescription>();

                            foreach (SimDescription parent in Relationships.GetParents(sim))
                            {
                                parents.Add(parent);

                                foreach (SimDescription grandParent in Relationships.GetParents(parent))
                                {
                                    grandParents.Add(grandParent);
                                }
                            }

                            if (parents.Count > 0)
                            {
                                if (sim.IsHuman)
                                {
                                    Genetics.InheritFacialBlends(builder, parents.ToArray(), new Random());
                                }
                                else
                                {
                                    GeneticsPet.InheritBodyShape(builder, parents, grandParents, new Random());
                                    GeneticsPet.InheritBasePeltLayer(builder, parents, grandParents, new Random());
                                    GeneticsPet.InheritPeltLayers(builder, parents, grandParents, new Random());
                                }

                                approach = Approach.Reinherited;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(sim, null, "Primary Outfit Creation", e);
                    return(Approach.None);
                }

                if (sim.IsRobot)
                {
                    OutfitUtils.AddMissingPartsBots(builder, (OutfitCategories)0x200002, true, sim);

                    Common.Sleep();

                    OutfitUtils.AddMissingPartsBots(builder, OutfitCategories.Everyday, true, sim);

                    Common.Sleep();
                }
                else if (sim.IsHuman)
                {
                    OutfitUtils.AddMissingParts(builder, (OutfitCategories)0x200002, true, sim, sim.IsAlien);

                    Common.Sleep();

                    OutfitUtils.AddMissingParts(builder, OutfitCategories.Everyday, true, sim, sim.IsAlien);

                    Common.Sleep();
                }
                else
                {
                    OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday | (OutfitCategories)0x200000, true, sim, speciesData);

                    Common.Sleep();

                    OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday, true, sim, speciesData);

                    Common.Sleep();
                }

                ResourceKey uniformKey = new ResourceKey();
                if (sim.IsHuman)
                {
                    if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, OutfitCategories.Everyday))
                    {
                        OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim);
                    }
                }

                OutfitUtils.SetAutomaticModifiers(builder);

                sim.ClearOutfits(OutfitCategories.Career, false);
                sim.ClearOutfits(OutfitCategories.MartialArts, false);
                sim.ClearOutfits(OutfitCategories.Special, false);

                foreach (OutfitCategories category in categoriesArray)
                {
                    ArrayList outfits = null;

                    if (!force)
                    {
                        outfits = sim.Outfits[category] as ArrayList;
                        if (outfits != null)
                        {
                            int index = 0;
                            while (index < outfits.Count)
                            {
                                SimOutfit anyOutfit = outfits[index] as SimOutfit;
                                if (anyOutfit == null)
                                {
                                    outfits.RemoveAt(index);
                                }
                                else if (!anyOutfit.IsValid)
                                {
                                    outfits.RemoveAt(index);
                                }
                                else
                                {
                                    index++;
                                }
                            }
                        }
                    }

                    if ((outfits == null) || (outfits.Count == 0))
                    {
                        OutfitUtils.MakeCategoryAppropriate(builder, category, sim);

                        if (sim.IsHuman)
                        {
                            if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, category))
                            {
                                OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim);
                            }
                        }

                        sim.RemoveOutfits(category, false);

                        CASParts.AddOutfit(sim, category, builder, true);
                    }

                    if (sim.IsUsingMaternityOutfits)
                    {
                        sim.BuildPregnantOutfit(category);
                    }
                }

                if (sim.IsMummy)
                {
                    OccultMummy.OnMerge(sim);
                }
                else if (sim.IsFrankenstein)
                {
                    OccultFrankenstein.OnMerge(sim, sim.OccultManager.mIsLifetimeReward);
                }
                else if (sim.IsGenie)
                {
                    OccultGenie.OverlayUniform(sim, OccultGenie.CreateUniformName(sim.Age, sim.Gender), ProductVersion.EP6, OutfitCategories.Everyday, CASSkinTones.BlueSkinTone, 0.68f);
                }
                else if (sim.IsImaginaryFriend)
                {
                    OccultImaginaryFriend friend = sim.OccultManager.GetOccultType(Sims3.UI.Hud.OccultTypes.ImaginaryFriend) as OccultImaginaryFriend;

                    OccultBaseClass.OverlayUniform(sim, OccultImaginaryFriend.CreateUniformName(sim.Age, friend.Pattern), ProductVersion.EP4, OutfitCategories.Special, CASSkinTones.NoSkinTone, 0f);
                }

                if (sim.IsMermaid)
                {
                    OccultMermaid.AddOutfits(sim, null);
                }


                if (sim.IsWerewolf)
                {
                    if (sim.ChildOrAbove)
                    {
                        SimOutfit newWerewolfOutfit = OccultWerewolf.GetNewWerewolfOutfit(sim.Age, sim.Gender);
                        if (newWerewolfOutfit != null)
                        {
                            sim.AddOutfit(newWerewolfOutfit, OutfitCategories.Supernatural, 0x0);
                        }
                    }
                }

                SimOutfit currentOutfit = null;
                if (sim.CreatedSim != null)
                {
                    if (reset)
                    {
                        ResetSimTask.Perform(sim.CreatedSim, false);
                    }

                    try
                    {
                        sim.CreatedSim.SwitchToOutfitWithoutSpin(Sim.ClothesChangeReason.GoingOutside, OutfitCategories.Everyday, true);
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(sim, e);
                    }

                    currentOutfit = sim.CreatedSim.CurrentOutfit;
                }
                else
                {
                    currentOutfit = sim.GetOutfit(OutfitCategories.Everyday, 0);
                }

                if (currentOutfit != null)
                {
                    ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, sim.AgeGenderSpecies);
                }

                return(approach);
            }
            catch (Exception e)
            {
                Common.Exception(sim, e);
                return(Approach.None);
            }
        }
        public static void SetRouteOptions(SimRoutingComponent ths, Route r, uint ageGenderFlags)
        {
            SimDescription simDescription  = ths.OwnerSim.SimDescription;
            Posture        previousPosture = ths.OwnerSim.Posture;

            if (!(ths.OwnerSim.CurrentInteraction is IHasCustomRouteOptions))
            {
                r.SetOption(Route.RouteOption.BeginAsCar, (ths.OwnerSim.Parent is Vehicle) && !(ths.OwnerSim.Parent is IBoat));
                r.SetOption(Route.RouteOption.EnablePlanningAsCar, simDescription.ChildOrAbove);
                r.SetOption(Route.RouteOption.DisablePlanningAsPedestrian, false);
                r.SetOption(Route.RouteOption.PushSimsAtDestination, true);
                r.SetOption(Route.RouteOption.UseAutoSlotFootprintLocking, true);
                r.SetOption(Route.RouteOption.ReplanToFindObstacleWhenPathPlanFails, true);
                r.SetOption(Route.RouteOption.IgnoreParent, false);
                r.SetOption(Route.RouteOption.IgnoreChildren, false);
                r.SetOption(Route.RouteOption.CreateSubPaths, true);
                r.SetOption(Route.RouteOption.CheckForFootprintsNearGoals, true);
                r.SetOption(Route.RouteOption.PenalizeGoalsOnDifferentLevels, true);

                bool flag = false;
                if (GameUtils.IsInstalled(ProductVersion.EP10))
                {
                    IBoat parent = ths.OwnerSim.Parent as IBoat;
                    if (parent != null)
                    {
                        flag       = true;
                        r.Follower = parent.Proxy;
                        r.FollowerAgeGenderSpecies = (uint)parent.GetBoatSpecies();
                        r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, true);
                        r.SetOption2(Route.RouteOption2.BeginAsBoat, true);
                        r.SetOption2(Route.RouteOption2.UseFollowerStartOrientation, true);
                        r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true);
                        r.AddObjectToIgnoreForRoute(ths.OwnerSim.ObjectId);
                    }

                    bool flag2 = OccultMermaid.IsEveryOneGroupedWithMeATeenOrAboveMermaid(ths.OwnerSim);
                    bool flag3 = false;
                    if (!flag2)
                    {
                        flag3 = ((previousPosture is CarryingChildPosture) || (previousPosture is CarryingPetPosture)) || ths.OwnerSim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation));
                    }

                    bool flag4 = simDescription.ChildOrAbove & !(previousPosture is ScubaDiving);
                    flag4 &= !(ths.OwnerSim.InteractionQueue.GetHeadInteraction() is Lifeguard.GiveCPR);
                    flag4 &= !(ths.OwnerSim.InteractionQueue.GetHeadInteraction() is Lifeguard.FakeInjury);
                    flag4 &= !(simDescription.CreatedByService is GrimReaper);
                    flag4 &= !flag2 || flag3;
                    flag4 &= !(previousPosture is BeingRiddenPosture) && !(previousPosture is RidingPosture);
                    bool flag5 = simDescription.ChildOrAbove && simDescription.IsHuman;
                    flag5 &= !(previousPosture is CarryingChildPosture) && !(previousPosture is CarryingPetPosture);
                    r.SetOption(Route.RouteOption.EnableWaterPlanning, flag5);
                    r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, !flag5);
                    r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, (parent != null) || flag4);
                    if (flag2 && flag5)
                    {
                        r.SetOption2(Route.RouteOption2.RouteAsMermaid, true);
                    }
                    else
                    {
                        r.SetOption2(Route.RouteOption2.RouteAsLifeguard, Lifeguard.ShouldUseRescueSwimWade(ths.OwnerSim));
                    }
                }

                if (GameUtils.IsInstalled(ProductVersion.EP3))
                {
                    r.SetOption(Route.RouteOption.EnableSubwayPlanning, true);
                }

                if (GameUtils.IsInstalled(ProductVersion.EP11)) /*&& GameUtils.IsFutureWorld())*/
                {
                    r.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, true);
                }

                if (GameUtils.IsInstalled(ProductVersion.EP5) && ((ths.OwnerSim.IsWildAnimal || ths.OwnerSim.IsStray) || (ths.OwnerSim.IsUnicorn || WildHorses.IsWildHorse(ths.OwnerSim))))
                {
                    r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, false);
                    r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, true);
                }

                if (ths.SimSatisfiesSpecialConditions())
                {
                    r.SetOption(Route.RouteOption.PassThroughObjects, true);
                    r.SetOption(Route.RouteOption.PassThroughWalls, true);
                }

                if (ths.OwnerSim.HasGhostBuff && !flag)
                {
                    r.SetOption(Route.RouteOption.RouteAsGhost, true);
                }

                if ((GameUtils.IsInstalled(ProductVersion.EP4) && (ths.OwnerSim.CarryingChildPosture != null)) && (Stroller.GetStroller(ths.OwnerSim, ths.OwnerSim.LotCurrent) != null))
                {
                    r.SetOption(Route.RouteOption.PlanUsingStroller, true);
                }

                if (ths.OwnerSim.IsHuman)
                {
                    SwimmingInPool pool = previousPosture as SwimmingInPool;
                    if (pool != null)
                    {
                        if (pool.ContainerIsOcean)
                        {
                            r.SetOption(Route.RouteOption.EnableWaterPlanning, true);
                        }
                    }
                    else
                    {
                        Ocean.PondAndOceanRoutingPosture posture2 = previousPosture as Ocean.PondAndOceanRoutingPosture;
                        if ((posture2 != null) && (posture2.WalkStyleToUse == Sim.WalkStyle.Wade))
                        {
                            r.SetOption(Route.RouteOption.EnableWaterPlanning, true);
                        }
                    }
                }

                if (GameUtils.IsInstalled(ProductVersion.EP8))
                {
                    // Custom
                    if (SimEx.GetOwnedAndUsableVehicle(ths.OwnerSim, ths.OwnerSim.LotHome, false, false, false, true) is CarUFO)
                    //if (OwnerSim.GetOwnedAndUsableVehicle(OwnerSim.LotHome, false, false, false, true) is CarUFO)
                    {
                        r.SetOption(Route.RouteOption.EnableUFOPlanning, true);
                    }
                    if ((ths.OwnerSim.IsHuman && ths.OwnerSim.SimDescription.ChildOrAbove) && PondManager.ArePondsFrozen())
                    {
                        bool flag6 = true;
                        while (previousPosture != null)
                        {
                            if (previousPosture.Satisfaction(CommodityKind.Standing, null) <= 0f)
                            {
                                flag6 = false;
                                break;
                            }
                            previousPosture = previousPosture.PreviousPosture;
                        }
                        if (flag6)
                        {
                            r.SetOption(Route.RouteOption.EnablePondPlanning, true);
                        }
                    }
                }

                r.ExitReasonsInterrupt = unchecked ((int)0xffa9bfff);
                if ((0x0 != (ageGenderFlags & 0x3)) && !ths.OwnerSim.LotCurrent.IsWorldLot)
                {
                    r.SetValidRooms(ths.OwnerSim.LotCurrent.LotId, null);
                }

                if ((ths.OwnerSim.IsHorse && ths.OwnerSim.SimDescription.AdultOrAbove) && !ths.OwnerSim.SimDescription.IsGhost)
                {
                    r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true);
                }

                if (((ths.OwnerSim.IsHorse || ths.OwnerSim.IsDeer) || (ths.OwnerSim.IsFullSizeDog && ths.OwnerSim.SimDescription.AdultOrAbove)) && !ths.OwnerSim.SimDescription.IsGhost)
                {
                    r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true);
                }

                if (ths.OwnerSim.IsHorse && ths.OwnerSim.IsInBeingRiddenPosture)
                {
                    r.SetOption(Route.RouteOption.RouteWhileMounted, true);
                }

                if (previousPosture is LeadingHorsePosture)
                {
                    r.SetOption(Route.RouteOption.EnablePlanningAsCar, false);
                    r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true);
                    r.SetOption(Route.RouteOption.RouteAsSimLeadingHorse, true);
                }

                if (ths.OwnerSim.IsPet && !ths.OwnerSim.IsInBeingRiddenPosture)
                {
                    r.SetOption(Route.RouteOption.IgnoreSidewalkAndLotRestrictions, true);
                }
            }
        }