Example #1
0
 protected static void OnFromBin(Common.IStatGenerator stats, SimDescription sim, SimDescription mom, SimDescription dad, Manager manager)
 {
     if (manager.GetValue <Option, bool>())
     {
         AlterSkinBlend(stats, sim, new List <SimDescription>(new SimDescription[] { mom, dad }));
     }
 }
Example #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));
        }
Example #3
0
        public bool Adjust(Common.IStatGenerator manager, SkillNames skillName)
        {
            if (mSkillLevels == null)
            {
                return(false);
            }

            Skill skill = Sim.SkillManager.GetElement(skillName);

            if (skill != null)
            {
                int   origLevel  = 0;
                float origPoints = 0;

                if (mSkillLevels.ContainsKey(skill.Guid))
                {
                    origLevel  = mSkillLevels[skill.Guid].First;
                    origPoints = mSkillLevels[skill.Guid].Second;
                }

                int change = skill.SkillLevel - origLevel;
                if (change > 0)
                {
                    manager.AddStat("Lowered: " + skill.Guid, change);

                    skill.SkillLevel  = origLevel;
                    skill.SkillPoints = origPoints;

                    skill.UpdateProgress();
                }
            }

            return(true);
        }
Example #4
0
        public bool AllowCastes(Common.IStatGenerator stats, Lot lot, SimDescription sim)
        {
            List <SimDescription> sims = new List <SimDescription>();

            sims.Add(sim);
            return(AllowCastes(stats, lot, sims));
        }
Example #5
0
            public Parameters(Scenario scenario, bool defaultAll)
            {
                mDefaultAll = defaultAll;

                mStats = scenario;

                mManager = scenario.Manager;

                mName = mManager.UnlocalizedName + " " + scenario.UnlocalizedName;

                IFriendlyScenario friendly = scenario as IFriendlyScenario;

                if (friendly != null)
                {
                    mIsFriendly = friendly.IsFriendly;
                }

                IRomanticScenario romantic = scenario as IRomanticScenario;

                if (romantic != null)
                {
                    mIsRomantic = romantic.IsRomantic;
                }

                mAbsoluteScoring = false;
            }
Example #6
0
 public void AddScoring(string stat, Common.IStatGenerator manager)
 {
     foreach (ScorePair score in mInternalList)
     {
         manager.AddScoring(stat, score.mScore);
     }
 }
Example #7
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);
            }
Example #8
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);
 }
            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);
            }
Example #10
0
        public ManagedBuyProduct(SimDescription sim, Common.IStatGenerator stats, int minimumPrice, BuildBuyProduct.eBuyCategory buyCategory, BuildBuyProduct.eBuySubCategory buySubCategory)
            : base(stats, buyCategory, buySubCategory, minimumPrice, sim.FamilyFunds)
        {
            mSim = sim;

            mMinimumPrice = minimumPrice;
        }
Example #11
0
        protected override ManagerLot.CheckResult OnLotPriceCheck(Common.IStatGenerator stats, Lot lot, int currentLotCost, int availableFunds)
        {
            if (availableFunds < Lots.GetLotCost(lot))
            {
                stats.IncStat("Find Lot: Too expensive");
                return(ManagerLot.CheckResult.Failure);
            }

            return(ManagerLot.CheckResult.Success);
        }
Example #12
0
 public bool AllowSkill(Common.IStatGenerator stats, SimDescription sim, SimData settings, SkillNames skill)
 {
     if (OnAllowSkill != null)
     {
         return(OnAllowSkill(stats, settings, skill));
     }
     else
     {
         return(true);
     }
 }
Example #13
0
        public bool Run(Common.IStatGenerator stats, Manager manager, SimDescription mom, SimDescription dad)
        {
            if (Sim == null)
            {
                return(false);
            }

            Manager = manager;

            return(PrivatePerform(stats, mom, dad, true));
        }
Example #14
0
        protected static void DropNonMatchingStudents(ManagerCareer manager, Common.IStatGenerator stats, Lot lot)
        {
            LotOptions lotOptions = manager.GetLotOptions(lot);

            foreach (RabbitHole hole in lot.GetObjects <RabbitHole>())
            {
                if (hole.CareerLocations == null)
                {
                    continue;
                }

                foreach (CareerLocation location in hole.CareerLocations.Values)
                {
                    if (location == null)
                    {
                        continue;
                    }

                    if (location.Career is School)
                    {
                        if (location.Workers == null)
                        {
                            continue;
                        }

                        foreach (SimDescription sim in new List <SimDescription>(location.Workers))
                        {
                            try
                            {
                                if (!lotOptions.AllowCastes(stats, sim))
                                {
                                    if (sim.CareerManager != null)
                                    {
                                        if (sim.CareerManager.School != null)
                                        {
                                            sim.CareerManager.School.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid);
                                        }

                                        sim.CareerManager.School = null;
                                    }

                                    manager.Scenarios.Post(new ScheduledAssignSchoolScenario(sim));
                                }
                            }
                            catch (Exception e)
                            {
                                Common.Exception(sim, e);
                            }
                        }
                    }
                }
            }
        }
Example #15
0
        protected static void AlterSkinBlend(Common.IStatGenerator stats, SimDescription sim, List <SimDescription> immediateParents)
        {
            List <SimDescription> choices = new List <SimDescription>(immediateParents);

            foreach (SimDescription parent in immediateParents)
            {
                if (parent.IsAlien)
                {
                    return;
                }

                foreach (SimDescription grand in Relationships.GetParents(parent))
                {
                    if (!grand.IsAlien)
                    {
                        choices.Add(grand);
                    }
                }
            }

            stats.AddStat("Blend Choices", choices.Count);

            if (choices.Count >= 2)
            {
                sim.SkinToneKey = FixInvisibleTask.ValidateSkinTone(RandomUtil.GetRandomObjectFromList(choices).SkinToneKey);

                RandomUtil.RandomizeListOfObjects(choices);

                float num4 = choices[0].SkinToneIndex;
                float num5 = choices[1].SkinToneIndex;
                if (num4 > num5)
                {
                    float num6 = num5;
                    num5 = num4;
                    num4 = num6;
                }
                float num8 = num5 - num4;

                float newIndex = 0;

                float num7 = RandomUtil.GetFloat(Sims3.Gameplay.CAS.Genetics.kSkinColorMaxPercentTravel / 100f);
                if (RandomUtil.CoinFlip())
                {
                    newIndex = num4 + (num8 * num7);
                }
                else
                {
                    newIndex = num5 - (num8 * num7);
                }

                sim.SkinToneIndex = newIndex;
            }
        }
Example #16
0
        public SimFromBin(Common.IStatGenerator stats, TManager manager)
            : base(manager, false)
        {
            mStats = stats;

            mDisallowed = Manager.GetValue <DisallowHouseholdOption <TManager>, List <string> >();

            mRandomChance = Manager.GetValue <SimFromRandomChanceOption <TManager>, int>();
            mBinChance    = Manager.GetValue <SimFromBinChanceOption <TManager>, int>();

            BinModel.Singleton.PopulateExportBin();
        }
Example #17
0
        protected int Add(Common.IStatGenerator stats, string scoring, SimScoringParameters parameters)
        {
            if (mMethod == null)
            {
                return(0);
            }

            int score = stats.AddScoring(scoring, mMethod.IScore(parameters));

            mInternalList.Add(new ScorePair(parameters.Actor, score));
            return(score);
        }
Example #18
0
        public static T Purchase(SimDescription sim, int minimumPrice, Common.IStatGenerator stats, string unlocalizedName, TestDelegate <T> test, BuildBuyProduct.eBuyCategory buyCategory, BuildBuyProduct.eBuySubCategory buySubCategory)
        {
            T obj = Inventories.InventoryFind <T>(sim);

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

            ManagedBuyProduct <T> list = new ManagedBuyProduct <T>(sim, stats, minimumPrice, buyCategory, buySubCategory);

            return(list.PrivatePurchase(stats, unlocalizedName, test));
        }
Example #19
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);
        }
Example #20
0
        public bool PassesHomeInspection(Common.IStatGenerator stats, Lot lot, ICollection <SimDescription> newMembers, ICollection <SimDescription> existing, FindLotFlags flags)
        {
            if (lot == null)
            {
                return(false);
            }

            List <SimDescription> members = new List <SimDescription> ();

            members.AddRange(newMembers);
            members.AddRange(existing);

            return(PassesHomeInspection(stats, lot, members, flags));
        }
Example #21
0
        public bool RandomChanceOfAttempt(Common.IStatGenerator stats, float baseChance)
        {
            stats.AddStat("Base Chance", baseChance);

            baseChance += (Sims.GetDepopulationDanger(false) * 10);
            if (Households.FamiliesPacked && (Lots.FreeLotRatio < 0.2f))
            {
                baseChance /= 3f;
            }

            stats.AddStat("Adjusted Chance", baseChance);

            return(RandomUtil.RandomChance(baseChance));
        }
Example #22
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);
        }
Example #23
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);
        }
Example #24
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);
        }
Example #25
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));
        }
Example #26
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);
        }
Example #27
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);
            }
        }
Example #28
0
        protected int PrivateScore(SP parameters, ICollection <IScoring <T, SubSP> > scoringList, string suffix)
        {
            Common.IStatGenerator manager = ScoringLookup.Stats;

            bool lowDebugging = false;

            if (manager != null)
            {
                lowDebugging = (manager.DebuggingLevel > Common.DebugLevel.Stats);
            }

            int totalScore = 0;

            foreach (IScoring <T, SubSP> scoring in scoringList)
            {
                string scoringName = null, fullScoringName = null;

                if (lowDebugging)
                {
                    scoringName = scoring.ToString() + suffix;

                    fullScoringName = "Duration " + Name + " " + scoringName;

                    scoringName = "Duration " + scoringName;
                }

                using (Common.TestSpan scoringTime2 = new Common.TestSpan(manager, scoringName))
                {
                    using (Common.TestSpan scoringTime = new Common.TestSpan(manager, fullScoringName, Common.DebugLevel.High))
                    {
                        int score = scoring.Score(parameters);

                        ScoringLookup.AddStat(scoring.ToString() + suffix, score);

                        if (score <= -1000)
                        {
                            return(score);
                        }

                        totalScore += score;
                    }
                }
            }

            return(totalScore);
        }
Example #29
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);
            }
Example #30
0
        protected static bool TestNextOpponent(Common.IStatGenerator stats, LogicSkill mySkill, SimDescription choice)
        {
            SimDescription nextOpponent = TournamentManagement.FindSuitableOpponent(mySkill.SkillOwner, Household.sHouseholdList, choice, new TournamentManagement.GetAffinity(mySkill.GetAffinity));

            if ((nextOpponent != null) &&
                (nextOpponent.SkillManager != null) &&
                ((nextOpponent.Household == null) || (!nextOpponent.Household.IsActive)))
            {
                Chess oppSkill = nextOpponent.SkillManager.AddElement(SkillNames.Chess) as Chess;
                if ((oppSkill != null) && (oppSkill.SkillLevel < LogicSkill.kChessSkillForOpponentPerRank[mySkill.mChessRank]))
                {
                    // Next opponent will receive free skills
                    return(false);
                }
            }

            return(true);
        }
Example #31
0
            public Parameters(Scenario scenario, bool defaultAll)
            {
                mDefaultAll = defaultAll;

                mStats = scenario;

                mManager = scenario.Manager;

                mName = mManager.UnlocalizedName + " " + scenario.UnlocalizedName;

                IFriendlyScenario friendly = scenario as IFriendlyScenario;
                if (friendly != null)
                {
                    mIsFriendly = friendly.IsFriendly;
                }

                IRomanticScenario romantic = scenario as IRomanticScenario;
                if (romantic != null)
                {
                    mIsRomantic = romantic.IsRomantic;
                }

                mAbsoluteScoring = false;
            }
Example #32
0
            public Parameters(ManagerProgressionBase manager, bool absolute, int scoreDelta, AllowFunc testAllow)
            {
                mTestAllow = testAllow;

                mStats = manager.Scoring;

                mScoreDelta = scoreDelta;

                mManager = manager;

                mIsFriendly = true;

                mIsRomantic = false;

                mDefaultAll = false;

                mAbsoluteScoring = absolute;

                mName = manager.UnlocalizedName;
            }