示例#1
0
        public static bool TestFight(Sim actor, Sim target, ActiveTopic topic, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
        {
            try
            {
                if (!CommonTest(actor, target))
                {
                    return(false);
                }

                if (TestBarBrawl(actor, target, topic, isAutonomous, ref greyedOutTooltipCallback))
                {
                    return(false);
                }
                else if ((actor.SimDescription.ChildOrBelow) || (target.SimDescription.ChildOrBelow))
                {
                    if ((actor.SimDescription.YoungAdultOrAbove) || (target.SimDescription.YoungAdultOrAbove))
                    {
                        return(false);
                    }
                }

                if (target.Service is Burglar)
                {
                    BurglarSituation situation = ServiceSituation.FindServiceSituationInvolving(target) as BurglarSituation;
                    if (((situation != null) && (situation.HasBeenApprehended || situation.HasBeenDefeated)) || (target.LotCurrent != Household.ActiveHousehold.LotHome))
                    {
                        return(false);
                    }
                    else if ((!actor.IsBrave && !actor.BuffManager.HasElement(BuffNames.OddlyPowerful)) && !actor.TraitManager.HasElement(TraitNames.CanApprehendBurglar))
                    {
                        return(false);
                    }
                    return(true);
                }

                if ((actor.Genealogy == null) || (target.Genealogy == null))
                {
                    return(false);
                }

                Relationship relationship = Relationship.Get(actor, target, false);
                if ((actor.HasTrait(TraitNames.MeanSpirited) && (relationship != null)) && ((relationship.AreFriendsOrRomantic() || (actor.Household.Contains(target.SimDescription) && (relationship.LTR.Liking >= 0f))) || target.Genealogy.IsParentOrStepParent(actor.Genealogy)))
                {
                    return(false);
                }

                return(((relationship == null) || (relationship.LTR.Liking < SocialComponent.kFightLikingValue)) && !target.Genealogy.IsParentOrStepParent(actor.Genealogy));
            }
            catch (Exception e)
            {
                Common.Exception(actor, target, e);
                return(false);
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 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;
 }
示例#5
0
        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;
        }
示例#6
0
        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);
        }