private static bool HarvestHarvestable(HarvestPlant ths, GameObject harvestable, Sim actor, BurglarSituation burglarSituation) { if (harvestable == null) { return(false); } harvestable.SetOwnerLot(actor.LotHome); harvestable.UnParent(); harvestable.RemoveFromWorld(); bool flag = false; if (burglarSituation == null) { if (actor.Inventory.TryToAdd(harvestable, false)) { flag = true; } } else { burglarSituation.StolenObjects.Add(harvestable); burglarSituation.CurrentValue += harvestable.Value; flag = true; } if (flag) { harvestable.AddFlags(GameObject.FlagField.WasHarvested); harvestable.RemoveComponent <HarvestableComponent>(); ths.PostHarvestHarvestable(actor, harvestable); return(flag); } harvestable.Destroy(); return(flag); }
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); }
public override bool Test(IActor a, IGameObject target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback)) { return(false); } HarvestPlant plant = target as HarvestPlant; if (plant == null) { return(false); } if (!plant.Barren) { return(false); } if (plant.CanProduceMoreHarvestables()) { return(false); } return(true); }
public override bool Run() { try { bool previousInteractionSuccessful = false; if (Target.RouteSimToMeAndCheckInUse(Actor) && HarvestPlant.HarvestTest(Target, Actor)) { ConfigureInteraction(); Plant.TryConfigureTendGardenInteraction(Actor.CurrentInteraction); previousInteractionSuccessful = DoHarvest(); } if (IsChainingPermitted(previousInteractionSuccessful)) { IgnorePlants.Add(Target); PushNextInteractionInChain(Singleton, HarvestPlant.HarvestTest, Target.LotCurrent); } return(previousInteractionSuccessful); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
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); }
public override bool Test(Sim a, HarvestPlant target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!a.IsCat || target is ForbiddenFruitTree) { return(false); } if (!a.SkillManager.HasElement(EWHerbLoreSkill.SkillNameID)) { return(false); } return(HarvestPlant.HarvestTest(target, a)); }
public static void MergePlantSeed(HarvestPlant plant, Ingredient ingredient) { plant.Seed = ingredient; plant.PlantDef = PlantHelper.GetPlantDefinition(plant.Seed); plant.mQualityLevel = ingredient.Plantable.QualityLevel; plant.SetGrowthState(plant.GrowthState); sMergedPlants.Add(plant); ErrorTrap.LogCorrection("Plant Seed Merged: " + ErrorTrap.GetName(plant)); }
public override bool Run() { HarvestPlant plant = Target as HarvestPlant; if (plant == null) { return(false); } plant.mBarren = false; plant.mLifetimeHarvestablesYielded = 0; return(true); }
public override void Finish() { foreach (HarvestPlant plant in sMergedPlants) { if (HarvestPlant.FindSlottedHarvestable(plant) != null) { plant.SetGrowthState(PlantGrowthState.Harvest); } } sMissingPlants.Clear(); sIngredients.Clear(); sMergedPlants.Clear(); }
// 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); } } } }
// 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); } } } }
private void CreateAnimationHarvest(int row, string name, int number)// create animation when user harvest one product { for (i = 0; i < number; i++) { HarvestPlant = (GameObject)Instantiate(HarvestPlantPrefabs, Vector3.zero, Quaternion.identity); HarvestPlant.name = name; if (name.Equals("gold")) { HarvestPlant.GetComponent <HarvestPlantScript>().setValue("Common/vang", new Vector3(240, 330, 0), 50); } else { HarvestPlant.GetComponent <HarvestPlantScript>().setValue("Common/sao", new Vector3(10, 330, 0), 50); } HarvestPlant.transform.parent = this.transform; HarvestPlant.GetComponent <Transform>().localPosition = cusObjects[5 * row].transform.localPosition + new Vector3(UnityEngine.Random.Range(-40, 40), UnityEngine.Random.Range(-20, 20) + 200, 0); HarvestPlant.GetComponent <Transform>().localScale = Vector3.one; } }
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); }
public override void OnDelayedWorldLoadFinished() { Overwatch.Log("CleanupHarvestPlant"); foreach (HarvestPlant plant in Sims3.Gameplay.Queries.GetObjects <HarvestPlant>()) { switch (plant.GrowthState) { case PlantGrowthState.Mycelium: if (Plant.IsMushroom(plant.Seed)) { continue; } plant.SetGrowthState(PlantGrowthState.Sprout); Overwatch.Log(" Growth Plant Stage Corrected A"); break; case PlantGrowthState.Harvest: if (HarvestPlant.FindSlottedHarvestable(plant) == null) { OmniPlant omniPlant = plant as OmniPlant; if (omniPlant != null) { if (omniPlant.FedObject == null) { continue; } } plant.PostHarvest(); Overwatch.Log(" Growth Plant Stage Corrected B"); } break; } } }
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); }
public override string GetInteractionName(Sim actor, HarvestPlant target, InteractionObjectPair iop) { return base.GetInteractionName(actor, target, new InteractionObjectPair(sOldSingleton, target)); }
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); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Common.StringBuilder msg = new Common.StringBuilder("Run"); try { Terrain terrain = parameters.mTarget as Terrain; if (terrain != null) { foreach (Sim sim in LotManager.Actors) { Common.TestSpan span = Common.TestSpan.CreateSimple(); Route r = null; uint simFlags = sim.SimDescription.SimFlags; try { r = Route.Create(sim.Proxy, simFlags); } finally { msg += Common.NewLine + sim.FullName; msg += Common.NewLine + " " + sim.SimDescription.mSimFlags; msg += Common.NewLine + " " + span.Duration; } SimDescription simDescription = sim.SimDescription; Posture previousPosture = sim.Posture; SimRoutingComponent routingComponent = sim.RoutingComponent as SimRoutingComponent; bool flag = false; span = Common.TestSpan.CreateSimple(); try { //routingComponent.SetRouteOptions(route, simFlags); if (!(sim.CurrentInteraction is IHasCustomRouteOptions)) { r.SetOption(Route.RouteOption.BeginAsCar, (sim.Parent is Vehicle) && !(sim.Parent is IBoat)); r.SetOption(Route.RouteOption.EnablePlanningAsCar, simDescription.ChildOrAbove); r.SetOption(Route.RouteOption.DisablePlanningAsPedestrian, false); r.SetOption(Route.RouteOption.PushSimsAtDestination, true); r.SetOption(Route.RouteOption.UseAutoSlotFootprintLocking, true); r.SetOption(Route.RouteOption.ReplanToFindObstacleWhenPathPlanFails, true); r.SetOption(Route.RouteOption.IgnoreParent, false); r.SetOption(Route.RouteOption.IgnoreChildren, false); r.SetOption(Route.RouteOption.CreateSubPaths, true); r.SetOption(Route.RouteOption.CheckForFootprintsNearGoals, true); r.SetOption(Route.RouteOption.PenalizeGoalsOnDifferentLevels, true); if (GameUtils.IsInstalled(ProductVersion.EP10)) { IBoat parent = sim.Parent as IBoat; if (parent != null) { flag = true; r.Follower = parent.Proxy; r.FollowerAgeGenderSpecies = (uint)parent.GetBoatSpecies(); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, true); r.SetOption2(Route.RouteOption2.BeginAsBoat, true); r.SetOption2(Route.RouteOption2.UseFollowerStartOrientation, true); r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); r.AddObjectToIgnoreForRoute(sim.ObjectId); } bool flag2 = OccultMermaid.IsEveryOneGroupedWithMeATeenOrAboveMermaid(sim); bool flag3 = false; if (!flag2) { flag3 = ((previousPosture is CarryingChildPosture) || (previousPosture is CarryingPetPosture)) || sim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation)); } bool flag4 = simDescription.ChildOrAbove & !(previousPosture is ScubaDiving); flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.GiveCPR); flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.FakeInjury); flag4 &= !(simDescription.CreatedByService is GrimReaper); flag4 &= !flag2 || flag3; flag4 &= !(previousPosture is BeingRiddenPosture) && !(previousPosture is RidingPosture); bool flag5 = simDescription.ChildOrAbove && simDescription.IsHuman; flag5 &= !(previousPosture is CarryingChildPosture) && !(previousPosture is CarryingPetPosture); r.SetOption(Route.RouteOption.EnableWaterPlanning, flag5); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, !flag5); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, (parent != null) || flag4); if (flag2 && flag5) { r.SetOption2(Route.RouteOption2.RouteAsMermaid, true); } else { r.SetOption2(Route.RouteOption2.RouteAsLifeguard, Lifeguard.ShouldUseRescueSwimWade(sim)); } } // Cut if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP3)) { r.SetOption(Route.RouteOption.EnableSubwayPlanning, true); } if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP5) && ((sim.IsWildAnimal || sim.IsStray) || (sim.IsUnicorn || WildHorses.IsWildHorse(sim)))) { r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, false); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, true); } if (routingComponent.SimSatisfiesSpecialConditions()) { r.SetOption(Route.RouteOption.PassThroughObjects, true); r.SetOption(Route.RouteOption.PassThroughWalls, true); } if (sim.HasGhostBuff && !flag) { r.SetOption(Route.RouteOption.RouteAsGhost, true); } if ((GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP4) && (sim.CarryingChildPosture != null)) && (Stroller.GetStroller(sim, sim.LotCurrent) != null)) { r.SetOption(Route.RouteOption.PlanUsingStroller, true); } if (sim.IsHuman) { SwimmingInPool pool = previousPosture as SwimmingInPool; if (pool != null) { if (pool.ContainerIsOcean) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } else { Ocean.PondAndOceanRoutingPosture posture2 = previousPosture as Ocean.PondAndOceanRoutingPosture; if ((posture2 != null) && (posture2.WalkStyleToUse == Sim.WalkStyle.Wade)) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } } // Cut if (GameUtils.IsInstalled(ProductVersion.EP8)) { if (SimEx.GetOwnedAndUsableVehicle(sim, sim.LotHome, false, false, false, true) is CarUFO) { r.SetOption(Route.RouteOption.EnableUFOPlanning, true); } if ((sim.IsHuman && sim.SimDescription.ChildOrAbove) && PondManager.ArePondsFrozen()) { bool flag6 = true; while (previousPosture != null) { if (previousPosture.Satisfaction(CommodityKind.Standing, null) <= 0f) { flag6 = false; break; } previousPosture = previousPosture.PreviousPosture; } if (flag6) { r.SetOption(Route.RouteOption.EnablePondPlanning, true); } } } } } finally { msg += Common.NewLine + " B " + span.Duration; } span = Common.TestSpan.CreateSimple(); try { if (!(sim.CurrentInteraction is IHasCustomRouteOptions)) { r.ExitReasonsInterrupt = unchecked ((int)0xffa9bfff); if ((0x0 != (simFlags & 0x3)) && !sim.LotCurrent.IsWorldLot) { r.SetValidRooms(sim.LotCurrent.LotId, null); } if ((sim.IsHorse && sim.SimDescription.AdultOrAbove) && !sim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); } if (((sim.IsHorse || sim.IsDeer) || (sim.IsFullSizeDog && sim.SimDescription.AdultOrAbove)) && !sim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); } if (sim.IsHorse && sim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.RouteWhileMounted, true); } if (previousPosture is LeadingHorsePosture) { r.SetOption(Route.RouteOption.EnablePlanningAsCar, false); r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); r.SetOption(Route.RouteOption.RouteAsSimLeadingHorse, true); } if (sim.IsPet && !sim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.IgnoreSidewalkAndLotRestrictions, true); } } //route = sim.CreateRoute(); } finally { msg += Common.NewLine + " C " + span.Duration; } } } AcademicTextBook book = parameters.mTarget as AcademicTextBook; if (book != null) { Sim a = parameters.mActor as Sim; GreyedOutTooltipCallback greyedOutTooltipCallback = null; if ((a.OccupationAsAcademicCareer != null) || !book.mRequireAcademics) { if (book.TestRockAndRead(a, false, ref greyedOutTooltipCallback)) { msg += Common.NewLine + "A"; } if (a.Inventory.Contains(parameters.mTarget) && !(a.Posture is Sim.StandingPosture)) { if (book.TestReadBook(a, false, ref greyedOutTooltipCallback)) { msg += Common.NewLine + "B"; } } if (a.GetObjectInRightHand() == parameters.mTarget) { if (book.TestReadBook(a, false, ref greyedOutTooltipCallback)) { msg += Common.NewLine + "C"; } } msg += Common.NewLine + "D"; } msg += Common.NewLine + "E"; } CommonDoor door = parameters.mTarget as CommonDoor; if (door != null) { if (door.mObjComponents != null) { msg += Common.NewLine + "Count: " + door.mObjComponents.Count; for (int i = 0x0; i < door.mObjComponents.Count; i++) { msg += Common.NewLine + door.mObjComponents[i].BaseType; if (door.mObjComponents[i].BaseType == typeof(PortalComponent)) { msg += Common.NewLine + " Found"; door.mObjComponents[i].Dispose(); door.mObjComponents.RemoveAt(i); break; } } if (door.mObjComponents.Count == 0x0) { door.mObjComponents = null; } } } HarvestPlant plant = parameters.mTarget as HarvestPlant; if (plant != null) { msg += Common.NewLine + "mBarren: " + plant.mBarren; msg += Common.NewLine + "mGrowthState: " + plant.mGrowthState; msg += Common.NewLine + "mDormant: " + plant.mDormant; msg += Common.NewLine + "mLeaflessState: " + plant.mLeaflessState; msg += Common.NewLine + "mLifetimeHarvestablesYielded: " + plant.mLifetimeHarvestablesYielded; msg += Common.NewLine + "NumLifetimeHarvestables: " + plant.PlantDef.NumLifetimeHarvestables; msg += Common.NewLine + "Yield: " + plant.GetYield(); } } catch (Exception e) { GameHitParameters <GameObject> .Exception(parameters, msg, e); } finally { Common.DebugWriteLog(msg); } return(OptionResult.SuccessClose); }
protected static void OnWeather(Event e) { WeatherEvent weatherEvent = e as WeatherEvent; if (weatherEvent == null) { return; } if (Household.ActiveHousehold == null) { return; } if (Household.ActiveHousehold.LotHome == null) { return; } /* * switch (weatherEvent.Weather) * { * case Weather.Rain: * case Weather.Hail: * foreach (Plant plant in Household.ActiveHousehold.LotHome.GetObjects<Plant>()) * { * if ((!plant.IsOutside) || (SeasonsManager.IsShelteredFromPrecipitation(plant))) continue; * * if (plant.WaterLevel < 100) * { * plant.WaterLevel = 100; * } * } * break; * } */ switch (weatherEvent.Weather) { case Weather.Hail: foreach (Plant plant in Household.ActiveHousehold.LotHome.GetObjects <Plant>()) { if ((!plant.IsOutside) || (SeasonsManager.IsShelteredFromPrecipitation(plant))) { continue; } if (RandomUtil.RandomChance(Tempest.Settings.mHailKillsPlants)) { plant.SetDead(); } } break; } switch (weatherEvent.Weather) { case Weather.Hail: case Weather.Snow: foreach (HarvestPlant plant in Sims3.Gameplay.Queries.GetObjects <HarvestPlant>()) { if ((!plant.IsOutside) || (SeasonsManager.IsShelteredFromPrecipitation(plant))) { continue; } if (RandomUtil.RandomChance(Tempest.Settings.mHailKillsHarvestables)) { HarvestPlant harvest = plant as HarvestPlant; if (harvest != null) { harvest.SetGrowthStateFromHarvestToNext(); } } } break; } }
public override string GetInteractionName(Sim actor, HarvestPlant target, InteractionObjectPair iop) { return(base.GetInteractionName(actor, target, new InteractionObjectPair(sOldSingleton, target))); }
private static bool HarvestHarvestable(HarvestPlant ths, GameObject harvestable, Sim actor, BurglarSituation burglarSituation) { if (harvestable == null) { return false; } harvestable.SetOwnerLot(actor.LotHome); harvestable.UnParent(); harvestable.RemoveFromWorld(); bool flag = false; if (burglarSituation == null) { if (actor.Inventory.TryToAdd(harvestable, false)) { flag = true; } } else { burglarSituation.StolenObjects.Add(harvestable); burglarSituation.CurrentValue += harvestable.Value; flag = true; } if (flag) { harvestable.AddFlags(GameObject.FlagField.WasHarvested); harvestable.RemoveComponent<HarvestableComponent>(); ths.PostHarvestHarvestable(actor, harvestable); return flag; } harvestable.Destroy(); return flag; }
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; }
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); } }