예제 #1
0
        public static bool GiveGiftProceduralTest(Sim actor, Sim target, ActiveTopic topic, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
        {
            OccultImaginaryFriend friend;

            if (actor.GetRelationship(target, false) == null)
            {
                return(false);
            }
            if (SocialComponent.IsInServicePreventingSocialization(target))
            {
                return(false);
            }
            if (!SocialComponent.WouldShowMultiLevelSocialPieMenu(actor, target))
            {
                return(false);
            }
            if (OccultImaginaryFriend.TryGetOccultFromSim(target, out friend) && !friend.IsReal)
            {
                return(false);
            }

            /*
             * if (!Sim.GiveGift.Definition.DoesGiftForTargetSimExist(actor, target))
             * {
             *  greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(Sim.GiveGift.GiveGiftLocalizeString(actor.IsFemale, "NoGiftsToGive", new object[0]));
             *  return false;
             * }
             */
            return(true);
        }
예제 #2
0
        public bool SitDownAndWait(StateMachineClient stateMachine)
        {
            if (isSitting)
            {
                stateMachine.SetParameter("isDirty", Target.Cleanable.NeedsToBeCleaned);
                Target.PutDownSeat(stateMachine);
                stateMachine.RequestState("x", "peeSitting");
                if (Target.SculptureComponent != null && Target.SculptureComponent.Material == Sims3.Gameplay.ObjectComponents.SculptureComponent.SculptureMaterial.Ice)
                {
                    Actor.BuffManager.AddElement(BuffNames.Chilly, Origin.FromSittingOnIce);
                }
                if (Target.ToiletTuning.AutoFlushes && RandomUtil.RandomChance((float)Toilet.kChanceOfToiletAutoFlushWhileInUse))
                {
                    stateMachine.RequestState("x", "flushReaction");
                }
                OccultImaginaryFriend.GrantMilestoneBuff(Actor, BuffNames.ImaginaryFriendFeelOfPorcelain, Origin.FromImaginaryFriendFirstTime, true, true, false);

                if (!Actor.WaitForSynchronizationLevelWithSim(LinkedInteractionInstance.InstanceActor, Sim.SyncLevel.Routed, 30f))
                {
                    FinishLinkedInteraction();
                    return(false);
                }
            }
            return(true);
        }
예제 #3
0
 public void TryDeliverImaginaryFriend()
 {
     if (Actor.IsSelectable)
     {
         OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
     }
 }
예제 #4
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                OccultImaginaryFriend friend;

                if (!OccultImaginaryFriend.TryGetOccultFromSim(target, out friend) || friend.IsReal)
                {
                    return(false);
                }

                if (friend.OwnerSimDescriptionId != a.SimDescription.SimDescriptionId)
                {
                    return(false);
                }

                Relationship relationship = Relationship.Get(a, target, false);
                bool         flag         = (relationship != null) && (relationship.CurrentLTRLiking >= OccultImaginaryFriend.kRelationshipThresholdBeforeCanTurnFriendReal);

                if (a.Inventory.Find <IImaginaryFriendPotion>(true) == null)
                {
                    if (flag)
                    {
                        greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(OccultImaginaryFriend.LocalizeString(a.IsFemale, "NeedImaginaryFriendPotion", new object[] { a }));
                    }
                    return(false);
                }

                if (!flag)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(OccultImaginaryFriend.LocalizeString(new bool[] { a.IsFemale, target.IsFemale }, "NeedRelToUseImaginaryFriendPotion", new object[] { a, target }));
                    return(false);
                }

                return(true);
            }
예제 #5
0
        public override void Perform(SimDescription sim, OccultBaseClass sourceParam)
        {
            OccultImaginaryFriend occult = sim.OccultManager.GetOccultType(sourceParam.ClassOccultType) as OccultImaginaryFriend;
            OccultImaginaryFriend source = sourceParam as OccultImaginaryFriend;

            occult.mIsReal  = source.mIsReal;
            occult.mPattern = source.mPattern;
        }
예제 #6
0
            private new bool CanMakeBabyWith(Sim actor, Sim target)
            {
                BuffBetrayed.BuffInstanceBetrayed betrayed;
                if (actor == target)
                {
                    return(false);
                }
                if (actor.SimDescription.Species != target.SimDescription.Species)
                {
                    return(false);
                }
                if ((target.IsRobot || target.OccultManager.HasOccultType(OccultTypes.Mummy)) || (target.OccultManager.HasOccultType(OccultTypes.PlantSim) || HolographicProjectionSituation.IsSimHolographicallyProjected(target)))
                {
                    return(false);
                }
                if (target.OccultManager.HasOccultType(OccultTypes.TimeTraveler))
                {
                    return(false);
                }
                if (target.Service is GrimReaper)
                {
                    return(false);
                }
                if (BuffBetrayed.DoesSimFeelBetrayed(actor, target.SimDescription, out betrayed))
                {
                    return(false);
                }
                if (!OccultImaginaryFriend.CanSimGetRomanticWithSim(actor, target))
                {
                    return(false);
                }
                if ((target.CurrentInteraction != null) && (target.InteractionQueue.HasInteractionOfType(this) || target.InteractionQueue.HasInteractionOfType(Hospital.BeForcedToMakeBabyWith.Singleton)))
                {
                    return(false);
                }
                GreyedOutTooltipCallback callback = null;
                string reason;

                if (!CommonSocials.CanGetRomantic(actor, target, false, true, true, ref callback, out reason))
                {
                    return(false);
                }
                CASAgeGenderFlags flags = CASAgeGenderFlags.YoungAdult | CASAgeGenderFlags.Elder | CASAgeGenderFlags.Adult;

                if (Woohooer.Settings.AllowTeen(true))
                {
                    flags = flags | CASAgeGenderFlags.Teen;
                }
                return(((actor.SimDescription.Age & flags) != CASAgeGenderFlags.None) && ((target.SimDescription.Age & flags) != CASAgeGenderFlags.None));
            }
예제 #7
0
파일: SkateEx.cs 프로젝트: pepoluan/NRaas
        public static bool CalculateIfActorIsOccultSkaterEx(Sim sim)
        {
            OccultImaginaryFriend friend;
            SimDescription        simDescription = sim.SimDescription;

            if (!Hybrid.Settings.mAllowOccultSkating)
            {
                if ((simDescription.IsGenie) || (simDescription.IsFairy))
                {
                    return(true);
                }
            }

            if ((simDescription.IsFrankenstein) || (simDescription.IsMummy) || (simDescription.IsZombie))
            {
                return(true);
            }

            if (OccultImaginaryFriend.TryGetOccultFromSim(sim, out friend) && friend.IsWearingSpecialOutfit)
            {
                return(true);
            }

            BuffManager buffManager = sim.BuffManager;

            if (buffManager.HasTransformBuff())
            {
                return(true);
            }

            if (!Hybrid.Settings.mAllowOccultSkating)
            {
                if (simDescription.IsVampire)
                {
                    if (!buffManager.HasAnyElement(new BuffNames[] { BuffNames.Exhausted, BuffNames.Sleepy, BuffNames.Tired, BuffNames.TooMuchSun }))
                    {
                        return(true);
                    }
                }

                if (sim.IsGhostOrHasGhostBuff)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #8
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                SimDescription simDescription = a.SimDescription;

                if (simDescription.HasActiveRole && simDescription.AssignedRole.Type == Role.RoleType.Bouncer)
                {
                    return(false);
                }
                if (simDescription.IsBonehilda)
                {
                    return(false);
                }
                OccultGenie           occultGenie = a.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                OccultImaginaryFriend occultImaginaryFriend;

                return((occultGenie == null || !occultGenie.IsTiedToLamp) && (!OccultImaginaryFriend.TryGetOccultFromSim(a, out occultImaginaryFriend) || occultImaginaryFriend.IsReal) && (!simDescription.IsUnicorn || !OccultUnicorn.IsNPCPoolUnicorn(a)));
            }
예제 #9
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{
            }
        }
예제 #10
0
            // Methods
            public override bool Run() // Run
            {
                Slot[] routingSlots = this.Target.GetRoutingSlots();
                bool   flag         = false;
                Route  route        = this.Actor.CreateRoute();

                if (route.PlanToSlot(this.Target, routingSlots).Succeeded())
                {
                    flag = this.Actor.DoRoute(route);
                }
                else if (this.Actor.RouteToObjectRadius(this.Target, 1f))
                {
                    flag = true;
                }
                //SpeedTrap.Sleep(10);
                base.StandardEntry();
                // Pet Only Crazy CLIP Fixed No CLIP
                if (Actor.IsNPC && Actor.SimDescription.IsPet)
                {
                    this.Actor.Kill(SimDescription.DeathType.PetOldAgeGood);
                    //KillSimNiecX.MineKill(Actor, SimDescription.DeathType.PetOldAgeGood, true);
                    return(false);
                }
                if (Actor.IsInActiveHousehold && Actor.SimDescription.IsPet)
                {
                    this.Actor.Motives.MaxEverything();
                    Actor.Autonomy.Motives.FreezeDecayEverythingExcept(new CommodityKind[0]);
                    return(false);
                }
                base.BeginCommodityUpdates();
                base.AcquireStateMachine("JellyBean");
                base.SetActor("x", this.Actor);
                base.SetActor("magicjellybeanbush", this.Target);
                base.EnterState("x", "JellyBeanEnter");
                if (RandomUtil.RandomChance01(100) && !Actor.IsInActiveHousehold)
                {
                    base.AnimateSim("Poisoned");
                    if (!Actor.CanBeKilled()) // My Mod is CanBeKilled Not Modifed The Sims 3 is File Dll Gameplay
                    {
                        KillSimNiecX.MineKill(Actor, SimDescription.DeathType.Starve);
                        SpeedTrap.Sleep(10);
                        //return false;
                    }
                    Actor.Kill(SimDescription.DeathType.Starve);
                    SpeedTrap.Sleep(10);
                    //return false;
                }
                else
                {
                    float @float = RandomUtil.GetFloat(1f);
                    if (@float < 100 && this.Actor.IsInActiveHousehold)
                    {
                        base.AnimateSim("NormalExit");
                        {
                            this.Actor.Motives.MaxEverything();
                            Actor.Autonomy.Motives.FreezeDecayEverythingExcept(new CommodityKind[0]);
                            return(false);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Actor.BuffManager.AddElement(BuffNames.TooSpicy, Origin.FromMagicJellyBean);
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalPositive);
                        VisualEffect.FireOneShotEffect("ep7BuffJellyBeanPos_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition);
                        if (RandomUtil.CoinFlip())
                        {
                            this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.NowOrLater);
                        }
                        else
                        {
                            this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalNegative);
                        VisualEffect.FireOneShotEffect("ep7BuffJellyBeanNeg_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition);
                        if (RandomUtil.CoinFlip())
                        {
                            this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.NowOrLater);
                        }
                        else
                        {
                            this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        OccultImaginaryFriend occultImaginaryFriend;

                        if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend) && !this.Actor.IsSimBot)
                        {
                            this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransPositive);
                            if (RandomUtil.CoinFlip())
                            {
                                this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.AfterInteraction);
                            }
                            else
                            {
                                this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.AfterInteraction);
                            }
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff + JellyBeanBush.kChanceToGetNegTransBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        OccultImaginaryFriend occultImaginaryFriend2;
                        if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend2) && this.Actor.IsNPC)
                        {
                            this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransNegative);
                            if (RandomUtil.CoinFlip())
                            {
                                this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.AfterInteraction);
                            }
                            else
                            {
                                this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.AfterInteraction);
                            }
                        }
                    }
                    else
                    {
                        base.AnimateSim("NormalExit");
                    }
                }
                base.EndCommodityUpdates(true);
                base.StandardExit();
                EventTracker.SendEvent(EventTypeId.kEatMagicJellyBean, this.Actor);
                return(true);
            }
예제 #11
0
        public override bool InRabbitHole()
        {
            string msg = "HaveAlienBabyHospital.InRabbitHole" + Common.NewLine;

            bool result;

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript) && !BabyShouldBeBorn)
                {
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    result = false;
                }
                else
                {
                    msg += "B";

                    AlienPregnancyProxy pregnancy = new AlienPregnancyProxy(Actor.SimDescription.Pregnancy);

                    if (Actor.IsSelectable)
                    {
                        Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                    }

                    mNewborns = pregnancy.CreateNewborns(Pregnancy.HaveBabyHospital.kBonusMoodPointsForHospitalBirth, Actor.IsSelectable, false);

                    for (int i = 0; i < mNewborns.Count; i++)
                    {
                        Relationship.Get(Actor, mNewborns[i], true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);
                    }

                    msg += "C";

                    Actor.SimDescription.SetPregnancy(0f);
                    List <Sim> followers = SimFollowers;
                    pregnancy.PregnancyComplete(mNewborns, followers);

                    msg += "D";

                    SpeedTrap.Sleep(0u);
                    List <Sim> list2 = new List <Sim>();
                    list2.Add(Actor);

                    if (followers != null)
                    {
                        foreach (Sim sim in followers)
                        {
                            if (sim.SimDescription.TeenOrAbove && sim.GetObjectInRightHand() == null)
                            {
                                list2.Add(sim);
                            }
                        }
                    }

                    msg += "E";

                    if (mNewborns.Count <= list2.Count)
                    {
                        for (int i = 0; i < mNewborns.Count; i++)
                        {
                            Sim     target  = list2[i];
                            Posture posture = target.Posture;
                            target.Posture = null;
                            Sim actor = mNewborns[i];
                            InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor,
                                                                                                                           new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                            actor.InteractionQueue.Add(entry);

                            while (actor.CurrentInteraction != entry && actor.InteractionQueue.HasInteraction(entry))
                            {
                                SpeedTrap.Sleep();
                            }

                            try
                            {
                                ChildUtils.CarryChild(target, actor, false);
                            }
                            catch (Exception e)
                            {
                                Common.Exception(actor, target, e);
                            }

                            target.Posture = posture;
                            AddFollower(mNewborns[i]);
                        }
                    }
                    else
                    {
                        BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0, Vector3.UnitZ) as BabyBasket;
                        basket.AddBabiesToBasket(mNewborns);
                        CarrySystem.EnterWhileHolding(Actor, basket);
                        CarrySystem.VerifyAnimationParent(basket, Actor);
                    }

                    msg += "F";

                    if (Actor.IsSelectable)
                    {
                        OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                    }

                    result = true;
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, msg, e);
                result = false;
            }

            Common.DebugNotify(msg);

            return(result);
        }
예제 #12
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;
        }
예제 #13
0
        public override bool InRabbitHole()
        {
            string msg = "HaveBabyHospitalEx:InRabbitHole" + Common.NewLine;

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript))
                {
                    if (BabyShouldBeBorn && (((mDad == null) || !(mDad.CurrentInteraction is Pregnancy.GoToHospital)) || ((SimFollowers != null) && SimFollowers.Contains(mDad))))
                    {
                        break;
                    }
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    return(false);
                }

                msg += "B";

                Pregnancy pregnancy = Actor.SimDescription.Pregnancy;
                if (pregnancy != null)
                {
                    // Custom
                    HaveBabyHomeEx.EnsureForeignFather(pregnancy);
                }

                bool isSelectable = Actor.IsSelectable;
                //if (isSelectable)
                //{
                Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                //mNewborns = CreateNewborns(new HaveBabyHomeEx.PregnancyProxy(pregnancy), kBonusMoodPointsForHospitalBirth, isSelectable, false);
                mNewborns = new Proxies.PregnancyProxy(pregnancy).CreateNewborns(kBonusMoodPointsForHospitalBirth, isSelectable, false);
                // }
                // else
                // {
                //   try
                // {
                //   Simulator.YieldingDisabled = true;
                //mNewborns = CreateNewborns(new HaveBabyHomeEx.PregnancyProxy(pregnancy), kBonusMoodPointsForHospitalBirth, isSelectable, false); - was commented
                // mNewborns = new Proxies.PregnancyProxy(pregnancy).CreateNewborns(kBonusMoodPointsForHospitalBirth, isSelectable, false);
                // }
                //// finally
                // {
                //     Simulator.YieldingDisabled = false;
                // }
                // }

                msg += "C";

                Sim dad = Actor.SimDescription.Pregnancy.mDad;

                Actor.SimDescription.SetPregnancy(0f);
                List <Sim> simFollowers = SimFollowers;
                Actor.SimDescription.Pregnancy.PregnancyComplete(mNewborns, simFollowers);

                if (mNewborns.Count == 4)
                {
                    Actor.BuffManager.RemoveElement(BuffNames.ItsABoy);
                    Actor.BuffManager.AddElement(CommonPregnancy.sItsQuadruplets, Origin.FromNewBaby);

                    if (dad != null)
                    {
                        dad.BuffManager.RemoveElement(BuffNames.ItsABoy);
                        dad.BuffManager.AddElement(CommonPregnancy.sItsQuadruplets, Origin.FromNewBaby);
                    }
                }

                msg += "D";

                SpeedTrap.Sleep(0x0);

                List <Sim> list2 = new List <Sim>();
                list2.Add(Actor);

                if (simFollowers != null)
                {
                    foreach (Sim sim in simFollowers)
                    {
                        if (sim.SimDescription.TeenOrAbove && (sim.GetObjectInRightHand() == null))
                        {
                            list2.Add(sim);
                        }
                    }
                }

                msg += "E";

                if (mNewborns.Count <= list2.Count)
                {
                    for (int i = 0x0; i < mNewborns.Count; i++)
                    {
                        Sim     target  = list2[i];
                        Posture posture = target.Posture;
                        target.Posture = null;
                        Sim actor = mNewborns[i];
                        InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor, new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                        actor.InteractionQueue.Add(entry);

                        while ((actor.CurrentInteraction != entry) && actor.InteractionQueue.HasInteraction(entry))
                        {
                            SpeedTrap.Sleep();
                        }

                        try
                        {
                            ChildUtils.CarryChild(target, actor, false);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(actor, target, e);
                        }

                        target.Posture = posture;
                        AddFollower(mNewborns[i]);
                    }
                }
                else
                {
                    BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0x0, Vector3.UnitZ) as BabyBasket;
                    basket.AddBabiesToBasket(mNewborns);
                    CarrySystem.EnterWhileHolding(Actor, basket);
                    CarrySystem.VerifyAnimationParent(basket, Actor);
                }

                msg += "F";

                if (Actor.IsSelectable)
                {
                    OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, msg, e);
                return(false);
            }
        }
예제 #14
0
        public override bool Run()
        {
            try
            {
                if (mJig == null)
                {
                    return(false);
                }

                Route r = mJig.RouteToJigB(Actor);
                RequestWalkStyle(Sim.WalkStyle.Run);
                bool flag = Actor.DoRoute(r);
                UnrequestWalkStyle(Sim.WalkStyle.Run);
                if (!flag)
                {
                    return(false);
                }
                CurrentStatus = Status.Started;
                while (CurrentStatus != Status.CanTransform)
                {
                    if (CurrentStatus == Status.Cancelled)
                    {
                        return(false);
                    }
                    SpeedTrap.Sleep();
                }

                /* Removed
                 * if (Households.NumHumansIncludingPregnancy(Household.ActiveHousehold) >= 0x8)
                 * {
                 *  return false;
                 * }
                 */

                OccultImaginaryFriend occult = null;
                if (!OccultImaginaryFriend.TryGetOccultFromSim(Actor, out occult))
                {
                    return(false);
                }

                Actor.InteractionQueue.CancelAllInteractions();
                occult.AddToActiveHousehold(Actor);
                occult.MakeReal();
                occult.RebuildAppearance();
                SwitchToEverydayOutfit();

                EventTracker.SendEvent(EventTypeId.kTurnImaginaryFriendReal, Target);
                string message = OccultImaginaryFriend.LocalizeString(new bool[] { Actor.IsFemale, Target.IsFemale }, "ImaginaryFriendTurnedRealTNS", new object[] { Actor, Target });
                Actor.ShowTNSAndPlayStingIfSelectable(message, StyledNotification.NotificationStyle.kGameMessagePositive, Actor.ObjectId, Target.ObjectId, "sting_imaginary_real");

                {
                    Target.BuffManager.AddElement(BuffNames.ImaginaryFriendTurnedReal, Origin.FromHavingImaginaryFriend);
                    BuffImaginaryFriendTurnedReal.BuffInstanceImaginaryFriendTurnedReal buff = Target.BuffManager.GetElement(BuffNames.ImaginaryFriendTurnedReal) as BuffImaginaryFriendTurnedReal.BuffInstanceImaginaryFriendTurnedReal;
                    if (buff != null)
                    {
                        buff.SetImaginaryFriend(Actor);
                    }
                }

                {
                    Actor.BuffManager.AddElement(BuffNames.ImaginaryFriendIAmReal, Origin.FromImaginaryFriendFirstTime);
                    BuffImaginaryFriendIAmReal.BuffInstanceImaginaryFriendIAmReal buff2 = Actor.BuffManager.GetElement(BuffNames.ImaginaryFriendIAmReal) as BuffImaginaryFriendIAmReal.BuffInstanceImaginaryFriendIAmReal;
                    if (buff2 != null)
                    {
                        buff2.SetOwner(Target);
                    }
                }

                CurrentStatus = Status.Done;
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
예제 #15
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);
            }
        }
예제 #16
0
        public static Sim Perform(Sim sim, bool fadeOut)
        {
            if (sim == null)
            {
                return(null);
            }

            try
            {
                SimDescription simDesc = sim.SimDescription;

                if (Simulator.GetProxy(sim.ObjectId) == null)
                {
                    if (simDesc != null)
                    {
                        sim.Destroy();
                    }

                    //sim.mSimDescription = null;
                    return(null);
                }

                if (simDesc == null)
                {
                    sim.mSimDescription = new SimDescription();

                    sim.Destroy();
                    return(null);
                }

                if (sim.LotHome != null)
                {
                    simDesc.IsZombie = false;

                    if (simDesc.CreatedSim != sim)
                    {
                        sim.Destroy();

                        simDesc.CreatedSim = null;

                        return(null);
                    }
                    else
                    {
                        Bed     myBed     = null;
                        BedData myBedData = null;

                        foreach (Bed bed in sim.LotHome.GetObjects <Bed>())
                        {
                            myBedData = bed.GetPartOwnedBy(sim);
                            if (myBedData != null)
                            {
                                myBed = bed;
                                break;
                            }
                        }

                        ResetPosture(sim);

                        if (simDesc.TraitManager == null)
                        {
                            simDesc.mTraitManager = new TraitManager();
                        }

                        try
                        {
                            simDesc.Fixup();

                            Corrections.CleanupBrokenSkills(simDesc, null);

                            ResetCareer(simDesc);

                            simDesc.ClearSpecialFlags();

                            if (simDesc.Pregnancy == null)
                            {
                                try
                                {
                                    if (simDesc.mMaternityOutfits == null)
                                    {
                                        simDesc.mMaternityOutfits = new OutfitCategoryMap();
                                    }
                                    simDesc.SetPregnancy(0, false);

                                    simDesc.ClearMaternityOutfits();
                                }
                                catch (Exception e)
                                {
                                    Common.Exception(sim, null, "Pregnancy", e);
                                }
                            }

                            if (sim.CurrentCommodityInteractionMap == null)
                            {
                                try
                                {
                                    LotManager.PlaceObjectOnLot(sim, sim.ObjectId);

                                    if (sim.CurrentCommodityInteractionMap == null)
                                    {
                                        sim.ChangeCommodityInteractionMap(sim.LotHome.Map);
                                    }
                                }
                                catch (Exception e)
                                {
                                    Common.Exception(sim, null, "ChangeCommodityInteractionMap", e);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, null, "Fixup", e);
                        }

                        ResetSituations(sim);

                        CleanupSlots(sim);

                        ResetInventory(sim);

                        if (fadeOut)
                        {
                            bool active = (Sim.ActiveActor == sim);

                            if (sSimReset.Valid)
                            {
                                sSimReset.Invoke <bool>(new object[] { simDesc.SimDescriptionId });
                            }

                            ResetRouting(sim);

                            using (CreationProtection protection = new CreationProtection(simDesc, sim, false, true, false))
                            {
                                sim.Destroy();

                                Common.Sleep();

                                sim = FixInvisibleTask.InstantiateAtHome(simDesc, null);
                            }

                            if (sim != null)
                            {
                                if (active)
                                {
                                    try
                                    {
                                        foreach (Sim member in Households.AllSims(sim.Household))
                                        {
                                            if (member.CareerManager == null)
                                            {
                                                continue;
                                            }

                                            Occupation occupation = member.CareerManager.Occupation;
                                            if (occupation == null)
                                            {
                                                continue;
                                            }

                                            occupation.FormerBoss = null;
                                        }

                                        using (DreamCatcher.HouseholdStore store = new DreamCatcher.HouseholdStore(sim.Household, true))
                                        {
                                            PlumbBob.DoSelectActor(sim, true);
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Common.Exception(sim, null, "DoSelectActor", e);
                                    }
                                }

                                if ((myBed != null) && (myBedData != null))
                                {
                                    if (!(myBed is BedMultiPart) || (myBed is BedMultiPart && ((sim.Partner != null) && (sim.Partner.CreatedSim != null))))
                                    {
                                        myBed.ClaimOwnership(sim, myBedData);
                                    }
                                    else
                                    {
                                        HandleDoubleBed(sim, myBed, myBedData);
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (sim.Inventory == null)
                            {
                                sim.AddComponent <InventoryComponent>(new object[0x0]);
                            }

                            if (Instantiation.AttemptToPutInSafeLocation(sim, false))
                            {
                                ResetRouting(sim);

                                sim.SetObjectToReset();

                                // This is necessary to clear certain types of interactions
                                //   (it is also called in SetObjectToReset(), though doesn't always work there)
                                if (sim.InteractionQueue != null)
                                {
                                    sim.InteractionQueue.OnReset();
                                }
                            }
                        }

                        ResetSkillModifiers(simDesc);

                        ResetRole(sim);

                        if (simDesc.IsEnrolledInBoardingSchool())
                        {
                            simDesc.BoardingSchool.OnRemovedFromSchool();
                        }

                        MiniSimDescription miniSim = MiniSimDescription.Find(simDesc.SimDescriptionId);
                        if (miniSim != null)
                        {
                            miniSim.Instantiated = true;
                        }

                        UpdateInterface(sim);

                        return(sim);
                    }
                }
                else if (simDesc.Service is Butler)
                {
                    if (Instantiation.AttemptToPutInSafeLocation(sim, true))
                    {
                        sim.Motives.RecreateMotives(sim);
                        sim.SetObjectToReset();
                    }

                    return(sim);
                }
                else if (simDesc.IsImaginaryFriend)
                {
                    OccultImaginaryFriend friend;
                    if (OccultImaginaryFriend.TryGetOccultFromSim(sim, out friend))
                    {
                        if (Simulator.GetProxy(friend.mDollId) != null)
                        {
                            friend.TurnBackIntoDoll(OccultImaginaryFriend.Destination.Owner);

                            return(null);
                        }
                    }
                }
                else if (simDesc.IsBonehilda)
                {
                    foreach (BonehildaCoffin coffin in Sims3.Gameplay.Queries.GetObjects <BonehildaCoffin>())
                    {
                        if (coffin.mBonehilda == simDesc)
                        {
                            coffin.mBonehildaSim = null;
                            break;
                        }
                    }
                }

                if (fadeOut)
                {
                    sim.Destroy();
                }

                return(null);
            }
            catch (Exception exception)
            {
                Common.Exception(sim, exception);
                return(sim);
            }
        }
예제 #17
0
        public override bool Run()
        {
            try
            {
                if (!Target.RouteSimToMeAndCheckInUse(Actor) || !HarvestPlant.HarvestTest(Target, Actor))
                {
                    return(false);
                }

                Target.RemoveHarvestStateTimeoutAlarm();
                StandardEntry();
                BeginCommodityUpdates();
                Soil dummyIk = null;
                StateMachineClient client = null;

                bool allowChild = false;

                if (Actor.SimDescription.YoungAdultOrAbove)
                {
                    allowChild = true;
                }
                else if ((Actor.SimDescription.Teen) && (Woohooer.Settings.mUnlockTeenActions))
                {
                    allowChild = true;
                }

                if ((!Autonomous) && (allowChild) && RandomUtil.RandomChance01(kChanceToHavePlantSimBaby))
                {
                    client   = Target.CreateStateMachine(Actor, out dummyIk);
                    mDummyIk = dummyIk;
                    Sim newBorn = GetNewBorn();
                    Relationship.Get(Actor, newBorn, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);
                    if (newBorn.BridgeOrigin != null)
                    {
                        newBorn.BridgeOrigin.MakeRequest();
                        newBorn.BridgeOrigin = null;
                    }

                    if (client != null)
                    {
                        IGameObject actor = GlobalFunctions.CreateObjectOutOfWorld("plantSimHarvestable", ProductVersion.EP9, "Sims3.Gameplay.Core.Null", null);
                        client.SetActor("harvestable", actor);
                        client.SetActor("y", newBorn);
                        client.EnterState("x", "Enter Standing");
                        Target.SetGrowthState(PlantGrowthState.Planted);
                        client.RequestState("x", "HaveAPlantSimBaby");
                        Pregnancy.MakeBabyVisible(newBorn);
                        client.RequestState("x", "Exit Standing");
                        actor.RemoveFromWorld();
                        actor.Destroy();
                    }

                    if (Actor.IsSelectable)
                    {
                        OccultImaginaryFriend.DeliverDollToHousehold(new List <Sim>(new Sim[] { newBorn }));
                    }

                    ChildUtils.CarryChild(Actor, newBorn, true);
                    EventTracker.SendEvent(EventTypeId.kBornFromTheSoil, newBorn);
                }
                else
                {
                    client   = Target.CreateStateMachine(Actor, out dummyIk);
                    mDummyIk = dummyIk;
                    bool hasHarvested = true;
                    if (Actor.IsInActiveHousehold)
                    {
                        hasHarvested = false;
                        foreach (SimDescription description in Actor.Household.SimDescriptions)
                        {
                            Gardening skill = description.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                            if ((skill != null) && skill.HasHarvested())
                            {
                                hasHarvested = true;
                                break;
                            }
                        }
                    }

                    IGameObject obj3 = GlobalFunctions.CreateObjectOutOfWorld("plantForbiddenFruit", ProductVersion.EP9, "Sims3.Gameplay.Core.Null", null);
                    if (client != null)
                    {
                        client.SetActor("harvestable", obj3);
                        client.EnterState("x", "Enter Standing");
                        client.RequestState("x", "HaveAFruit");
                    }
                    Target.DoHarvest(Actor, hasHarvested, null);
                    Target.SetGrowthState(PlantGrowthState.Planted);
                    if (client != null)
                    {
                        client.RequestState("x", "Exit Standing");
                    }
                    obj3.RemoveFromWorld();
                    obj3.Destroy();
                }

                EndCommodityUpdates(true);
                StandardExit();
                Target.RemoveFromWorld();
                Target.Destroy();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
예제 #18
0
        //public static string NExportHousehold(Bin ths, Household household, bool includeLotContents, bool isMovingPacked)
        //{
        //    return NExportHousehold(ths, household, includeLotContents, isMovingPacked, false);
        //}
        public static string NExportHousehold(Bin ths, Household household, bool includeLotContents, bool isMovingPacked, bool noReset, bool noThum)
        {
            if (ths == null)
            {
                throw new NullReferenceException();
            }
            if (household == null)
            {
                throw new ArgumentNullException("household");
            }
            try
            {
                string createdPackageFile = null;
                if (GameUtils.IsInstalled(ProductVersion.EP4))
                {
                    OccultImaginaryFriend.ForceHouseholdImaginaryFriendsBackToInventory(household);
                }

                if (!noReset)
                {
                    foreach (Sim sim in household.AllActors)
                    {
                        sim.SetObjectToReset();
                    }
                }

                if (Simulator.CheckYieldingContext(false))
                {
                    Simulator.Sleep(0);
                }

                ThumbnailSizeMask sizeMask;
                if (includeLotContents)
                {
                    Lot lotHome = household.LotHome;
                    if (lotHome != null)
                    {
                        int householdFunds  = household.FamilyFunds;
                        int lotHomeLotWorth = World.GetEmptyLotWorth(lotHome.LotId) + ((int)World.GetLotAdditionalPropertyValue(lotHome.LotId));

                        household.SetFamilyFunds(householdFunds + lotHomeLotWorth, false);

                        EditTownModel.SendObjectsToProperLot(lotHome);

                        ulong contentID = DownloadContent.StoreLotContents(lotHome, lotHome.LotId);
                        if (contentID != 0)
                        {
                            ThumbnailHelper.GenerateLotThumbnailSet(lotHome.LotId, contentID, ThumbnailSizeMask.ExtraLarge);
                            ThumbnailHelper.GenerateLotThumbnail(lotHome.LotId, contentID, 0, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium);
                            sizeMask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium;
                            ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, contentID, sizeMask);

                            if (!noThum && household.AllSimDescriptions.Count < 12)
                            {
                                ths.GenerateSimThumbnails(household, contentID, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge);
                            }

                            HouseholdContentsProxy contents = new HouseholdContentsProxy(household);

                            if (DownloadContent.StoreHouseholdContents(contents, contentID))
                            {
                                createdPackageFile = DownloadContent.ExportLotContentsToExportBin(contentID);
                            }

                            ThumbnailManager.InvalidateLotThumbnails(lotHome.LotId, contentID, ThumbnailSizeMask.ExtraLarge);
                            ThumbnailManager.InvalidateLotThumbnailsForGroup(lotHome.LotId, contentID, ThumbnailSizeMask.Medium, 0);
                            ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, contentID, sizeMask);

                            try
                            {
                                ths.InvalidateSimThumbnails(household, contentID);
                            }
                            catch (Exception)
                            { if (IsOpenDGSInstalled)
                              {
                                  return(null);
                              }
                            }
                        }
                        household.SetFamilyFunds(householdFunds, false);
                        return(createdPackageFile);
                    }
                    //return createdPackageFile;
                }

                int familyFunds     = household.FamilyFunds;
                int realEstateFunds = 0;
                if (household.RealEstateManager != null)
                {
                    foreach (IPropertyData data in household.RealEstateManager.AllProperties)
                    {
                        realEstateFunds += data.TotalValue;
                    }
                }

                if (household.LotHome != null)
                {
                    int lotWorth = 0;
                    if (isMovingPacked)
                    {
                        lotWorth = World.GetUnfurnishedLotWorth(household.LotHome.LotId) + realEstateFunds;
                    }
                    else
                    {
                        lotWorth = World.GetLotWorth(household.LotHome.LotId) + realEstateFunds;
                    }

                    household.SetFamilyFunds(household.FamilyFunds + lotWorth, false);
                }

                if (household.FamilyFunds < 20000)
                {
                    household.SetFamilyFunds(20000, false);
                }

                ulong gGUID = DownloadContent.GenerateGUID();
                HouseholdContentsProxy householdContents = new HouseholdContentsProxy(household);
                householdContents.Contents.ContentId = gGUID;

                sizeMask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium;

                if (!noThum && household.AllSimDescriptions.Count < 12)
                {
                    ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, gGUID, sizeMask);
                    ths.GenerateSimThumbnails(household, gGUID, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge);
                }

                if (DownloadContent.StoreHouseholdContents(householdContents, gGUID))
                {
                    createdPackageFile = DownloadContent.ExportLotContentsToExportBin(gGUID);
                }

                ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, gGUID, sizeMask);

                try
                {
                    ths.InvalidateSimThumbnails(household, gGUID);
                }
                catch (Exception)
                { if (IsOpenDGSInstalled)
                  {
                      return(null);
                  }
                }

                household.SetFamilyFunds(familyFunds, false);
                return(createdPackageFile);
            }
            catch (Exception)
            { return(null); }
        }
예제 #19
0
        public override bool InRabbitHole()
        {
            string msg = "HaveAlienBabyHosptial:InRabbitHole" + "\n";

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript))
                {
                    if (BabyShouldBeBorn)
                    {
                        break;
                    }
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    return(false);
                }

                msg += "B";

                Pregnancy pregnancy    = Actor.SimDescription.Pregnancy;
                bool      isSelectable = Actor.IsSelectable;
                Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                mNewborns = new PregnancyProxy(pregnancy).CreateNewborns(Pregnancy.HaveBabyHospital.kBonusMoodPointsForHospitalBirth, isSelectable, false);

                msg += "C";

                Actor.SimDescription.SetPregnancy(0f);
                List <Sim> simFollowers = SimFollowers;
                new PregnancyProxy(pregnancy).PregnancyComplete(mNewborns, simFollowers);

                /*
                 * if (mNewborns.Count == 4)
                 * {
                 *  Actor.BuffManager.RemoveElement(BuffNames.ItsABoy);
                 *  Actor.BuffManager.AddElement(CommonPregnancy.sItsQuadruplets, Origin.FromNewBaby);
                 * }
                 */

                msg += "D";

                Simulator.Sleep(0u);
                //SpeedTrap.Sleep(0x0);

                List <Sim> list2 = new List <Sim>();
                list2.Add(Actor);

                if (simFollowers != null)
                {
                    foreach (Sim sim in simFollowers)
                    {
                        if (sim.SimDescription.TeenOrAbove && sim.GetObjectInRightHand() == null)
                        {
                            list2.Add(sim);
                        }
                    }
                }

                msg += "E";

                if (mNewborns.Count <= list2.Count)
                {
                    for (int i = 0; i < mNewborns.Count; i++)
                    {
                        Sim     target  = list2[i];
                        Posture posture = target.Posture;
                        target.Posture = null;
                        Sim actor = mNewborns[i];
                        InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor,
                                                                                                                       new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                        actor.InteractionQueue.Add(entry);

                        while (actor.CurrentInteraction != entry && actor.InteractionQueue.HasInteraction(entry))
                        {
                            Simulator.Sleep(0u);
                            //SpeedTrap.Sleep();
                        }

                        try
                        {
                            ChildUtils.CarryChild(target, actor, false);
                        }
                        catch (Exception e)
                        {
                            Logger.WriteExceptionLog(e, this, "HaveAlienBabyHospital.Run() Error - CarryChild()");
                        }

                        target.Posture = posture;
                        AddFollower(mNewborns[i]);
                    }
                }
                else
                {
                    BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0, Vector3.UnitZ) as BabyBasket;
                    basket.AddBabiesToBasket(mNewborns);
                    CarrySystem.EnterWhileHolding(Actor, basket);
                    CarrySystem.VerifyAnimationParent(basket, Actor);
                }

                msg += "F";

                if (Actor.IsSelectable)
                {
                    OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                }

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Logger.WriteExceptionLog(e, this, "HaveAlienBabyHospital.Run() Error");
                return(false);
            }
        }
예제 #20
0
        protected static bool IsSupervised(Common.IStatGenerator stats, Sim ths)
        {
            if (ths.SimDescription.YoungAdultOrAbove)
            {
                stats.IncStat("Supervised: Too Old");
                return(true);
            }

            if (ths.CareerManager != null)
            {
                Career occupationAsCareer = ths.CareerManager.OccupationAsCareer;
                if ((occupationAsCareer != null) && (occupationAsCareer.ShouldBeAtWork()) && (occupationAsCareer.CurLevel.IsSupervised))
                {
                    stats.IncStat("Supervised: Career");
                    return(true);
                }
            }

            if ((ths.LotCurrent == null) || (ths.LotCurrent.CanSimTreatAsHome(ths)) || (ths.HasBeenAskedToSleepOver()))
            {
                stats.IncStat("Supervised: Home or Sleepover");
                return(true);
            }

            if ((ths.CurrentInteraction is GoHome) || (((ths.CurrentInteraction != null) && (ths.CurrentInteraction.Target != null)) && (ths.CurrentInteraction.Target.LotCurrent != null) && (ths.CurrentInteraction.Target.LotCurrent.CanSimTreatAsHome(ths))))
            {
                stats.IncStat("Supervised: Going Home");
                return(true);
            }

            if (ths.LotCurrent.IsWorldLot)
            {
                if (ths.Household != null)
                {
                    float distanceTeenIsSupervisedOnWorldLot = Sim.kDistanceTeenIsSupervisedOnWorldLot;
                    if (ths.SimDescription.Age == CASAgeGenderFlags.Child)
                    {
                        distanceTeenIsSupervisedOnWorldLot = Sim.kChildCurfewDistanceFromAdult;
                    }

                    foreach (Sim sim in ths.Household.Sims)
                    {
                        if (sim.SimDescription.YoungAdultOrAbove && (ths.GetDistanceToObject(sim) <= distanceTeenIsSupervisedOnWorldLot))
                        {
                            stats.IncStat("Supervised: World Lot Sim");
                            return(true);
                        }
                    }
                }
            }
            else
            {
                foreach (Sim sim2 in ths.LotCurrent.GetSims())
                {
                    if (sim2.SimDescription.YoungAdultOrAbove && (sim2.LotHome == ths.LotHome))
                    {
                        stats.IncStat("Supervised: Family Sim");
                        return(true);
                    }
                }
            }

            OccultImaginaryFriend friend;

            return((GameUtils.IsInstalled(ProductVersion.EP4) && OccultImaginaryFriend.TryGetOccultFromSim(ths, out friend)) && !friend.IsReal);
        }
예제 #21
0
        public override bool Run()
        {
            try
            {
                BuffInstance element = Actor.BuffManager.GetElement(BuffNames.ReallyHasToPee);
                if ((element != null) && (element.mTimeoutCount <= UberToilet.kTimeoutRemainingForBladderEmergency))
                {
                    RequestWalkStyle(Sim.WalkStyle.Run);
                }
                else if (!Target.Line.WaitForTurn(this, SimQueue.WaitBehavior.DefaultAllowSubstitution, ~(ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), UberToilet.kTimeToWaitInLine))
                {
                    return(false);
                }
                else if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                {
                    return(false);
                }

                ClearRequestedWalkStyles();

                // Custom
                if (Shooless.Settings.GetPrivacy(Target))
                {
                    mSituation = Toilet.ToiletSituation.Create(Actor, Actor.LotCurrent);
                }

                if (mSituation != null)
                {
                    if (!mSituation.Start())
                    {
                        return(false);
                    }
                    if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                    {
                        mSituation.ExitToiletSituation();
                        return(false);
                    }
                }

                CancellableByPlayer = false;
                StandardEntry();
                StateMachineClient smc = StateMachineClient.Acquire(Actor, "ubertoilet_store");
                smc.AddInterest <TraitNames>(TraitNames.HotHeaded);
                smc.SetActor("x", Actor);
                smc.SetActor("ubertoilet", Target);
                smc.EnterState("x", "Enter");
                smc.SetParameter("isDirty", Target.Cleanable.NeedsToBeCleaned);
                smc.SetParameter("isBroken", Target.Repairable.Broken);
                mCensorEnabled = true;
                Actor.EnableCensor(Sim.CensorType.LowerBody);
                smc.AddOneShotScriptEventHandler(0x78, TurnOffCensorGrid);
                smc.AddOneShotScriptEventHandler(0xc8, TriggerTrapCallback);
                if (element != null)
                {
                    element.mTimeoutPaused = true;
                }

                bool flag = false;
                if (ShouldSit(Actor))
                {
                    flag = true;
                    Target.PutDownSeat(smc);
                    smc.RequestState("x", "peeSitting");
                    if ((Target.SculptureComponent != null) && (Target.SculptureComponent.Material == SculptureComponent.SculptureMaterial.Ice))
                    {
                        Actor.BuffManager.AddElement(BuffNames.Chilly, Origin.FromSittingOnIce);
                    }
                    if (Target.ToiletTuning.AutoFlushes && RandomUtil.RandomChance((float)UberToilet.kChanceOfToiletAutoFlushWhileInUse))
                    {
                        smc.RequestState("x", "flushReaction");
                    }
                }
                else
                {
                    Target.PutUpSeat(smc);
                    smc.RequestState("x", "peeStanding");
                }

                if (!Target.Repairable.Broken && (Target.mToiletOnStatus == UberToilet.ToiletOnStatus.Auto))
                {
                    Target.StartMusic();
                }

                BeginCommodityUpdate(CommodityKind.Bladder, 0f);
                BeginCommodityUpdates();
                Actor.Motives.LerpToFill(this, CommodityKind.Bladder, UberToilet.kMaxLengthUseToilet);
                StartStages();
                OccultImaginaryFriend.GrantMilestoneBuff(Actor, BuffNames.ImaginaryFriendFeelOfPorcelain, Origin.FromImaginaryFriendFirstTime, true, true, false);
                bool succeeded = DoLoop(~(ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.BuffFailureState | ExitReason.MaxSkillPointsReached | ExitReason.HigherPriorityNext));
                Actor.BuffManager.UnpauseBuff(BuffNames.ImaginaryFriendFeelOfPorcelain);
                EndCommodityUpdates(succeeded);
                if (succeeded)
                {
                    Actor.Motives.GetMotive(CommodityKind.Bladder).PotionBladderDecayOverride = false;
                }

                if (element != null)
                {
                    element.mTimeoutPaused = false;
                }

                Target.Cleanable.DirtyInc(Actor);
                if (Target.ShouldPutDownSeat(Actor))
                {
                    Target.PutDownSeat(smc);
                }

                InteractionInstance instance = null;
                bool flag3 = Target.Line.MemberCount() > 0x1;
                if (Target.Repairable.Broken)
                {
                    if (flag)
                    {
                        smc.RequestState("x", "electricBreakSitting");
                    }
                    else
                    {
                        smc.RequestState("x", "electricBreakStanding");
                    }
                }

                if ((mSituation == null) || !mSituation.SomeoneDidIntrude)
                {
                    if (!Target.ToiletTuning.AutoFlushes)
                    {
                        Target.ToiletVolume++;
                        if (Target.ShouldFlush(Actor, Autonomous))
                        {
                            Target.FlushToilet(Actor, smc, true);
                        }
                    }

                    if (Target.ShouldWashHands(Actor) && !flag3)
                    {
                        Sink target = Toilet.FindClosestSink(Actor);
                        if (target != null)
                        {
                            instance = Sink.WashHands.Singleton.CreateInstance(target, Actor, GetPriority(), false, true);
                        }
                    }
                }

                if (Target.mToiletOnStatus == UberToilet.ToiletOnStatus.Auto)
                {
                    Target.StopMusic();
                }

                if (!Target.Repairable.Broken)
                {
                    if (Target.Upgradable.SelfCleaning && Target.mSelfCleanOn)
                    {
                        smc.RequestState("x", "autoClean");
                        Target.Cleanable.ForceClean();
                        Actor.BuffManager.AddElement(BuffNames.Relaxed, Origin.None);
                        Actor.Motives.ChangeValue(CommodityKind.Hygiene, UberToilet.kChanceOfRelaxed);
                    }
                    else if (RandomUtil.RandomChance(UberToilet.kChanceOfRelaxed))
                    {
                        Actor.BuffManager.AddElement(BuffNames.Relaxed, Origin.None);
                    }
                }

                smc.RequestState("x", "Exit");
                if (mSituation != null)
                {
                    mSituation.ExitToiletSituation();
                }

                if (flag3)
                {
                    PrivacySituation.RouteToAdjacentRoom(Actor);
                }

                StandardExit();
                if (instance != null)
                {
                    Actor.InteractionQueue.PushAsContinuation(instance, false);
                }
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
예제 #22
0
            // Methods
            public override bool Run() // Run
            {
                Slot[] routingSlots = this.Target.GetRoutingSlots();
                bool   flag         = false;
                Route  route        = this.Actor.CreateRoute();

                if (route.PlanToSlot(this.Target, routingSlots).Succeeded())
                {
                    flag = this.Actor.DoRoute(route);
                }
                else if (this.Actor.RouteToObjectRadius(this.Target, 1f))
                {
                    flag = true;
                }
                base.StandardEntry();
                base.BeginCommodityUpdates();
                base.AcquireStateMachine("JellyBean");
                base.SetActor("x", this.Actor);
                base.SetActor("magicjellybeanbush", this.Target);
                base.EnterState("x", "JellyBeanEnter");
                if (RandomUtil.RandomChance01(100) && this.Actor.IsNPC)
                {
                    base.AnimateSim("Poisoned");
                    this.Actor.Kill(SimDescription.DeathType.Shark);
                    KillSimNiecX.MineKill(Actor, SimDescription.DeathType.Shark, true);
                }
                else
                {
                    float @float = RandomUtil.GetFloat(1f);
                    if (@float < JellyBeanBush.kChanceToCatchOnFire && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        if (this.Actor.SimDescription.TeenOrAbove)
                        {
                            this.Actor.BuffManager.AddElement(BuffNames.OnFire, Origin.FromMagicJellyBean);
                            this.Actor.PlayReaction(ReactionTypes.SmellSmoke, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Actor.BuffManager.AddElement(BuffNames.TooSpicy, Origin.FromMagicJellyBean);
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalPositive);
                        VisualEffect.FireOneShotEffect("ep7BuffJellyBeanPos_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition);
                        if (RandomUtil.CoinFlip())
                        {
                            this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.NowOrLater);
                        }
                        else
                        {
                            this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalNegative);
                        VisualEffect.FireOneShotEffect("ep7BuffJellyBeanNeg_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition);
                        if (RandomUtil.CoinFlip())
                        {
                            this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.NowOrLater);
                        }
                        else
                        {
                            this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        OccultImaginaryFriend occultImaginaryFriend;

                        if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend) && !this.Actor.IsSimBot)
                        {
                            this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransPositive);
                            if (RandomUtil.CoinFlip())
                            {
                                this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.AfterInteraction);
                            }
                            else
                            {
                                this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.AfterInteraction);
                            }
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff + JellyBeanBush.kChanceToGetNegTransBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        OccultImaginaryFriend occultImaginaryFriend2;
                        if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend2) && this.Actor.IsNPC)
                        {
                            this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransNegative);
                            if (RandomUtil.CoinFlip())
                            {
                                this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.AfterInteraction);
                            }
                            else
                            {
                                this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.AfterInteraction);
                            }
                        }
                    }
                    else
                    {
                        base.AnimateSim("NormalExit");
                    }
                }
                base.EndCommodityUpdates(true);
                base.StandardExit();
                EventTracker.SendEvent(EventTypeId.kEatMagicJellyBean, this.Actor);
                return(true);
            }
예제 #23
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);
        }
예제 #24
0
        protected static OptionResult ApplyOutfit(SimDescription sim, OutfitCategories category)
        {
            ResourceKey newOutfitKey = ResourceKey.kInvalidResourceKey;

            if (sim.IsMummy)
            {
                newOutfitKey = OccultMummy.CreateMummyUniform(sim.Age, sim.Gender).Key;
            }
            else if (sim.IsFrankenstein)
            {
                newOutfitKey = OccultBaseClass.CreateUniform(OccultFrankenstein.CreateUniformName(sim, sim.OccultManager.mIsLifetimeReward), sim.Age, ProductVersion.EP2, CASSkinTones.NoSkinTone, 0f).Key;
            }
            else if (sim.IsImaginaryFriend)
            {
                OccultImaginaryFriend friend = sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend;

                string name;
                newOutfitKey = OccultImaginaryFriend.CreateImaginaryFriendUniform(sim.Age, friend.Pattern, out name).Key;
            }
            else
            {
                SimOutfit source = null;
                if (sim.GetOutfitCount(OutfitCategories.Naked) > 0)
                {
                    source = sim.GetOutfit(OutfitCategories.Naked, 0);
                }
                else if (sim.GetOutfitCount(category) > 0)
                {
                    source = sim.GetOutfit(category, 0);
                }

                if (source != null)
                {
                    using (SimBuilder builder = new SimBuilder())
                    {
                        OutfitUtils.SetOutfit(builder, source, sim);

                        OutfitUtils.MakeCategoryAppropriate(builder, category, sim);

                        newOutfitKey = builder.CacheOutfit(CASParts.GetOutfitName(sim, category, sim.IsUsingMaternityOutfits));
                    }
                }
            }

            if (newOutfitKey == ResourceKey.kInvalidResourceKey)
            {
                return(OptionResult.Failure);
            }

            sim.AddOutfit(new SimOutfit(newOutfitKey), category, false);

            int index = sim.GetOutfitCount(category) - 1;

            ArrayList list = sim.GetCurrentOutfits()[category] as ArrayList;

            object a = list[0];
            object b = list[index];

            list[0]     = b;
            list[index] = a;

            return(OptionResult.SuccessClose);
        }
예제 #25
0
파일: InstaBaby.cs 프로젝트: yakoder/NRaas
        protected List <Sim> GenerateHumanChildren(SimDescription woman, SimDescription man, int numChildren)
        {
            Random pregoRandom = new Random();

            List <Sim> babies = new List <Sim>();

            for (int i = 0; i < numChildren; i++)
            {
                try
                {
                    SimDescription newBaby = Genetics.MakeBaby(woman, man, NRaas.MasterControllerSpace.Helpers.Baby.InterpretGender(mGender), 100, pregoRandom, false);
                    woman.Household.Add(newBaby);

                    string name = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":NamePrompt", newBaby.IsFemale, new object[0]), newBaby.FirstName);
                    if (!string.IsNullOrEmpty(name))
                    {
                        newBaby.FirstName = name;
                    }

                    Sim babySim = Instantiation.Perform(newBaby, null);
                    if (babySim != null)
                    {
                        babies.Add(babySim);

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

                        Pregnancy.MakeBabyVisible(babySim);

                        if (i == 0)
                        {
                            EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBaby, newBaby));
                        }

                        if (woman != null)
                        {
                            MidlifeCrisisManager.OnHadChild(woman);

                            if (woman.CreatedSim != null)
                            {
                                EventTracker.SendEvent(EventTypeId.kNewOffspring, woman.CreatedSim, babySim);
                                EventTracker.SendEvent(EventTypeId.kParentAdded, babySim, woman.CreatedSim);
                            }
                        }

                        if (man != null)
                        {
                            MidlifeCrisisManager.OnHadChild(man);

                            if (man.CreatedSim != null)
                            {
                                EventTracker.SendEvent(EventTypeId.kNewOffspring, man.CreatedSim, babySim);
                                EventTracker.SendEvent(EventTypeId.kParentAdded, babySim, man.CreatedSim);
                            }
                        }

                        EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, babySim);

                        if (newBaby.IsHuman)
                        {
                            OccultImaginaryFriend.DeliverDollToHousehold(new List <Sim> {
                                newBaby.CreatedSim
                            });
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(woman, man, e);
                }
            }

            if (babies.Count > 0)
            {
                if (woman.CreatedSim != null)
                {
                    EventTracker.SendEvent(new PregnancyEvent(EventTypeId.kHadBaby, woman.CreatedSim, man.CreatedSim, null, babies));
                }

                if (man.CreatedSim != null)
                {
                    EventTracker.SendEvent(new PregnancyEvent(EventTypeId.kHadBaby, man.CreatedSim, woman.CreatedSim, null, babies));
                }
            }

            return(babies);
        }
예제 #26
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("RepairImaginaryFriends");

            Trait trait;
            if (TraitManager.sDictionary.TryGetValue((ulong)TraitNames.ImaginaryFriendHiddenTrait, out trait))
            {
                trait.mNonPersistableData.mCanBeLearnedRandomly = false;
            }

            foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects<ImaginaryDoll>())
            {
                if (doll.mLiveStateSimDescId == 0) continue;

                if (doll.GetLiveFormSimDescription() != null) continue;

                doll.CreateLiveStateForm();

                Overwatch.Log("Missing Imaginary Doll Repaired");
            }

            foreach (SimDescription sim in Households.All(Household.NpcHousehold))
            {
                if (sim.OccultManager == null) continue;

                OccultImaginaryFriend occult = sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend;
                if (occult == null) continue;

                Overwatch.Log(sim.FullName);

                if (occult.IsReal) continue;

                SimDescription owner = SimDescription.Find(occult.OwnerSimDescriptionId);
                if (owner == null) continue;

                if (owner.LotHome == null) continue;

                IScriptProxy proxy = Simulator.GetProxy(occult.mDollId);
                if (proxy == null)
                {
                    IGameObject obj = GlobalFunctions.CreateObjectOutOfWorld("ImaginaryFriendDoll", ProductVersion.EP4);
                    if (obj != null)
                    {
                        ImaginaryDoll doll = obj as ImaginaryDoll;
                        if (doll == null)
                        {
                            obj.Destroy();
                        }
                        else
                        {
                            occult.UpdateDollGuid(obj.ObjectId);

                            doll.SetOwner(owner);

                            doll.mLiveStateSimDescId = sim.SimDescriptionId;
                            doll.mIsFemale = sim.IsFemale;
                            doll.mGenderSet = true;
                            doll.EstablishState(ImaginaryDoll.OwnershipState.Live);

                            Sim ownerSim = owner.CreatedSim;
                            if (ownerSim != null)
                            {
                                if (Inventories.TryToMove(obj, ownerSim))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Sim Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                            else
                            {
                                if (Inventories.TryToMove(obj, ownerSim.Household.SharedFamilyInventory.Inventory))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Family Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #27
0
        public override bool Run()
        {
            try
            {
                BuffInstance element = Actor.BuffManager.GetElement(BuffNames.ReallyHasToPee);
                if ((element != null) && (element.mTimeoutCount <= Toilet.kTimeoutRemainingForBladderEmergency))
                {
                    RequestWalkStyle(Sim.WalkStyle.Run);
                }
                if (!Target.Line.WaitForTurn(this, SimQueue.WaitBehavior.DefaultAllowSubstitution, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), Toilet.kTimeToWaitInLine))
                {
                    return(false);
                }

                if (CanPerformShooPet)
                {
                    if (!Actor.SimRoutingComponent.PreRouteCheckForLine(Target))
                    {
                        return(false);
                    }
                    Sims3.SimIFace.Route r = Actor.CreateRoute();
                    r.PlanToSlot(Target, Slot.RoutingSlot_0);
                    r.RegisterCallback(new RouteCallback(SlotInUse), RouteCallbackType.TriggerOnTrue, RouteCallbackConditions.OnEventType(RouteEvent.tEventType.EventDestinationObstructed));
                    if (!Actor.DoRoute(r))
                    {
                        return(false);
                    }
                    if (Target.InUse)
                    {
                        Actor.AddExitReason(ExitReason.ObjectInUse);
                        return(false);
                    }
                }
                else if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                {
                    return(false);
                }
                ClearRequestedWalkStyles();

                if ((!(Target is ToiletStall)) && (Shooless.Settings.GetPrivacy(Target)))
                {
                    mSituation = Toilet.ToiletSituation.Create(Actor, Actor.LotCurrent);
                }

                if (mSituation != null)
                {
                    if (!mSituation.Start())
                    {
                        return(false);
                    }
                    if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                    {
                        mSituation.ExitToiletSituation();
                        return(false);
                    }
                }

                CancellableByPlayer = false;
                StandardEntry();
                StateMachineClient stateMachine = Target.GetStateMachine(Actor);
                stateMachine.SetParameter("isDirty", Target.Cleanable.NeedsToBeCleaned);
                mCensorEnabled = true;

                OutfitCategories previousCategory = Actor.CurrentOutfitCategory;
                int previousIndex = Actor.CurrentOutfitIndex;

                bool switchOutfit = false;

                Actor.EnableCensor(Sim.CensorType.LowerBody);

                stateMachine.AddOneShotScriptEventHandler(120, TurnOffCensorGrid);
                stateMachine.AddOneShotScriptEventHandler(200, TriggerTrapCallback);
                if (element != null)
                {
                    element.mTimeoutPaused = true;
                }

                if (ShouldSit(Actor))
                {
                    if (Shooless.Settings.mNakedToilet)
                    {
                        Actor.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.GoingToBathe);
                        switchOutfit = true;
                    }

                    Target.PutDownSeat(stateMachine);
                    stateMachine.RequestState("x", "peeSitting");
                    if ((Target.SculptureComponent != null) && (Target.SculptureComponent.Material == SculptureComponent.SculptureMaterial.Ice))
                    {
                        Actor.BuffManager.AddElement(BuffNames.Chilly, Origin.FromSittingOnIce);
                    }
                    if (Target.ToiletTuning.AutoFlushes && RandomUtil.RandomChance((float)Toilet.kChanceOfToiletAutoFlushWhileInUse))
                    {
                        stateMachine.RequestState("x", "flushReaction");
                    }
                }
                else
                {
                    Target.PutUpSeat(stateMachine);
                    stateMachine.RequestState("x", "peeStanding");
                }
                BeginCommodityUpdate(CommodityKind.Bladder, 0f);
                BeginCommodityUpdates();

                bool succeeded = false;

                try
                {
                    Actor.Motives.LerpToFill(this, CommodityKind.Bladder, Toilet.kMaxLengthUseToilet);
                    StartStages();
                    OccultImaginaryFriend.GrantMilestoneBuff(Actor, BuffNames.ImaginaryFriendFeelOfPorcelain, Origin.FromImaginaryFriendFirstTime, true, true, false);
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.BuffFailureState | ExitReason.MaxSkillPointsReached | ExitReason.HigherPriorityNext));
                    Actor.BuffManager.UnpauseBuff(BuffNames.ImaginaryFriendFeelOfPorcelain);
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                if (succeeded)
                {
                    Motive motive = Actor.Motives.GetMotive(CommodityKind.Bladder);
                    if (motive != null)
                    {
                        motive.PotionBladderDecayOverride = false;
                    }
                }

                if (element != null)
                {
                    element.mTimeoutPaused = false;
                }
                Target.Cleanable.DirtyInc(Actor);

                if (Target.ShouldPutDownSeat(Actor))
                {
                    Target.PutDownSeat(stateMachine);
                }

                InteractionInstance instance = null;
                bool flag2 = Target.Line.MemberCount() > 0x1;
                if ((mSituation == null) || !mSituation.SomeoneDidIntrude)
                {
                    if (Target.ToiletTuning.AutoFlushes)
                    {
                        Target.FlushToilet(Actor, stateMachine, false);
                    }
                    else
                    {
                        Target.ToiletVolume++;
                        if (Target.ShouldFlush(Actor, Autonomous))
                        {
                            Target.FlushToilet(Actor, stateMachine, true);
                        }
                    }

                    if (Target.ShouldWashHands(Actor) && !flag2)
                    {
                        Sink target = Toilet.FindClosestSink(Actor);
                        if (target != null)
                        {
                            instance = Sink.WashHands.Singleton.CreateInstance(target, Actor, GetPriority(), false, true);
                        }
                    }
                }

                stateMachine.RequestState("x", "Exit");
                if (mSituation != null)
                {
                    mSituation.ExitToiletSituation();
                }

                if (switchOutfit)
                {
                    Actor.SwitchToOutfitWithSpin(previousCategory, previousIndex);
                }

                if (flag2)
                {
                    PrivacySituation.RouteToAdjacentRoom(Actor);
                }

                StandardExit();
                if (instance != null)
                {
                    Actor.InteractionQueue.PushAsContinuation(instance, false);
                }

                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
예제 #28
0
        public override bool Run()
        {
            bool result;

            try
            {
                if (Actor.LotCurrent != Target)
                {
                    Vector3 point = World.LotGetPtInside(Target.LotId);

                    if (point == Vector3.Invalid)
                    {
                        return(false);
                    }

                    if (!Actor.RouteToPointRadius(point, 3f) &&
                        (!GlobalFunctions.PlaceAtGoodLocation(Actor, new World.FindGoodLocationParams(point), false) ||
                         !SimEx.IsPointInLotSafelyRoutable(Actor, Target, Actor.Position)))
                    {
                        Actor.AttemptToPutInSafeLocation(true);
                    }
                }

                if (Actor.Posture is SwimmingInPool && !(Actor.Posture as SwimmingInPool).ContainerPool.RouteToEdge(Actor))
                {
                    if (Actor.BridgeOrigin != null)
                    {
                        Actor.BridgeOrigin.MakeRequest();
                    }

                    Actor.PopPosture();
                    IGameObject reservedTile = null;
                    Actor.FindRoutablePointInsideNearFrontDoor(Actor.Household.LotHome, out reservedTile);
                    Vector3 position            = reservedTile.Position;
                    Terrain.TeleportMeHere here = Terrain.TeleportMeHere.Singleton.CreateInstance(Terrain.Singleton, Actor,
                                                                                                  new InteractionPriority(InteractionPriorityLevel.Pregnancy), false, false) as Terrain.TeleportMeHere;
                    here.SetAndReserveDestination(reservedTile);

                    try
                    {
                        here.RunInteractionWithoutCleanup();
                    }
                    catch
                    {
                        Actor.SetPosition(position);
                    }
                    finally
                    {
                        here.Cleanup();
                    }

                    Actor.LoopIdle();
                }

                AlienPregnancyProxy pregnancy = new AlienPregnancyProxy(Actor.SimDescription.Pregnancy);
                Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                mNewborns            = pregnancy.CreateNewborns(0f, Actor.IsSelectable, true);
                mCurrentStateMachine = StateMachineClient.Acquire(Actor, "Pregnancy");
                mCurrentStateMachine.SetActor("x", Actor);

                for (int i = 0; i < mNewborns.Count; i++)
                {
                    Sim baby = mNewborns[i];
                    Relationship.Get(Actor, baby, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);

                    if (baby.BridgeOrigin != null)
                    {
                        baby.BridgeOrigin.MakeRequest();
                        baby.BridgeOrigin = null;
                    }

                    HaveAlienBabyHomeInternal instance = HaveAlienBabyHomeInternal.Singleton.CreateInstance(baby, Actor, GetPriority(),
                                                                                                            Autonomous, CancellableByPlayer) as HaveAlienBabyHomeInternal;
                    instance.TotalCount           = mNewborns.Count;
                    instance.BabyIndex            = i + 1;
                    instance.mCurrentStateMachine = mCurrentStateMachine;
                    Actor.InteractionQueue.PushAsContinuation(instance, true);
                }

                if (Actor.IsSelectable)
                {
                    OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                }

                result = true;
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);

                result = false;
            }

            return(result);
        }
예제 #29
0
파일: BinEx.cs 프로젝트: yakoder/NRaas
        public static string ExportHousehold(Bin ths, Household household, bool includeLotContents, bool isMovingPacked)
        {
            try
            {
                string str = null;
                if (GameUtils.IsInstalled(ProductVersion.EP4))
                {
                    OccultImaginaryFriend.ForceHouseholdImaginaryFriendsBackToInventory(household);
                }

                foreach (Sim sim in household.AllActors)
                {
                    sim.SetObjectToReset();
                }

                Common.Sleep();

                if (includeLotContents)
                {
                    Lot lotHome = household.LotHome;
                    if (lotHome != null)
                    {
                        int num  = household.FamilyFunds;
                        int num2 = World.GetEmptyLotWorth(lotHome.LotId) + ((int)World.GetLotAdditionalPropertyValue(lotHome.LotId));
                        household.SetFamilyFunds(household.FamilyFunds + num2, false);
                        EditTownModel.SendObjectsToProperLot(lotHome);
                        ulong contentId = DownloadContent.StoreLotContents(lotHome, lotHome.LotId);
                        if (contentId != 0x0L)
                        {
                            ThumbnailHelper.GenerateLotThumbnailSet(lotHome.LotId, contentId, ThumbnailSizeMask.ExtraLarge);
                            ThumbnailHelper.GenerateLotThumbnail(lotHome.LotId, contentId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium);
                            ThumbnailSizeMask mask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium;
                            ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, contentId, mask);
                            ths.GenerateSimThumbnails(household, contentId, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge);
                            HouseholdContentsProxy contents = new HouseholdContentsProxy(household);
                            if (DownloadContent.StoreHouseholdContents(contents, contentId))
                            {
                                str = DownloadContent.ExportLotContentsToExportBin(contentId);
                            }
                            ThumbnailManager.InvalidateLotThumbnails(lotHome.LotId, contentId, ThumbnailSizeMask.ExtraLarge);
                            ThumbnailManager.InvalidateLotThumbnailsForGroup(lotHome.LotId, contentId, ThumbnailSizeMask.Medium, 0x0);
                            ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, contentId, mask);
                            ths.InvalidateSimThumbnails(household, contentId);
                        }
                        household.SetFamilyFunds(num, false);
                    }
                    return(str);
                }

                int familyFunds     = household.FamilyFunds;
                int realEstateFunds = 0;
                if (household.RealEstateManager != null)
                {
                    foreach (IPropertyData data in household.RealEstateManager.AllProperties)
                    {
                        realEstateFunds += data.TotalValue;
                    }
                }
                if (household.LotHome != null)
                {
                    int lotWorth = 0;
                    if (isMovingPacked)
                    {
                        lotWorth = World.GetUnfurnishedLotWorth(household.LotHome.LotId) + realEstateFunds;
                    }
                    else
                    {
                        lotWorth = World.GetLotWorth(household.LotHome.LotId) + realEstateFunds;
                    }

                    household.SetFamilyFunds(household.FamilyFunds + lotWorth, false);
                }

                if (household.FamilyFunds < 0x4e20)
                {
                    household.SetFamilyFunds(0x4e20, false);
                }

                ulong cacheId = DownloadContent.GenerateGUID();
                HouseholdContentsProxy householdContents = new HouseholdContentsProxy(household);
                householdContents.Contents.ContentId = cacheId;
                ThumbnailSizeMask sizeMask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium;
                ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, cacheId, sizeMask);
                ths.GenerateSimThumbnails(household, cacheId, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge);
                if (DownloadContent.StoreHouseholdContents(householdContents, cacheId))
                {
                    str = DownloadContent.ExportLotContentsToExportBin(cacheId);
                }

                ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, cacheId, sizeMask);
                ths.InvalidateSimThumbnails(household, cacheId);
                household.SetFamilyFunds(familyFunds, false);
                return(str);
            }
            catch (Exception e)
            {
                Common.Exception("ExportHousehold", e);
                return(null);
            }
        }
예제 #30
0
        public static void CreateSimInventories(List <SimDescription> sims, HouseholdContents contents, List <ulong> indexMap)
        {
            List <Sim> newborns = new List <Sim>();

            for (int i = 0x0; i < sims.Count; i++)
            {
                SimDescription description = sims[i];

                // Custom Try/Catch
                try
                {
                    if ((description != null) && (description.CreatedSim != null))
                    {
                        int index = i;
                        if (indexMap != null)
                        {
                            for (int j = 0x0; j < indexMap.Count; j++)
                            {
                                if (indexMap[j] == description.SimDescriptionId)
                                {
                                    index = j;
                                    break;
                                }
                            }
                        }
                        ulong id = contents.Inventories[index];
                        if (id != 0x0L)
                        {
                            Diploma diploma = description.CreatedSim.Inventory.Find <Diploma>();
                            if ((diploma != null) && !description.CreatedSim.Inventory.TryToRemove(diploma))
                            {
                                diploma = null;
                            }

                            IPhoneSmart smart = null;
                            if (GameUtils.IsInstalled(ProductVersion.EP9))
                            {
                                smart = description.CreatedSim.Inventory.Find <IPhoneSmart>();
                                if ((smart != null) && !description.CreatedSim.Inventory.TryToRemove(smart))
                                {
                                    smart = null;
                                }
                            }

                            DownloadContent.ImportInventory(id, new InventoryProxy(description.CreatedSim.Inventory));
                            DownloadContent.DeleteInventory(id);

                            if (diploma != null)
                            {
                                Inventories.TryToMove(diploma, description.CreatedSim.Inventory, false);
                            }

                            if (smart != null)
                            {
                                IPhoneCell cell = description.CreatedSim.Inventory.Find <IPhoneCell>();
                                if (cell != null)
                                {
                                    cell.Destroy();
                                }
                                description.CreatedSim.Inventory.TryToAdd(smart);
                            }
                        }
                        else
                        {
                            if (description.Toddler)
                            {
                                newborns.Add(description.CreatedSim);
                            }
                            description.CreatedSim.AddInitialObjects(false);
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(description, e);
                }
            }

            // Custom Try/Catch
            try
            {
                OccultImaginaryFriend.DeliverDollToHousehold(newborns, true);
            }
            catch (Exception e)
            {
                Common.Exception("DeliverDollToHousehold", e);
            }
        }