Пример #1
0
            public static bool AddFire(Common.IStatGenerator stats, GameObject obj)
            {
                LotLocation loc         = LotLocation.Invalid;
                ulong       lotLocation = World.GetLotLocation(obj.PositionOnFloor, ref loc);

                if (!World.HasSolidFloor(obj.LotCurrent.mLotId, loc))
                {
                    stats.IncStat("No Solid Floor");
                    return(false);
                }

                if (lotLocation == 0x0L)
                {
                    stats.IncStat("No Location");
                    return(false);
                }

                if (Sims3.Gameplay.Objects.Fire.CreateFire(lotLocation, loc) == null)
                {
                    stats.IncStat("CreateFire Fail");
                    return(false);
                }

                return(true);
            }
Пример #2
0
        public bool Allow(Common.IStatGenerator stats, Lot lot, ICollection <SimDescription> sims, FindLotFlags flags, bool allowRentable)
        {
            LotOptions lotData = Options.GetLotOptions(lot);

            if (UnchartedIslandMarker.IsUnchartedIsland(lot))
            {
                stats.IncStat("Find Lot: Uncharted");
                return(false);
            }
            else if (!lotData.GetValue <AllowLotUseOption, bool>())
            {
                stats.IncStat("Find Lot: Lot Allow Denied");
                return(false);
            }
            else if (!PassesHomeInspection(stats, lot, sims, flags))
            {
                stats.IncStat("Find Lot: Home Inspection");
                return(false);
            }

            if (!allowRentable)
            {
                if (Money.GetDeedOwner(lot) != null)
                {
                    return(false);
                }
            }

            return(lotData.AllowCastes(stats, sims));
        }
Пример #3
0
            protected static bool OnDualAllow(Common.IStatGenerator stats, SimData actorData, SimData targetData, Managers.Manager.AllowCheck check)
            {
                ulong id = actorData.GetValue <ArrangedMarriageOption, ulong>();

                if (id != 0)
                {
                    if (targetData.SimDescription.SimDescriptionId != id)
                    {
                        stats.IncStat("Arranged");
                        return(false);
                    }
                }

                id = targetData.GetValue <ArrangedMarriageOption, ulong>();
                if (id != 0)
                {
                    if (actorData.SimDescription.SimDescriptionId != id)
                    {
                        stats.IncStat("Arranged");
                        return(false);
                    }
                }

                return(true);
            }
Пример #4
0
            public void IncStat(string stat)
            {
                if (!Common.kDebugging)
                {
                    return;
                }

                mStats.IncStat(mName + " " + stat);
            }
Пример #5
0
        public static void IncStat(string stat)
        {
            if (sStats == null)
            {
                return;
            }

            sStats.IncStat(stat);
        }
Пример #6
0
        public BuyProductList(Common.IStatGenerator stats, BuildBuyProduct.eBuyCategory buyCategory, BuildBuyProduct.eBuySubCategory buySubCategory, int minimumPrice, int maximumPrice)
        {
            List <object> products = UserToolUtils.GetObjectProductListFiltered((uint)buyCategory, uint.MaxValue, (ulong)buySubCategory, ulong.MaxValue, ulong.MaxValue, 0x0, uint.MaxValue, 0x0, 0x0);

            stats.IncStat("BuyProduct " + buyCategory);
            stats.IncStat("BuyProduct " + buySubCategory);

            stats.AddStat("BuyProduct Possibles", products.Count);

            foreach (object obj in products)
            {
                BuildBuyProduct product = obj as BuildBuyProduct;
                if (product == null)
                {
                    continue;
                }

                if (!product.ShowInCatalog)
                {
                    continue;
                }

                if (product.Price < minimumPrice)
                {
                    continue;
                }

                if (product.Price > maximumPrice)
                {
                    continue;
                }

                // 319e4f1d:00000000:00000000000f5f40
                if (product.ObjectInstanceName == "RCcart")
                {
                    continue;
                }

                // 319e4f1d:00000000:00000000000f5e5a
                if (product.ProductResourceKey != ResourceKey.kInvalidResourceKey && product.ProductResourceKey.ToString() == "319e4f1d:00000000:00000000000f5e5a")
                {
                    continue;
                }

                // Common.WriteLog("Product: " + product.CatalogName + " ResKey: " + product.ProductResourceKey + " Instance: " + product.ObjectInstanceName);

                mProducts.Add(product);
            }

            stats.AddStat("BuyProduct Results", mProducts.Count);
        }
Пример #7
0
        protected static bool OnPrivateAllow(Common.IStatGenerator stats, SimData settings, Managers.Manager.AllowCheck check)
        {
            if (!settings.GetValue <AllowSkillOption, bool>())
            {
                stats.IncStat("Allow: Skills Denied");
                return(false);
            }
            else if (!settings.GetValue <AllowPushSkillOption, bool>())
            {
                stats.IncStat("Allow: Push Denied");
                return(false);
            }

            return(true);
        }
Пример #8
0
        protected override ManagerLot.CheckResult OnLotPriceCheck(Common.IStatGenerator stats, Lot lot, int currentLotCost, int availableFunds)
        {
            if (currentLotCost < lot.Cost * 0.8)
            {
                stats.IncStat("Find Lot: Too expensive (A)");
                return(ManagerLot.CheckResult.Failure);
            }
            else if (availableFunds < lot.Cost)
            {
                stats.IncStat("Find Lot: Too expensive (B)");
                return(ManagerLot.CheckResult.Failure);
            }

            return(ManagerLot.CheckResult.Success);
        }
Пример #9
0
 public bool TestCooldown(Common.IStatGenerator stats, SimDescription sim)
 {
     if (sim.Partner == null)
     {
         stats.IncStat("No Partner");
         return(false);
     }
     else if (stats.AddScoring("Pregnancy Cooldown", TestElapsedTime <DayOfLastRomanceOption, ExpectedPregnancyScenario.MinTimeFromRomanceToPregnancyOption>(sim)) < 0)
     {
         stats.AddStat("Too Soon After Romance", GetElapsedTime <DayOfLastRomanceOption>(sim));
         return(false);
     }
     else if (stats.AddScoring("Pregnancy Cooldown", TestElapsedTime <DayOfLastRomanceOption, ExpectedPregnancyScenario.MinTimeFromRomanceToPregnancyOption>(sim.Partner)) < 0)
     {
         stats.AddStat("Too Soon After Romance", GetElapsedTime <DayOfLastRomanceOption>(sim.Partner));
         return(false);
     }
     else if (stats.AddScoring("New Baby Cooldown", TestElapsedTime <DayOfLastBabyOption, ExpectedPregnancyScenario.MinTimeFromBabyToPregnancyOption>(sim)) < 0)
     {
         stats.AddStat("Too Soon After Baby", GetElapsedTime <DayOfLastBabyOption>(sim));
         return(false);
     }
     else if (stats.AddScoring("New Baby Cooldown", TestElapsedTime <DayOfLastBabyOption, ExpectedPregnancyScenario.MinTimeFromBabyToPregnancyOption>(sim.Partner)) < 0)
     {
         stats.AddStat("Too Soon After Baby", GetElapsedTime <DayOfLastBabyOption>(sim.Partner));
         return(false);
     }
     return(true);
 }
Пример #10
0
        public bool IsOpposing(Common.IStatGenerator stats, SimDescription simA, SimDescription simB, bool testSplit)
        {
            if ((testSplit) && (!GetValue <BrokenHomeScenario.SplitOpposingClanOption, bool>()))
            {
                return(false);
            }

            LawfulnessType lawfulA = GetLawfulness(simA);
            LawfulnessType lawfulB = GetLawfulness(simB);

            switch (lawfulA)
            {
            case LawfulnessType.Lawful:
                if (lawfulB == LawfulnessType.Unlawful)
                {
                    stats.IncStat("Lawful Fail");
                    return(true);
                }
                break;

            case LawfulnessType.Unlawful:
                if (lawfulB == LawfulnessType.Lawful)
                {
                    stats.IncStat("Lawful Fail");
                    return(true);
                }
                break;
            }

            List <SimPersonality> clansA = GetClanMembership(simA, true);

            List <SimPersonality> clansB = GetClanMembership(simB, true);

            foreach (SimPersonality clanA in clansA)
            {
                foreach (SimPersonality clanB in clansB)
                {
                    if (clanA.IsOpposing(clanB))
                    {
                        stats.IncStat("Opposing: " + clanA.UnlocalizedName + ", " + clanB.UnlocalizedName);
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #11
0
        public bool PutAwayBook(Common.IStatGenerator stats, Book book, Lot lot)
        {
            Bookshelf shelf = book.MyShelf;

            if ((shelf == null) || (!shelf.InWorld))
            {
                List <Bookshelf> shelves = new List <Bookshelf>();
                foreach (Bookshelf choice in lot.GetObjects <Bookshelf>())
                {
                    if (choice.Inventory == null)
                    {
                        continue;
                    }

                    if (!choice.InWorld)
                    {
                        continue;
                    }

                    if ((choice.Repairable != null) && (choice.Repairable.Broken))
                    {
                        continue;
                    }

                    shelves.Add(choice);
                }

                if (shelves.Count > 0)
                {
                    shelf = RandomUtil.GetRandomObjectFromList(shelves);
                }
            }

            if (shelf != null)
            {
                stats.IncStat("Book Shelved");

                shelf.Inventory.TryToMove(book);
                return(true);
            }
            else
            {
                stats.IncStat("No Shelf");

                return(false);
            }
        }
Пример #12
0
            protected static bool OnAllow(Common.IStatGenerator stats, SimData sim, Managers.Manager.AllowCheck check)
            {
                SimDescription simDesc = sim.SimDescription;

                if (!sim.GetValue <AllowBreakupOption, bool>())
                {
                    stats.IncStat("Allow: Breakup Denied");
                    return(false);
                }
                else if (!StoryProgression.Main.GetValue <AllowBreakupOption, bool>(simDesc.Partner))
                {
                    stats.IncStat("Allow: Breakup Partner Denied");
                    return(false);
                }

                return(true);
            }
Пример #13
0
            protected override ManagerLot.CheckResult OnLotPriceCheck(Common.IStatGenerator stats, Lot lot, int currentLotCost, int availableFunds)
            {
                int cost = Lots.GetLotCost(lot);

                if (availableFunds < cost)
                {
                    stats.IncStat("Find Lot: Too expensive");
                    return(ManagerLot.CheckResult.Failure);
                }
                else if (cost < mBetterHome)
                {
                    stats.IncStat("Find Lot: Too Cheap");
                    return(ManagerLot.CheckResult.Failure);
                }

                return(ManagerLot.CheckResult.Success);
            }
Пример #14
0
        protected static bool OnAllowSkill(Common.IStatGenerator stats, SimData settings, SkillNames skill)
        {
            if (settings.HasValue <DisallowSkillOption, SkillNames>(skill))
            {
                stats.IncStat("Allow: " + skill + " Denied");
                return(false);
            }
            else if (settings.GetValue <AllowOnlyExistingSkillOption, bool>())
            {
                if (settings.SimDescription.SkillManager.GetSkillLevel(skill) < 1)
                {
                    stats.IncStat("Allow: " + skill + " Only Existing Denied");
                    return(false);
                }
            }

            return(true);
        }
Пример #15
0
        protected static ManagerLot.CheckResult OnLotPriceCheck(Common.IStatGenerator stats, Lot lot, int currentLotCost, int availableFunds)
        {
            if (availableFunds < StoryProgression.Main.Lots.GetLotCost(lot))
            {
                stats.IncStat("Find Lot: Too expensive");
                return(ManagerLot.CheckResult.Failure);
            }

            return(ManagerLot.CheckResult.Success);
        }
Пример #16
0
        public bool AllowCastes(Common.IStatGenerator stats, IEnumerable <SimDescription> sims)
        {
            if (sims == null)
            {
                return(true);
            }

            RequireCasteLotOption  requireCastes  = GetInternalOption <RequireCasteLotOption>();
            DisallowCasteLotOption disallowCastes = GetInternalOption <DisallowCasteLotOption>();

            if ((requireCastes == null) && (disallowCastes == null))
            {
                return(true);
            }

            foreach (SimDescription sim in sims)
            {
                SimData simData = StoryProgression.Main.GetData(sim);

                if ((disallowCastes != null) && (disallowCastes.Count > 0))
                {
                    if (disallowCastes.Contains(simData.Castes))
                    {
                        stats.IncStat("Find Lot: Disallow Caste Denied");
                        return(false);
                    }
                }

                if ((requireCastes != null) && (requireCastes.Count > 0))
                {
                    if (!requireCastes.Contains(simData.Castes))
                    {
                        stats.IncStat("Find Lot: Require Caste Denied");
                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #17
0
        public override void Dispose()
        {
            foreach (ExportBinContents content in mLoaded.Keys)
            {
                try
                {
                    if (content.Household != null)
                    {
                        foreach (SimDescription sim in new List <SimDescription> (content.Household.AllSimDescriptions))
                        {
                            Manager.Deaths.CleansingKill(sim, true);
                        }

                        mStats.IncStat("SimFromBin Household Disposed");

                        content.Household.Destroy();
                        content.Household.Dispose();
                    }

                    if (content.mHouseholdContents != null)
                    {
                        ExportBinContentsEx.Flush(content);
                    }
                }
                catch (Exception e)
                {
                    Common.DebugException(content.HouseholdName, e);
                }
            }

            foreach (SimDescription sim in mDispose)
            {
                sim.Dispose();
            }

            mStats.IncStat("SimFromBin Clear");

            BinModel.Singleton.ClearExportBin();
        }
Пример #18
0
        protected static bool TestNextOpponent(Common.IStatGenerator stats, MartialArts mySkill)
        {
            SimDescription tournamentChallenger = ManagerSim.Find(mySkill.mTournamentChallenger);

            if (!TestNextOpponent(stats, mySkill, tournamentChallenger))
            {
                stats.IncStat("Next Opponent Fail");
                return(false);
            }

            int possibleWins = mySkill.mSparringTournamentMatchWins + 1;

            int newRank = 0;

            while ((newRank < MartialArts.kTournamentWinsToImproveSparringRank.Length) && (possibleWins >= MartialArts.kTournamentWinsToImproveSparringRank[newRank]))
            {
                newRank++;
            }

            if (newRank > mySkill.mTournamentRank)
            {
                int oldRank = mySkill.mTournamentRank;
                mySkill.mTournamentRank = newRank;
                try
                {
                    if (!TestNextOpponent(stats, mySkill, tournamentChallenger))
                    {
                        stats.IncStat("Next Rank Fail");
                        return(false);
                    }
                }
                finally
                {
                    mySkill.mTournamentRank = oldRank;
                }
            }

            return(true);
        }
Пример #19
0
        public static bool IsRequired(Common.IStatGenerator stats, SimDescription sim)
        {
            Political job = sim.Occupation as Political;

            if (job == null)
            {
                stats.IncStat("No Job");
                return(false);
            }
            else if (!job.HasCampaignMoneyMetric())
            {
                stats.IncStat("No Need");
                return(false);
            }
            else if (GetRemaining(sim) <= 0)
            {
                stats.IncStat("Unnecessary");
                return(false);
            }

            return(true);
        }
Пример #20
0
        public bool AllowEnemy(Common.IStatGenerator stats, SimDescription actor, SimDescription target, AllowCheck check)
        {
            if ((check & AllowCheck.UserDirected) == AllowCheck.None)
            {
                if (actor.IsEP11Bot)
                {
                    if (!HasEnemyChips(actor))
                    {
                        stats.IncStat("Allow: Robot");
                        return(false);
                    }
                }

                if (target.IsEP11Bot)
                {
                    if (!HasEnemyChips(target))
                    {
                        stats.IncStat("Allow: Robot");
                        return(false);
                    }
                }
            }

            SimData actorData  = GetData(actor);
            SimData targetData = GetData(target);

            if (!actorData.Allowed <AllowCasteEnemyOption>(targetData, true))
            {
                stats.IncStat("Caste Enemy Denied");
                return(false);
            }
            else if (actorData.Disallowed <DisallowCasteEnemyOption>(targetData, true))
            {
                stats.IncStat("Caste Enemy Denied");
                return(false);
            }

            return(true);
        }
Пример #21
0
        public bool CanHaveAutonomousRomance(Common.IStatGenerator stats, SimDescription sim, SimDescription other, bool fullTest)
        {
            if ((sim.Household == null) || (other.Household == null))
            {
                stats.IncStat("No Home");
                return(false);
            }
            else if ((sim.Genealogy == null) || (other.Genealogy == null))
            {
                stats.IncStat("No Genealogy");
                return(false);
            }
            else if ((fullTest) && ((SimTypes.IsSelectable(sim)) || (SimTypes.IsSelectable(other))))
            {
                stats.IncStat("Active");
                return(false);
            }
            else if ((fullTest) && (!sim.CheckAutonomousGenderPreference(other)))
            {
                stats.IncStat("Gender Pref");
                return(false);
            }
            else
            {
                bool testRelation = fullTest;
                if ((sim.Partner == other) || (other.Partner == sim))
                {
                    testRelation = false;
                }

                if (!Relationships.CanHaveRomanceWith(stats.IncStat, sim, other, true, true, testRelation, GetValue <ManagerFlirt.CompleteAncestorCheckOption, bool>()))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #22
0
        public bool BumpToEngagement(Common.IStatGenerator stats, SimDescription a, SimDescription b)
        {
            if (a.Partner != b)
            {
                IncStat("BumpUp: Not Partner");
                stats.IncStat("BumpUp: Not Partner");
                return(false);
            }

            Relationship relation = ManagerSim.GetRelationship(a, b);

            while (relation.CurrentLTR != LongTermRelationshipTypes.Fiancee)
            {
                if (!BumpToHigherState(stats, a, b))
                {
                    break;
                }
            }

            if (relation.CurrentLTR != LongTermRelationshipTypes.Fiancee)
            {
                IncStat("BumpUp: Not Engaged");
                stats.IncStat("BumpUp: Not Engaged");
                return(false);
            }

            if (a.CreatedSim != null)
            {
                a.CreatedSim.BuffManager.AddElement(BuffNames.NewlyEngaged, Origin.FromSocialization);
            }

            if (b.CreatedSim != null)
            {
                b.CreatedSim.BuffManager.AddElement(BuffNames.NewlyEngaged, Origin.FromSocialization);
            }

            return(true);
        }
Пример #23
0
        protected static bool TestNextOpponent(Common.IStatGenerator stats, LogicSkill mySkill)
        {
            if (!TestNextOpponent(stats, mySkill, mySkill.mChessRankingNextChallenger))
            {
                stats.IncStat("Next Opponent Fail");
                return(false);
            }

            int possibleWins = mySkill.NumberOfChessTournamentWins + 1;

            int newRank = 0;

            while ((newRank < LogicSkill.kTournamentGamesWinsToImproveRank.Length) && (possibleWins >= LogicSkill.kTournamentGamesWinsToImproveRank[newRank]))
            {
                newRank++;
            }

            if (newRank > mySkill.mChessRank)
            {
                int oldRank = mySkill.mChessRank;
                mySkill.mChessRank = newRank;
                try
                {
                    if (!TestNextOpponent(stats, mySkill, mySkill.mChessRankingNextChallenger))
                    {
                        stats.IncStat("Next Rank Fail");
                        return(false);
                    }
                }
                finally
                {
                    mySkill.mChessRank = oldRank;
                }
            }

            return(true);
        }
Пример #24
0
        protected T PrivatePurchase(Common.IStatGenerator stats, string unlocalizedName, TestDelegate <T> test)
        {
            if (Count == 0)
            {
                stats.IncStat("No Purchase Choices " + unlocalizedName);
                return(null);
            }

            int price;
            T   obj = Get <T>(stats, unlocalizedName, test, out price);

            if (obj != null)
            {
                Inventories.TryToMove(obj, mSim.CreatedSim);

                NRaas.StoryProgression.Main.Money.AdjustFunds(mSim, "BuyItem", -price);
                return(obj);
            }
            else
            {
                stats.IncStat("No Purchase " + unlocalizedName);
                return(null);
            }
        }
Пример #25
0
        public static bool TestNearElderLimit(Common.IStatGenerator stats, SimDescription sim, int limit)
        {
            if ((sim.AdultOrAbove) && (limit > 0))
            {
                int daysToTransition = (int)(AgingManager.Singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(sim)) - AgingManager.Singleton.AgingYearsToSimDays(sim.AgingYearsSinceLastAgeTransition));

                if (daysToTransition < limit)
                {
                    stats.IncStat("Near Elder Denied");
                    return(false);
                }
            }

            return(true);
        }
Пример #26
0
        public bool IsFriendly(Common.IStatGenerator stats, SimDescription simA, SimDescription simB)
        {
            List <SimPersonality> clans = GetClanMembership(simA, true);

            foreach (SimPersonality clan in clans)
            {
                if (clan.IsFriendly(simA, simB))
                {
                    stats.IncStat("Clan Friendly " + clan.UnlocalizedName);
                    return(true);
                }
            }

            return(false);
        }
Пример #27
0
        public bool PassesHomeInspection(Common.IStatGenerator stats, Lot lot, ICollection <SimDescription> sims, FindLotFlags flags)
        {
            if (lot == null)
            {
                return(false);
            }

            Dictionary <HomeInspection.Reason, bool> existingResults = new Dictionary <HomeInspection.Reason, bool>();

            if (sims != null)
            {
                Dictionary <Household, bool> houses = new Dictionary <Household, bool>();

                foreach (SimDescription sim in sims)
                {
                    if ((sim.Household != null) && (!houses.ContainsKey(sim.Household)))
                    {
                        houses.Add(sim.Household, true);

                        if (sim.LotHome != null)
                        {
                            foreach (HomeInspection.Result result in new HomeInspection(sim.LotHome).Satisfies(HouseholdsEx.All(sim.Household)))
                            {
                                existingResults[result.mReason] = true;
                            }
                        }
                    }

                    if (sim.Occupation != null)
                    {
                        if (((flags & FindLotFlags.InspectCareerItems) == FindLotFlags.InspectCareerItems) && (GetValue <CareerObjectInspectionOption, bool>()))
                        {
                            DreamJob job = ManagerCareer.GetDreamJob(sim.Occupation.Guid);
                            if (job != null)
                            {
                                if (!job.Satisfies(Careers, sim, lot, true))
                                {
                                    stats.IncStat("Career Inspection Fail");
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }

            return(PassesHomeInspection(stats, lot, existingResults.Keys, new HomeInspection(lot).Satisfies(sims), flags));
        }
Пример #28
0
        protected ManagerLot.CheckResult OnLotPriceCheck(Common.IStatGenerator stats, Lot lot, int currentLotCost, int availableFunds)
        {
            Vector2 range = GetValue <ImmigrantMoveInScenario.LotPriceRangeOption, Vector2>();

            if ((range.x == 0) && (range.y == 0))
            {
                return(ManagerLot.CheckResult.IgnoreCost);
            }

            int cost = Lots.GetLotCost(lot);

            if ((range.x <= cost) && (cost <= range.y))
            {
                return(ManagerLot.CheckResult.IgnoreCost);
            }
            else
            {
                stats.IncStat("Out of Range");
                return(ManagerLot.CheckResult.Failure);
            }
        }
Пример #29
0
        public T Get <T>(Common.IStatGenerator stats, string name, TestDelegate <T> test, out int price)
            where T : class
        {
            List <BuildBuyProduct> choices = new List <BuildBuyProduct>(mProducts);

            RandomUtil.RandomizeListOfObjects(choices);

            stats.AddStat(name + " Total", choices.Count);

            foreach (BuildBuyProduct choice in choices)
            {
                ResourceKey key = choice.ProductResourceKey;

                Hashtable overrides = new Hashtable(0x1);

                IGameObject obj = null;

                try
                {
                    obj = GlobalFunctions.CreateObjectInternal(key, overrides, null);
                }
                catch (Exception e)
                {
                    Common.DebugException(key.ToString(), e);
                    continue;
                }

                T result = obj as T;
                if (result == null)
                {
                    stats.IncStat(name + " Mismatch " + choice.ObjectInstanceName, Common.DebugLevel.High);
                    stats.IncStat(name + " Wrong Type " + obj.GetType().Name, Common.DebugLevel.High);
                }
                else if ((test != null) && (!test(result)))
                {
                    stats.IncStat(name + " Test Fail");
                }
                else
                {
                    BuildBuyModel model = Sims3.Gameplay.UI.Responder.Instance.BuildBuyModel;

                    List <ResourceKey> presets = new List <ResourceKey>();

                    uint[] objectPresetIdList = model.GetObjectPresetIdList(obj.ObjectId);
                    for (uint i = 0; i < objectPresetIdList.Length; i++)
                    {
                        ThumbnailKey thumbnail = model.GetObjectProductThumbnailKey(obj.ObjectId, ThumbnailSize.Large);
                        if (thumbnail.mDescKey != ResourceKey.kInvalidResourceKey)
                        {
                            uint id = objectPresetIdList[i];
                            thumbnail.mDescKey.GroupId = (thumbnail.mDescKey.GroupId & 0xff000000) | (id & 0xffffff);
                            ResourceKeyContentCategory customContentTypeFromKeyAndPresetIndex = UIUtils.GetCustomContentTypeFromKeyAndPresetIndex(model.GetObjectProductKey(obj.ObjectId), i);
                            if (customContentTypeFromKeyAndPresetIndex == ResourceKeyContentCategory.kInstalled)
                            {
                                customContentTypeFromKeyAndPresetIndex = UIUtils.GetCustomContentType(model.GetObjectProductKey(obj.ObjectId));
                            }
                            string presetString = model.GetPresetString(thumbnail.mDescKey);
                            if (presetString != string.Empty)
                            {
                                KeyValuePair <string, Dictionary <string, Complate> > presetEntryFromPresetString = (KeyValuePair <string, Dictionary <string, Complate> >)SimBuilder.GetPresetEntryFromPresetString(presetString);
                                if ((presetEntryFromPresetString.Value != null) && (presetEntryFromPresetString.Value.Count > 0))
                                {
                                    presets.Add(thumbnail.mDescKey);
                                }
                            }
                        }
                    }

                    if (presets.Count > 0)
                    {
                        ResourceKey preset = RandomUtil.GetRandomObjectFromList(presets);

                        string presetString = model.GetPresetString(preset);
                        if (!string.IsNullOrEmpty(presetString))
                        {
                            object presetEntryFromPresetString = SimBuilder.GetPresetEntryFromPresetString(presetString);
                            if (presetEntryFromPresetString is KeyValuePair <string, Dictionary <string, Complate> > )
                            {
                                FinalizePresetTask.Perform(obj.ObjectId, (KeyValuePair <string, Dictionary <string, Complate> >)presetEntryFromPresetString);
                            }
                        }
                    }

                    stats.IncStat(name + " Found");

                    price = (int)choice.Price;

                    return(result);
                }

                obj.Destroy();
            }

            price = 0;
            return(null);
        }
Пример #30
0
        protected static bool Perform(Common.IStatGenerator stats, SimDescription sim, int amount, ref bool push)
        {
            if (sim.CreatedSim == null)
            {
                stats.IncStat("Hibernating");
                return(false);
            }
            else if (!Inventories.VerifyInventory(sim))
            {
                stats.IncStat("No Inventory");
                return(false);
            }

            School school = sim.CareerManager.School;

            if (school != null)
            {
                if (school.OwnersHomework == null)
                {
                    school.OwnersHomework = GlobalFunctions.CreateObjectOutOfWorld("Homework") as Homework;
                    school.OwnersHomework.OwningSimDescription = sim;
                    Inventories.TryToMove(school.OwnersHomework, sim.CreatedSim);

                    stats.IncStat("Homework Created");
                }

                if ((!sim.CreatedSim.Inventory.Contains(school.OwnersHomework)) &&
                    (school.OwnersHomework.LotCurrent != sim.CreatedSim.LotCurrent) &&
                    (school.OwnersHomework.UseCount == 0))
                {
                    Inventories.TryToMove(school.OwnersHomework, sim.CreatedSim);

                    stats.IncStat("Homework Moved");
                }
            }

            if (amount > 100)
            {
                amount = 100;
            }

            bool success = false;

            foreach (Homework obj in Inventories.InventoryFindAll <Homework>(sim))
            {
                if (obj.PercentComplete < 0)
                {
                    continue;
                }

                if ((amount < 0) || (obj.PercentComplete < amount))
                {
                    obj.PercentComplete = amount;
                    stats.AddStat("Homework Value", amount);

                    if (amount > 90)
                    {
                        push = true;
                    }

                    success = true;
                }
            }
            return(success);
        }