Ejemplo n.º 1
0
		public override void Cleanup()
		{
			if (!mInteractionPushed || mSoilPlacementFailure)
			{
				if (mCurrentTarget != null)
				{
					UnreservePlantablePlantingFailed(mCurrentTarget, Actor, mInteractionType);
				}
				if (mCurrentSoil != null)
				{
					mCurrentSoil.Destroy();
					mCurrentSoil = null;
				}
			}
			if (!mInteractionPushed && mObjectsToPlant != null)
			{
				while (mObjectsToPlant.Count > 0)
				{
					EWPetDoPlant.CleanupPlantInstances(mObjectsToPlant[0], Actor, mInteractionType);
					mObjectsToPlant.RemoveAt(0);
				}
			}
			base.Cleanup();
		}
Ejemplo n.º 2
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;
		}