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 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); }