Example #1
0
        public static bool HasActiveRelation(Household home)
        {
            if (Household.ActiveHousehold == null)
            {
                return(false);
            }

            foreach (SimDescription sim in HouseholdsEx.All(home))
            {
                foreach (SimDescription active in HouseholdsEx.All(Household.ActiveHousehold))
                {
                    if (Relationships.IsCloselyRelated(sim, active, false))
                    {
                        return(true);
                    }

                    Relationship relation = Relationship.Get(sim, active, false);
                    if (relation == null)
                    {
                        continue;
                    }

                    if (relation.AreFriendsOrRomantic())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #2
0
        public static Dictionary<SimDescription, string> GetTravelChoices(Sim travelInitiator, Type filter, bool forUniversity)
        {
            Dictionary<SimDescription, string> results = new Dictionary<SimDescription, string>();

            foreach (Sim sim in LotManager.Actors)
            {
                if (sim.Household != travelInitiator.Household)
                {
                    if (GameStates.sTravelData != null) continue;
                }

                if ((sim.Household != travelInitiator.Household) || (!SimTypes.IsSelectable(sim)))
                {
                    bool allow = false;

                    if ((filter & Type.Friends) != Type.None)
                    {
                        foreach (Sim member in Households.AllSims(travelInitiator.Household))
                        {
                            if (member == sim) continue;

                            Relationship relation = Relationship.Get(sim, travelInitiator, false);
                            if (relation == null) continue;

                            if (relation.AreFriendsOrRomantic())
                            {
                                allow = true;
                                break;
                            }
                        }
                    }

                    if (!allow) continue;
                }

                results[sim.SimDescription] = TravelUtilEx.CheckForReasonsToFailTravel(sim.SimDescription, filter, forUniversity ? WorldName.University : WorldName.Undefined, false, false);
            }

            return results;
        }
Example #3
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);
            }
        }
Example #4
0
        public bool AlterRelationship(SimDescription sim, SimDescription source, bool positive)
        {
            if (!ShowingSigns)
            {
                return(false);
            }

            if (source == null)
            {
                return(false);
            }

            if (!positive)
            {
                // You really can't avoid the sim if you live together
                if (sim.Household == source.Household)
                {
                    return(false);
                }
            }

            if (!Vector.Settings.mAllowRelationshipDelta)
            {
                return(false);
            }

            Relationship relation = Relationship.Get(sim, source, true);

            if (relation == null)
            {
                return(false);
            }

            int delta = mNonPersistableData.GetRelationshipDelta(mStage, positive);

            if (delta == 0)
            {
                return(false);
            }

            if (relation.AreFriendsOrRomantic())
            {
                return(false);
            }

            if (delta < 0)
            {
                // If we are already negative, don't make it further
                if (relation.CurrentLTRLiking <= 0)
                {
                    return(false);
                }
            }
            else
            {
                if (mInfector == source.SimDescriptionId)
                {
                    return(false);
                }
            }

            relation.LTR.UpdateLiking(delta);
            return(true);
        }