Esempio n. 1
0
        public static List <OccultTypes> CreateList(OccultTypes types, bool onlyTransferable)
        {
            List <OccultTypes> results = new List <OccultTypes>();

            foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes)))
            {
                if (type == OccultTypes.None)
                {
                    continue;
                }

                if ((types & type) != type)
                {
                    continue;
                }

                if (onlyTransferable)
                {
                    if (!OccultManager.DoesOccultTransferToOffspring(type))
                    {
                        continue;
                    }
                }

                results.Add(type);
            }

            return(results);
        }
Esempio n. 2
0
        public static void SetupForInstantiatedSim(OccultManager ths)
        {
            if (ths == null)
            {
                return;
            }

            if (ths.mOccultList == null)
            {
                return;
            }

            foreach (OccultBaseClass occult in ths.mOccultList)
            {
                try
                {
                    // If the trait is missing, the special motives for Fairies is missing
                    ApplyTrait(ths.mOwnerDescription, occult.ClassOccultType);

                    occult.FixUpOccult(ths.mOwnerDescription);
                    occult.SetupInstantiatedSim(ths.mOwnerDescription.CreatedSim);
                }
                catch (Exception e)
                {
                    Common.Exception(ths.mOwnerDescription, null, "Occult: " + occult.GetType(), e);
                }
            }
        }
Esempio n. 3
0
        public static string GetLocalizedName(OccultTypes type)
        {
            switch (type)
            {
            case OccultTypes.Vampire:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Vampire));

            case OccultTypes.Mummy:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Mummy));

            case OccultTypes.Frankenstein:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Frankenstein));

            case OccultTypes.ImaginaryFriend:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.ImaginaryFriend));

            case OccultTypes.Unicorn:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Unicorn));

            case OccultTypes.Genie:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Genie));

            case OccultTypes.Werewolf:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Werewolf));

            case OccultTypes.Fairy:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Fairy));

            case OccultTypes.Witch:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Witch));

            case OccultTypes.Ghost:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Ghost));

            case OccultTypes.Mermaid:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Mermaid));

            case OccultTypes.PlantSim:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.PlantSim));

            case OccultTypes.TimeTraveler:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.TimeTraveler));

            case OccultTypes.Robot:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Robot));

            default:
                return(Common.Localize("OccultTypes:None"));
            }
        }
Esempio n. 4
0
        public static void MergeOccults(OccultManager ths, OccultManager source)
        {
            Common.StringBuilder msg = new Common.StringBuilder("MergeOccults " + ths.mOwnerDescription.FullName + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

            foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes)))
            {
                try
                {
                    switch (type)
                    {
                        case OccultTypes.None:
                        case OccultTypes.Ghost:
                            break;

                        default:
                            if ((source.HasOccultType(type)) && (!ths.HasOccultType(type)))
                            {
                                msg += Common.NewLine + "A " + type;
                                Traveler.InsanityWriteLog(msg);

                                ths.MergeOccult(type);
                            }

                            if ((!source.HasOccultType(type)) && (ths.HasOccultType(type)))
                            {
                                msg += Common.NewLine + "B " + type;
                                Traveler.InsanityWriteLog(msg);

                                OccultTypeHelper.Remove(ths.mOwnerDescription, type, false);
                            }
                            break;
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(ths.mOwnerDescription, null, "Type: " + type, e);
                }
            }
        }
Esempio n. 5
0
        public static string GetMotiveLocalizedName(CommodityKind kind)
        {
            switch (kind)
            {
            case CommodityKind.Hunger:
            case CommodityKind.Energy:
            case CommodityKind.Hygiene:
            case CommodityKind.Fun:
            case CommodityKind.Social:
            case CommodityKind.Bladder:
            case CommodityKind.AlienBrainPower:
                return(Common.LocalizeEAString("Ui/Caption/HUD/MotivesPanel:Motive" + kind));

            case CommodityKind.DogDestruction:
                return(Common.LocalizeEAString("Ui/Caption/HUD/MotivesPanel:MotiveDestructionDog"));

            case CommodityKind.CatScratch:
                return(Common.LocalizeEAString("Ui/Caption/HUD/MotivesPanel:MotiveScratchCat"));

            case CommodityKind.HorseThirst:
                return(Common.Localize("Species:Horse") + " " + Common.LocalizeEAString("Ui/Caption/HUD/MotivesPanel:MotiveThirstHorse"));

            case CommodityKind.HorseExercise:
                return(Common.LocalizeEAString("Ui/Caption/HUD/MotivesPanel:MotiveExerciseHorse"));

            case CommodityKind.VampireThirst:
                return(OccultManager.GetSingularOccultName(OccultTypesAll.Vampire) + " " + Common.LocalizeEAString("Ui/Caption/HUD/MotivesPanel:MotiveHungerVampire"));
            }

            string result;

            if (Common.Localize("Commodity:" + kind.ToString(), false, new object[0], out result))
            {
                return(result);
            }
            else
            {
                return(kind.ToString());
            }
        }
Esempio n. 6
0
        public static void MergeOccults(OccultManager ths, OccultManager source)
        {
            Common.StringBuilder msg = new Common.StringBuilder("MergeOccults " + ths.mOwnerDescription.FullName + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

            foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes)))
            {
                try
                {
                    switch (type)
                    {
                    case OccultTypes.None:
                    case OccultTypes.Ghost:
                        break;

                    default:
                        if ((source.HasOccultType(type)) && (!ths.HasOccultType(type)))
                        {
                            msg += Common.NewLine + "A " + type;
                            Traveler.InsanityWriteLog(msg);

                            ths.MergeOccult(type);
                        }

                        if ((!source.HasOccultType(type)) && (ths.HasOccultType(type)))
                        {
                            msg += Common.NewLine + "B " + type;
                            Traveler.InsanityWriteLog(msg);

                            OccultTypeHelper.Remove(ths.mOwnerDescription, type, false);
                        }
                        break;
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(ths.mOwnerDescription, null, "Type: " + type, e);
                }
            }
        }
Esempio n. 7
0
        public static bool IsValidOccult(SimDescription sim, List <OccultTypes> types)
        {
            if (sim == null)
            {
                return(false);
            }

            OccultManager manager = sim.OccultManager;

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

            foreach (OccultTypes type in types)
            {
                if (manager.HasOccultType(type))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 8
0
        protected List <Sim> GeneratePetChildren(SimDescription woman, SimDescription man, int numChildren)
        {
            Random pregoRandom = new Random();

            float[] chanceOfTwin = new float[] { 1f, PetPregnancy.kChanceEggSizeTwo, PetPregnancy.kChanceEggSizeThree, PetPregnancy.kChanceEggSizeFour };

            int index = 0;

            SimDescription eggLead = null;

            GeneticsPet.SetName nameSet = GeneticsPet.SetName.SetNameNonInteractive;
            if (woman.IsHorse)
            {
                nameSet = GeneticsPet.SetName.SetNameInteractive;
            }

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

            for (int i = 0; i < numChildren; i++)
            {
                try
                {
                    OccultTypes occult = RandomUtil.CoinFlip() ? woman.OccultManager.CurrentOccultTypes : man.OccultManager.CurrentOccultTypes;
                    if (!OccultManager.DoesOccultTransferToOffspring(occult))
                    {
                        occult = OccultTypes.None;
                    }

                    SimDescription newBaby = null;
                    if (pregoRandom.NextDouble() > chanceOfTwin[index])
                    {
                        index = 0x0;
                    }

                    if ((index == 0x0) || (woman.IsHorse))
                    {
                        CASAgeGenderFlags species = woman.Species;
                        if ((man != null) && (pregoRandom.NextDouble() > 0.5))
                        {
                            species = man.Species;
                        }

                        newBaby = GeneticsPet.MakePetDescendant(man, woman, CASAgeGenderFlags.Child, NRaas.MasterControllerSpace.Helpers.Baby.InterpretGender(mGender), species, pregoRandom, true, nameSet, i, occult);
                        if (newBaby != null)
                        {
                            if (RandomUtil.CoinFlip())
                            {
                                newBaby.SetDeathStyle(woman.DeathStyle, true);
                            }
                            else
                            {
                                newBaby.SetDeathStyle(man.DeathStyle, true);
                            }
                        }
                    }
                    else
                    {
                        newBaby = GeneticsPet.MakeSameEggDescendant(eggLead, man, woman, NRaas.MasterControllerSpace.Helpers.Baby.InterpretGender(mGender), pregoRandom, true, nameSet, i);
                        if (newBaby != null)
                        {
                            newBaby.SetDeathStyle(eggLead.DeathStyle, true);
                        }
                    }

                    eggLead = newBaby;

                    index++;
                    if (index >= chanceOfTwin.Length)
                    {
                        index = chanceOfTwin.Length - 1;
                    }

                    if (newBaby == null)
                    {
                        continue;
                    }

                    newBaby.WasCasCreated = false;

                    woman.Household.Add(newBaby);

                    Vector3 position = woman.CreatedSim.Position;

                    Sim babyToHide = Instantiation.Perform(newBaby, position, null, null);

                    babies.Add(babyToHide);

                    if (newBaby.DeathStyle != SimDescription.DeathType.None)
                    {
                        Urnstone.SimToPlayableGhost(babyToHide);
                    }

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

                    if (woman.CreatedSim != null)
                    {
                        EventTracker.SendEvent(EventTypeId.kNewOffspringPet, woman.CreatedSim, babyToHide);
                    }

                    if (man.CreatedSim != null)
                    {
                        EventTracker.SendEvent(EventTypeId.kNewOffspringPet, man.CreatedSim, babyToHide);
                    }

                    foreach (Sim sim in CommonSpace.Helpers.Households.AllHumans(woman.Household))
                    {
                        EventTracker.SendEvent(EventTypeId.kNewPet, sim, babyToHide);
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(woman, man, e);
                }
            }

            return(babies);
        }
Esempio n. 9
0
        public static SimDescription MakeDescendant(SimDescription dad, SimDescription mom, SimDescription robotDad, SimDescription robotMom,
                                                    CASAgeGenderFlags age, CASAgeGenderFlags gender, float averageMood, Random pregoRandom, bool interactive, bool updateGenealogy,
                                                    bool setName, WorldName homeWorld, bool plantSimBaby, Pregnancy.BabyCustomizeData customizeData)
        {
            if (robotDad == null && robotMom == null)
            {
                Common.DebugNotify("CommonSurrogatePregnancy.MakeDescendant" + Common.NewLine + " - Fail: Robot Parnets Null");
                return(null);
            }

            SimBuilder simBuilder = new SimBuilder();

            simBuilder.Age            = age;
            simBuilder.Gender         = gender;
            simBuilder.Species        = CASAgeGenderFlags.Human;
            simBuilder.TextureSize    = 1024u;
            simBuilder.UseCompression = true;
            List <SimDescription> list = new List <SimDescription>();

            if (mom != null)
            {
                list.Add(mom);
            }

            if (dad != null)
            {
                list.Add(dad);
            }

            float alienDNAPercentage = SimDescription.GetAlienDNAPercentage(dad, mom, true);

            SimDescription[] array = list.ToArray();
            bool             flag  = alienDNAPercentage >= SimDescription.kMinAlienDNAPercentToBeAlien;

            if (plantSimBaby)
            {
                float skinToneIndex = OccultPlantSim.kBaseGreenSkinIndex + RandomUtil.GetFloat(1f - OccultPlantSim.kBaseGreenSkinIndex);
                simBuilder.SkinTone      = new ResourceKey(2751605866008866797uL, 55867754u, 0u);
                simBuilder.SkinToneIndex = skinToneIndex;
            }
            else
            {
                Genetics.InheritSkinColor(simBuilder, array, pregoRandom, homeWorld);
            }

            if (customizeData.IsBabyCustomized)
            {
                CASPart mPart = customizeData.EyeColorPreset.mPart;

                if (simBuilder.AddPart(mPart))
                {
                    string mPresetString = customizeData.EyeColorPreset.mPresetString;

                    if (!string.IsNullOrEmpty(mPresetString))
                    {
                        OutfitUtils.ApplyPresetStringToPart(simBuilder, mPart, mPresetString);
                    }
                }
            }
            else
            {
                Genetics.InheritEyeColor(simBuilder, array, pregoRandom);
            }

            Genetics.InheritFacialBlends(simBuilder, array, pregoRandom);
            ResourceKey geneticHairstyleKey = Genetics.InheritHairStyle(gender, dad, mom, pregoRandom, flag);

            Genetics.InheritBodyShape(simBuilder, array, pregoRandom);
            bool  flag2 = pregoRandom.Next(0, 2) == 0;
            float num   = (float)pregoRandom.NextDouble() * 100f;

            Color[] array2;

            if (customizeData.IsBabyCustomized)
            {
                array2 = new Color[10];

                for (int i = 0; i < 4; i++)
                {
                    array2[i]     = customizeData.HairColor[i];
                    array2[i + 5] = customizeData.HairColor[i];
                }

                array2[4] = customizeData.HairColor[0];
                array2[9] = customizeData.HairColor[0];
            }
            else if (age == CASAgeGenderFlags.Elder)
            {
                array2 = Genetics.GetRandomElderHairColor();
            }
            else
            {
                array2 = Genetics.InheritHairColor(simBuilder, array, pregoRandom);
            }

            SimDescription baby = Genetics.MakeSim(simBuilder, CASAgeGenderFlags.Baby, gender, simBuilder.SkinTone, simBuilder.SkinToneIndex, array2, homeWorld, 4294967295u, false);

            if (baby == null)
            {
                return(null);
            }

            baby.SetAlienDNAPercentage(alienDNAPercentage);
            baby.GeneticHairstyleKey = geneticHairstyleKey;
            bool flag3 = false;

            if (num < Genetics.kInheritMomHiddenBodyHairStyleChance)
            {
                flag3 |= Genetics.InheritBodyHairstyle(baby, mom);
            }

            if (!flag3 || num < Genetics.kInheritDadBodyHairStyleChance + Genetics.kInheritMomHiddenBodyHairStyleChance)
            {
                Genetics.InheritBodyHairstyle(baby, dad);
            }

            if (customizeData.IsBabyCustomized)
            {
                Genetics.TraitOutcome traitOutcome = Genetics.AssignTraits(baby, dad, mom, false, averageMood, pregoRandom);
                List <TraitNames>     list2        = new List <TraitNames>();
                List <Trait>          list3        = new List <Trait>();

                foreach (Trait current in baby.TraitManager.List)
                {
                    if (!current.IsVisible)
                    {
                        list3.Add(current);
                    }
                }

                baby.TraitManager.RemoveAllElements();

                if (customizeData.CurrentTraits != null)
                {
                    foreach (ITraitEntryInfo current2 in customizeData.CurrentTraits)
                    {
                        baby.TraitManager.AddElement((TraitNames)current2.TraitGuid);
                    }

                    if (customizeData.CurrentTraits.Count != 2)
                    {
                        baby.TraitManager.AddRandomTrait(2 - customizeData.CurrentTraits.Count);
                    }

                    foreach (Trait current3 in list3)
                    {
                        baby.TraitManager.AddHiddenElement((TraitNames)current3.TraitGuid);
                    }
                }

                foreach (Trait current4 in baby.TraitManager.List)
                {
                    if (current4.IsVisible)
                    {
                        list2.Add((TraitNames)current4.TraitGuid);
                    }
                }

                if (interactive)
                {
                    bool   isFemale   = baby.IsFemale;
                    string titleText  = Localization.LocalizeString(baby.IsFemale, "Gameplay/CAS/Genetics:MakeBabyTitle", new object[0]);
                    string promptText = null;

                    switch (traitOutcome)
                    {
                    case Genetics.TraitOutcome.Horrible:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescTwoTraitsHorrible";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                                baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale),
                                baby.TraitManager.GetElement((ulong)list2[1]).TraitName(baby.IsFemale)
                            });
                        break;
                    }

                    case Genetics.TraitOutcome.Bad:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescTwoTraitsBad";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                                baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale),
                                baby.TraitManager.GetElement((ulong)list2[1]).TraitName(baby.IsFemale)
                            });
                        break;
                    }

                    case Genetics.TraitOutcome.Average:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescTwoTraits";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                                baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale),
                                baby.TraitManager.GetElement((ulong)list2[1]).TraitName(baby.IsFemale)
                            });
                        break;
                    }

                    case Genetics.TraitOutcome.Good:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescOneTraits";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                                baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale)
                            });
                        break;
                    }

                    case Genetics.TraitOutcome.Excellent:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDesc";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                            });
                        break;
                    }
                    }

                    while (string.IsNullOrEmpty(baby.FirstName))
                    {
                        baby.FirstName = StringInputDialog.Show(titleText, promptText, "", CASBasics.GetMaxNameLength(), StringInputDialog.Validation.SimNameText);
                    }
                }
            }
            else
            {
                Genetics.AssignTraits(baby, dad, mom, interactive, averageMood, pregoRandom);
            }

            if (setName)
            {
                baby.LastName = array[0].LastName;

                if (!interactive)
                {
                    baby.FirstName = SimUtils.GetRandomGivenName(baby.IsMale, homeWorld);
                }
            }

            baby.CelebrityManager.SetBabyLevel(Genetics.AssignBabyCelebrityLevel(dad, mom));

            if (updateGenealogy)
            {
                if (robotDad != null && robotMom == null)
                {
                    if (robotDad.Genealogy != null)
                    {
                        robotDad.Genealogy.AddChild(baby.Genealogy);
                    }

                    if (mom != null && mom.Genealogy != null)
                    {
                        mom.Genealogy.AddChild(baby.Genealogy);
                    }
                }
                else if (robotMom != null && robotDad == null)
                {
                    if (robotMom.Genealogy != null)
                    {
                        robotMom.Genealogy.AddChild(baby.Genealogy);
                    }

                    if (dad != null && dad.Genealogy != null)
                    {
                        dad.Genealogy.AddChild(baby.Genealogy);
                    }
                }
                else
                {
                    if (robotDad.Genealogy != null)
                    {
                        robotDad.Genealogy.AddChild(baby.Genealogy);
                    }

                    if (robotMom.Genealogy != null)
                    {
                        robotMom.Genealogy.AddChild(baby.Genealogy);
                    }
                }
            }

            OccultTypes occultTypes = OccultTypes.None;

            if (flag2)
            {
                if (mom != null)
                {
                    CASSupernaturalData supernaturalData = mom.SupernaturalData;

                    if (supernaturalData != null)
                    {
                        occultTypes = supernaturalData.OccultType;
                    }
                }
            }
            else if (dad != null)
            {
                CASSupernaturalData supernaturalData2 = dad.SupernaturalData;

                if (supernaturalData2 != null)
                {
                    occultTypes = supernaturalData2.OccultType;
                }
            }

            if (plantSimBaby)
            {
                occultTypes = OccultTypes.PlantSim;
            }

            if (!OccultManager.DoesOccultTransferToOffspring(occultTypes))
            {
                occultTypes = OccultTypes.None;
            }

            if (RandomUtil.CoinFlip())
            {
                if (occultTypes == OccultTypes.Fairy)
                {
                    baby.AddSupernaturalData(OccultTypes.Fairy);
                    CASFairyData fairyData = baby.SupernaturalData as CASFairyData;

                    if (fairyData != null)
                    {
                        Vector3   wingColor;
                        WingTypes wingType;
                        Genetics.InheritWings(baby, mom, dad, pregoRandom, out wingColor, out wingType);
                        fairyData.WingType  = wingType;
                        fairyData.WingColor = wingColor;
                    }
                }

                if (occultTypes != OccultTypes.None)
                {
                    baby.OccultManager.AddOccultType(occultTypes, false, false, false);
                }
            }

            return(baby);
        }
Esempio n. 10
0
        public override void Startup()
        {
            Common.StringBuilder msg = new Common.StringBuilder("LiveModeStateEx:Startup" + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

            try
            {
                UIManager.BlackBackground(false);

                msg += "A1";
                Traveler.InsanityWriteLog(msg);

                // StateMachineState:Startup()
                mBaseCallFlag |= BaseCallFlag.kStartup;

                // InWorldSubState:Startup()
                while (sDelayNextStateStartupCount > 0x0)
                {
                    SpeedTrap.Sleep();
                }

                msg += "A2";
                Traveler.InsanityWriteLog(msg);

                EventTracker.SendEvent(new InWorldSubStateEvent(this, true));

                //base.Startup();

                msg += "A3";
                Traveler.InsanityWriteLog(msg);

                ShowUI(true);

                if (CameraController.IsMapViewModeEnabled() && !TutorialModel.Singleton.IsTutorialRunning())
                {
                    CameraController.EnableCameraMapView(true);
                }

                msg += "B";
                Traveler.InsanityWriteLog(msg);

                CASExitLoadScreen.Close();

                bool traveling = false;
                if (GameStates.IsTravelling)
                {
                    if (GameStates.sTravelData == null)
                    {
                        GameStates.ClearTravelStatics();
                    }
                    else
                    {
                        traveling = true;
                        GameStatesEx.OnArrivalAtVacationWorld();
                    }
                }

                msg += "C";
                Traveler.InsanityWriteLog(msg);

                if (GameStates.sNextSimToSelect != null)
                {
                    DreamCatcher.SelectNoLotCheckImmediate(GameStates.sNextSimToSelect, true, true);
                    GameStates.sNextSimToSelect = null;
                }

                msg += "D";
                Traveler.InsanityWriteLog(msg);

                bool flag2 = false;
                if (LoadingScreenController.Instance != null)
                {
                    if ((GameStates.IsPerfTestRunning || (CommandLine.FindSwitch("campos") != null)) || (CommandLine.FindSwitch("camtarget") != null))
                    {
                        msg += "D1";
                        Traveler.InsanityWriteLog(msg);

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                    }
                    else if (traveling)
                    {
                        msg += "D2";
                        Traveler.InsanityWriteLog(msg);

                        uint customFlyThroughIndex = CameraController.GetCustomFlyThroughIndex();
                        if (GameStates.IsNewGame && (customFlyThroughIndex != 0x0))
                        {
                            msg += "D3";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, false);
                            ShowUI(false);
                            ShowMaptags(false);

                            msg += "D4";
                            Traveler.InsanityWriteLog(msg);

                            AudioManager.MusicMode = MusicMode.Flyby;
                            CameraController.OnCameraFlyThroughFinishedCallback += OnCameraFlyThroughFinishedEvent;
                            CameraController.StartFlyThrough(customFlyThroughIndex, false);
                            flag2 = true;

                            msg += "D5";
                            Traveler.InsanityWriteLog(msg);

                            GameUtils.EnableSceneDraw(true);
                            LoadingScreenController.Unload();
                            while (LoadingScreenController.Instance != null)
                            {
                                Sleep(0.0);
                            }
                        }
                        else
                        {
                            msg += "D6";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, true);
                            Camera.SetView(CameraView.SimView, true, true);
                        }
                    }
                    else
                    {
                        msg += "D7";
                        Traveler.InsanityWriteLog(msg);

                        Camera.RestorePersistedState();

                        msg += "D8";
                        Traveler.InsanityWriteLog(msg);

                        WaitForLotLoad(false, true);
                    }
                }
                else if (traveling)
                {
                    msg += "D9";
                    Traveler.InsanityWriteLog(msg);

                    WaitForLotLoad(!GameUtils.IsUniversityWorld(), true);
                    Camera.SetView(CameraView.SimView, true, true);
                }

                msg += "E";
                Traveler.InsanityWriteLog(msg);

                UserToolUtils.UserToolGeneric(0xc8, new ResourceKey(0x0L, 0x0, 0x0));
                if (!flag2)
                {
                    GameUtils.Unpause();
                }

                if (AudioManager.MusicMode != MusicMode.Flyby)
                {
                    AudioManager.MusicMode = MusicMode.None;
                }

                msg += "F";
                Traveler.InsanityWriteLog(msg);

                InWorldSubState.EdgeScrollCheck();
                InWorldSubState.OpportunityDialogCheck();

                try
                {
                    DreamsAndPromisesManager.ValidateLifetimeWishes();
                }
                catch (Exception e)
                {
                    Common.Exception(msg, e);
                }

                LifeEventManager.ValidatePendingLifeEvents();
                if (GameUtils.IsInstalled(ProductVersion.EP9))
                {
                    Tutorialette.TriggerLesson(Lessons.Degrees, Sim.ActiveActor);
                }

                if (GameUtils.GetCurrentWorldType() == WorldType.Base)
                {
                    Tutorialette.TriggerLesson(Lessons.Traveling, Sim.ActiveActor);
                }

                if (Sims3.Gameplay.ActiveCareer.ActiveCareer.ActiveCareerShowGeneralLesson)
                {
                    Tutorialette.TriggerLesson(Lessons.Professions, Sim.ActiveActor);
                }

                msg += "G";
                Traveler.InsanityWriteLog(msg);

                Tutorialette.TriggerLesson(Lessons.AgingStageLengths, Sim.ActiveActor);

                Sim selectedActor = PlumbBob.SelectedActor;
                if (selectedActor != null)
                {
                    // Custom
                    if (GameStates.sMovingWorldData != null)
                    {
                        WorldData.MergeFromCrossWorldData();
                    }

                    if (selectedActor.LotHome != null)
                    {
                        if (selectedActor.LotHome.HasVirtualResidentialSlots)
                        {
                            Tutorialette.TriggerLesson(Lessons.ApartmentLiving, selectedActor);
                        }
                    }
                    else
                    {
                        Lot lot = Helpers.TravelUtilEx.FindLot();
                        if (lot != null)
                        {
                            lot.MoveIn(selectedActor.Household);

                            foreach (SimDescription sim in Households.All(selectedActor.Household))
                            {
                                if (sim.CreatedSim == null)
                                {
                                    FixInvisibleTask.Perform(sim, false);
                                }
                                else
                                {
                                    bool replace = (sim.CreatedSim == selectedActor);

                                    ResetSimTask.Perform(sim.CreatedSim, false);

                                    if (replace)
                                    {
                                        selectedActor = sim.CreatedSim;
                                    }
                                }
                            }

                            msg += "MoveIn";
                        }
                    }

                    if (selectedActor.Household != null)
                    {
                        foreach (SimDescription description in Households.Humans(selectedActor.Household))
                        {
                            // Custom
                            if (GameStates.sMovingWorldData != null)
                            {
                                CrossWorldControl.Restore(description);
                            }

                            if (description.Child || description.Teen)
                            {
                                Tutorialette.TriggerLesson(Lessons.Pranks, null);
                                break;
                            }
                        }
                    }

                    if (selectedActor.BuffManager != null)
                    {
                        BuffMummysCurse.BuffInstanceMummysCurse element = selectedActor.BuffManager.GetElement(BuffNames.MummysCurse) as BuffMummysCurse.BuffInstanceMummysCurse;
                        if (element != null)
                        {
                            BuffMummysCurse.SetCursedScreenFX(element.CurseStage, false);
                        }
                    }

                    if (selectedActor.CareerManager != null)
                    {
                        selectedActor.CareerManager.UpdateCareerUI();
                    }

                    if (Traveler.Settings.mAllowSpawnWeatherStone && GameUtils.IsInstalled(ProductVersion.EP7) && GameUtils.IsInstalled(ProductVersion.EP8))
                    {
                        Sims3.Gameplay.UI.Responder.Instance.TrySpawnWeatherStone();
                    }
                }

                msg += "H";
                Traveler.InsanityWriteLog(msg);

                // Custom
                if (GameStates.sMovingWorldData != null)
                {
                    GameStatesEx.UpdateMiniSims(GameStatesEx.GetAllSims());

                    foreach (SimDescription sim in Households.All(Household.ActiveHousehold))
                    {
                        MiniSimDescription miniSim = MiniSimDescription.Find(sim.SimDescriptionId);
                        if (miniSim != null)
                        {
                            miniSim.Instantiated = true;
                            if (miniSim.HomeWorld != GameUtils.GetCurrentWorld())
                            {
                                miniSim.HomeWorld = GameUtils.GetCurrentWorld();
                            }
                        }

                        if (sim.HomeWorld != GameUtils.GetCurrentWorld())
                        {
                            sim.HomeWorld = GameUtils.GetCurrentWorld();
                        }
                    }
                }

                GameStates.SetupPostMoveData();
                GameStates.ClearMovingData();
                MovingWorldsWizardCheck();

                // Custom
                Household.IsTravelImport = false;

                InWorldSubStateEx.PlaceLotWizardCheck(this);

                msg += "I";
                Traveler.InsanityWriteLog(msg);

                foreach (Sim sim in LotManager.Actors)
                {
                    try
                    {
                        if (sim.HasBeenDestroyed)
                        {
                            continue;
                        }

                        OccultManager occultManager = sim.OccultManager;
                        if (occultManager != null)
                        {
                            occultManager.RestoreOccultIfNecessary();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, null, msg, e);
                    }
                }

                msg += "J";
                Traveler.InsanityWriteLog(msg);

                // Custom
                foreach (SimDescription description in SimListing.GetResidents(false).Values)
                {
                    if (description.LotHome == null)
                    {
                        continue;
                    }

                    MiniSimDescription miniSimDescription = description.GetMiniSimDescription();
                    if (miniSimDescription != null)
                    {
                        miniSimDescription.LotHomeId = description.LotHome.LotId;
                    }
                }

                msg += "K";
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
            finally
            {
                CASExitLoadScreen.Close();
            }
        }
Esempio n. 11
0
        public static void SetupForInstantiatedSim(OccultManager ths)
        {
            if (ths == null) return;

            if (ths.mOccultList == null) return;

            foreach (OccultBaseClass occult in ths.mOccultList)
            {
                try
                {
                    // If the trait is missing, the special motives for Fairies is missing
                    ApplyTrait(ths.mOwnerDescription, occult.ClassOccultType);

                    occult.FixUpOccult(ths.mOwnerDescription);
                    occult.SetupInstantiatedSim(ths.mOwnerDescription.CreatedSim);
                }
                catch (Exception e)
                {
                    Common.Exception(ths.mOwnerDescription, null, "Occult: " + occult.GetType(), e);
                }
            }
        }
Esempio n. 12
0
        public static void ValidateOccult(SimDescription sim, Logger log)
        {
            OccultManager manager = sim.OccultManager;
            if (manager == null)
            {
                manager = new OccultManager(sim);

                if (log != null)
                {
                    log(" Missing Occult Added: " + sim.FullName);
                }
            }

            if (manager.mOccultList == null)
            {
                manager.mOccultList = new List<OccultBaseClass>();

                if (log != null)
                {
                    log(" Missing OccultList Added: " + sim.FullName);
                }
            }

            List<OccultTypes> toAdd = new List<OccultTypes>();

            foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes)))
            {
                if (type == OccultTypes.None) continue;

                bool found = false;
                foreach (OccultBaseClass occult in manager.mOccultList)
                {
                    if (occult.ClassOccultType == type)
                    {
                        found = true;
                        break;
                    }
                }

                if ((manager.CurrentOccultTypes & type) == type)
                {
                    ApplyTrait(sim, type);

                    if (!found)
                    {
                        toAdd.Add(type);

                        manager.mCurrentOccultTypes &= ~type;
                    }
                }
                else
                {
                    if (found)
                    {
                        manager.mCurrentOccultTypes |= type;

                        if (log != null)
                        {
                            log(" Occult Restored A: " + type.ToString() + " (" + sim.FullName + ")");
                        }
                    }
                }
            }

            foreach (OccultTypes type in toAdd)
            {
                if (!Add(sim, type, false, false)) continue;

                if (log != null)
                {
                    log(" Occult Restored B: " + type.ToString() + " (" + sim.FullName + ")");
                }
            }
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }
Esempio n. 15
0
        public static void ValidateOccult(SimDescription sim, Logger log)
        {
            OccultManager manager = sim.OccultManager;

            if (manager == null)
            {
                manager = new OccultManager(sim);

                if (log != null)
                {
                    log(" Missing Occult Added: " + sim.FullName);
                }
            }

            if (manager.mOccultList == null)
            {
                manager.mOccultList = new List <OccultBaseClass>();

                if (log != null)
                {
                    log(" Missing OccultList Added: " + sim.FullName);
                }
            }

            List <OccultTypes> toAdd = new List <OccultTypes>();

            foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes)))
            {
                if (type == OccultTypes.None)
                {
                    continue;
                }

                bool found = false;
                foreach (OccultBaseClass occult in manager.mOccultList)
                {
                    if (occult.ClassOccultType == type)
                    {
                        found = true;
                        break;
                    }
                }

                if ((manager.CurrentOccultTypes & type) == type)
                {
                    ApplyTrait(sim, type);

                    if (!found)
                    {
                        toAdd.Add(type);

                        manager.mCurrentOccultTypes &= ~type;
                    }
                }
                else
                {
                    if (found)
                    {
                        manager.mCurrentOccultTypes |= type;

                        if (log != null)
                        {
                            log(" Occult Restored A: " + type.ToString() + " (" + sim.FullName + ")");
                        }
                    }
                }
            }

            foreach (OccultTypes type in toAdd)
            {
                if (!Add(sim, type, false, false))
                {
                    continue;
                }

                if (log != null)
                {
                    log(" Occult Restored B: " + type.ToString() + " (" + sim.FullName + ")");
                }
            }
        }
Esempio n. 16
0
        public Sim _NInstantiate(Vector3 position, ResourceKey outfitKey, bool addInitialObjects, bool forceAlwaysAnimate)
        {
            if (runI)
            {
                return(null);
            }

            if (NiecHelperSituation.__acorewIsnstalled__)
            {
                if (!Instantiator.kDontCallDGSACore && NFinalizeDeath.RUNIACORE != null)
                {
                    NFinalizeDeath.RUNIACORE(false);
                }
                else
                {
                    NFinalizeDeath.CheckNHSP();
                }
            }

            if (CreatedSim != null)
            {
                return(CreatedSim);
            }

            if (AgingState != null)
            {
                bool isDefaultOutfit = outfitKey == mDefaultOutfitKey;
                AgingState.PreInstantiateSim(ref outfitKey);
                if (isDefaultOutfit)
                {
                    mDefaultOutfitKey = outfitKey;
                }
            }

            Hashtable hashtable = new Hashtable(forceAlwaysAnimate ? 4 : 2);

            hashtable["simOutfitKey"] = outfitKey;
            hashtable["rigKey"]       = CASUtils.GetRigKeyForAgeGenderSpecies(Age | Gender | Species);

            if (forceAlwaysAnimate)
            {
                hashtable["enableSimPoseProcessing"] = 1u;
                hashtable["animationRunsInRealtime"] = 1u;
            }

            string         instanceName = "GameSim";
            ProductVersion version      = ProductVersion.BaseGame;

            if (Species != CASAgeGenderFlags.Human)
            {
                instanceName = "Game" + Species;
                version      = ProductVersion.EP5;
            }

            bool shouldNullHousehold = false;

            if (Household == null)
            {
                mHousehold          = Household.NpcHousehold ?? Household.ActiveHousehold;
                shouldNullHousehold = true;
            }

            Sim sim = GlobalFunctions.CreateObjectWithOverrides(instanceName, version, position, 0, Vector3.UnitZ, hashtable, new SimInitParameters(this)) as Sim;

            if (sim != null)
            {
                sim.mSimDescription = this;
                this.mSim           = sim;

                if (sim.SimRoutingComponent != null)
                {
                    sim.SimRoutingComponent.EnableDynamicFootprint();
                    sim.SimRoutingComponent.ForceUpdateDynamicFootprint();
                }

                try
                {
                    if (sim.IsSelectable)
                    {
                        sim.AddInitialObjects(true);
                    }
                }
                catch (ResetException)
                { throw; }
                catch (Exception)
                { }

                PushAgingEnabledToAgingManager();

                if (OccultManager != null)
                {
                    OccultManager.SetupForInstantiatedSim();
                }

                if (GameUtils.IsFutureWorld())
                {
                    CauseEffectService.ApplyCauseAndEffectModsToSim(sim);
                }
                if (IsAlien)
                {
                    World.ObjectSetVisualOverride(sim.ObjectId, eVisualOverrideTypes.Alien, null);
                }

                if (EventTracker.sInstance != null)
                {
                    EventTracker.SendEvent(EventTypeId.kSimInstantiated, null, sim);
                }

                MiniSimDescription miniSimDescription = MiniSimDescription.Find(SimDescriptionId);
                if (miniSimDescription != null && (GameStates.IsTravelling || mHomeWorld != GameUtils.GetCurrentWorld()))
                {
                    miniSimDescription.UpdateInWorldRelationships(this);
                }

                if (HealthManager != null)
                {
                    HealthManager.Startup();
                }

                if (Household.RoommateManager != null && Household.RoommateManager.IsNPCRoommate(SimDescriptionId))
                {
                    Household.RoommateManager.AddRoommateInteractions(sim);
                }
            }

            if (OccultManager != null && SkinToneKey.InstanceId == 15475186560318337848uL && !OccultManager.HasOccultType(OccultTypes.Vampire) && !OccultManager.HasOccultType(OccultTypes.Werewolf) && !IsGhost)
            {
                World.ObjectSetVisualOverride(CreatedSim.ObjectId, eVisualOverrideTypes.Genie, null);
            }

            if (Household != null && Household.IsAlienHousehold)
            {
                (Sims3.UI.Responder.Instance.HudModel as HudModel).OnSimCurrentWorldChanged(true, this);
            }

            if (shouldNullHousehold && mHousehold == Household.NpcHousehold)
            {
                mHousehold = null;
            }

            sim.mSimDescription = this;
            this.mSim           = sim;

            return(sim);
        }
Esempio n. 17
0
        /*
         * DebugString: "_NFixUp(): if (ListCollon.NullSimSimDescription == this)"
         * DebugString: "NMScript Exception Log
         * System.Exception: no message
         *
         #0: 0x0001f throw      in Sims3.Gameplay.CAS.Sims3.Gameplay.CAS.SimDescription:Fixup () ()
         #1: 0x00050 callvirt   in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.RecoverMissingSims:PrivatePerformAction (bool) (9193E9C0 [0] )
         #2: 0x00011 callvirt   in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAction (bool) (9193E9C0 [0] )
         #3: 0x00002 call       in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAlarm () ()
         #4: 0x0001b callvirt   in NRaas.NRaas.Overwatch:OnTimer () ()
         #5: 0x00000            in Sims3.Gameplay.Sims3.Gameplay.Function:Invoke () ()
         #6: 0x00003 callvirt   in NRaas.Common+FunctionTask:Simulate () ()
         */
        public void _NFixUp()
        {
            if (runI)
            {
                return;
            }

            if (ListCollon.NullSimSimDescription == this)
            {
                if (niec_native_func.cache_done_niecmod_native_debug_text_to_debugger)
                {
                    niec_native_func.OutputDebugString("_NFixUp(): if (ListCollon.NullSimSimDescription == this)");
                    try
                    {
                        throw new Exception("no message");
                    }
                    catch (Exception ex)
                    {
                        NiecException.SendTextExceptionToDebugger(ex);
                    }
                }

                mIsValidDescription = false;
                NFinalizeDeath.SimDesc_NullToEmpty(this);
                mIsValidDescription = true;

                if (UnsafeFixNUllSimDESC)
                {
                    var p = NFinalizeDeath.GetSafeSelectActor();
                    if (p != null && p.SimDescription != null)
                    {
                        mOutfits = p.SimDescription.Outfits;
                    }
                    if (!waitrunningtask01)
                    {
                        waitrunningtask01 = true;
                        NiecTask.Perform(() =>
                        {
                            for (int i = 0; i < 800; i++)
                            {
                                Simulator.Sleep(0);
                            }
                            waitrunningtask01 = false;
                            NFinalizeDeath.SimDescCleanse(this, true, false);
                        });
                    }
                }
                else if (!waitrunningtask01)
                {
                    waitrunningtask01 = true;
                    NiecTask.Perform(() =>
                    {
                        for (int i = 0; i < 50; i++)
                        {
                            Simulator.Sleep(0);
                        }
                        waitrunningtask01 = false;
                        NFinalizeDeath.SimDescCleanse(this, true, true);
                    });
                }
                return;
            }

            mIsValidDescription = true;

            if (base.TraitManager != null)
            {
                base.TraitManager.SetSimDescription(this);
                base.TraitManager.Fixup();
            }

            if (CreatedSim != null && CreatedSim.Inventory != null)
            {
                foreach (TraitChip item in CreatedSim.Inventory.FindAll <TraitChip>(false))
                {
                    item.OnLoadFixup();
                    if (item.Owner == null)
                    {
                        item.SetOwner(this);
                    }
                }
            }

            MiniSimDescription miniSimDescription = MiniSimDescription.Find(SimDescriptionId);

            if ((GameStates.IsTravelling || GameStates.IsEditingOtherTown) && miniSimDescription != null)
            {
                base.CASGenealogy = miniSimDescription.Genealogy;
            }

            if (GameObjectRelationships != null)
            {
                int i = 0;
                while (i < GameObjectRelationships.Count)
                {
                    if (!Sims3.SimIFace.Objects.IsValid(GameObjectRelationships[i].GameObjectDescription.GameObject.ObjectId))
                    {
                        GameObjectRelationships.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            if (mGenealogy == null)
            {
                mGenealogy = new Genealogy(this);
            }

            if (SkillManager == null)
            {
                SkillManager = new SkillManager(this);
            }
            else
            {
                SkillManager.OnLoadFixup();
            }

            if (CareerManager == null)
            {
                CareerManager = new CareerManager(this);
            }
            else
            {
                CareerManager.OnLoadFixup();
            }

            if (VisaManager == null)
            {
                VisaManager = new VisaManager(this);
            }
            else
            {
                VisaManager.OnLoadFixup();
            }

            if (CelebrityManager == null)
            {
                CelebrityManager = new CelebrityManager(SimDescriptionId);
            }
            else if (CelebrityManager.Owner == null)
            {
                CelebrityManager.ResetOwnerSimDescription(SimDescriptionId);
            }

            if (LifeEventManager == null || !LifeEventManager.IsValid)
            {
                LifeEventManager = new LifeEventManager(this);
            }

            LifeEventManager.ClearInvalidActiveNodes();

            if (OccultManager == null)
            {
                OccultManager = new OccultManager(this);
            }
            else
            {
                OccultManager.OnLoadFixup();
            }

            if (IsPet)
            {
                if (PetManager == null)
                {
                    PetManager = CreatePetManager();
                }
            }
            else if (PetManager != null)
            {
                PetManager.Dispose();
                PetManager = null;
            }

            if (IsEP11Bot)
            {
                if (TraitChipManager == null)
                {
                    TraitChipManager = new TraitChipManager(this);
                }
                else if (TraitChipManager.Owner == null)
                {
                    TraitChipManager.ResetOwnerSimDescription(SimDescriptionId);
                }
                TraitChipManager.OnLoadFixup();
            }
            else if (TraitChipManager != null)
            {
                TraitChipManager.Dispose();
                TraitChipManager = null;
            }

            AssignSchool();

            if (mSimDescriptionId == 0)
            {
                MakeUniqueId();
            }

            if (ReadBookDataList == null)
            {
                ReadBookDataList = new Dictionary <string, ReadBookData>();
            }

            PushAgingEnabledToAgingManager();

            if (mInitialShape.Owner == null || mCurrentShape.Owner == null || mInitialShape.Owner != this || mCurrentShape.Owner != this)
            {
                mInitialShape.Owner = (mCurrentShape.Owner = this);
            }

            if (OpportunityHistory == null)
            {
                OpportunityHistory = new OpportunityHistory();
            }

            if (Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile && !Household.IsTravelImport && !GameStates.IsIdTravelling(SimDescriptionId))
            {
                mDisplayedShape.Owner    = mCurrentShape.Owner;
                mDisplayedShape.Fit      = mCurrentShape.Fit;
                mDisplayedShape.Weight   = mCurrentShape.Weight;
                mDisplayedShape.Pregnant = mCurrentShape.Pregnant;
                ResetLifetimeHappinessStatistics();
                mHomeWorld = GameUtils.GetCurrentWorld();
            }

            if (mHomeWorld == WorldName.Undefined)
            {
                mHomeWorld = GameUtils.GetCurrentWorld();
            }

            if (RelicStats == null)
            {
                RelicStats = new RelicStatTracking(this);
            }

            RelicStats.SetSimDescription(this);

            if (TombStats == null)
            {
                TombStats = new TombStatTracking(this);
            }

            TombStats.SetSimDescription(this);

            if (Singing == null)
            {
                Singing = new SingingInfo(this);
            }

            Singing.SetSimDesctiption(this);

            if (AssignedRole != null)
            {
                AssignedRole.OnLoadFixUp();
            }

            Lot lot = LotManager.GetLot(mVirtualLotId);

            if (lot != null)
            {
                lot.VirtualMoveIn(this);
            }

            if (Species == CASAgeGenderFlags.None)
            {
                Species = CASAgeGenderFlags.Human;
            }

            if (!CASLogic.GetSingleton().IsMusicTypeInstalled(FavoriteMusic))
            {
                RandomizeFavoriteMusic();
            }

            if (GetCurrentOutfits() != null)
            {
                OutfitCategories[] array = new OutfitCategories[5]
                {
                    OutfitCategories.None,
                    OutfitCategories.All,
                    OutfitCategories.CategoryMask,
                    OutfitCategories.PrimaryCategories,
                    OutfitCategories.PrimaryHorseCategories
                };

                foreach (var outfitCategories in array)
                {
                    if (GetOutfitCount(outfitCategories) > 0)
                    {
                        RemoveOutfits(outfitCategories, false);
                        if (base.mMaternityOutfits != null)
                        {
                            base.mMaternityOutfits.Remove(outfitCategories);
                        }
                        if (base.mOutfits != null)
                        {
                            base.mOutfits.Remove(outfitCategories);
                        }
                    }
                }
            }

            if (!GameUtils.IsInstalled(ProductVersion.EP4))
            {
                Sim.PlayPretend.RemoveAllChildCostumeOutfits(this);

                if (CreatedSim != null && CreatedSim.CurrentOutfitCategory == OutfitCategories.ChildImagination)
                {
                    CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday);
                }

                RemoveOutfits(OutfitCategories.ChildImagination, true);

                base.Outfits.Remove(OutfitCategories.ChildImagination);

                if (SpoiledGiftHistory != null)
                {
                    SpoiledGiftHistory.Clear();
                    SpoiledGiftHistory = null;
                }
            }

            if (CreatedSim != null && (OccultManager == null || !OccultManager.HasOccultType(OccultTypes.Vampire | OccultTypes.Genie | OccultTypes.Werewolf | OccultTypes.Ghost)) && mSkinToneKey.InstanceId == 15475186560318337848uL)
            {
                World.ObjectSetVisualOverride(CreatedSim.ObjectId, eVisualOverrideTypes.Genie, null);
            }
        }
Esempio n. 18
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;
        }