Example #1
0
        public bool DoWeed()
        {
            EWHerbLoreSkill skill = EWHerbLoreSkill.StartSkillGain(Actor);

            if (skill != null)
            {
                StandardEntry();
                BeginCommodityUpdates();
                AcquireStateMachine("eatharvestablepet");
                mCurrentStateMachine.SetActor("x", Actor);
                mCurrentStateMachine.EnterState("x", "Enter");
                SetParameter("IsEatingOnGround", paramValue: true);
                AnimateSim("EatHarvestable");
                StartStagesForTendableInteraction(this);
                bool flag = DoLoop(ExitReason.Default);
                //PauseTendGardenInteractionStage(Actor.CurrentInteraction);
                if (flag)
                {
                    Target.AddSimWhoHelpedGrow(Actor);
                    Target.HasWeeds = false;
                    EventTracker.SendEvent(EventTypeId.kWeededPlant, Actor, Target);
                }
                AnimateSim("Exit");
                EndCommodityUpdates(flag);
                StandardExit();
                EventTracker.SendEvent(EventTypeId.kGardened, Actor);
                //UpdateTendGardenTimeSpent(this, SetWeedTimeSpent);
                skill.StopSkillGain();
                return(flag);
            }
            return(false);
        }
        public bool DoDispose(Sim Actor, Plant Target, InteractionInstance interaction)
        {
            IDisposePlantInteraction disposePlantInteraction = interaction as IDisposePlantInteraction;

            if (disposePlantInteraction == null)
            {
                return(false);
            }

            EWHerbLoreSkill skill = EWHerbLoreSkill.StartSkillGain(Actor);

            if (skill != null)
            {
                disposePlantInteraction.ReachedPlantDeletePointOfNoReturn();
                interaction.StandardEntry();
                interaction.BeginCommodityUpdates();

                // TODO: Hope to use dig animation here. Need to be converted?
                AcquireStateMachine("eatharvestablepet");
                mCurrentStateMachine.SetActor("x", Actor);
                mCurrentStateMachine.EnterState("x", "Enter");
                SetParameter("IsEatingOnGround", paramValue: true);

                uint footprintHash = Target.GetFootprintHash();
                Target.DisableFootprint(footprintHash);
                Target.GetSoil().DisableFootprint(1478897068u);

                AnimateSim("EatHarvestable");
                AnimateSim("Exit");
                interaction.EndCommodityUpdates(true);
                interaction.StandardExit();
                return(true);
            }
            return(false);
        }
        public override bool Run()
        {
            EWHerbLoreSkill skill = EWHerbLoreSkill.StartSkillGain(Actor);

            if (skill != null)
            {
                // Unable to use PetCarrySystem because plantable not recognized as IPetCarryable
                // Not clear on how this interface works.
                // Fortunately the CarryUtils methods used by both carry systems are less picky.
                if (Actor.RouteToObjectRadius(Target, 0.3f))
                {
                    if (Target.Plantable.PlantDef.GetModelName(out string modelname))
                    {
                        CarryUtils.Acquire(Actor, Target);
                        Actor.CarryStateMachine.SetParameter("Height", SurfaceHeight.Floor);
                        Enter(Actor, Target, modelname);
                        CarryUtils.Request(Actor, "PickUp");
                        CarryUtils.Request(Actor, "Carry");
                        AnimateIntoSimInventory(Actor);
                        //CarryUtils.VerifyAnimationParent(Target, Actor);
                        // Note: PutInSimInventory includes ExitCarry. This means the
                        // state machine has exited and can't be used again without Acquire
                        bool success = CarryUtils.PutInSimInventory(Actor);
                        skill.StopSkillGain();
                        skill.AddPoints(200);                          // This takes some know-how for a pet
                        return(success);
                    }
                }
            }
            return(false);
        }
Example #4
0
        public static EWHerbLoreSkill StartSkillGain(Sim actor)
        {
            EWHerbLoreSkill skill = actor.SkillManager.GetSkill <EWHerbLoreSkill>(SkillNameID);

            if (skill == null)
            {
                skill = actor.SkillManager.AddElement(SkillNameID) as EWHerbLoreSkill;
            }
            if (skill == null)
            {
                Show(new Format("Error: Attempt to add EWHerbLoreSkill to " + actor.Name + " FAILED.",
                                NotificationStyle.kDebugAlert));
                return(null);
            }

            // TODO: Check for skill gain modifiers
            skill.StartSkillGain(kEWHerbLoreGainRateNormal);
            return(skill);
        }
Example #5
0
        public override bool Run()
        {
            if (!Target.RouteSimToMeAndCheckInUse(Actor))
            {
                return(false);
            }
            EWHerbLoreSkill skill = EWHerbLoreSkill.StartSkillGain(Actor);

            if (skill != null)
            {
                StandardEntry();
                BeginCommodityUpdates();
                bool flag = DoLoop(ExitReason.Default, LoopFunc, null, kTimeBetweenReactions);
                EndCommodityUpdates(flag);
                StandardExit();
                skill.StopSkillGain();
                return(flag);
            }
            return(false);
        }
Example #6
0
        public bool DoWater()
        {
            // Not going to start skill gain until water is at least retrieved.
            // No extra points for that much routing.
            EWHerbLoreSkill skill = EWHerbLoreSkill.StartSkillGain(Actor);

            if (skill != null)
            {
                StandardEntry();
                BeginCommodityUpdates();
                //mCurrentStateMachine = Target.GetStateMachine(Actor, out Soil dummyIk);
                //if (mCurrentStateMachine == null)
                //{
                //	EndCommodityUpdates(succeeded: false);
                //	StandardExit();
                //}
                //mDummyIk = dummyIk;
                AcquireStateMachine("eatharvestablepet");
                mCurrentStateMachine.SetActor("x", Actor);
                mCurrentStateMachine.EnterState("x", "Enter");
                SetParameter("IsEatingOnGround", paramValue: true);
                AnimateSim("EatHarvestable");
                StartWateringSound();
                //AddOneShotScriptEventHandler(1001u, new SacsEventHandler(StartWateringSound));
                AddOneShotScriptEventHandler(201u, new SacsEventHandler(StopWateringSound));
                StartStagesForTendableInteraction(this);
                float duration = Target.GetWaterDuration(Actor);
                if (duration == 0f)
                {
                    duration = 1f;
                }
                float startingWaterLevel = Target.WaterLevel;
                float targetWaterLevel   = 100f;
                Target.AddSimWhoHelpedGrow(Actor);
                EventTracker.SendEvent(EventTypeId.kWateredPlant, Actor, Target);
                bool flag = DoLoop(ExitReason.Default, delegate(StateMachineClient unused, LoopData ld)
                {
                    float num2             = ld.mLifeTime / duration;
                    this.Target.WaterLevel = num2 * targetWaterLevel + (1f - num2) * startingWaterLevel;
                    if (this.Target.WaterLevel > targetWaterLevel)
                    {
                        this.Target.WaterLevel = targetWaterLevel;
                    }
                    if (ld.mLifeTime > duration)
                    {
                        this.Actor.AddExitReason(ExitReason.Finished);
                    }
                }, null);
                //PauseTendGardenInteractionStage(Actor.CurrentInteraction);
                if (flag && Target.WaterLevel < targetWaterLevel)
                {
                    Target.WaterLevel = targetWaterLevel;
                }

                AnimateSim("Exit");
                EventTracker.SendEvent(EventTypeId.kGardened, Actor);
                EndCommodityUpdates(succeeded: true);
                StandardExit();
                skill.StopSkillGain();
                //UpdateTendGardenTimeSpent(this, SetWaterTimeSpent);
                return(flag);
            }
            return(false);
        }
Example #7
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);
        }
Example #8
0
		public bool RunCommon()
		{
			if (mObjectsToPlant == null || mObjectsToPlant.Count == 0)
			{
				return false;
			}
			EWHerbLoreSkill skill = EWHerbLoreSkill.StartSkillGain(Actor);
			if (skill != null)
			{
				while (mObjectsToPlant.Count > 0)
				{
					PlantableObjectData data = mObjectsToPlant[0];
					CurrentTarget = data.PlantableObject;
					CurrentSoil = data.Soil;
					if (Plant.DoPlantRoute(Actor, CurrentSoil))
					{
						UnreservePlantablePlantingSucceeded();
						Plant plant = CreatePlantFromSeed(CurrentTarget, CurrentSoil, Actor);
						plant.UpdateHealth();
						plant.AddToUseList(Actor);
						AcquireStateMachine("eatharvestablepet");
						mCurrentStateMachine.SetActor("x", Actor);
						mCurrentStateMachine.EnterState("x", "Enter");
						SetParameter("IsEatingOnGround", paramValue: true);
						// Parrotting the dummyIK code from the plantMedium state machine
						mDummyIk = Soil.Create(isDummyIk: true);
						//mDummyIk.SetHiddenFlags(-1);
						mDummyIk.SetPosition(plant.GetSoil().Position);
						Vector3 forward = plant.GetSoil().Position - Actor.Position;
						mDummyIk.SetForward(forward);
						mDummyIk.AddToWorld();
						BeginCommodityUpdates();
						AddOneShotScriptEventHandler(201u, new SacsEventHandler(ScriptHandlerOnSimAboutToPlant));
						AnimateSim("EatHarvestable");
						skill.Planted(plant);
						AnimateSim("Exit");
						EndCommodityUpdates(succeeded: true);
						plant.RemoveFromUseList(Actor);
						CurrentSoil.RemoveFromUseList(Actor);
						if (mDummyIk != null)
						{
							mDummyIk.Destroy();
							mDummyIk = null;
						}
						EventTracker.SendEvent(EventTypeId.kGardened, Actor);
						if (PlantHelper.IsSeed(CurrentTarget))
						{
							EventTracker.SendEvent(EventTypeId.kEventSeedPlanted, Actor, CurrentTarget);
						}
						EventTracker.SendEvent(EventTypeId.kPlantedObject, Actor, plant);
					}
					else
					{
						CleanupPlantInstances(data, Actor, PlantInteractionType);
						mObjectsToPlant.RemoveAt(0);
					}
				}
				skill.StopSkillGain();
				skill.AddSkillPointsLevelClamped(200, 10); // Bonus, Planting takes animal thinking
				return true;
			}
			return false;
		}
Example #9
0
		public bool DoSoilPlacementAndPlant()
		{
			EWHerbLoreSkill skill = EWHerbLoreSkill.StartSkillGain(Actor);
			if (skill != null)
			{
				mCurrentTarget = Target;
				bool flag = false;
				do
				{
					flag = false;
					if (!ReservePlantable())
					{
						break;
					}
					mCurrentSoil = (GlobalFunctions.CreateObjectOutOfWorld("GardenSoil") as Soil);
					if (mCurrentSoil == null)
					{
						break;
					}
					mCurrentSoil.SetPlantDef(PlantHelper.GetPlantDefinition(mCurrentTarget));
					mCurrentSoil.AddToWorld();
					mCurrentSoil.Ghost();
					if (!PlaceSoil())
					{
						mSoilPlacementFailure = true;
						break;
					}
					mCurrentSoil.AddToUseList(Actor);
					mCurrentSoil.SetPlanted();
					if (mObjectsToPlant == null)
					{
						mObjectsToPlant = new List<PlantableObjectData>();
					}
					mObjectsToPlant.Add(new PlantableObjectData(mCurrentTarget, mCurrentSoil));
					if (mInteractionType != PlantInteractionType.FromInventoryPlantMany)
					{
						continue;
					}
					uint stackNumber = Actor.Inventory.GetStackNumber(mCurrentTarget);
					if (stackNumber != 0)
					{
						List<IGameObject> stackObjects = Actor.Inventory.GetStackObjects(stackNumber, checkInUse: true);
						if (stackObjects.Count > 0)
						{
							mCurrentTarget = stackObjects[0];
							flag = true;
						}
					}
				} while (flag);

				if (mObjectsToPlant != null && mObjectsToPlant.Count > 0)
				{
					EWPetDoPlant petDoPlant = EWPetDoPlant.Singleton.CreateInstance(Target, Actor, mPriority,
						base.Autonomous, cancellableByPlayer: true) as EWPetDoPlant;
					if (petDoPlant != null)
					{
						petDoPlant.SetObjectsToPlant(mObjectsToPlant);
						petDoPlant.PlantInteractionType = mInteractionType;
						if (Actor.InteractionQueue.Add(petDoPlant))
						{
							mInteractionPushed = true;
						}
					}
				}
				skill.StopSkillGain();
				return true;
			}
			return false;
		}