Example #1
0
        public static StateMachineClient CreateStateMachine(Sim s, HarvestPlant p, out Soil dummyIk)
        {
            dummyIk = Soil.Create(isDummyIk: true);
            StateMachineClient val = StateMachineClient.Acquire(s, "petgardening");

            //dummyIk.SetHiddenFlags(HiddenFlags.Nothing);
            dummyIk.SetPosition(p.GetSoil().Position);
            Vector3 forward = p.GetSoil().Position - s.Position;

            dummyIk.SetForward(forward);
            dummyIk.AddToWorld();
            val.SetActor("x", s);
            val.SetActor("gardenPlantBush", p);
            val.SetActor("gardenSoil", p.GetSoil());
            val.SetActor("Dummy", dummyIk);
            if (!p.PlantDef.GetPlantHeight(out PlantHeight height))
            {
                height = PlantHeight.Medium;
            }
            val.SetParameter("Plant Height", height);
            return(val);
        }
Example #2
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 #3
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;
		}