Esempio n. 1
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. 2
0
        private bool DoHarvestEx()
        {
            Soil soil;

            Target.RemoveHarvestStateTimeoutAlarm();
            StandardEntry();
            BeginCommodityUpdates();
            StateMachineClient stateMachine = Target.GetStateMachine(Actor, out soil);

            mDummyIk = soil;
            bool hasHarvested = true;

            if (Actor.IsInActiveHousehold)
            {
                hasHarvested = false;
                foreach (SimDescription description in Actor.Household.SimDescriptions)
                {
                    Gardening skill = description.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                    if ((skill != null) && skill.HasHarvested())
                    {
                        hasHarvested = true;
                        break;
                    }
                }
            }

            if (stateMachine != null)
            {
                stateMachine.RequestState("x", "Loop Harvest");
            }

            Plant.StartStagesForTendableInteraction(this);
            while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)))
            {
                if ((ActiveStage != null) && ActiveStage.IsComplete((InteractionInstance)this))
                {
                    Actor.AddExitReason(ExitReason.StageComplete);
                }
            }

            Plant.PauseTendGardenInteractionStage(Actor.CurrentInteraction);
            if (Actor.HasExitReason(ExitReason.StageComplete))
            {
                HarvestPlantEx.DoHarvest(Target, Actor, hasHarvested, mBurglarSituation);
            }

            if (stateMachine != null)
            {
                stateMachine.RequestState("x", "Exit Standing");
            }

            EndCommodityUpdates(true);
            StandardExit();
            Plant.UpdateTendGardenTimeSpent(this, new Plant.UpdateTendGardenTimeSpentDelegate(HarvestPlant.Harvest.SetHarvestTimeSpent));
            return(Actor.HasExitReason(ExitReason.StageComplete));
        }
Esempio n. 3
0
 public static void UpdateGardeningSkillJournal(MoneyTree ths, Gardening gardeningSkill, PlantDefinition harvestPlantDef, List<GameObject> objectsHarvested)
 {
     foreach (GameObject obj2 in objectsHarvested)
     {
         HarvestMoneyBag bag = obj2 as HarvestMoneyBag;
         if (bag != null)
         {
             gardeningSkill.MoneyBagHarvested(bag.Value, harvestPlantDef);
         }
     }
 }
Esempio n. 4
0
 public static void UpdateGardeningSkillJournal(MoneyTree ths, Gardening gardeningSkill, PlantDefinition harvestPlantDef, List <GameObject> objectsHarvested)
 {
     foreach (GameObject obj2 in objectsHarvested)
     {
         HarvestMoneyBag bag = obj2 as HarvestMoneyBag;
         if (bag != null)
         {
             gardeningSkill.MoneyBagHarvested(bag.Value, harvestPlantDef);
         }
     }
 }
Esempio n. 5
0
 // From HarvestPlant
 protected static void UpdateGardeningSkillJournal(HarvestPlant ths, Gardening gardeningSkill, PlantDefinition harvestPlantDef, List <GameObject> objectsHarvested)
 {
     foreach (GameObject obj2 in objectsHarvested)
     {
         gardeningSkill.Harvested(Plant.GetQuality(obj2.Plantable.QualityLevel), harvestPlantDef);
         if (Plant.IsMushroom(ths.Seed))
         {
             Collecting collecting = gardeningSkill.SkillOwner.SkillManager.AddElement(SkillNames.Collecting) as Collecting;
             if (collecting != null)
             {
                 bool flag;
                 collecting.Collected(obj2 as Ingredient, out flag);
             }
         }
     }
 }
Esempio n. 6
0
 // From HarvestPlant
 protected static void UpdateGardeningSkillJournal(HarvestPlant ths, Gardening gardeningSkill, PlantDefinition harvestPlantDef, List<GameObject> objectsHarvested)
 {
     foreach (GameObject obj2 in objectsHarvested)
     {
         gardeningSkill.Harvested(Plant.GetQuality(obj2.Plantable.QualityLevel), harvestPlantDef);
         if (Plant.IsMushroom(ths.Seed))
         {
             Collecting collecting = gardeningSkill.SkillOwner.SkillManager.AddElement(SkillNames.Collecting) as Collecting;
             if (collecting != null)
             {
                 bool flag;
                 collecting.Collected(obj2 as Ingredient, out flag);
             }
         }
     }
 }
Esempio n. 7
0
        /// <summary>
        /// ça a pas grand chose à foutre là quand on y pense
        /// </summary>
        public void HandleOnNextHour()
        {
            // en soit à terme, il faudrait que la fonction soit dans la case elle même
            // delay/grow/10/BecomeItem(carotte)
            // pas si compliqué que ça quand on y pense

            // decrease time
            int timeLeft = GetValue();

            --timeLeft;
            SetContent(timeLeft.ToString());

            // don't do anything if the time left is above 0
            if (timeLeft > 0)
            {
                return;
            }
            TimeManager.GetInstance().onNextHour -= HandleOnNextHour;


            // ici devraient être les actions
            switch (name)
            {
            case "dry":
                Gardening.Dry(this);
                break;

            case "grow":
                Gardening.Grow(this);
                break;

            default:
                //Debug.LogError("timer property : " + name + " is dead end");
                break;
            }
        }
Esempio n. 8
0
        private static bool DoHarvest(HarvestPlant ths, Sim actor, bool hasHarvested, BurglarSituation burglarSituation)
        {
            Slot[]            containmentSlots = ths.GetContainmentSlots();
            List <GameObject> objectsHarvested = new List <GameObject>();

            foreach (Slot slot in containmentSlots)
            {
                GameObject containedObject = ths.GetContainedObject(slot) as GameObject;
                if ((containedObject != null) && HarvestHarvestable(ths, containedObject, actor, burglarSituation))
                {
                    objectsHarvested.Add(containedObject);
                }
            }

            if (actor.TraitManager.HasElement(TraitNames.GathererTrait) && RandomUtil.RandomChance01(TraitTuning.GathererTraitExtraHarvestablesChance))
            {
                int gathererTraitNumberOfExtraHarvestables = TraitTuning.GathererTraitNumberOfExtraHarvestables;
                for (int i = 0; i < gathererTraitNumberOfExtraHarvestables; i++)
                {
                    GameObject item = ths.Seed.Copy(false) as GameObject;
                    if (item != null)
                    {
                        objectsHarvested.Add(item);
                    }
                }
            }

            if (objectsHarvested.Count <= 0x0)
            {
                return(false);
            }
            Gardening  skill      = actor.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
            Collecting collecting = actor.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);

            int skillDifficulty = ths.PlantDef.GetSkillDifficulty();

            if (skill != null)
            {
                if (skill.SkillLevel <= skillDifficulty)
                {
                    if (actor.SimDescription.IsFairy && skill.IsFairySkill())
                    {
                        skill.AddPoints(ths.PlantDef.SkillPointsHarvest * Skill.SkillLevelBumpMultiplierForFairies);
                    }
                    else
                    {
                        skill.AddPoints(ths.PlantDef.SkillPointsHarvest);
                    }
                }

                if ((ths is MoneyTree) || (ths is OmniPlant))
                {
                    ths.UpdateGardeningSkillJournal(skill, ths.PlantDef, objectsHarvested);
                }
                else
                {
                    // Custom
                    UpdateGardeningSkillJournal(ths, skill, ths.PlantDef, objectsHarvested);
                }
            }
            if (!hasHarvested)
            {
                actor.ShowTNSIfSelectable(Common.LocalizeEAString(actor.IsFemale, "Gameplay/Objects/Gardening/HarvestPlant/Harvest:FirstHarvest", new object[] { actor, ths.PlantDef.Name }), StyledNotification.NotificationStyle.kGameMessagePositive, ths.ObjectId, actor.ObjectId);
            }

            if (collecting == null)
            {
                collecting = (Collecting)actor.SkillManager.AddElement(SkillNames.Collecting);
            }
            collecting.CollectedFromHarvest(objectsHarvested);

            ths.PostHarvest();
            return(true);
        }
Esempio n. 9
0
        public static void NotifySell(SimDescription sim, GameObject obj, int value)
        {
            try
            {
                obj.SoldFor(value);

                if (obj.CanBeSold())
                {
                    if (IsCollectable(obj))
                    {
                        foreach (SimDescription member in sim.Household.AllSimDescriptions)
                        {
                            Collecting skill = member.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);
                            if (skill != null)
                            {
                                skill.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj.HasFlags(GameObject.FlagField.WasHarvested))
                    {
                        Gardening gardening = sim.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                        if (gardening != null)
                        {
                            gardening.HarvestableSold(value);
                        }
                        foreach (SimDescription member in sim.Household.AllSimDescriptions)
                        {
                            gardening = member.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                            if (gardening != null)
                            {
                                gardening.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj is INectarBottle)
                    {
                        INectarBottle bottle = obj as INectarBottle;

                        NectarSkill skill = sim.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);
                        if (skill != null)
                        {
                            skill.SellNectarBottle(value);
                        }

                        if ((bottle.Creator != null) && (bottle.Creator.IsValid))
                        {
                            skill = bottle.Creator.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);
                            if (skill != null)
                            {
                                skill.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj is IInvention)
                    {
                        IInvention invention = obj as IInvention;

                        SimDescription inventor = invention.Inventor;

                        if ((inventor != null) && (inventor.IsValid))
                        {
                            InventingSkill skill2 = inventor.SkillManager.GetSkill <InventingSkill>(SkillNames.Inventing);
                            if (skill2 != null)
                            {
                                skill2.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj is IScubaCollectible)
                    {
                        ScubaDivingSkill skill3 = sim.SkillManager.AddElement(SkillNames.ScubaDiving) as ScubaDivingSkill;
                        if (skill3 != null)
                        {
                            skill3.SimoleonsFromSellingCollectibles += value;
                            skill3.UpdateXpForEarningMoney(value);
                        }
                    }

                    if (sim.CreatedSim != null)
                    {
                        obj.SendObjectSoldEvent(sim.CreatedSim);
                    }
                }
            }
            catch (Exception e)
            {
                Common.DebugException(sim.CreatedSim, obj, e);
            }
        }
Esempio n. 10
0
        public override bool Run()
        {
            try
            {
                if (!Target.RouteSimToMeAndCheckInUse(Actor) || !HarvestPlant.HarvestTest(Target, Actor))
                {
                    return(false);
                }

                Target.RemoveHarvestStateTimeoutAlarm();
                StandardEntry();
                BeginCommodityUpdates();
                Soil dummyIk = null;
                StateMachineClient client = null;

                bool allowChild = false;

                if (Actor.SimDescription.YoungAdultOrAbove)
                {
                    allowChild = true;
                }
                else if ((Actor.SimDescription.Teen) && (Woohooer.Settings.mUnlockTeenActions))
                {
                    allowChild = true;
                }

                if ((!Autonomous) && (allowChild) && RandomUtil.RandomChance01(kChanceToHavePlantSimBaby))
                {
                    client   = Target.CreateStateMachine(Actor, out dummyIk);
                    mDummyIk = dummyIk;
                    Sim newBorn = GetNewBorn();
                    Relationship.Get(Actor, newBorn, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);
                    if (newBorn.BridgeOrigin != null)
                    {
                        newBorn.BridgeOrigin.MakeRequest();
                        newBorn.BridgeOrigin = null;
                    }

                    if (client != null)
                    {
                        IGameObject actor = GlobalFunctions.CreateObjectOutOfWorld("plantSimHarvestable", ProductVersion.EP9, "Sims3.Gameplay.Core.Null", null);
                        client.SetActor("harvestable", actor);
                        client.SetActor("y", newBorn);
                        client.EnterState("x", "Enter Standing");
                        Target.SetGrowthState(PlantGrowthState.Planted);
                        client.RequestState("x", "HaveAPlantSimBaby");
                        Pregnancy.MakeBabyVisible(newBorn);
                        client.RequestState("x", "Exit Standing");
                        actor.RemoveFromWorld();
                        actor.Destroy();
                    }

                    if (Actor.IsSelectable)
                    {
                        OccultImaginaryFriend.DeliverDollToHousehold(new List <Sim>(new Sim[] { newBorn }));
                    }

                    ChildUtils.CarryChild(Actor, newBorn, true);
                    EventTracker.SendEvent(EventTypeId.kBornFromTheSoil, newBorn);
                }
                else
                {
                    client   = Target.CreateStateMachine(Actor, out dummyIk);
                    mDummyIk = dummyIk;
                    bool hasHarvested = true;
                    if (Actor.IsInActiveHousehold)
                    {
                        hasHarvested = false;
                        foreach (SimDescription description in Actor.Household.SimDescriptions)
                        {
                            Gardening skill = description.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                            if ((skill != null) && skill.HasHarvested())
                            {
                                hasHarvested = true;
                                break;
                            }
                        }
                    }

                    IGameObject obj3 = GlobalFunctions.CreateObjectOutOfWorld("plantForbiddenFruit", ProductVersion.EP9, "Sims3.Gameplay.Core.Null", null);
                    if (client != null)
                    {
                        client.SetActor("harvestable", obj3);
                        client.EnterState("x", "Enter Standing");
                        client.RequestState("x", "HaveAFruit");
                    }
                    Target.DoHarvest(Actor, hasHarvested, null);
                    Target.SetGrowthState(PlantGrowthState.Planted);
                    if (client != null)
                    {
                        client.RequestState("x", "Exit Standing");
                    }
                    obj3.RemoveFromWorld();
                    obj3.Destroy();
                }

                EndCommodityUpdates(true);
                StandardExit();
                Target.RemoveFromWorld();
                Target.Destroy();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Esempio n. 11
0
        public static bool DoHarvest(HarvestPlant ths, Sim actor, bool hasHarvested, BurglarSituation burglarSituation)
        {
            Slot[]            containmentSlots = ths.GetContainmentSlots();
            List <GameObject> objectsHarvested = new List <GameObject>();

            foreach (Slot slot in containmentSlots)
            {
                GameObject containedObject = ths.GetContainedObject(slot) as GameObject;
                if ((containedObject != null) && ths.HarvestHarvestable(containedObject, actor, burglarSituation))
                {
                    objectsHarvested.Add(containedObject);
                }
            }

            if (actor.TraitManager.HasElement(TraitNames.GathererTrait) && RandomUtil.RandomChance01(TraitTuning.GathererTraitExtraHarvestablesChance))
            {
                int gathererTraitNumberOfExtraHarvestables = TraitTuning.GathererTraitNumberOfExtraHarvestables;
                for (int i = 0; i < gathererTraitNumberOfExtraHarvestables; i++)
                {
                    GameObject item = ths.Seed.Copy(false) as GameObject;
                    if (item != null)
                    {
                        objectsHarvested.Add(item);
                    }
                }
            }

            ScienceSkill element = actor.SkillManager.GetSkill <ScienceSkill>(SkillNames.Science);

            if ((element != null) && RandomUtil.RandomChance01(ScienceSkill.kSuccessRateBonusesGardening[element.SkillLevel]))
            {
                int num3 = ScienceSkill.kNumExtraHarvestables[element.SkillLevel];
                for (int j = 0; j < num3; j++)
                {
                    GameObject obj6 = ths.Seed.Copy(false) as GameObject;
                    if (obj6 != null)
                    {
                        objectsHarvested.Add(obj6);
                    }
                }
            }

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

            foreach (GameObject obj7 in objectsHarvested)
            {
                ths.ManipulateHarvestable(actor, obj7);
            }

            Gardening  skill           = actor.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
            Collecting collecting      = actor.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);
            int        skillDifficulty = ths.PlantDef.GetSkillDifficulty();

            if (skill != null)
            {
                if (skill.SkillLevel <= skillDifficulty)
                {
                    if (actor.SimDescription.IsFairy && skill.IsFairySkill())
                    {
                        skill.AddPoints(ths.PlantDef.SkillPointsHarvest * Skill.SkillLevelBumpMultiplierForFairies);
                    }
                    else
                    {
                        skill.AddPoints(ths.PlantDef.SkillPointsHarvest);
                    }
                }

                if (ths is MoneyTree)
                {
                    MoneyTreeEx.UpdateGardeningSkillJournal(ths as MoneyTree, skill, ths.PlantDef, objectsHarvested);
                }
                else
                {
                    ths.UpdateGardeningSkillJournal(skill, ths.PlantDef, objectsHarvested);
                }
            }

            if (!hasHarvested)
            {
                actor.ShowTNSIfSelectable(Localization.LocalizeString(actor.IsFemale, "Gameplay/Objects/Gardening/HarvestPlant/Harvest:FirstHarvest", new object[] { actor, ths.PlantDef.Name }), StyledNotification.NotificationStyle.kGameMessagePositive, ths.ObjectId, actor.ObjectId);
            }

            if (collecting == null)
            {
                collecting = actor.SkillManager.AddElement(SkillNames.Collecting) as Collecting;
            }

            collecting.CollectedFromHarvest(objectsHarvested);
            ths.PostHarvest();
            return(true);
        }
Esempio n. 12
0
        protected static void EnactCorrections(Collecting skill)
        {
            Overwatch.Log(" Correcting: " + skill.SkillOwner.FullName);

            if (skill.mGlowBugData == null)
            {
                skill.mGlowBugData = new Dictionary <Sims3.Gameplay.Objects.Insect.InsectType, Collecting.GlowBugStats>();

                Overwatch.Log("  GlowBugData Fixed");
            }

            if (skill.mMushroomData == null)
            {
                skill.mMushroomData = new Dictionary <string, Collecting.MushroomStats>();

                Overwatch.Log("  MushroomData Fixed");
            }

            if (skill.mHarvestData == null)
            {
                skill.mHarvestData = new Dictionary <string, Collecting.HarvestStats>();

                Overwatch.Log("  HarvestData Fixed");
            }

            if (skill.mMetalData != null)
            {
                List <RockGemMetal> remove = new List <RockGemMetal>();

                foreach (KeyValuePair <RockGemMetal, Collecting.MetalStats> data in skill.mMetalData)
                {
                    if (data.Value.count == 0)
                    {
                        remove.Add(data.Key);
                    }
                }

                foreach (RockGemMetal metal in remove)
                {
                    skill.mMetalData.Remove(metal);
                }
            }

            Gardening gardening = skill.SkillOwner.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);

            if ((gardening != null) && (gardening.mHarvestCounts.Count != 0))
            {
                bool success = false;

                foreach (KeyValuePair <string, Gardening.PlantInfo> plants in gardening.mHarvestCounts)
                {
                    string ingredient = null;
                    foreach (IngredientData choice in IngredientData.IngredientDataList)
                    {
                        if (choice.PlantName == plants.Key)
                        {
                            ingredient = choice.mStringKey;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(ingredient))
                    {
                        continue;
                    }

                    Collecting.HarvestStats data = null;
                    if (!skill.mHarvestData.TryGetValue(ingredient, out data))
                    {
                        data = new Collecting.HarvestStats();
                        skill.mHarvestData.Add(ingredient, data);

                        data.quality = (int)plants.Value.BestQuality;
                        if (data.quality <= 0)
                        {
                            data.quality = (int)Quality.Bad;
                        }
                    }
                    else
                    {
                        if (data.quality < (int)plants.Value.BestQuality)
                        {
                            data.quality = (int)plants.Value.BestQuality;
                        }

                        if (data.count >= plants.Value.HarvestablesCount)
                        {
                            continue;
                        }
                    }

                    if (data.mostExpensive < plants.Value.MostExpensive)
                    {
                        data.mostExpensive = plants.Value.MostExpensive;
                    }

                    if (data.count < plants.Value.HarvestablesCount)
                    {
                        data.count = plants.Value.HarvestablesCount;
                    }

                    success = true;
                }

                if (success)
                {
                    Overwatch.Log("  HarvestData Reconciled");
                }
            }
        }