Example #1
0
        public static bool DoHarvest(Sim actor, HarvestPlant target, EWHerbLoreSkill skill)
        {
            Slot[]            containmentSlots = target.GetContainmentSlots();
            List <GameObject> list             = new List <GameObject>();

            Slot[] array = containmentSlots;
            foreach (Slot slotName in array)
            {
                GameObject gameObject = target.GetContainedObject(slotName) as GameObject;
                if (gameObject != null && target.HarvestHarvestable(gameObject, actor, null))
                {
                    list.Add(gameObject);
                }
            }

            if (list.Count > 0)
            {
                skill.UpdateSkillJournal(target.PlantDef, list);

                if (!skill.HasHarvested())
                {
                    actor.ShowTNSIfSelectable(Localization.LocalizeString(actor.IsFemale,
                                                                          "Gameplay/Objects/Gardening/HarvestPlant/Harvest:FirstHarvest", actor, target.PlantDef.Name),
                                              NotificationStyle.kGameMessagePositive, target.ObjectId, actor.ObjectId);
                }
                target.PostHarvest();
                return(true);
            }
            return(false);
        }
Example #2
0
        public bool DoHarvest()
        {
            EWHerbLoreSkill skill = EWHerbLoreSkill.StartSkillGain(Actor);

            if (skill != null)
            {
                Target.RemoveHarvestStateTimeoutAlarm();
                StandardEntry();
                BeginCommodityUpdates();
                if (!Target.PlantDef.GetPlantHeight(out PlantHeight height))
                {
                    height = PlantHeight.Medium;
                }
                // TODO: Different animations -- scratching post for medium and high plants?
                AcquireStateMachine("eatharvestablepet");
                mCurrentStateMachine.SetActor("x", Actor);
                mCurrentStateMachine.EnterState("x", "Enter");
                SetParameter("IsEatingOnGround", paramValue: true);
                AnimateSim("EatHarvestable");
                Plant.StartStagesForTendableInteraction(this);
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.Default))
                {
                    if (base.ActiveStage != null && base.ActiveStage.IsComplete(this))
                    {
                        Actor.AddExitReason(ExitReason.StageComplete);
                    }
                }
                //Plant.PauseTendGardenInteractionStage(Actor.CurrentInteraction);
                AnimateSim("Exit");
                Slot[]            containmentSlots = Target.GetContainmentSlots();
                List <GameObject> list             = new List <GameObject>();
                Slot[]            array            = containmentSlots;
                foreach (Slot slotName in array)
                {
                    GameObject gameObject = Target.GetContainedObject(slotName) as GameObject;
                    if (gameObject != null && Target.HarvestHarvestable(gameObject, Actor, null))
                    {
                        list.Add(gameObject);
                    }
                }

                if (list.Count > 0)
                {
                    skill.UpdateSkillJournal(Target.PlantDef, list);

                    if (!skill.HasHarvested())
                    {
                        Actor.ShowTNSIfSelectable(Localization.LocalizeString(Actor.IsFemale,
                                                                              "Gameplay/Objects/Gardening/HarvestPlant/Harvest:FirstHarvest", Actor, Target.PlantDef.Name),
                                                  NotificationStyle.kGameMessagePositive, Target.ObjectId, Actor.ObjectId);
                    }
                    Target.PostHarvest();
                    EndCommodityUpdates(succeeded: true);
                    StandardExit();
                    skill.StopSkillGain();
                    //Plant.UpdateTendGardenTimeSpent(this, SetHarvestTimeSpent);
                    return(Actor.HasExitReason(ExitReason.StageComplete));
                }
            }
            return(false);
        }