Exemple #1
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);
        }