Esempio n. 1
0
        protected override bool Perform(SkillNames skill)
        {
            foreach (RabbitHole hole in Sims3.Gameplay.Queries.GetObjects <RabbitHole>())
            {
                foreach (InteractionObjectPair pair in hole.Interactions)
                {
                    RabbitHole.AttendClassInRabbitHole.Definition interaction = pair.InteractionDefinition as RabbitHole.AttendClassInRabbitHole.Definition;
                    if (interaction == null)
                    {
                        continue;
                    }

                    if (interaction.Skill != skill)
                    {
                        continue;
                    }

                    if (Situations.PushInteraction(this, Sim, hole, interaction))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 2
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Computer computer = ManagerLot.GetUsableComputer(Sim);

            if (computer == null)
            {
                IncStat("No Computer");
                return(false);
            }

            Career occupation = Sim.Occupation as Career;

            if (!occupation.CanWriteReport())
            {
                if (Sim.Occupation is LawEnforcement)
                {
                    LawEnforcement career = Sim.Occupation as LawEnforcement;

                    if (!career.CanInterview())
                    {
                        IncStat("Police Level Fail");
                        return(false);
                    }

                    foreach (SimDescription sim in Sims.Adults)
                    {
                        if (career.HasSimBeenInterviewed(sim))
                        {
                            continue;
                        }

                        career.SimInterviewed(sim);
                        break;
                    }
                }
                else if (Sim.Occupation is Journalism)
                {
                    Journalism career = Sim.Occupation as Journalism;

                    if (!career.CanInterview())
                    {
                        IncStat("Journalism Level Fail");
                        return(false);
                    }

                    foreach (SimDescription sim in Sims.Adults)
                    {
                        if (career.HasSimBeenInterviewed(sim))
                        {
                            continue;
                        }

                        career.SimInterviewed(sim);
                        break;
                    }
                }
            }

            return(Situations.PushInteraction <Computer>(this, Sim, computer, Computer.WriteReport.Singleton));
        }
Esempio n. 3
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            bool pushed = false;

            Gardening gardeningSkill = Sim.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);

            List <HarvestPlant> plants = GatherPlants();

            if ((plants == null) || (plants.Count == 0))
            {
                IncStat("No Plants");
                return(false);
            }

            int index = 0;

            while (index < plants.Count)
            {
                HarvestPlant plant = plants[index];

                if ((plant is Sims3.Gameplay.Objects.Gardening.OmniPlant) || (!Sims3.Gameplay.Objects.Gardening.HarvestPlant.HarvestTest(plant, null)))
                {
                    IncStat("Unharvestable");
                    plants.RemoveAt(index);
                    continue;
                }
                else if (!plant.CanProduceMoreHarvestables())
                {
                    if ((gardeningSkill != null) && (gardeningSkill.SkillLevel <= plant.PlantDef.GetSkillRequirement()))
                    {
                        plant.mLifetimeHarvestablesYielded = 0;

                        IncStat("Replanted");
                    }
                    else
                    {
                        IncStat("Skill Too Low");

                        index++;
                        continue;
                    }
                }

                if (Situations.PushInteraction(this, Sim, plant, HarvestEx.Singleton))
                {
                    plants.RemoveAt(index);

                    pushed = true;
                }
                else
                {
                    IncStat("Failure");
                    break;
                }
            }

            return(pushed);
        }
Esempio n. 4
0
        protected override bool Push()
        {
            if (!mPush)
            {
                return(false);
            }

            return(Situations.PushInteraction(this, Sim, Sim.CreatedSim, Sims3.Gameplay.Actors.Sim.GoToLibrary.Singleton as InteractionDefinition));
        }
Esempio n. 5
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            bool success = false;

            while (mCollectables.Count > 0)
            {
                GameObject choice = RandomUtil.GetRandomObjectFromList(mCollectables);
                mCollectables.Remove(choice);

                InteractionDefinition interaction = null;
                if (choice is RockGemMetalBase)
                {
                    interaction = CollectEx.Singleton;

                    IncStat("Collect");
                }
                else if (choice is MinorPet)
                {
                    interaction = CaptureEx.Singleton;

                    IncStat("Capture");
                }
                else if (choice is InsectJig)
                {
                    interaction = CatchInsectEx.Singleton;

                    IncStat("CatchInsect");
                }
                else if ((choice is DigSite) && (Sim.TeenOrAbove))
                {
                    interaction = Excavate.Singleton;

                    IncStat("Excavate");
                }
                else
                {
                    continue;
                }

                if (Situations.PushInteraction(this, Sim, choice, interaction))
                {
                    IncStat("Pushed");
                    success = true;
                }
                else
                {
                    break;
                }
            }

            return(success);
        }
Esempio n. 6
0
        protected bool Perform(Book book)
        {
            if ((book != null) && (Inventories.TryToMove(book, Sim.CreatedSim)))
            {
                if (Situations.PushInteraction(this, Sim, book, ReadBook.FromSimInventorySingleton))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 7
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <RabbitHole> schools = new List <RabbitHole>(Sims3.Gameplay.Queries.GetObjects <SchoolRabbitHole>());

            if (schools.Count == 0)
            {
                return(false);
            }

            RabbitHole choice = RandomUtil.GetRandomObjectFromList(schools);

            return(Situations.PushInteraction(this, Sim, choice, Education.GiveLectureInAtRabbitHole.Singleton));
        }
Esempio n. 8
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            Computer computer = ManagerLot.GetUsableComputer(Sim);

            if (computer == null)
            {
                IncStat("No Computer");
                return(false);
            }

            return(Situations.PushInteraction(this, Sim, computer, HackEx.Singleton));
        }
Esempio n. 9
0
 protected override bool Push()
 {
     if (mRabbitHole != null)
     {
         return(Situations.PushInteraction(this, Sim, mRabbitHole, InvestInRabbithole.InvestSingleton));
     }
     else if (mLot != null)
     {
         return(Situations.PushInteraction(this, Sim, mLot, PurchaseVenueEx.Singleton));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 10
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <ShowVenue> list = new List <ShowVenue>(Sims3.Gameplay.Queries.GetObjects <ShowVenue>());

            foreach (ShowVenue hole in list)
            {
                GreyedOutTooltipCallback tooltip = null;
                if (hole.PerformConcertAllowed(ref tooltip))
                {
                    return(Situations.PushInteraction(this, Sim, hole, PerformConcert.Singleton));
                }
            }

            return(false);
        }
Esempio n. 11
0
        protected override bool Push()
        {
            Book choice = null;

            foreach (Book journal in Inventories.InventoryFindAll <Book>(Sim, true, OnTest))
            {
                if (Book.HasBeenRead(Sim, journal.Data.ID))
                {
                    continue;
                }

                choice = journal;
                break;
            }

            return(Situations.PushInteraction <Book>(this, Sim, choice, ReadBook.FromSimInventorySingleton));
        }
Esempio n. 12
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            DogHuntingSkill skill = Sim.SkillManager.AddElement(SkillNames.DogHunting) as DogHuntingSkill;

            if (skill == null)
            {
                IncStat("Skill Fail");
                return(false);
            }

            if (Situations.PushInteraction <Terrain>(this, Sim, Terrain.Singleton, Terrain.SniffOut.SniffOutSingleton))
            {
                return(true);
            }

            IncStat("Sniff Out Fail");
            return(false);
        }
Esempio n. 13
0
        protected bool ProgressPrivateEye(Occupation occupation)
        {
            if (!Test(Sim.CreatedSim, PoliceStation.LowLevelPoliceWork.Singleton))
            {
                PoliceStation.LowLevelPoliceWork interaction = Sim.CreatedSim.InteractionQueue.GetCurrentInteraction() as PoliceStation.LowLevelPoliceWork;
                if (interaction != null)
                {
                    if (interaction.CurrentTone == null)
                    {
                        List <ITone> allTones = new List <ITone>();

                        foreach (InteractionToneDisplay tone in interaction.AvailableTonesForDisplay())
                        {
                            allTones.Add(tone.InteractionTone);
                        }

                        string name = null;
                        if (CareerToneScenario.SetTone(interaction, allTones, ref name))
                        {
                            IncStat("Private Eye Tone");
                        }
                    }
                }

                return(true);
            }
            ;

            RabbitHole hole = ManagerSituation.FindRabbitHole(RabbitHoleType.PoliceStation);

            if (hole == null)
            {
                IncStat("No Police Station");
                return(false);
            }

            return(Situations.PushInteraction <RabbitHole>(this, Sim, hole, PoliceStation.LowLevelPoliceWork.Singleton));
        }
Esempio n. 14
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <GameObject> easels  = new List <GameObject>();
            List <GameObject> empties = new List <GameObject>();

            /*
             * foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
             * {
             *  foreach (DraftingTable table in lot.GetObjects<DraftingTable>())
             *  {
             *      if (table.Stool == null) continue;
             *
             *      if (table.InUse) continue;
             *
             *      DraftingTable.Canvas draft = table.Draft;
             *      if (draft != null)
             *      {
             *          if (!table.IsDraftValid(Sim.CreatedSim, SkillNames.Painting, OccupationNames.Undefined))
             *          {
             *              continue;
             *          }
             *
             *          if (draft.IsComplete)
             *          {
             *              if (!Situations.PushInteraction(Sim, table, DraftingTable.TakeDraft.Singleton))
             *              {
             *                  continue;
             *              }
             *          }
             *          else
             *          {
             *              easels.Add(table);
             *          }
             *      }
             *      else
             *      {
             *          empties.Add(table);
             *      }
             *  }
             * }
             * if (easels.Count == 0)
             * {
             *  easels.AddRange(empties);
             * }
             */

            if (easels.Count == 0)
            {
                foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
                {
                    foreach (Easel easel in lot.GetObjects <Easel>())
                    {
                        if (easel.CanSell(Sim.CreatedSim))
                        {
                            TakePainting(easel, Sim.CreatedSim);
                        }

                        if (!easel.CanPaint(Sim.CreatedSim))
                        {
                            continue;
                        }

                        if (easel.CurrentCanvas != null)
                        {
                            easels.Add(easel);
                        }
                        else
                        {
                            empties.Add(easel);
                        }
                    }
                }

                if (easels.Count == 0)
                {
                    easels.AddRange(empties);
                }
            }

            if (easels.Count == 0)
            {
                IncStat("No Easel");
                return(false);
            }

            GameObject choice = RandomUtil.GetRandomObjectFromList(easels);

            if (choice is Easel)
            {
                return(Situations.PushInteraction(this, Sim, choice, PaintEx.Singleton));
            }
            else
            {
                return(Situations.PushInteraction(this, Sim, choice, DraftingTable.Research.SingletonPainting));
            }
        }
Esempio n. 15
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            ManagedBuyProduct <ComputerLaptop> .Purchase(Sim, 0, this, UnlocalizedName, null, BuildBuyProduct.eBuyCategory.kBuyCategoryElectronics, BuildBuyProduct.eBuySubCategory.kBuySubCategoryComputers);

            List <Computer> computers = new List <Computer>();

            List <Computer> inventory = new List <Computer>();

            foreach (Computer computer in Inventories.InventoryFindAll <Computer>(Sim))
            {
                inventory.Add(computer);

                if (!computer.IsComputerUsable(Sim.CreatedSim, true, false, true))
                {
                    continue;
                }

                computers.Add(computer);
            }

            if (computers.Count == 0)
            {
                Computer broken = null;

                foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
                {
                    foreach (Computer computer in lot.GetObjects <Computer>())
                    {
                        if (!computer.IsComputerUsable(Sim.CreatedSim, true, false, true))
                        {
                            broken = computer;
                            continue;
                        }

                        computers.Add(computer);
                    }
                }

                if (computers.Count == 0)
                {
                    if (inventory.Count > 0)
                    {
                        foreach (Computer computer in inventory)
                        {
                            Money.Sell(Sim, computer);
                        }

                        IncStat("Sell Broken");
                    }

                    if (broken != null)
                    {
                        IncStat("Push Repair");

                        Add(frame, new ScheduledRepairScenario(Sim, broken), ScenarioResult.Start);
                        return(false);
                    }
                    else
                    {
                        IncStat("No Computer");
                        return(false);
                    }
                }
            }
            else if ((Sim.CreatedSim.LotCurrent == null) || (!Sim.CreatedSim.LotCurrent.CanSimTreatAsHome(Sim.CreatedSim)))
            {
                Situations.PushGoHome(this, Sim);
            }

            if (GetValue <RefineWritingOption, bool>())
            {
                return(Situations.PushInteraction(this, Sim, RandomUtil.GetRandomObjectFromList(computers), Computer.PracticeWriting.Singleton));
            }
            else
            {
                return(Situations.PushInteraction(this, Sim, RandomUtil.GetRandomObjectFromList(computers), NRaas.StoryProgressionSpace.Interactions.WriteNovelEx.Singleton));
            }
        }
Esempio n. 16
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (!mSuccess.TestBeforehand(Manager, Sim, Target))
            {
                IncStat("Success TestBeforehand Fail");
                return(false);
            }

            if (!mFailure.TestBeforehand(Manager, Sim, Target))
            {
                IncStat("Failure TestBeforehand Fail");
                return(false);
            }

            mFail = false;
            if (!string.IsNullOrEmpty(mSneakinessScoring))
            {
                foreach (SimDescription member in CommonSpace.Helpers.Households.All(Target.Household))
                {
                    if (AddScoring("Target Sneak", ScoringLookup.GetScore(mSneakinessScoring, member)) > AddScoring("Sim Sneak", ScoringLookup.GetScore(mSneakinessScoring, Sim)))
                    {
                        mFail = true;
                        break;
                    }
                }
            }

            if (!base.PrivateUpdate(frame))
            {
                return(false);
            }

            if (mFail)
            {
                if (!Situations.PushVisit(this, Sim, Target.LotHome))
                {
                    IncStat("Push Fail");
                    return(false);
                }

                mFailure.Perform(this, frame, "Failure", Sim, Target);
                return(true);
            }
            else
            {
                List <Origin> types = new List <Origin>(sTypes);

                while (types.Count > 0)
                {
                    Origin type = RandomUtil.GetRandomObjectFromList(types);
                    types.Remove(type);

                    IncStat("Try " + type);

                    GameObject boobyTrap = null;

                    switch (type)
                    {
                    case Origin.FromPrankDoorbellDitch:
                        if (!mAllowDoorPranks)
                        {
                            continue;
                        }

                        if (Situations.PushInteraction(this, Sim, Target.LotHome, Door.PrankDoorbellDitch.Singleton))
                        {
                            return(true);
                        }
                        break;

                    case Origin.FromPrankFlamingBag:
                        if (!mAllowDoorPranks)
                        {
                            continue;
                        }

                        if (Situations.PushInteraction(this, Sim, Target.LotHome, Door.PrankFlamingBag.Singleton))
                        {
                            return(true);
                        }
                        break;

                    case Origin.FromPrankThrowingEggs:
                        if (!mAllowDoorPranks)
                        {
                            continue;
                        }

                        if (Situations.PushInteraction(this, Sim, Target.LotHome, Door.PrankThrowingEggs.Singleton))
                        {
                            return(true);
                        }
                        break;

                    case Origin.FromPrankToilet:
                        Toilet[] toilets = Target.LotHome.GetObjects <Toilet>();
                        if (toilets.Length > 0)
                        {
                            boobyTrap = RandomUtil.GetRandomObjectFromList(toilets);
                        }
                        break;

                    case Origin.FromPrankSink:
                        Sink[] sinks = Target.LotHome.GetObjects <Sink>();
                        if (sinks.Length > 0)
                        {
                            boobyTrap = RandomUtil.GetRandomObjectFromList(sinks);
                        }
                        break;

                    case Origin.FromPrankShower:
                        Shower[] showers = Target.LotHome.GetObjects <Shower>();
                        if (showers.Length > 0)
                        {
                            boobyTrap = RandomUtil.GetRandomObjectFromList(showers);
                        }
                        break;

                    case Origin.FromPrankWhoopeeCushion:
                        ChairDining[] chairs = Target.LotHome.GetObjects <ChairDining>();
                        if (chairs.Length > 0)
                        {
                            boobyTrap = RandomUtil.GetRandomObjectFromList(chairs);
                        }
                        break;

                    case Origin.FromPrankComputer:
                        Computer[] computers = Target.LotHome.GetObjects <Computer>();
                        if (computers.Length > 0)
                        {
                            if (Situations.PushInteraction(this, Sim, RandomUtil.GetRandomObjectFromList(computers), Computer.SetBoobyTrap.Singleton))
                            {
                                mSuccess.Perform(this, frame, "Success", Sim, Target);
                                return(true);
                            }
                        }
                        break;
                    }

                    if (boobyTrap != null)
                    {
                        if (Situations.PushInteraction(this, Sim, boobyTrap, SetBoobyTrap.Singleton))
                        {
                            mSuccess.Perform(this, frame, "Success", Sim, Target);
                            return(true);
                        }
                    }
                }

                IncStat("No Choices");
                return(false);
            }
        }
Esempio n. 17
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <GameObject> tables  = new List <GameObject>();
            List <GameObject> empties = new List <GameObject>();

            OccupationNames occupation = OccupationNames.Undefined;
            SkillNames      skill      = SkillNames.Painting;

            if (Sim.CreatedSim.Occupation is Stylist)
            {
                skill      = SkillNames.Styling;
                occupation = OccupationNames.Stylist;
            }
            else if (Sim.CreatedSim.Occupation is InteriorDesigner)
            {
                occupation = OccupationNames.InteriorDesigner;
            }

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim.Household))
            {
                foreach (DraftingTable table in lot.GetObjects <DraftingTable>())
                {
                    if (table.Stool == null)
                    {
                        continue;
                    }

                    if (table.InUse)
                    {
                        continue;
                    }

                    DraftingTable.Canvas draft = table.Draft;
                    if (draft != null)
                    {
                        if (!table.IsDraftValid(Sim.CreatedSim, skill, occupation))
                        {
                            IncStat("Draft Mismatch");
                            continue;
                        }
                        else if ((draft.IsComplete) && (!TakeDraft(table)))
                        {
                            IncStat("Take Fail");
                            continue;
                        }
                        else
                        {
                            tables.Add(table);
                        }
                    }
                    else
                    {
                        empties.Add(table);
                    }
                }
            }

            if (tables.Count == 0)
            {
                tables.AddRange(empties);
            }

            if (tables.Count == 0)
            {
                IncStat("No Tables");
                return(false);
            }

            GameObject choice = RandomUtil.GetRandomObjectFromList(tables);

            if (Sim.CreatedSim.Occupation is Stylist)
            {
                return(Situations.PushInteraction(this, Sim, choice, DraftingTable.Research.SingletonStylist));
            }
            else if (Sim.CreatedSim.Occupation is InteriorDesigner)
            {
                return(Situations.PushInteraction(this, Sim, choice, DraftingTable.Research.SingletonInteriorDesigner));
            }
            else
            {
                return(Situations.PushInteraction(this, Sim, choice, DraftingTable.Research.SingletonPainting));
            }
        }
Esempio n. 18
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <NectarMaker> choices = new List <NectarMaker>();
            NectarMaker        best = null, broken = null;

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (NectarMaker maker in lot.GetObjects <NectarMaker>())
                {
                    if (!maker.Repairable.Broken)
                    {
                        choices.Add(maker);
                        if (maker.Inventory.IsFull())
                        {
                            best = maker;
                        }
                    }
                    else
                    {
                        broken = maker;
                    }

                    foreach (NectarBottle bottle in maker.mBottles)
                    {
                        Inventories.TryToMove(bottle, Sim.CreatedSim);
                    }

                    AddStat("Collected Bottles", maker.mBottles.Count);

                    maker.mBottles.Clear();
                }
            }

            List <NectarRack> racks = new List <NectarRack>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (NectarRack rack in lot.GetObjects <NectarRack>())
                {
                    if (rack.HasTreasure())
                    {
                        continue;
                    }

                    if (rack.Buyable)
                    {
                        continue;
                    }

                    if (rack.Tasteable)
                    {
                        continue;
                    }

                    if (rack.Inventory.IsFull())
                    {
                        continue;
                    }

                    racks.Add(rack);
                }
            }

            if (racks.Count > 0)
            {
                List <NectarBottle> bottles = new List <NectarBottle>(Inventories.InventoryFindAll <NectarBottle>(Sim));
                foreach (NectarBottle bottle in bottles)
                {
                    if (!bottle.CanBeSold())
                    {
                        continue;
                    }

                    NectarRack rack = RandomUtil.GetRandomObjectFromList(racks);

                    IncStat("Rack Stored");
                    rack.Inventory.TryToMove(bottle);

                    if (rack.Inventory.IsFull())
                    {
                        racks.Remove(rack);
                        if (racks.Count == 0)
                        {
                            break;
                        }
                    }
                }
            }

            if (best != null)
            {
                choices.Clear();
                choices.Add(best);
            }

            if (choices.Count == 0)
            {
                if (broken != null)
                {
                    IncStat("Attempt Repair");

                    Add(frame, new ScheduledRepairScenario(Sim, broken), ScenarioResult.Start);
                }
                else
                {
                    IncStat("No Choice");
                }
                return(false);
            }

            NectarMaker choice = RandomUtil.GetRandomObjectFromList(choices);

            if (!choice.Inventory.IsFull())
            {
                List <Ingredient> list = new List <Ingredient>(Inventories.InventoryFindAll <Ingredient>(Sim));

                while (list.Count > 0)
                {
                    Ingredient ingredient = RandomUtil.GetRandomObjectFromList(list);
                    list.Remove(ingredient);

                    if (!choice.CanAddToInventory(ingredient))
                    {
                        continue;
                    }

                    if (choice.Inventory.TryToMove(ingredient))
                    {
                        IncStat("Added: " + ingredient.CatalogName);
                    }

                    if (choice.Inventory.IsFull())
                    {
                        break;
                    }
                }
            }

            if (choice.Inventory.IsFull())
            {
                if ((ManagerCareer.HasSkillCareer(Sim, SkillNames.Nectar)) ||
                    (!ManagerCareer.HasSkillCareer(Sim.Household, SkillNames.Nectar)))
                {
                    int skillLevel = Sim.SkillManager.GetSkillLevel(SkillNames.Nectar);

                    List <NectarMaker.MakeNectarStyle> styles = new List <NectarMaker.MakeNectarStyle>();

                    styles.Add(NectarMaker.MakeNectarStyle.Basic);

                    if (skillLevel >= NectarMaker.kConcentratedUnlockLevel)
                    {
                        styles.Add(NectarMaker.MakeNectarStyle.Concentrated);
                    }
                    if (skillLevel >= NectarMaker.kMassProduceUnlockLevel)
                    {
                        styles.Add(NectarMaker.MakeNectarStyle.MassProduce);
                    }
                    if (skillLevel >= NectarMaker.kExtendedNectarationUnlockLevel)
                    {
                        styles.Add(NectarMaker.MakeNectarStyle.ExtendedNectaration);
                    }

                    return(Situations.PushInteraction(this, Sim, choice, new MakeNectarEx.Definition(RandomUtil.GetRandomObjectFromList(styles))));
                }
                else
                {
                    IncStat("Not Job");
                    return(false);
                }
            }
            else
            {
                IncStat("Not Full");
                return(false);
            }
        }
Esempio n. 19
0
            protected override bool PrivateUpdate(ScenarioFrame frame)
            {
                mPushes++;

                if (Sim.CreatedSim == null)
                {
                    IncStat("Hibernating");
                    return false;
                }
                else if (Sim.CreatedSim.InteractionQueue == null)
                {
                    IncStat("No Queue");
                    return false;
                }

                if (mPushes <= 1)
                {
                    Sim.CreatedSim.InteractionQueue.CancelAllInteractions();
                }

                bool maxSkill = true;

                List<SkillNames> practiceSkills = new List<SkillNames>();

                RidingSkill riding = Sim.SkillManager.GetSkill<RidingSkill>(SkillNames.Riding);
                if ((riding == null) || (!riding.ReachedMaxLevel()))
                {
                    maxSkill = false;

                    practiceSkills.Add(SkillNames.Riding);
                }

                Racing racing = mHorse.SkillManager.GetSkill<Racing>(SkillNames.Racing);
                if ((racing == null) || (!racing.ReachedMaxLevel()))
                {
                    maxSkill = false;

                    practiceSkills.Add(SkillNames.Racing);
                }

                Jumping jumping = mHorse.SkillManager.GetSkill<Jumping>(SkillNames.Jumping);
                if ((jumping == null) || (!jumping.ReachedMaxLevel()))
                {
                    maxSkill = false;

                    practiceSkills.Add(SkillNames.Jumping);
                }

                List<EquestrianCenter> lotCenters = new List<EquestrianCenter>();
                List<EquestrianCenter> centers = new List<EquestrianCenter>();
                foreach (EquestrianCenter hole in Sims3.Gameplay.Queries.GetObjects<EquestrianCenter>())
                {
                    if (Sim.CreatedSim.LotCurrent == hole.LotCurrent)
                    {
                        lotCenters.Add(hole);
                    }

                    centers.Add(hole);
                }

                if (lotCenters.Count > 0)
                {
                    centers = lotCenters;
                }

                EquestrianCenter center = null;

                if (centers.Count > 0)
                {
                    center = RandomUtil.GetRandomObjectFromList(centers);
                }
                else
                {
                    IncStat("No Centers");
                }

                if (center != null)
                {
                    CompetitionType type = CompetitionType.Racing;

                    bool canCompete = (maxSkill) || (RandomUtil.CoinFlip());

                    if (canCompete)
                    {
                        List<CompetitionType> types = new List<CompetitionType>(sTypes);

                        while (types.Count > 0)
                        {
                            type = RandomUtil.GetRandomObjectFromList(types);
                            types.Remove(type);

                            canCompete = false;

                            switch (type)
                            {
                                case CompetitionType.CrossCountry:
                                    if (RidingSkill.CanEnterCrossCountryCompetition(Sim))
                                    {
                                        canCompete = true;
                                    }
                                    break;
                                case CompetitionType.Jumping:
                                    if (!RidingSkill.CanEnterJumpingCompetition(Sim))
                                    {
                                        canCompete = true;
                                    }
                                    break;
                                case CompetitionType.Racing:
                                    if (!RidingSkill.CanEnterRacingCompetition(Sim))
                                    {
                                        canCompete = true;
                                    }
                                    break;
                            }

                            if (canCompete)
                            {
                                break;
                            }
                        }
                    }

                    if (canCompete)
                    {
                        List<CompetitionLevel> levels = new List<CompetitionLevel>();

                        foreach (CompetitionLevel level in sLevels)
                        {
                            GreyedOutTooltipCallback callback = null;
                            if (EquestrianCenter.EnterEquestrianCompetition.CanEnterCompetition(type, level, Sim.CreatedSim, false, ref callback))
                            {
                                levels.Add(level);
                            }
                        }

                        if (levels.Count == 0)
                        {
                            IncStat("No Levels");
                        }
                        else
                        {
                            CompetitionLevel level = RandomUtil.GetRandomObjectFromList(levels);

                            if (Common.kDebugging)
                            {
                                Common.DebugNotify("Compete " + type + " " + level, Sim.CreatedSim);
                            }

                            if (!Situations.PushVisit(this, Sim, center.LotCurrent))
                            {
                                IncStat("Visit Fail");
                                return false;
                            }
                            else if (Situations.PushInteraction<EquestrianCenter>(this, Sim, center, new EnterEquestrianCompetitionEx.Definition(type, level)))
                            {
                                return true;
                            }
                            else
                            {
                                IncStat("Competition Fail");
                            }
                        }
                    }
                }

                if (practiceSkills.Count == 0)
                {
                    IncStat("No Practice Skills");
                    return false;
                }

                bool practiceJumping = true;

                if ((riding != null) & (riding.SkillLevel >= RidingSkill.kLevelForTrainForRacing))
                {
                    switch (RandomUtil.GetRandomObjectFromList(practiceSkills))
                    {
                        case SkillNames.Riding:
                            practiceJumping = RandomUtil.CoinFlip();
                            break;
                        case SkillNames.Racing:
                            practiceJumping = false;
                            break;
                    }
                }

                if (!practiceJumping)
                {
                    List<TrainingPosts> lotPosts = new List<TrainingPosts>();
                    List<TrainingPosts> posts = new List<TrainingPosts>();
                    foreach(TrainingPosts post in Sims3.Gameplay.Queries.GetObjects<TrainingPosts>())
                    {
                        if (Sim.CreatedSim.LotCurrent == post.LotCurrent)
                        {
                            lotPosts.Add(post);
                        }

                        posts.Add(post);
                    }

                    if (lotPosts.Count > 0)
                    {
                        posts = lotPosts;
                    }

                    if (posts.Count > 0)
                    {
                        TrainingPosts choice = RandomUtil.GetRandomObjectFromList(posts);

                        if (!Situations.PushVisit(this, Sim, choice.LotCurrent))
                        {
                            IncStat("Visit Fail");
                            return false;
                        }
                        else if (Situations.PushInteraction<TrainingPosts>(this, Sim, choice, new ManagerSituation.WithCallbackPush(Manager, TrainingPosts.RiderTrainForRacing.Singleton, null, null, new MountScenario(Sim, mPushes))))
                        {
                            return true;
                        }
                        else
                        {
                            IncStat("Traning Fail");
                        }
                    }
                }

                int ridingSkill = 0;
                if (riding != null)
                {
                    ridingSkill = riding.SkillLevel;
                }

                List<HorseJump> lotJumps = new List<HorseJump>();
                List<HorseJump> jumps = new List<HorseJump>();
                foreach (HorseJump jump in Sims3.Gameplay.Queries.GetObjects<HorseJump>())
                {
                    if (jump.LotCurrent == null) continue;

                    if (!jump.LotCurrent.IsCommunityLot)
                    {
                        if (!jump.LotCurrent.CanSimTreatAsHome(Sim.CreatedSim)) continue;
                    }

                    if (jump.JumpTuning == null) continue;

                    if (jump.JumpTuning.HighSuccessChances[ridingSkill] < 0.75) continue;

                    if (Sim.CreatedSim.LotCurrent == jump.LotCurrent)
                    {
                        lotJumps.Add(jump);
                    }

                    jumps.Add(jump);
                }

                if (lotJumps.Count > 0)
                {
                    jumps = lotJumps;
                }

                if (jumps.Count > 0)
                {
                    HorseJump choice = RandomUtil.GetRandomObjectFromList(jumps);

                    if (!Situations.PushVisit(this, Sim, choice.LotCurrent))
                    {
                        IncStat("Visit Fail");
                        return false;
                    }
                    else if (Situations.PushInteraction<HorseJump>(this, Sim, choice, new ManagerSituation.WithCallbackPush(Manager, HorseJump.Jump.Singleton, null, null, new MountScenario(Sim, mPushes))))
                    {
                        return true;
                    }
                    else
                    {
                        IncStat("Jump Fail");
                        return false;
                    }
                }
                else
                {
                    IncStat("No Jump Choices");
                    return false;
                }
            }
Esempio n. 20
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            CatHuntingSkill skill = Sim.SkillManager.AddElement(SkillNames.CatHunting) as CatHuntingSkill;

            if (skill == null)
            {
                IncStat("Skill Fail");
                return(false);
            }

            if ((skill.SkillLevel < 1) || (!skill.CanCatchAnything()) || (RandomUtil.RandomChance(25)))
            {
                PopulateFishingPoints();

                List <GameObjectHit> fishingSpots = new List <GameObjectHit>();
                foreach (Pair <Lot, GameObjectHit> pair in sFishingPoints)
                {
                    if ((pair.First.IsCommunityLot) || (pair.First.CanSimTreatAsHome(Sim.CreatedSim)))
                    {
                        fishingSpots.Add(pair.Second);
                    }
                }

                if (fishingSpots.Count != 0x0)
                {
                    Terrain.CatFishHere fishing = Terrain.CatFishHere.Singleton.CreateInstance(Terrain.Singleton, Sim.CreatedSim, Sim.CreatedSim.InheritedPriority(), true, true) as Terrain.CatFishHere;
                    if (fishing == null)
                    {
                        IncStat("Fish Creation Fail");
                    }
                    else
                    {
                        fishing.Hit = RandomUtil.GetRandomObjectFromList <GameObjectHit>(fishingSpots);

                        if (Situations.PushInteraction(this, Sim, Managers.Manager.AllowCheck.Active, fishing))
                        {
                            return(true);
                        }

                        IncStat("Fish Fail");
                    }
                }
                else
                {
                    IncStat("No Fishing Spots");
                }
            }

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

            foreach (SimDescription sim in new SimScoringList(this, "LikesCats", HouseholdsEx.Humans(Sim.Household), false).GetBestByMinScore(1))
            {
                if (sim.ChildOrBelow)
                {
                    continue;
                }

                choices.Add(sim);
            }

            if (choices.Count == 0)
            {
                IncStat("No Master");
                return(false);
            }

            CatHuntingComponent.StalkForPrey interaction = CatHuntingComponent.StalkForPrey.Singleton.CreateInstance(Sim.CreatedSim, Sim.CreatedSim, Sim.CreatedSim.InheritedPriority(), true, true) as CatHuntingComponent.StalkForPrey;
            if (interaction == null)
            {
                IncStat("Catch Creation Fail");
                return(false);
            }

            interaction.PushedByGoCatch         = true;
            interaction.PickAnyPrey             = true;
            interaction.PresentToID             = RandomUtil.GetRandomObjectFromList(choices).SimDescriptionId;
            interaction.ForceCatchFailureObject = false;

            if (Situations.PushInteraction(this, Sim, Managers.Manager.AllowCheck.Active, interaction))
            {
                return(true);
            }

            IncStat("Catch Prey Fail");
            return(false);
        }
Esempio n. 21
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Occupation occupation = Occupation;

            if (occupation is PrivateEye)
            {
                return(ProgressPrivateEye(occupation));
            }
            else if (occupation is Stylist)
            {
                if (!Test(Sim.CreatedSim, DraftingTable.Research.SingletonStylist))
                {
                    return(false);
                }

                Add(frame, new DraftingPushScenario(Sim), ScenarioResult.Start);
                return(true);
            }
            else if (occupation is InteriorDesigner)
            {
                if (!Test(Sim.CreatedSim, DraftingTable.Research.SingletonStylist))
                {
                    return(false);
                }

                Add(frame, new DraftingPushScenario(Sim), ScenarioResult.Start);
                return(true);
            }
            else if (occupation is GhostHunter)
            {
                return(ProgressJobBased(occupation as ActiveCareer));
            }
            else if (occupation is ActiveFireFighter)
            {
                if (Sim.CreatedSim.GetSituationOfType <FirefighterSituation>() != null)
                {
                    IncStat("In Situation");
                    return(true);
                }

                if ((Household.ActiveHousehold == null) || (Household.ActiveHousehold.LotHome == null))
                {
                    IncStat("No Active Household");
                    return(true);
                }

                if (occupation.ActiveCareerLotID != Sim.CreatedSim.LotCurrent.LotId)
                {
                    return(Situations.PushInteraction(this, Sim, Managers.Manager.AllowCheck.None, occupation.GetInteractionToTakeSimToWork()));
                }

                if (Sim.CreatedSim.InteractionQueue.HasInteractionOfType(AthleticGameObject.WorkOut.Singleton))
                {
                    IncStat("Relax");

                    Sim.CreatedSim.InteractionQueue.CancelAllInteractions();
                    return(true);
                }

                bool activeFirefighter = false;

                if (!GetValue <AllowInactiveFireRepairOption, bool>())
                {
                    foreach (Sim sim in HouseholdsEx.AllSims(Household.ActiveHousehold))
                    {
                        if (sim.Occupation is ActiveFireFighter)
                        {
                            activeFirefighter = true;
                            break;
                        }
                    }
                }

                if ((!activeFirefighter) && (RandomUtil.CoinFlip()))
                {
                    List <GameObject> objs = new List <GameObject>();

                    foreach (GameObject obj in Sim.CreatedSim.LotCurrent.GetObjects <GameObject>())
                    {
                        if (obj.MaintenenceComponent == null)
                        {
                            continue;
                        }

                        objs.Add(obj);
                    }

                    if (objs.Count == 0)
                    {
                        IncStat("No Maintain Objects");
                        return(false);
                    }

                    IncStat("Maintain");

                    GameObject choice = RandomUtil.GetRandomObjectFromList(objs);

                    choice.MaintenenceComponent.MaintenanceLevel = 0;

                    return(Situations.PushInteraction <GameObject>(this, Sim, choice, MaintenanceComponent.MaintainObject.Singleton));
                }
                else
                {
                    List <AthleticGameObject> objs = new List <AthleticGameObject>();

                    foreach (AthleticGameObject obj in Sim.CreatedSim.LotCurrent.GetObjects <AthleticGameObject>())
                    {
                        objs.Add(obj);
                    }

                    if (objs.Count == 0)
                    {
                        IncStat("No Gym Objects");
                        return(false);
                    }

                    IncStat("Workout");

                    AthleticGameObject choice = RandomUtil.GetRandomObjectFromList(objs);

                    return(Situations.PushInteraction <AthleticGameObject>(this, Sim, choice, AthleticGameObject.WorkOut.Singleton));
                }
            }

            return(false);
        }
Esempio n. 22
0
        protected bool ProgressJobBased(ActiveCareer occupation)
        {
            List <InteractionDefinition> interactions = new List <InteractionDefinition>();

            Job job = GetExistingJob(occupation);

            if (job != null)
            {
                InteractionDefinition definition;
                GameObject            target;
                job.GetInteractionDefinitionAndTargetToGoToWork(out definition, out target);

                interactions.Add(definition);
            }

            if (!Test(Sim.CreatedSim, interactions))
            {
                return(false);
            }

            if (occupation.HasJobAtLot(Sim.CreatedSim.LotCurrent))
            {
                IncStat("Already On Site");
                return(false);
            }

            if (job == null)
            {
                List <JobId> choices = new List <JobId>();

                foreach (JobId id in occupation.GetCurrentLevelStaticData().RandomCustomerJobIds)
                {
                    if (IsValidJobId(id))
                    {
                        choices.Add(id);
                    }
                }

                if (choices.Count == 0)
                {
                    IncStat("No Choices");
                    return(false);
                }

                JobId jobId = RandomUtil.GetRandomObjectFromList(choices);

                JobCreationSpec jobCreationSpec;
                if (!occupation.TryCreateJobCreationSpec(jobId, out jobCreationSpec))
                {
                    IncStat("Creation Fail");
                    return(false);
                }

                if (!GetValue <AllowGhostHunterOnActiveOptionV2, bool>())
                {
                    if ((Household.ActiveHousehold == null) || (jobCreationSpec.mLot.CanSimTreatAsHome(Sims3.Gameplay.Actors.Sim.ActiveActor)))
                    {
                        IncStat("Active Lot Fail");
                        return(false);
                    }
                }

                jobCreationSpec.mStartTime = SimClock.CurrentTime();

                if (!TryCreateJobForCustomer(occupation, jobCreationSpec, occupation.GetCurrentLevelStaticData(), out job))
                {
                    IncStat("CreateJob Fail");
                    return(false);
                }

                if (job == null)
                {
                    IncStat("No Job");
                    return(false);
                }

                job.SetTimeoutAlarm((float)job.Specification.mHoursAvailable);
            }

            job.MapTagEnabled = true;

            job.SetCurrentJobLocation();

            if (!Situations.PushInteraction(this, Sim, Managers.Manager.AllowCheck.None, occupation.CreateGoToActiveCareerJobInteraction(job)))
            {
                IncStat("Push Fail");
                return(false);
            }

            IncStat("Pushed");
            return(true);
        }
Esempio n. 23
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            LaundryState state;

            if (!mPushed.TryGetValue(Sim.Household, out state))
            {
                state = new LaundryState();
                mPushed.Add(Sim.Household, state);
            }

            List <GameObject> broken = new List <GameObject>();

            if (!state.mDryer)
            {
                List <ClothingPileWet> wetPiles = new List <ClothingPileWet>(Sim.LotHome.GetObjects <ClothingPileWet>());

                foreach (ICanDryClothes obj in Sim.LotHome.GetObjects <ICanDryClothes>())
                {
                    if (obj.IsAvailible())
                    {
                        continue;
                    }

                    Clothesline line = obj as Clothesline;
                    if (line != null)
                    {
                        IncStat("Try Empty Line");

                        if (Situations.PushInteraction(this, Sim, line, Clothesline.GetCleanLaundry.Singleton))
                        {
                            state.mDryer = true;

                            IncStat("Push Empty Line");
                            return(true);
                        }

                        if (wetPiles.Count > 0)
                        {
                            ClothingPileWet pile = RandomUtil.GetRandomObjectFromList(wetPiles);
                            wetPiles.Remove(pile);

                            if (Situations.PushInteraction(this, Sim, pile, ClothingPileWet.DryClothesOnClothesline.Singleton))
                            {
                                state.mDryer = true;

                                IncStat("Hang Wet Pile");
                                return(true);
                            }
                        }
                    }
                    else
                    {
                        Dryer dryer = obj as Dryer;
                        if (dryer != null)
                        {
                            IncStat("Try Empty Dryer");

                            if (Situations.PushInteraction(this, Sim, dryer, Dryer.GetCleanLaundry.Singleton))
                            {
                                state.mDryer = true;

                                IncStat("Push Empty Dryer");
                                return(true);
                            }

                            if (wetPiles.Count > 0)
                            {
                                ClothingPileWet pile = RandomUtil.GetRandomObjectFromList(wetPiles);
                                wetPiles.Remove(pile);

                                if (Situations.PushInteraction(this, Sim, pile, ClothingPileWet.DryClothesInDryer.Singleton))
                                {
                                    state.mDryer = true;

                                    IncStat("Dry Wet Pile");
                                    return(true);
                                }
                            }

                            if ((dryer.Repairable != null) && (dryer.Repairable.Broken))
                            {
                                broken.Add(dryer);
                            }
                        }
                    }
                }
            }

            if (!state.mWasher)
            {
                foreach (WashingMachine machine in Sim.LotHome.GetObjects <WashingMachine>())
                {
                    if (machine.mWashState == WashingMachine.WashState.HasCleanLaundry)
                    {
                        if (WashingMachine.DryClothesBase.DoesClotheslineExist(Sim.LotHome))
                        {
                            IncStat("Try Clothesline");

                            if (Situations.PushInteraction(this, Sim, machine, WashingMachine.DryClothesOnClothesline.Singleton))
                            {
                                state.mWasher = true;

                                IncStat("Push Clothesline");
                                return(true);
                            }
                        }
                        else
                        {
                            IncStat("Try Dryer");

                            if (Situations.PushInteraction(this, Sim, machine, WashingMachine.DryClothesInDryer.Singleton))
                            {
                                state.mWasher = true;

                                IncStat("Push Dryer");
                                return(true);
                            }
                        }
                    }
                    else if (machine.CanDoLaundry())
                    {
                        IncStat("Try Washer");

                        if (Situations.PushInteraction(this, Sim, machine, WashingMachine.DoLaundry.Singleton))
                        {
                            state.mWasher = true;

                            IncStat("Push Washer");
                            return(true);
                        }
                    }

                    if ((machine.Repairable != null) && (machine.Repairable.Broken))
                    {
                        broken.Add(machine);
                    }
                }
            }

            if (broken.Count > 0)
            {
                IncStat("Repair Push");

                Add(frame, new ScheduledRepairScenario(Sim, RandomUtil.GetRandomObjectFromList(broken)), ScenarioResult.Start);
                return(true);
            }

            return(false);
        }
Esempio n. 24
0
 protected override bool PrivateUpdate(ScenarioFrame frame)
 {
     return(Situations.PushInteraction(this, Sim, RandomUtil.GetRandomObjectFromList(mSpots), FishAutonomouslyEx.Singleton));
 }
Esempio n. 25
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <SculptingStation> stations = new List <SculptingStation>();
            List <SculptingStation> empties  = new List <SculptingStation>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (SculptingStation station in lot.GetObjects <SculptingStation>())
                {
                    if (station.HasFinishedSculpture())
                    {
                        GameObject sculpture = station.GetCurrentSculpture();

                        station.OnHandToolChildUnslottedBase(sculpture, Slot.ContainmentSlot_0);

                        sculpture.UnParent();

                        if (!Sim.Household.SharedFamilyInventory.Inventory.TryToMove(sculpture))
                        {
                            int value = Money.Sell(Sim, sculpture);

                            AddStat("Sculpture Sold", value);
                        }
                        else
                        {
                            IncStat("Sculpture Stored");
                        }
                    }

                    if (station.HasUnfinishedSculpture())
                    {
                        GameObject currentSculpture = station.GetCurrentSculpture();
                        if ((currentSculpture != null) && (currentSculpture.SculptureComponent != null))
                        {
                            if (currentSculpture.SculptureComponent.Artist == Sim)
                            {
                                stations.Add(station);
                            }
                        }
                    }
                    else
                    {
                        empties.Add(station);
                    }
                }
            }

            if (stations.Count == 0)
            {
                stations.AddRange(empties);
            }

            if (stations.Count == 0)
            {
                IncStat("No Station");
                return(false);
            }

            SculptingStation choice = RandomUtil.GetRandomObjectFromList(stations);

            if (choice.HasUnfinishedSculpture())
            {
                IncStat("Sculpture Continued");

                return(Situations.PushInteraction(this, Sim, choice, ContinueSculptureEx.Singleton));
            }
            else
            {
                List <SculptureComponent.SculptureMaterial> materials = new List <SculptureComponent.SculptureMaterial>();

                int skillLevel = Sim.SkillManager.GetSkillLevel(SkillNames.Sculpting);

                skillLevel = Math.Max(0, skillLevel);

                foreach (SculptureComponent.SculptureMaterial material in Enum.GetValues(typeof(SculptureComponent.SculptureMaterial)))
                {
                    if (material == SculptureComponent.SculptureMaterial.None)
                    {
                        continue;
                    }

                    if (material == SculptureComponent.SculptureMaterial.Metal)
                    {
                        continue;
                    }

                    if (!SculptingSkill.HasLevelForMaterial(skillLevel, material))
                    {
                        continue;
                    }

                    if (!SculptingSkill.CanAfford(Sim.CreatedSim, material))
                    {
                        continue;
                    }

                    materials.Add(material);
                }

                if (materials.Count == 0)
                {
                    IncStat("No Material");
                    return(false);
                }

                SculptureComponent.SculptureMaterial materialChoice = RandomUtil.GetRandomObjectFromList(materials);

                List <SculptingSkill.SkillSculptureData> sculptures = SculptingSkill.ValidRandomSculpturesForLevelAndMaterial(skillLevel, materialChoice, Sim.CreatedSim);
                if (sculptures.Count == 0)
                {
                    IncStat("No Sculptures");
                    return(false);
                }

                SculptingSkill.SkillSculptureData sculptureChoice = RandomUtil.GetWeightedRandomObjectFromList(sculptures.ToArray()) as SculptingSkill.SkillSculptureData;

                IncStat("Sculpture Started");

                return(Situations.PushInteraction(this, Sim, choice, new CreateSculptureEx.Definition(null, sculptureChoice, materialChoice, new string[0])));
            }
        }
Esempio n. 26
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            InventingSkill skill = Sim.SkillManager.GetElement(SkillNames.Inventing) as InventingSkill;

            List <InventionWorkbench> benches = new List <InventionWorkbench>();
            List <InventionWorkbench> empties = new List <InventionWorkbench>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (InventionWorkbench bench in lot.GetObjects <InventionWorkbench>())
                {
                    if (bench.InUse)
                    {
                        continue;
                    }

                    if (bench.mIsMakingFrankensim)
                    {
                        continue;
                    }

                    if (bench.mInventionProgress > 0)
                    {
                        if (skill == null)
                        {
                            continue;
                        }

                        if (!skill.KnownInventions.Contains(bench.mInventionKey))
                        {
                            continue;
                        }

                        benches.Add(bench);
                    }
                    else
                    {
                        empties.Add(bench);
                    }
                }
            }

            if (benches.Count == 0)
            {
                benches.AddRange(empties);

                if (benches.Count == 0)
                {
                    IncStat("No Bench");
                    return(false);
                }
            }

            int minimumScrap   = InventionWorkbench.kNumScrapsPerDiceRoll * 10;
            int inventoryScrap = Inventories.InventoryFindAll <Scrap>(Sim).Count;

            if (inventoryScrap < minimumScrap)
            {
                List <JunkPile> piles = new List <JunkPile>();
                foreach (JunkPile pile in Sims3.Gameplay.Queries.GetObjects <JunkPile>())
                {
                    if (pile.IsEmpty)
                    {
                        continue;
                    }

                    if (pile.LotCurrent == Sim.LotHome)
                    {
                        piles.Add(pile);
                    }
                    else if (pile.LotCurrent == null)
                    {
                        continue;
                    }
                    else if (pile.LotCurrent.IsCommunityLot)
                    {
                        piles.Add(pile);
                    }
                }

                bool success = false;

                while (piles.Count > 0)
                {
                    JunkPile junkChoice = RandomUtil.GetRandomObjectFromList(piles);
                    piles.Remove(junkChoice);

                    if (!Situations.PushInteraction(this, Sim, junkChoice, DigThroughEx.Singleton))
                    {
                        break;
                    }

                    IncStat("Push Dig Through");

                    success = true;
                }

                if (!success)
                {
                    Money.AdjustFunds(Sim, "BuyItem", -InventionWorkbench.Restock.GetScrapCost(minimumScrap - inventoryScrap));

                    AddStat("Buy Scrap", minimumScrap - inventoryScrap);

                    CreateScrap(Sim.CreatedSim, minimumScrap - inventoryScrap);
                }
                else
                {
                    return(true);
                }
            }

            InventionWorkbench choice = RandomUtil.GetRandomObjectFromList(benches);

            if (choice.mInventionProgress > 0)
            {
                IncStat("Try Continue");

                if (Situations.PushInteraction(this, Sim, choice, MakeInventionEx.Singleton))
                {
                    return(true);
                }

                IncStat("Continue Fail");
                return(false);
            }
            else
            {
                if ((skill != null) && (skill.GetUndiscoveredInventions().Count == 0x0) && (skill.ReachedMaxLevel()))
                {
                    IncStat("Try Start New");

                    if (Situations.PushInteraction(this, Sim, choice, MakeInventionEx.Singleton))
                    {
                        return(true);
                    }

                    IncStat("Start New Fail");
                    return(false);
                }
                else
                {
                    if ((skill == null) || (skill.KnownInventions.Count == 0) || (RandomUtil.RandomChance(25)))
                    {
                        IncStat("Try Invent");

                        if (Situations.PushInteraction(this, Sim, choice, new InventionWorkbench.Invent.Definition()))
                        {
                            return(true);
                        }

                        IncStat("Invent Fail");
                        return(false);
                    }
                    else
                    {
                        IncStat("Try Start New");

                        if (Situations.PushInteraction(this, Sim, choice, MakeInventionEx.Singleton))
                        {
                            return(true);
                        }

                        IncStat("Start New Fail");
                        return(false);
                    }
                }
            }
        }
Esempio n. 27
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            if (sSkills == null)
            {
                sSkills = new Dictionary <Sims3.Gameplay.Skills.SkillNames, InteractionDefinition>();

                sSkills.Add(Sims3.Gameplay.Skills.SkillNames.Guitar, GuitarPlayForTips.Singleton);
                sSkills.Add(Sims3.Gameplay.Skills.SkillNames.BassGuitar, BassGuitarPlayForTips.Singleton);
                sSkills.Add(Sims3.Gameplay.Skills.SkillNames.Piano, PianoPlayForTips.Singleton);
                sSkills.Add(Sims3.Gameplay.Skills.SkillNames.Drums, DrumsPlayForTips.Singleton);
                sSkills.Add(Sims3.Gameplay.Skills.SkillNames.LaserHarp, LaserHarpPlayForTips.Singleton);
            }

            List <Sims3.Gameplay.Skills.SkillNames> choices = new List <Sims3.Gameplay.Skills.SkillNames>();

            SimData data = Options.GetSim(Sim);

            foreach (Sims3.Gameplay.Skills.SkillNames skill in sSkills.Keys)
            {
                if (!Skills.AllowSkill(this, Sim, data, skill))
                {
                    continue;
                }

                choices.Add(skill);
            }

            if (choices.Count == 0)
            {
                IncStat("No Choices");
                return(false);
            }

            BandInstrument        instrument = null;
            InteractionDefinition definition = null;

            RandomUtil.RandomizeListOfObjects(choices);

            foreach (Sims3.Gameplay.Skills.SkillNames skill in choices)
            {
                switch (skill)
                {
                case Sims3.Gameplay.Skills.SkillNames.Guitar:
                    instrument = Inventories.InventoryFind <Guitar>(Sim);
                    if (instrument == null)
                    {
                        instrument = ManagedBuyProduct <Guitar> .Purchase(Sim, 0, this, UnlocalizedName, null, BuildBuyProduct.eBuyCategory.kBuyCategoryElectronics, BuildBuyProduct.eBuySubCategory.kBuySubCategoryHobbiesAndSkills);
                    }
                    break;

                case Sims3.Gameplay.Skills.SkillNames.BassGuitar:
                    instrument = Inventories.InventoryFind <BassGuitar>(Sim);
                    if (instrument == null)
                    {
                        instrument = ManagedBuyProduct <BassGuitar> .Purchase(Sim, 0, this, UnlocalizedName, null, BuildBuyProduct.eBuyCategory.kBuyCategoryElectronics, BuildBuyProduct.eBuySubCategory.kBuySubCategoryHobbiesAndSkills);
                    }
                    break;

                case Sims3.Gameplay.Skills.SkillNames.Piano:
                    instrument = Inventories.InventoryFind <Piano>(Sim);
                    if (instrument == null)
                    {
                        instrument = ManagedBuyProduct <Piano> .Purchase(Sim, 0, this, UnlocalizedName, null, BuildBuyProduct.eBuyCategory.kBuyCategoryElectronics, BuildBuyProduct.eBuySubCategory.kBuySubCategoryHobbiesAndSkills);
                    }
                    break;

                case Sims3.Gameplay.Skills.SkillNames.Drums:
                    instrument = Inventories.InventoryFind <Drums>(Sim);
                    if (instrument == null)
                    {
                        instrument = ManagedBuyProduct <Drums> .Purchase(Sim, 0, this, UnlocalizedName, null, BuildBuyProduct.eBuyCategory.kBuyCategoryElectronics, BuildBuyProduct.eBuySubCategory.kBuySubCategoryHobbiesAndSkills);
                    }
                    break;

                case Sims3.Gameplay.Skills.SkillNames.LaserHarp:
                    instrument = Inventories.InventoryFind <LaserHarp>(Sim);
                    if (instrument == null)
                    {
                        instrument = ManagedBuyProduct <LaserHarp> .Purchase(Sim, 0, this, UnlocalizedName, null, BuildBuyProduct.eBuyCategory.kBuyCategoryElectronics, BuildBuyProduct.eBuySubCategory.kBuySubCategoryHobbiesAndSkills);
                    }
                    break;
                }

                if (instrument != null)
                {
                    definition = sSkills[skill];
                    break;
                }
            }

            if (instrument == null)
            {
                IncStat("No Instrument");
                return(false);
            }

            Lot lot = Sim.CreatedSim.LotCurrent;

            if ((Sim.LotHome == lot) || (lot.IsWorldLot) || (lot.IsResidentialLot))
            {
                if (!Situations.PushVisit(this, Sim, Lots.GetCommunityLot(Sim.CreatedSim, null, true)))
                {
                    IncStat("Push Lot Fail");
                    return(false);
                }
            }

            return(Situations.PushInteraction(this, Sim, instrument, definition));
        }