Example #1
0
        protected override bool IsAvailable(Sim sim, IMagicalDefinition definition)
        {
            if (!base.IsAvailable(sim, definition))
            {
                return(false);
            }

            OccultGenie genie = sim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;

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

            if (!genie.MagicPoints.HasPoints())
            {
                return(false);
            }

            if (GetMana(sim) - definition.SpellSettings.mMinMana <= 0)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        public override void ConsumeMana(Sim actor, IInteractionProxy proxy, IMagicalDefinition definition)
        {
            OccultGenie genie = actor.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;

            if (genie != null)
            {
                genie.MagicPoints.UsePoints((int)definition.SpellSettings.mMinMana);
                (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
            }
        }
Example #3
0
        private static bool PrivateUsePoints(Sim sim, MagicWand wand, int points, OccultTypes type)
        {
            if (!OccultTypeHelper.HasType(sim, type))
            {
                return(false);
            }

            switch (type)
            {
            case OccultTypes.Genie:
                OccultGenie genie = sim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                if (genie != null)
                {
                    genie.MagicPoints.UsePoints(points);
                    (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
                    return(true);
                }
                break;

            case OccultTypes.Fairy:
                sim.Motives.ChangeValue(CommodityKind.AuraPower, -points);
                (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
                return(true);

            case OccultTypes.Witch:
                if (wand != null)
                {
                    wand.DrainMotive(sim, CommodityKind.MagicFatigue, -points);
                    return(true);
                }
                else
                {
                    float num = (points * DefaultWand.kMotiveDrainMultiplier) * MagicWand.kMoonPhaseMotiveDrainMultiplier[World.GetLunarPhase()];
                    if (sim.BuffManager.HasElement(BuffNames.AnimalFamiliar))
                    {
                        num *= MagicWand.kFamiliarMotiveMultiplier;
                    }
                    sim.Motives.ChangeValue(CommodityKind.MagicFatigue, -num);
                    (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
                }
                break;

            case OccultTypes.Unicorn:
                OccultUnicorn unicorn = sim.OccultManager.GetOccultType(OccultTypes.Unicorn) as OccultUnicorn;
                if (unicorn != null)
                {
                    unicorn.MagicPoints.UsePoints(points);
                    (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
                    return(true);
                }
                break;
            }

            return(false);
        }
Example #4
0
        public override float GetMana(Sim sim)
        {
            OccultGenie genie = sim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;

            if (genie == null)
            {
                return(0);
            }

            return(genie.MagicPoints.mCurrentMagicPointValue);
        }
Example #5
0
 public static void OnFreedFromLamp(OccultGenie ths, Sim freer, Sim genie, bool addToFreerHousehold)
 {
     genie.SimDescription.MotivesDontDecay = false;
     genie.SimDescription.Marryable        = true;
     genie.SimDescription.AgingEnabled     = true;
     ths.mLamp = null;
     if (addToFreerHousehold /*&& freer.Household.CanAddSpeciesToHousehold(CASAgeGenderFlags.Human)*/)
     {
         freer.Household.AddSim(genie);
         freer.Household.AddOutfitToWardrobe(genie.CurrentOutfit.Key);
     }
     EventTracker.SendEvent(EventTypeId.kFreeGenie, freer);
 }
Example #6
0
 public static void OnFreedFromLamp(OccultGenie ths, Sim freer, Sim genie, bool addToFreerHousehold)
 {
     genie.SimDescription.MotivesDontDecay = false;
     genie.SimDescription.Marryable = true;
     genie.SimDescription.AgingEnabled = true;
     ths.mLamp = null;
     if (addToFreerHousehold /*&& freer.Household.CanAddSpeciesToHousehold(CASAgeGenderFlags.Human)*/)
     {
         freer.Household.AddSim(genie);
         freer.Household.AddOutfitToWardrobe(genie.CurrentOutfit.Key);
     }
     EventTracker.SendEvent(EventTypeId.kFreeGenie, freer);
 }
Example #7
0
        public static bool IsLampGenie(SimDescription sim)
        {
            if (!sim.IsGenie)
            {
                return(false);
            }

            OccultGenie occultType = sim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;

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

            return(occultType.IsTiedToLamp);
        }
Example #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)));
            }
Example #9
0
        public static void OnRemoval(OccultGenie ths, SimDescription simDes, bool alterOutfit)
        {
            if (ths.mGenieMagicPoints != null)
            {
                ths.mGenieMagicPoints.RestorePoints();
            }

            OutfitCategories everyday = OutfitCategories.Everyday;
            int index      = 0x0;
            Sim createdSim = simDes.CreatedSim;

            if (createdSim != null)
            {
                createdSim.SetOpacity(1f, 0f);
                createdSim.Motives.RestoreDecays();
                everyday = createdSim.CurrentOutfitCategory;
                index    = createdSim.CurrentOutfitIndex;
            }

            simDes.MotivesDontDecay = false;
            simDes.Marryable        = true;
            simDes.AgingEnabled     = true;

            if (simDes.TraitManager.HasElement(TraitNames.ImmuneToFire))
            {
                simDes.TraitManager.RemoveElement(TraitNames.ImmuneToFire);
            }
            if (simDes.TraitManager.HasElement(TraitNames.GenieHiddenTrait))
            {
                simDes.TraitManager.RemoveElement(TraitNames.GenieHiddenTrait);
            }

            if (alterOutfit)
            {
                simDes.SetSkinToneForAllOutfits(simDes.Age, CASSkinTones.NoSkinTone | CASSkinTones.HumanSkinTone, ths.mOldSkinToneIndex);
                if (createdSim != null)
                {
                    Sim.SwitchOutfitHelper helper = new Sim.SwitchOutfitHelper(createdSim, everyday, index);
                    helper.Start();
                    helper.Wait(false);
                    helper.ChangeOutfit();
                    helper.Dispose();
                }
            }
        }
Example #10
0
        private static float GetMagicLevel(Sim actor, OccultTypes exclude, out OccultTypes selection)
        {
            if (exclude != OccultTypes.Fairy)
            {
                Motive motive = actor.Motives.GetMotive(CommodityKind.AuraPower);
                if (motive != null)
                {
                    selection = OccultTypes.Fairy;
                    return(motive.UIValue);
                }
            }

            if (exclude != OccultTypes.Witch)
            {
                Motive motive = actor.Motives.GetMotive(CommodityKind.MagicFatigue);
                if (motive != null)
                {
                    selection = OccultTypes.Witch;
                    return(-motive.UIValue);
                }
            }

            if (exclude != OccultTypes.Genie)
            {
                OccultGenie genie = actor.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                if (genie != null)
                {
                    selection = OccultTypes.Genie;
                    return((genie.MagicPoints.mCurrentMagicPointValue * 100) / genie.MagicPoints.mMaxMagicPoints);
                }
            }

            if (exclude != OccultTypes.Unicorn)
            {
                OccultUnicorn unicorn = actor.OccultManager.GetOccultType(OccultTypes.Unicorn) as OccultUnicorn;
                if (unicorn != null)
                {
                    selection = OccultTypes.Unicorn;
                    return((unicorn.MagicPoints.mCurrentMagicPointValue * 100) / unicorn.MagicPoints.mMaxMagicPoints);
                }
            }

            selection = OccultTypes.None;
            return(0);
        }
Example #11
0
        public static void OnRemoval(OccultGenie ths, SimDescription simDes, bool alterOutfit)
        {
            if (ths.mGenieMagicPoints != null)
            {
                ths.mGenieMagicPoints.RestorePoints();
            }

            OutfitCategories everyday = OutfitCategories.Everyday;
            int index = 0x0;
            Sim createdSim = simDes.CreatedSim;
            if (createdSim != null)
            {
                createdSim.SetOpacity(1f, 0f);
                createdSim.Motives.RestoreDecays();
                everyday = createdSim.CurrentOutfitCategory;
                index = createdSim.CurrentOutfitIndex;
            }

            simDes.MotivesDontDecay = false;
            simDes.Marryable = true;
            simDes.AgingEnabled = true;

            if (simDes.TraitManager.HasElement(TraitNames.ImmuneToFire))
            {
                simDes.TraitManager.RemoveElement(TraitNames.ImmuneToFire);
            }
            if (simDes.TraitManager.HasElement(TraitNames.GenieHiddenTrait))
            {
                simDes.TraitManager.RemoveElement(TraitNames.GenieHiddenTrait);
            }

            if (alterOutfit)
            {
                simDes.SetSkinToneForAllOutfits(simDes.Age, CASSkinTones.NoSkinTone | CASSkinTones.HumanSkinTone, ths.mOldSkinToneIndex);
                if (createdSim != null)
                {
                    Sim.SwitchOutfitHelper helper = new Sim.SwitchOutfitHelper(createdSim, everyday, index);
                    helper.Start();
                    helper.Wait(false);
                    helper.ChangeOutfit();
                    helper.Dispose();
                }
            }
        }
Example #12
0
        private static bool PrivateHasPoints(Sim sim, OccultTypes type, bool allowFailure)
        {
            if (!OccultTypeHelper.HasType(sim, type))
            {
                return(false);
            }

            switch (type)
            {
            case OccultTypes.Genie:
                OccultGenie genie = sim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                if (genie != null)
                {
                    return(genie.MagicPoints.HasPoints());
                }
                break;

            case OccultTypes.Fairy:
                return(!sim.BuffManager.HasElement(BuffNames.FairyAuraFailure));

            case OccultTypes.Witch:
                if (allowFailure)
                {
                    return(true);
                }

                return(!sim.BuffManager.HasElement(BuffNames.DepletedMagic));

            case OccultTypes.Unicorn:
                OccultUnicorn unicorn = sim.OccultManager.GetOccultType(OccultTypes.Unicorn) as OccultUnicorn;
                if (unicorn != null)
                {
                    return(unicorn.MagicPoints.HasPoints());
                }
                break;
            }

            return(false);
        }
Example #13
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!OccultTypeHelper.HasType(a, OccultTypes.Genie))
                {
                    return(false);
                }

                if (target.LotHome != null)
                {
                    if (Households.All(target.Household).Count <= 1)
                    {
                        return(false);
                    }
                }

                OccultGenie occultType = a.SimDescription.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;

                if (target.SimDescription.IsBonehilda)
                {
                    return(false);
                }

                if (((target.Service != null) && (target.Service.ServiceType == ServiceType.GrimReaper)) || (target.Household == a.Household))
                {
                    return(false);
                }

                if (DaycareSituation.IsInDaycareSituationWith(target, a))
                {
                    return(false);
                }

                if ((target.BuffManager.HasElement(BuffNames.WeddingDay) || target.IsEngaged) || target.SimDescription.IsPregnant)
                {
                    return(false);
                }

                if (GameUtils.IsOnVacation())
                {
                    return(false);
                }

                if (((isAutonomous || (occultType == null)) || (target.OccultManager.HasOccultType(OccultTypes.Genie) || target.BuffManager.HasElement(BuffNames.Ensorcelled))) || !a.SimDescription.ChildOrAbove)
                {
                    return(false);
                }

                if (!occultType.MagicPoints.HasPoints())
                {
                    greyedOutTooltipCallback = delegate
                    {
                        return(Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/GenieOutOfPoints:OutOfPoints", new object[] { a }));
                    };
                    return(false);
                }

                /*
                 * if (!a.Household.CanAddSpeciesToHousehold(CASAgeGenderFlags.Human))
                 * {
                 *  greyedOutTooltipCallback = delegate
                 *  {
                 *      return Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:HouseholdFull", new object[] { a });
                 *  };
                 *  return false;
                 * }
                 *
                 * if (!a.Household.CanAddSpeciesToHousehold(target.SimDescription.Species, 0x1, true))
                 * {
                 *  greyedOutTooltipCallback = delegate {
                 *      return Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a });
                 *  };
                 *  return false;
                 * }
                 */
                if (target.SimDescription.ToddlerOrBelow)
                {
                    return(false);
                }

                if (target.Household.IsServiceNpcHousehold && (target.SimDescription.CreatedByService != null))
                {
                    greyedOutTooltipCallback = delegate
                    {
                        return(Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a }));
                    };
                    return(false);
                }

                if (target.SimDescription.IsDead || ((target.SimDescription.Service != null) && (target.SimDescription.Service.ServiceType == ServiceType.GrimReaper)))
                {
                    greyedOutTooltipCallback = delegate {
                        return(Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a }));
                    };
                    return(false);
                }

                /*
                 * if (target.SimDescription.AssignedRole != null)
                 * {
                 *  RoleData data = target.SimDescription.AssignedRole.Data;
                 *  if ((data != null) && !data.CanBeEnsorceled)
                 *  {
                 *      greyedOutTooltipCallback = delegate
                 *      {
                 *          return Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a });
                 *      };
                 *      return false;
                 *  }
                 * }
                 */
                return(true);
            }
Example #14
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);
            }
        }
Example #15
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);
        }
Example #16
0
        public static bool Remove(SimDescription sim, OccultTypes type, bool alterOutfit)
        {
            if (sim.OccultManager == null)
            {
                return(false);
            }

            if (sim.CreatedSim != null)
            {
                try
                {
                    if (sim.CreatedSim.CurrentOutfitCategory == OutfitCategories.Special)
                    {
                        sim.CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday);
                    }
                }
                catch
                { }
            }

            OccultVampire vampire = sim.OccultManager.GetOccultType(type) as OccultVampire;

            if (vampire != null)
            {
                if ((vampire.mOwningSim == null) || (vampire.mOwningSim.MapTagManager == null))
                {
                    vampire.mPreyMapTag = null;
                }
            }

            if (sim.GetOutfitCount(OutfitCategories.Everyday) == 1)
            {
                SimOutfit outfit = sim.GetOutfit(OutfitCategories.Everyday, 0);

                using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(OutfitCategories.Everyday, 1), outfit))
                { }
            }

            if (type == OccultTypes.Unicorn)
            {
                OccultUnicornEx.OnRemoval(sim);
            }

            bool success = false;

            OccultManager occultManager = sim.OccultManager;

            try
            {
                if (occultManager.HasOccultType(type))
                {
                    occultManager.mCurrentOccultTypes ^= type;
                    foreach (OccultBaseClass occultClass in occultManager.mOccultList)
                    {
                        if (type == occultClass.ClassOccultType)
                        {
                            if ((occultManager.mOwnerDescription.SupernaturalData != null) && (occultManager.mOwnerDescription.SupernaturalData.OccultType == type))
                            {
                                occultManager.mOwnerDescription.RemoveSupernaturalData();
                            }

                            OccultGenie genie = occultClass as OccultGenie;
                            if (genie != null)
                            {
                                OccultGenieEx.OnRemoval(genie, occultManager.mOwnerDescription, alterOutfit);
                            }
                            else
                            {
                                OccultPlantSim plantSim = occultClass as OccultPlantSim;
                                if (plantSim != null)
                                {
                                    OccultPlantSimEx.OnRemoval(plantSim, occultManager.mOwnerDescription, alterOutfit);
                                }
                                else
                                {
                                    occultClass.OnRemoval(occultManager.mOwnerDescription);
                                }
                            }

                            occultManager.mOccultList.Remove(occultClass);
                            occultManager.mIsLifetimeReward = false;
                            if (occultManager.mOccultList.Count == 0x0)
                            {
                                occultManager.mOccultList = null;
                            }
                            break;
                        }
                    }

                    (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();

                    occultManager.UpdateOccultUI();

                    EventTracker.SendEvent(EventTypeId.kLostOccult, occultManager.mOwnerDescription.CreatedSim);
                }

                //occultManager.RemoveOccultType(type);
                success = true;
            }
            catch (Exception e)
            {
                bool showError = true;
                switch (type)
                {
                case OccultTypes.Genie:
                case OccultTypes.ImaginaryFriend:
                    if (sim.CreatedSim == null)
                    {
                        showError = false;
                    }
                    break;
                }

                if (showError)
                {
                    Common.Exception(sim, e);
                }
            }

            if (!success)
            {
                for (int i = occultManager.mOccultList.Count - 1; i >= 0; i--)
                {
                    if (type == occultManager.mOccultList[i].ClassOccultType)
                    {
                        occultManager.mOccultList.RemoveAt(i);
                    }

                    (Sims3.UI.Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();
                    sim.OccultManager.UpdateOccultUI();
                }
            }

            TraitNames trait = TraitFromOccult(type);

            if (trait != TraitNames.Unknown)
            {
                sim.TraitManager.RemoveElement(trait);
            }

            return(success);
        }
Example #17
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;
        }
Example #18
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{
            }
        }
Example #19
0
        public override bool Run()
        {
            try
            {
                if (!Actor.Inventory.Contains(Target))
                {
                    if (!Actor.RouteToObjectRadiusAndCheckInUse(Target, 0.7f))
                    {
                        return(false);
                    }

                    StandardEntry();
                    BeginCommodityUpdates();
                    Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true);
                    if (!Actor.Inventory.TryToAdd(Target))
                    {
                        EndCommodityUpdates(false);
                        StandardExit();
                        return(false);
                    }
                }
                else
                {
                    StandardEntry();
                    BeginCommodityUpdates();
                }

                SocialJigTwoPerson person = GlobalFunctions.CreateObjectOutOfWorld(SocialJig.SocialJigMedatorNames.SocialJigTwoPerson.ToString()) as SocialJigTwoPerson;
                person.RegisterParticipants(Actor, null);
                Sim createdSim = null;
                try
                {
                    World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Actor.Position);
                    fglParams.BooleanConstraints |= FindGoodLocationBooleans.Routable;
                    if (GlobalFunctions.PlaceAtGoodLocation(person, fglParams, true))
                    {
                        Route r = Actor.CreateRoute();
                        r.PlanToSlot(person, person.GetSlotForActor(Actor, true));
                        r.DoRouteFail = true;
                        if (Actor.DoRoute(r))
                        {
                            bool paramValue = false;
                            mSummonGenieBroadcast = new ReactionBroadcaster(Actor, kSummonGenieBroadcastParams, SummonGenieBroadcastCallback);
                            Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.Gameplay.Gameflow.GameSpeed.Normal, Sims3.Gameplay.Gameflow.SetGameSpeedContext.Gameplay);
                            if (Target.mGenieDescription == null)
                            {
                                Target.mGenieDescription = OccultGenie.CreateGenie(Actor, Target);
                                createdSim = Target.mGenieDescription.CreatedSim;
                                EventTracker.SendEvent(EventTypeId.kCleanLamp, Actor, Target);
                                paramValue = true;
                            }
                            else
                            {
                                createdSim = Target.mGenieDescription.Instantiate(Vector3.OutOfWorld, false);
                                OccultGenie occultType          = null;
                                DateAndTime previousDateAndTime = SimClock.CurrentTime();
                                do
                                {
                                    SpeedTrap.Sleep(0xa);
                                    occultType = createdSim.OccultManager.GetOccultType(OccultTypes.None | OccultTypes.Genie) as OccultGenie;
                                }while ((occultType == null) && (SimClock.ElapsedTime(TimeUnit.Minutes, previousDateAndTime) < 120f));

                                if (occultType != null)
                                {
                                    occultType.SetGenieLampRelations(Actor, createdSim, Target);
                                }
                                else
                                {
                                    createdSim.Destroy();
                                    createdSim = null;
                                }
                            }

                            if (createdSim != null)
                            {
                                createdSim.FadeOut(false, false, 0f);
                                createdSim.GreetSimOnLot(Actor.LotCurrent);
                                createdSim.AddToWorld();
                                Slot slotForActor = person.GetSlotForActor(createdSim, false);
                                createdSim.SetPosition(person.GetSlotPosition(slotForActor));
                                createdSim.SetForward(person.GetForwardOfSlot(slotForActor));
                                IGameObject actor = GlobalFunctions.CreateObject("GenieLamp", ProductVersion.EP6, Vector3.OutOfWorld, 0x0, Vector3.UnitZ, null, null);
                                if (!actor.IsActorUsingMe(Actor))
                                {
                                    actor.AddToUseList(Actor);
                                }
                                EnterStateMachine("GenieLampSummon", "Enter", "x");
                                SetActor("lamp", actor);
                                SetParameter("isFirstTime", paramValue);
                                AnimateSim("Exit");
                                actor.Destroy();
                                createdSim.FadeIn();
                                VisualEffect effect = VisualEffect.Create("ep6GenieAppearSmoke_main");
                                effect.SetPosAndOrient(createdSim.Position, Vector3.UnitX, Vector3.UnitZ);
                                effect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);
                                OpportunityManager opportunityManager = Actor.OpportunityManager;
                                if ((opportunityManager != null) && opportunityManager.HasOpportunity(OpportunityNames.EP6_ReleaseGenie_SummonGenie))
                                {
                                    OccultGenie genie2 = createdSim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                                    if (genie2 == null)
                                    {
                                        createdSim.Destroy();
                                        createdSim = null;
                                    }
                                    else
                                    {
                                        OccultGenieEx.OnFreedFromLamp(genie2, Actor, createdSim, true);
                                        if (opportunityManager.GetLastOpportunity(OpportunityCategory.Special) == OpportunityNames.EP6_ReleaseGenie_SummonGenie)
                                        {
                                            opportunityManager.ClearLastOpportunity(OpportunityCategory.Special);
                                        }

                                        EventTracker.SendEvent(EventTypeId.kGrantedWishToFreeGenie, Actor, Target);
                                        if (Target.InInventory)
                                        {
                                            Actor.Inventory.RemoveByForce(Target);
                                            if (Target.IsOnHandTool)
                                            {
                                                Target.RemoveFromWorld();
                                            }
                                        }
                                        else
                                        {
                                            Target.RemoveFromWorld();
                                        }
                                        EnterStateMachine("FreeTheGenie", "Enter", "x");
                                        SetActor("x", createdSim);
                                        AnimateSim("Exit");
                                    }
                                }
                                else
                                {
                                    Target.mGenieSocializingEvent        = EventTracker.AddListener(EventTypeId.kSocialInteraction, OnSocialization);
                                    Target.CheckGenieReturnToLamp        = createdSim.AddAlarmRepeating(1f, TimeUnit.Minutes, Target.CheckGenieReturnToLampCallback, "Genie Check to return to lamp", AlarmType.AlwaysPersisted);
                                    Target.mTimeSinceLastSocialWithGenie = SimClock.CurrentTime();
                                }
                            }
                        }
                    }
                }
                finally
                {
                    person.Destroy();
                }

                EndCommodityUpdates(true);
                StandardExit(createdSim == null, createdSim == null);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }