Exemple #1
0
        protected void PrivateAddBandMember(RockBand ths, SimDescription otherSimDesc)
        {
            if (ths.mBandInfo == null)
            {
                ths.mBandInfo = new RockBandInfo();
                ths.mBandInfo.AddBandMember(ths.SkillOwner.SimDescriptionId);
                Sim createdSim = ths.SkillOwner.CreatedSim;
                if (createdSim != null)
                {
                    ActiveTopic.AddToSim(createdSim, "Rock Band");
                }
            }

            //if (ths.mBandInfo.NumBandMembers < 0x4)
            {
                ths.mBandInfo.AddBandMember(otherSimDesc.SimDescriptionId);
                Sim sim = otherSimDesc.CreatedSim;
                if (sim != null)
                {
                    ActiveTopic.AddToSim(sim, "Rock Band");
                }

                SkillManager skillManager = otherSimDesc.SkillManager;
                RockBand skill = skillManager.GetSkill<RockBand>(SkillNames.RockBand);
                if (skill == null)
                {
                    skillManager.AddAutomaticSkill(SkillNames.RockBand);
                    skill = skillManager.GetSkill<RockBand>(SkillNames.RockBand);
                }

                skill.mBandInfo = ths.mBandInfo;
                skill.BandNameUpdate(ths.mBandInfo.BandName);
            }
        }
        private List<RockBand> InitialiseRockBands()
        {
            List<RockBand> rockbands = new List<RockBand>();

            RockBand greatBand = new RockBand();
            greatBand.Name = "Great band";
            greatBand.Id = 1;
            greatBand.Albums = new List<Album>(){new Album(){Title = "First album", Year = 2000}, new Album(){Title = "Second album", Year = 2003}
                , new Album(){Title = "Third album", Year=2005}};
            greatBand.Prizes = new List<Prize>() { new Prize() { Name = "Best band" }, new Prize() { Name = "Best newcomers" } };

            RockBand rockBand = new RockBand();
            rockBand.Name = "Funny band";
            rockBand.Id = 2;
            rockBand.Albums = new List<Album>(){new Album(){Title = "Debut", Year = 1979}, new Album(){Title = "Continuation", Year = 1980}
                , new Album(){Title = "New Year", Year=1982}, new Album(){Title ="Summer", Year=1985}};
            rockBand.Prizes = new List<Prize>() { new Prize() { Name = "Cool band" }, new Prize() { Name = "Best band" }, new Prize() { Name = "First choice" } };

            RockBand anotherBand = new RockBand();
            anotherBand.Name = "Sounds good";
            anotherBand.Id = 3;
            anotherBand.Albums = new List<Album>() { new Album() { Title = "The beginning", Year = 1982 }, new Album() { Title = "The end", Year = 1986 } };
            anotherBand.Prizes = new List<Prize>() { new Prize() { Name = "First choice" } };

            RockBand rb = new RockBand();
            rb.Name = "Sounds good";
            rb.Id = 4;
            rb.Albums = new List<Album>() { new Album() { Title = "Cool", Year = 1988 }, new Album() { Title = "Yeah", Year = 1989 }
                , new Album() { Title = "Oooooohhh", Year = 1990 }, new Album() { Title = "Entertain", Year = 1991 }, new Album() { Title = "Go home", Year = 1992 }};
            rb.Prizes = new List<Prize>() { new Prize() { Name = "First choice" }, new Prize() { Name = "Cool band" } };

            rockbands.Add(greatBand);
            rockbands.Add(rockBand);
            rockbands.Add(anotherBand);
            rockbands.Add(rb);

            return rockbands;
        }
            public void Restore(SimDescription sim)
            {
                try
                {
                    sim.mGenderPreferenceMale   = mMalePreference;
                    sim.mGenderPreferenceFemale = mFemalePreference;

                    if (sim.Pregnancy != null)
                    {
                        sim.Pregnancy.mGender = mPregnantGender;
                    }

                    if (sim.CreatedSim != null)
                    {
                        if (mPreviousOutfitCategory != OutfitCategories.None)
                        {
                            SimOutfit outfit = sim.GetOutfit(mPreviousOutfitCategory, mPreviousOutfitIndex);
                            if (outfit != null)
                            {
                                sim.CreatedSim.mPreviousOutfitKey = outfit.Key;
                            }
                        }

                        if (sim.CreatedSim.DreamsAndPromisesManager != null)
                        {
                            ActiveDreamNode node = sim.CreatedSim.DreamsAndPromisesManager.LifetimeWishNode;
                            if (node != null)
                            {
                                node.InternalCount = mLifetimeWishTally;
                            }
                        }
                    }

                    foreach (TraitNames trait in mTraits)
                    {
                        if (sim.TraitManager.HasElement(trait))
                        {
                            continue;
                        }

                        sim.TraitManager.AddElement(trait);
                    }

                    SocialNetworkingSkill networkSkill = sim.SkillManager.GetSkill <SocialNetworkingSkill>(SkillNames.SocialNetworking);
                    if (networkSkill != null)
                    {
                        networkSkill.mNumberOfFollowers = mNumberOfFollowers;
                        networkSkill.mBlogsCreated      = mBlogsCreated;
                    }

                    RockBand bandSkill = sim.SkillManager.GetSkill <RockBand>(SkillNames.RockBand);
                    if (bandSkill != null)
                    {
                        bandSkill.mBandInfo = mBandInfo;
                    }

                    Collecting collecting = sim.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);
                    if (collecting != null)
                    {
                        collecting.mGlowBugData        = mGlowBugData;
                        collecting.mMushroomsCollected = mMushroomsCollected;
                    }

                    NectarSkill nectar = sim.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);
                    if (nectar != null)
                    {
                        nectar.mHashesMade = mNectarHashesMade;
                    }

                    Photography photography = sim.SkillManager.GetSkill <Photography>(SkillNames.Photography);
                    if (photography != null)
                    {
                        // Forces a recalculation of the completion count
                        photography.mCollectionsCompleted = uint.MaxValue;

                        if (mSubjectRecords != null)
                        {
                            photography.mSubjectRecords = mSubjectRecords;
                        }
                    }

                    RidingSkill riding = sim.SkillManager.GetSkill <RidingSkill>(SkillNames.Riding);
                    if (riding != null)
                    {
                        if (mCrossCountryCompetitionsWon != null)
                        {
                            riding.mCrossCountryCompetitionsWon = mCrossCountryCompetitionsWon.ToArray();
                        }

                        if (mJumpCompetitionsWon != null)
                        {
                            riding.mJumpCompetitionsWon = mJumpCompetitionsWon.ToArray();
                        }
                    }

                    Bartending mixology = sim.SkillManager.GetSkill <Bartending>(SkillNames.Bartending);
                    if (mixology != null)
                    {
                        if (mCustomDrinks != null)
                        {
                            mixology.mUniqueDrinks = mCustomDrinks;
                        }
                    }

                    if (mOccult != null)
                    {
                        foreach (OccultBaseClass occult in mOccult)
                        {
                            if (OccultTypeHelper.Add(sim, occult.ClassOccultType, false, false))
                            {
                                OccultTransfer transfer = OccultTransfer.Get(occult.ClassOccultType);
                                if (transfer != null)
                                {
                                    transfer.Perform(sim, occult);
                                }
                            }
                        }
                    }

                    mOccult = null;

                    if (mOutfitCache != null)
                    {
                        foreach (SavedOutfit.Cache.Key outfit in mOutfitCache.Outfits)
                        {
                            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, false))
                            {
                                builder.Builder.SkinTone      = mSkinToneKey;
                                builder.Builder.SkinToneIndex = mSkinToneIndex;

                                outfit.Apply(builder, true, null, null);
                            }
                        }

                        foreach (SavedOutfit.Cache.Key outfit in mOutfitCache.AltOutfits)
                        {
                            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, true))
                            {
                                builder.Builder.SkinTone      = mSkinToneKey;
                                builder.Builder.SkinToneIndex = mSkinToneIndex;

                                outfit.Apply(builder, true, null, null);
                            }
                        }

                        int count         = 0;
                        int originalCount = mOutfitCache.GetOutfitCount(OutfitCategories.Everyday, false);

                        while ((originalCount > 0) && (originalCount < sim.GetOutfitCount(OutfitCategories.Everyday)) && (count < originalCount))
                        {
                            CASParts.RemoveOutfit(sim, new CASParts.Key(OutfitCategories.Everyday, sim.GetOutfitCount(OutfitCategories.Everyday) - 1), false);
                            count++;
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(sim, e);
                }
            }
            public CrossWorldData(SimDescription sim)
            {
                mName = sim.FullName;

                mOutfitCache = new SavedOutfit.Cache(sim);

                SimOutfit outfit = sim.GetOutfit(OutfitCategories.Everyday, 0);

                if (outfit != null)
                {
                    mSkinToneKey   = outfit.SkinToneKey;
                    mSkinToneIndex = outfit.SkinToneIndex;
                }
                else
                {
                    mSkinToneKey   = sim.SkinToneKey;
                    mSkinToneIndex = sim.SkinToneIndex;
                }

                mMalePreference   = sim.mGenderPreferenceMale;
                mFemalePreference = sim.mGenderPreferenceFemale;

                if (sim.CreatedSim != null)
                {
                    if (sim.CreatedSim.mPreviousOutfitKey != null)
                    {
                        try
                        {
                            mPreviousOutfitCategory = sim.GetOutfitCategoryFromResKey(sim.CreatedSim.mPreviousOutfitKey, out mPreviousOutfitIndex);
                        }
                        catch
                        { }
                    }

                    if (sim.CreatedSim.DreamsAndPromisesManager != null)
                    {
                        ActiveDreamNode node = sim.CreatedSim.DreamsAndPromisesManager.LifetimeWishNode;
                        if (node != null)
                        {
                            mLifetimeWishTally = node.InternalCount;
                        }
                    }
                }

                if (sim.Pregnancy != null)
                {
                    mPregnantGender = sim.Pregnancy.mGender;
                }

                foreach (Trait trait in sim.TraitManager.List)
                {
                    if (trait.IsReward)
                    {
                        continue;
                    }

                    mTraits.Add(trait.Guid);
                }

                SocialNetworkingSkill networkSkill = sim.SkillManager.GetSkill <SocialNetworkingSkill>(SkillNames.SocialNetworking);

                if (networkSkill != null)
                {
                    // This value is set to mNumberOfBlogFollowers for some reason
                    mNumberOfFollowers = networkSkill.mNumberOfFollowers;

                    // Not transitioned at all
                    mBlogsCreated = networkSkill.mBlogsCreated;
                }

                RockBand bandSkill = sim.SkillManager.GetSkill <RockBand>(SkillNames.RockBand);

                if (bandSkill != null)
                {
                    mBandInfo = bandSkill.mBandInfo;
                }

                Collecting collecting = sim.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);

                if (collecting != null)
                {
                    // Error in CollectingPropertyStreamWriter:Export() requires that mGlowBugData by transfered manually
                    //   Exported as two Int64, but Imported as a Int64 and Int32
                    mGlowBugData = collecting.mGlowBugData;

                    mMushroomsCollected = collecting.mMushroomsCollected;
                }

                NectarSkill nectar = sim.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);

                if (nectar != null)
                {
                    mNectarHashesMade = nectar.mHashesMade;
                }

                Photography photography = sim.SkillManager.GetSkill <Photography>(SkillNames.Photography);

                if (photography != null)
                {
                    mSubjectRecords = photography.mSubjectRecords;
                }

                RidingSkill riding = sim.SkillManager.GetSkill <RidingSkill>(SkillNames.Riding);

                if (riding != null)
                {
                    // Error in the Import (Copy/Paste fail by the looks of it), where the CrossCountry Wins are imported instead
                    mCrossCountryCompetitionsWon = new List <uint>(riding.mCrossCountryCompetitionsWon);
                    mJumpCompetitionsWon         = new List <uint>(riding.mJumpCompetitionsWon);
                }

                // EA hosed the color, glass and drink picks
                Bartending mixology = sim.SkillManager.GetSkill <Bartending>(SkillNames.Bartending);

                if (mixology != null)
                {
                    mCustomDrinks = mixology.mUniqueDrinks;
                }

                if ((sim.OccultManager != null) && (sim.OccultManager.mOccultList != null))
                {
                    mOccult = new List <OccultBaseClass>(sim.OccultManager.mOccultList);
                }
            }
Exemple #5
0
        public static void CleanupBrokenSkills(SimDescription sim, Logger log)
        {
            try
            {
                if (sim.SkillManager == null)
                {
                    return;
                }

                List <ulong> remove = new List <ulong>();
                foreach (KeyValuePair <ulong, Skill> value in sim.SkillManager.mValues)
                {
                    Skill skill = value.Value;

                    if (skill == null)
                    {
                        remove.Add(value.Key);
                    }
                    else
                    {
                        Skill staticSkill = SkillManager.GetStaticSkill(skill.Guid);
                        if (staticSkill != null)
                        {
                            if (skill.NonPersistableData == null)
                            {
                                skill.mNonPersistableData = staticSkill.mNonPersistableData;

                                if (skill.NonPersistableData != null)
                                {
                                    if (log != null)
                                    {
                                        log(" Broken Skill " + skill.Guid + " Repaired " + sim.FullName);
                                    }
                                }
                                else
                                {
                                    remove.Add(value.Key);
                                }
                            }

                            if (skill.SkillLevel > staticSkill.MaxSkillLevel)
                            {
                                skill.SkillLevel = staticSkill.MaxSkillLevel;

                                if (log != null)
                                {
                                    log(" Skill Level Reduced To Max " + skill.Guid + ": " + sim.FullName);
                                }
                            }
                        }
                        else
                        {
                            remove.Add(value.Key);
                        }
                    }
                }

                foreach (ulong guid in remove)
                {
                    sim.SkillManager.mValues.Remove(guid);

                    if (log != null)
                    {
                        log("Broken Skill " + guid + " Dropped " + sim.FullName);
                    }
                }

                NectarSkill nectarSkill = sim.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);
                if (nectarSkill != null)
                {
                    if (nectarSkill.mSimIDsServed == null)
                    {
                        nectarSkill.mSimIDsServed = new List <ulong>();
                    }

                    if (nectarSkill.mHashesMade == null)
                    {
                        nectarSkill.mHashesMade = new List <uint>();
                    }
                }

                RockBand bandSkill = sim.SkillManager.GetSkill <RockBand>(SkillNames.RockBand);
                if (bandSkill != null)
                {
                    if (bandSkill.mBandGigsStats != null)
                    {
                        bandSkill.mBandGigsStats.Remove(null);
                    }
                }

                BroomRidingSkill broomRidingSkill = sim.SkillManager.GetSkill <BroomRidingSkill>(SkillNames.BroomRiding);
                if (broomRidingSkill != null)
                {
                    if (broomRidingSkill.mLotsVisited == null)
                    {
                        broomRidingSkill.mLotsVisited = new List <Lot>();

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

                    for (int i = broomRidingSkill.mLotsVisited.Count - 1; i >= 0; i--)
                    {
                        if (broomRidingSkill.mLotsVisited[i] == null)
                        {
                            broomRidingSkill.mLotsVisited.RemoveAt(i);

                            if (log != null)
                            {
                                log(" Invalid LotsVisited Removed: " + sim.FullName);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(sim, e);
            }
        }