public static void Initialize(Initializers ths) { Common.StringBuilder msg = new Common.StringBuilder("Initialize"); try { GameUtils.BeginLoadEvent("GameInit"); for (int i = 0x0; i < ths.mInitializerRecords.Count; i++) { Initializers.Record record = ths.mInitializerRecords[i]; GameUtils.BeginLoadEvent("GameInit/" + record.ToString()); Initializers.Action action = record.Instantiate(); if (action.Valid) { msg += Common.NewLine + "Instance: " + action.mInstance; msg += Common.NewLine + "Init: " + action.mInit; msg += Common.NewLine + "Type: " + action.mType; Traveler.InsanityWriteLog(msg); try { string header = action.mType + " - " + action.mInit; using (Common.TestSpan span = new Common.TestSpan(Common.ExternalTimeSpanLogger.sLogger, header)) { if (header == "Sims3.Gameplay.CAS.SimDescription - Void PostLoadFixUp()") { PostLoadFixUp(); } else { action.DoInit(); } } } catch (Exception e) { Common.Exception(msg, e); } } GameUtils.EndLoadEvent(); } GameUtils.EndLoadEvent(); } finally { Common.WriteLog(msg); } }
public bool Test() { string name = "Allow " + UnlocalizedName; if (!Main.SecondCycle) { name = "First " + name; } using (Common.TestSpan span = new Common.TestSpan(Scenarios, name)) { return(Allow()); } }
protected ICollection <SimDescription> FindPotentialMothers(int additionalBabyCount) { List <SimDescription> choices = new List <SimDescription>(); foreach (SimDescription sim in Sims.All) { using (Common.TestSpan span = new Common.TestSpan(Scenarios, "FindPotentialMothers")) { if (!AllowSpecies(sim)) { continue; } IncStat(sim.FullName, Common.DebugLevel.Logging); if ((sim.IsHuman) && (sim.Partner == null)) { IncStat("Unpartnered"); } else if (sim.IsPregnant) { IncStat("Already Pregnant"); } else if (!Pregnancies.Allow(this, sim, sim.Partner, Managers.Manager.AllowCheck.Active)) { //IncStat("Allow Fail"); continue; } else if (!TestPreferredBaby(this, sim, additionalBabyCount)) { //IncStat("Preferred Fail"); continue; } else if (!Pregnancies.TestCooldown(this, sim)) { //IncStat("Cooldown Fail"); continue; } else { choices.Add(sim); } } } AddStat("Fertile Choices", choices.Count); return(new SimScoringList(this, "PotentialMother", choices, false).GetBestByMinScore(0)); }
protected static void OnTimer() { try { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration STCDesire:OnTimer")) { ScoringLookup.UnloadCaches(false); Common.FunctionTask.Perform(OnRecalulateDesire); } } catch (Exception e) { Common.Exception("STCDesire:OnTimer", e); } }
protected int PrivateScore(SP parameters, ICollection <IScoring <T, SubSP> > scoringList, string suffix) { Common.IStatGenerator manager = ScoringLookup.Stats; bool lowDebugging = false; if (manager != null) { lowDebugging = (manager.DebuggingLevel > Common.DebugLevel.Stats); } int totalScore = 0; foreach (IScoring <T, SubSP> scoring in scoringList) { string scoringName = null, fullScoringName = null; if (lowDebugging) { scoringName = scoring.ToString() + suffix; fullScoringName = "Duration " + Name + " " + scoringName; scoringName = "Duration " + scoringName; } using (Common.TestSpan scoringTime2 = new Common.TestSpan(manager, scoringName)) { using (Common.TestSpan scoringTime = new Common.TestSpan(manager, fullScoringName, Common.DebugLevel.High)) { int score = scoring.Score(parameters); ScoringLookup.AddStat(scoring.ToString() + suffix, score); if (score <= -1000) { return(score); } totalScore += score; } } } return(totalScore); }
protected static void OnSocialEvent(Event e) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration AttractionHelper:OnSocialEvent")) { SocialEvent socialEvent = e as SocialEvent; if ((socialEvent != null) && (socialEvent.WasAccepted)) { Sim actor = socialEvent.Actor as Sim; Sim target = socialEvent.TargetObject as Sim; if ((actor != null) && (target != null)) { bool created = false; LastCheck lastCheck = GetLastCheck(actor.SimDescription.SimDescriptionId, target.SimDescription.SimDescriptionId, true, out created); if (created) { SetLastCheck(target.SimDescription.SimDescriptionId, actor.SimDescription.SimDescriptionId, lastCheck); } bool force = false; if ((!lastCheck.mAttractionNotice) && ((SimTypes.IsSelectable(actor)) || (SimTypes.IsSelectable(target)))) { force = true; } if ((force) || ((lastCheck.mTime + SimClock.kSimulatorTicksPerSimDay) > SimClock.CurrentTicks)) { lastCheck.mTime = SimClock.CurrentTicks; Relationship relation = Relationship.Get(actor, target, false); if (relation != null) { RelationshipEx.CalculateAttractionScore(relation, !lastCheck.mAttractionNotice); if ((SimTypes.IsSelectable(actor)) || (SimTypes.IsSelectable(target))) { lastCheck.mAttractionNotice = true; } } } } } } }
public static void OnWorldLoadFinishedEx(object sender, EventArgs args) { Common.StringBuilder msg = new Common.StringBuilder("ToInWorldState:OnWorldLoadFinishedEx <Begin>"); Traveler.InsanityWriteLog(msg); try { using (Common.TestSpan span = new Common.TestSpan(Common.ExternalTimeSpanLogger.sLogger, "OnWorldLoadFinishedEx", Common.DebugLevel.Low)) { msg += Common.NewLine + "Order"; foreach (Delegate del in sOnWorldLoadFinishedEventHandler.GetInvocationList()) { msg += Common.NewLine + del.Method + " : " + del.Method.DeclaringType.AssemblyQualifiedName + " : " + del.Target; } msg += Common.NewLine + "Actual"; foreach (Delegate del in sOnWorldLoadFinishedEventHandler.GetInvocationList()) { using (Common.TestSpan subSpan = new Common.TestSpan(Common.ExternalTimeSpanLogger.sLogger, "OnWorldLoadFinishedEx: " + del.Method + " : " + del.Method.DeclaringType.AssemblyQualifiedName, Common.DebugLevel.Low)) { msg += Common.NewLine + del.Method + " : " + del.Method.DeclaringType.AssemblyQualifiedName + " : " + del.Target; Traveler.InsanityWriteLog(msg); try { del.DynamicInvoke(new object[] { sender, args }); } catch (Exception e) { Traveler.InsanityException(msg, e); } } } } msg += Common.NewLine + "ToInWorldState:OnWorldLoadFinishedEx <End>"; Traveler.InsanityWriteLog(msg); } catch (Exception e) { Traveler.InsanityException(msg, e); } }
public List <SimDescription> GetAllowedTargets(SimDescription sim) { List <SimDescription> results = new List <SimDescription>(); if (Target != null) { if (TargetTest(Target)) { results.Add(Target); } } else { ICollection <SimDescription> sims = null; using (Common.TestSpan span = new Common.TestSpan(Scenarios, "GetTargets " + UnlocalizedName)) { sims = GetTargets(sim); } if (sims != null) { AddStat("Target Potentials", sims.Count); foreach (SimDescription target in new List <SimDescription> (sims)) { Target = target; if (TargetTest(target)) { IncStat("Included"); results.Add(target); } Main.Sleep("DualSimScenario:GetAllowedTargets"); } AddStat("Target Allowed", results.Count); } else { IncStat("Empty Target List"); } } return(results); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { try { Sim target = parameters.mTarget as Sim; using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, "Total", Common.DebugLevel.Stats)) { GetUnfilteredSocials(parameters.mActor.SocialComponent, parameters.mActor as Sim, target, Relationship.Get(parameters.mActor as Sim, target, false)); } Common.RecordErrors(); } catch (Exception e) { GameHitParameters <GameObject> .Exception(parameters, e); } return(OptionResult.SuccessClose); }
public List <SimDescription> GetAllowedSims() { List <SimDescription> results = new List <SimDescription>(); if (Sim != null) { if (Test(Sim)) { results.Add(Sim); } } else { ICollection <SimDescription> sims = null; using (Common.TestSpan span = new Common.TestSpan(Scenarios, "GetSims " + UnlocalizedName)) { sims = GetSims(); } if (sims != null) { AddStat("Sim Potentials", sims.Count); foreach (SimDescription sim in new List <SimDescription> (sims)) { Sim = sim; if (Test(sim)) { IncStat("Included"); results.Add(sim); } Main.Sleep("SimScenario:GetAllowedSims"); } AddStat("Sim Allowed", results.Count); } } return(results); }
protected static void OnSocialEvent(Event e) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration TeenAdultControl:OnSocialEvent")) { SocialEvent socialEvent = e as SocialEvent; if ((socialEvent != null) && (socialEvent.WasAccepted)) { Common.StringBuilder msg = new Common.StringBuilder("TeenAdult:OnSocialEvent"); Sim actor = socialEvent.Actor as Sim; Sim target = socialEvent.TargetObject as Sim; if ((actor == null) || (target == null)) return; if ((!actor.SimDescription.Teen) || (actor.SimDescription.Teen == target.SimDescription.Teen)) return; msg += Common.NewLine + actor.FullName; msg += Common.NewLine + target.FullName; msg += Common.NewLine + socialEvent.SocialName; Relationship relation = Relationship.Get(actor, target, false); if (relation == null) return; LongTermRelationshipTypes newState = LongTermRelationshipTypes.Undefined; switch (socialEvent.SocialName) { case "Propose Going Steady": if ((actor.Partner != target.SimDescription) || (target.Partner != actor.SimDescription)) { Relationships.SetPartner(actor.SimDescription, target.SimDescription); newState = LongTermRelationshipTypes.Partner; } break; case "Propose Marriage": newState = LongTermRelationshipTypes.Fiancee; break; case "Have Private Wedding": case "Get Married Using Wedding Arch": newState = LongTermRelationshipTypes.Spouse; break; case "Lets Just Be Friends": case "Break Up": newState = LongTermRelationshipTypes.Ex; SetPreviousState(actor.SimDescription, target.SimDescription, newState); SetPreviousState(target.SimDescription, actor.SimDescription, newState); break; case "Divorce": newState = LongTermRelationshipTypes.ExSpouse; SetPreviousState(actor.SimDescription, target.SimDescription, newState); SetPreviousState(target.SimDescription, actor.SimDescription, newState); break; default: if (!relation.AreRomantic()) { List<SocialRuleRHS> list = SocialRuleRHS.Get(socialEvent.SocialName); if (list != null) { bool romantic = false; foreach (SocialRuleRHS rhs in list) { if ((rhs.InteractionBitsAdded & LongTermRelationship.InteractionBits.Romantic) == LongTermRelationship.InteractionBits.Romantic) { romantic = true; break; } } if (romantic) { msg += Common.NewLine + "A"; newState = LongTermRelationshipTypes.RomanticInterest; } } } else { msg += Common.NewLine + "C"; newState = relation.CurrentLTR; } break; } msg += Common.NewLine + newState; if (newState != LongTermRelationshipTypes.Undefined) { Perform(relation, newState); } //Common.DebugStackLog(msg); } } }
private static bool CanGetPreggers(Sim sim, bool isAutonomous, ref GreyedOutTooltipCallback callback, out string reason) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CanGetPreggers", Common.DebugLevel.Stats)) { if (SimTypes.IsPassporter(sim.SimDescription)) { reason = "Passport"; callback = Common.DebugTooltip(reason); return(false); } if (isAutonomous) { if (!sim.IsRobot && sim.SimDescription.Elder) { reason = "Elder"; callback = Common.DebugTooltip(reason); return(false); } else if (Households.IsFull(sim.Household, sim.IsPet, Woohooer.Settings.mMaximumHouseholdSizeForAutonomousV2[PersistedSettings.GetSpeciesIndex(sim)])) { reason = "House Full"; callback = Common.DebugTooltip(reason); return(false); } } else { if (!CommonPregnancy.SatisfiesMaximumOccupants(sim, isAutonomous, ref callback)) { reason = "Maximum Occupants"; return(false); } } if (!sim.IsRobot && SimTypes.IsSkinJob(sim.SimDescription)) { reason = "Non-Robot Skin Job Fail"; callback = Common.DebugTooltip(reason); return(false); } else if (sim.BuffManager.HasTransformBuff()) { reason = "Transform Buff"; callback = Common.DebugTooltip(reason); return(false); } else if (!sim.IsRobot && sim.SimDescription.IsVisuallyPregnant) { reason = "Already Pregnant"; callback = Common.DebugTooltip(reason); return(false); } else if (sim.IsRobot && sim.SimDescription.IsPregnant) { reason = "Already Pregnant"; callback = Common.DebugTooltip(reason); return(false); } if (sim.Household != null && sim.Household.IsTouristHousehold) { MiniSimDescription description = MiniSimDescription.Find(sim.SimDescription.SimDescriptionId); if (description == null) { reason = "Too Many Sims"; callback = delegate { return(Common.LocalizeEAString(sim.IsFemale, "Gameplay/Actors/Sim/TryForBaby:TooManySims", new object[] { sim })); }; return(false); } } else if (sim.LotHome == null) { reason = "Too Many Sims"; callback = delegate { if (sim.Household.IsAlienHousehold) { return(Common.LocalizeEAString(sim.IsFemale, "Gameplay/Actors/Sim/TryForBaby:AlienNPCs", new object[] { sim })); } else { return(Common.LocalizeEAString(sim.IsFemale, "Gameplay/Actors/Sim/TryForBaby:TooManySims", new object[] { sim })); } }; return(false); } else if (sim.SimDescription.IsDueToAgeUp() || (sim.SimDescription.AgingState != null && sim.SimDescription.AgingState.IsAgingInProgress())) { reason = "Aging Up Fail"; callback = Common.DebugTooltip(reason); return(false); } else if (SimTypes.IsLampGenie(sim.SimDescription)) { reason = "Lamp Genie"; callback = Common.DebugTooltip(reason); return(false); } if (sStoryProgressionAllowImpregnation.Valid && Woohooer.Settings.TestStoryProgression(isAutonomous)) { reason = sStoryProgressionAllowImpregnation.Invoke <string>(new object[] { sim.SimDescription, isAutonomous }); if (reason != null) { callback = Woohooer.StoryProgressionTooltip(reason, false); return(false); } } reason = null; return(true); } }
protected bool TargetTest(SimDescription sim) { using (Common.TestSpan span = new Common.TestSpan(Scenarios, "AllowDualSim " + UnlocalizedName)) { return TargetAllow(sim); } }
protected static void OnSocialEvent(Event e) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CommonSocials:OnSocialEvent")) { SocialEvent socialEvent = e as SocialEvent; if ((socialEvent != null) && (!socialEvent.WasRecipient)) { Sim actor = socialEvent.Actor as Sim; Sim target = socialEvent.TargetObject as Sim; if (SimTypes.IsSelectable(actor)) { if (sRomanticSocials.ContainsKey(socialEvent.SocialName)) { actor.IncreaseGenderPreferenceAfterAmorousStuff(target); } } // Since the IsRomantic is disabled on all the action data, we must compensate for some coding that is missing if (GetRomanticJealousy(socialEvent.SocialName, true) != JealousyLevel.None) { JealousyLevel level = GetRomanticJealousy(socialEvent.SocialName, false); if (socialEvent.WasAccepted) { // Part of SocialInteractionA:Run() if (actor.SimDescription.IsVampire && target.BuffManager.HasElement(BuffNames.GarlicBreath)) { OccultVampire.GarlicEffects(actor, Origin.FromEatingGarlic); } if (target.SimDescription.IsVampire && socialEvent.Actor.BuffManager.HasElement(BuffNames.GarlicBreath)) { OccultVampire.GarlicEffects(target, Origin.FromEatingGarlic); } Relationship relation = Relationship.Get(actor, target, false); if (relation != null) { relation.UpdateRomanceVisibilityForPdaIfNecessary(actor, target, level); } GroupingSituation.EndDateIfPdaIsNotWithDatingSim(actor, target); } bool witnessed = false; foreach (Sim witness in actor.LotCurrent.GetSims()) { if (witness == actor) continue; if (witness == target) continue; if (!CaresAboutJealousy(actor, target, witness, level, false)) continue; witnessed = true; if (!SocialComponentEx.CheckCheating(witness, actor, target, level)) { if (socialEvent.WasAccepted) { SocialComponentEx.CheckCheating(witness, target, actor, level); } } } SendCheatingEvents(actor, target, witnessed, level, socialEvent.WasAccepted); } } } }
public static bool CanTryForBaby(Sim a, Sim target, bool autonomous, CommonWoohoo.WoohooStyle style, ref GreyedOutTooltipCallback greyedOutTooltipCallback, out string reason) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CanTryForBaby", Common.DebugLevel.Stats)) { int chance = 0; bool teenCanTry = false; int speciesIndex = PersistedSettings.GetSpeciesIndex(a); PregnancyChoice pregnancyChoice = PregnancyChoice.Either; switch (style) { case CommonWoohoo.WoohooStyle.Risky: if ((a.SimDescription.Teen) || (target.SimDescription.Teen)) { chance = Woohooer.Settings.mRiskyTeenBabyMadeChance; } else { chance = Woohooer.Settings.mRiskyBabyMadeChanceV2[speciesIndex]; } teenCanTry = Woohooer.Settings.mTeenRiskyAutonomous; pregnancyChoice = Woohooer.Settings.mRiskyPregnancyChoice; break; case CommonWoohoo.WoohooStyle.TryForBaby: if ((a.SimDescription.Teen) || (target.SimDescription.Teen)) { chance = Woohooer.Settings.mTryForBabyTeenBabyMadeChance; } else { chance = Woohooer.Settings.mTryForBabyMadeChanceV2[speciesIndex]; } teenCanTry = Woohooer.Settings.mTeenTryForBabyAutonomous; pregnancyChoice = Woohooer.Settings.mTryForBabyPregnancyChoice; break; } if (chance <= 0) { greyedOutTooltipCallback = Common.DebugTooltip("Chance Fail"); reason = "Chance Fail"; return(false); } if (!CommonSocials.CanGetRomantic(a, target, autonomous, true, true, ref greyedOutTooltipCallback, out reason)) { return(false); } if (autonomous) { if ((sStoryProgressionAllowPregnancy.Valid) && (Woohooer.Settings.TestStoryProgression(autonomous))) { reason = sStoryProgressionAllowPregnancy.Invoke <string>(new object[] { a.SimDescription, target.SimDescription, autonomous }); if (reason != null) { greyedOutTooltipCallback = Woohooer.StoryProgressionTooltip(reason, false); return(false); } } } if (a.SimDescription.Gender == target.SimDescription.Gender) { if (!Woohooer.Settings.mAllowSameSexTryForBabyV2[speciesIndex]) { greyedOutTooltipCallback = Common.DebugTooltip("Same Sex Fail"); reason = "Same Sex Fail"; return(false); } if ((!CanGetPreggers(a, autonomous, ref greyedOutTooltipCallback, out reason)) && (!CanGetPreggers(target, autonomous, ref greyedOutTooltipCallback, out reason))) { return(false); } } else { if (a.IsFemale) { if (!CanGetPreggers(a, autonomous, ref greyedOutTooltipCallback, out reason)) { return(false); } } else { if (!CanGetPreggers(target, autonomous, ref greyedOutTooltipCallback, out reason)) { return(false); } } } if ((autonomous) || (Woohooer.Settings.mTestAllConditionsForUserDirected[speciesIndex])) { if (HasBlockingBuff(a)) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:BuffBlock")); }; reason = "BuffBlock"; return(false); } if (HasBlockingBuff(target)) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:BuffBlock")); }; reason = "BuffBlock"; return(false); } if ((a.SimDescription.Gender != target.SimDescription.Gender) || (pregnancyChoice != PregnancyChoice.Either)) { if (autonomous) { if (a.SimDescription.IsPregnant) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:Pregnant")); }; reason = "Pregnant"; return(false); } if (target.SimDescription.IsPregnant) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:Pregnant")); }; reason = "Pregnant"; return(false); } } else { if (a.SimDescription.IsVisuallyPregnant) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:Pregnant")); }; reason = "Pregnant"; return(false); } if (target.SimDescription.IsVisuallyPregnant) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:Pregnant")); }; reason = "Pregnant"; return(false); } } } if ((a.SimDescription.IsMale) && (target.SimDescription.IsMale)) { if (!Woohooer.Settings.mAutonomousMaleMaleTryForBabyV2[speciesIndex]) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:SameSexDenied")); }; reason = "SameSexDenied"; return(false); } if (a.SimDescription.Elder) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:Elder")); }; reason = "Elder"; return(false); } if (target.SimDescription.Elder) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:Elder")); }; return(false); } } if ((a.SimDescription.IsFemale) && (target.SimDescription.IsFemale)) { if (!Woohooer.Settings.mAutonomousFemaleFemaleTryForBabyV2[speciesIndex]) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:SameSexDenied")); }; reason = "SameSexDenied"; return(false); } } if ((a.SimDescription.Elder) && (a.SimDescription.IsFemale)) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:Elder")); }; reason = "Elder"; return(false); } if ((target.SimDescription.Elder) && (target.SimDescription.IsFemale)) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:Elder")); }; reason = "Elder"; return(false); } if ((a.SimDescription.Teen) || (target.SimDescription.Teen)) { if ((!teenCanTry) && (autonomous)) { greyedOutTooltipCallback = delegate { return(Common.LocalizeEAString("NRaas.Woohooer:Teenagers")); }; reason = "Teenagers"; return(false); } } if ((SimTypes.IsSkinJob(a.SimDescription)) || (SimTypes.IsSkinJob(target.SimDescription))) { greyedOutTooltipCallback = delegate { return(Common.Localize("TryForBaby:SkinJob")); }; reason = "SkinJob"; return(false); } } return(true); } }
private static bool CanGetPreggers(Sim sim, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback, out string reason) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CanGetPreggers", Common.DebugLevel.Stats)) { if (SimTypes.IsPassporter(sim.SimDescription)) { greyedOutTooltipCallback = Common.DebugTooltip("Passport"); reason = "Passport"; return false; } if (isAutonomous) { if (sim.SimDescription.Elder) { greyedOutTooltipCallback = Common.DebugTooltip("Elder"); reason = "Elder"; return false; } else if (Households.IsFull(sim.Household, sim.IsPet, Woohooer.Settings.mMaximumHouseholdSizeForAutonomousV2[PersistedSettings.GetSpeciesIndex(sim)])) { greyedOutTooltipCallback = Common.DebugTooltip("House Full"); reason = "House Full"; return false; } } else { if (!SatisfiesMaximumOccupants(sim, isAutonomous, ref greyedOutTooltipCallback)) { reason = "MaximumOccupants"; return false; } } if (SimTypes.IsSkinJob(sim.SimDescription)) { greyedOutTooltipCallback = Common.DebugTooltip("Skin Job Fail"); reason = "Skin Job Fail"; return false; } else if (sim.BuffManager.HasTransformBuff()) { greyedOutTooltipCallback = Common.DebugTooltip("Transform Buff"); reason = "Transform Buff"; return false; } else if (sim.SimDescription.IsVisuallyPregnant) { greyedOutTooltipCallback = Common.DebugTooltip("Already Pregnant"); reason = "Already Pregnant"; return false; } if ((sim.Household != null) && (sim.Household.IsTouristHousehold)) { MiniSimDescription description = MiniSimDescription.Find(sim.SimDescription.SimDescriptionId); if (description == null) { greyedOutTooltipCallback = delegate { return Common.LocalizeEAString(sim.IsFemale, "Gameplay/Actors/Sim/TryForBaby:TooManySims", new object[] { sim }); }; reason = "TooManySims"; return false; } } else if (sim.LotHome == null) { greyedOutTooltipCallback = delegate { if (sim.Household.IsAlienHousehold) { return Common.LocalizeEAString(sim.IsFemale, "Gameplay/Actors/Sim/TryForBaby:AlienNPCs", new object[] { sim }); } else { return Common.LocalizeEAString(sim.IsFemale, "Gameplay/Actors/Sim/TryForBaby:TooManySims", new object[] { sim }); } }; reason = "TooManySims"; return false; } else if ((sim.SimDescription.IsDueToAgeUp()) || ((sim.SimDescription.AgingState != null) && (sim.SimDescription.AgingState.IsAgingInProgress()))) { greyedOutTooltipCallback = Common.DebugTooltip("Aging Up Fail"); reason = "Aging Up Fail"; return false; } else if (SimTypes.IsLampGenie(sim.SimDescription)) { greyedOutTooltipCallback = Common.DebugTooltip("Lamp Genie"); reason = "Lamp Genie"; return false; } if ((sStoryProgressionAllowImpregnation.Valid) && (Woohooer.Settings.TestStoryProgression(isAutonomous))) { reason = sStoryProgressionAllowImpregnation.Invoke<string>(new object[] { sim.SimDescription, isAutonomous }); if (reason != null) { greyedOutTooltipCallback = Woohooer.StoryProgressionTooltip(reason, false); return false; } } reason = null; return true; } }
protected ScenarioResult Run(ScenarioFrame frame) { try { if (Scenarios == null) { return(ScenarioResult.Failure); } string name = "Duration " + UnlocalizedName; if (!Main.SecondCycle) { name = "First " + name; } using (Common.TestSpan span = new Common.TestSpan(Scenarios, name)) { AddTry(); if (!Test()) { AllowFailCleanup(); return(ScenarioResult.Failure); } AddAllowed(); List <Scenario> list = new List <Scenario>(); int continueChance = ContinueChance; int maximum = 0; bool random = true; GatherResult result = GatherResult.Failure; string gatherName = "Gather " + UnlocalizedName; if (!Main.SecondCycle) { gatherName = "First " + gatherName; } using (Common.TestSpan gatherSpan = new Common.TestSpan(Scenarios, gatherName)) { result = Gather(list, ref continueChance, ref maximum, ref random); } switch (result) { case GatherResult.Update: return(Update(frame)); case GatherResult.Failure: IncStat("Gathering Failure"); return(ScenarioResult.Failure); } // Stops the PushAndPrint() routine from firing mPushed = true; AddStat("Gathered", list.Count); if (list.Count == 0) { return(ScenarioResult.Failure); } if (maximum <= 0) { maximum = list.Count; } if (continueChance != 100) { AddStat("Chance", continueChance); } bool first = true; int count = 0; if (random) { while (list.Count > 0) { int index = RandomUtil.GetInt(list.Count - 1); Scenario item = list[index]; list.RemoveAt(index); item.mFirst = first; first = false; Add(frame, item, continueChance); count++; if (count > maximum) { AddStat("Maximum", count); break; } } } else { foreach (Scenario item in list) { item.mFirst = first; first = false; Add(frame, item, continueChance); count++; if (count > maximum) { AddStat("Maximum", count); break; } } } return(ScenarioResult.Success); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(ToString(), e); return(ScenarioResult.Failure); } }
protected static void OnLTRChanged(Event e) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration TeenAdultControl:OnLTRChanged")) { if (!sInLTRChanged) { try { sInLTRChanged = true; RelationshipLTRChangedEvent ltrEvent = e as RelationshipLTRChangedEvent; if ((ltrEvent != null) && (ltrEvent.OldLTR != ltrEvent.RelationshipState)) { Common.StringBuilder msg = new Common.StringBuilder("TeenAdult:OnLTRChanged"); Relationship relation = ltrEvent.Relationship; SimDescription descA = relation.SimDescriptionA; SimDescription descB = relation.SimDescriptionB; bool perform = false; LTRData oldLTR = LTRData.Get(ltrEvent.OldLTR); if (oldLTR != null) { if (LongTermRelationship.RelationshipIsInappropriate(oldLTR, descA, descB, ltrEvent.OldLTR)) { perform = true; } } LongTermRelationshipTypes wasRel = ltrEvent.RelationshipState; msg += Common.NewLine + relation.SimDescriptionA.FullName; msg += Common.NewLine + relation.SimDescriptionB.FullName; msg += Common.NewLine + "Old: " + ltrEvent.OldLTR; msg += Common.NewLine + "Was: " + wasRel; msg += Common.NewLine + "Perform: " + perform; if ((perform) && (descA.IsHuman) && (descB.IsHuman)) { if (((descA.Teen) && (descB.YoungAdultOrAbove)) || ((descB.Teen) && (descA.YoungAdultOrAbove))) { sTracer.Perform(); if (sTracer.mRevert) { Perform(relation, ltrEvent.OldLTR); msg += Common.NewLine + "Now: " + ltrEvent.RelationshipState; } if (!sTracer.mIgnore) { msg += Common.NewLine + sTracer; Common.DebugStackLog(msg); } } } } } finally { sInLTRChanged = false; } } } }
protected static void OnSocialEvent(Event e) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration TeenAdultControl:OnSocialEvent")) { SocialEvent socialEvent = e as SocialEvent; if ((socialEvent != null) && (socialEvent.WasAccepted)) { Common.StringBuilder msg = new Common.StringBuilder("TeenAdult:OnSocialEvent"); Sim actor = socialEvent.Actor as Sim; Sim target = socialEvent.TargetObject as Sim; if ((actor == null) || (target == null)) { return; } if ((!actor.SimDescription.Teen) || (actor.SimDescription.Teen == target.SimDescription.Teen)) { return; } msg += Common.NewLine + actor.FullName; msg += Common.NewLine + target.FullName; msg += Common.NewLine + socialEvent.SocialName; Relationship relation = Relationship.Get(actor, target, false); if (relation == null) { return; } LongTermRelationshipTypes newState = LongTermRelationshipTypes.Undefined; switch (socialEvent.SocialName) { case "Propose Going Steady": if ((actor.Partner != target.SimDescription) || (target.Partner != actor.SimDescription)) { Relationships.SetPartner(actor.SimDescription, target.SimDescription); newState = LongTermRelationshipTypes.Partner; } break; case "Propose Marriage": newState = LongTermRelationshipTypes.Fiancee; break; case "Have Private Wedding": case "Get Married Using Wedding Arch": newState = LongTermRelationshipTypes.Spouse; break; case "Lets Just Be Friends": case "Break Up": newState = LongTermRelationshipTypes.Ex; SetPreviousState(actor.SimDescription, target.SimDescription, newState); SetPreviousState(target.SimDescription, actor.SimDescription, newState); break; case "Divorce": newState = LongTermRelationshipTypes.ExSpouse; SetPreviousState(actor.SimDescription, target.SimDescription, newState); SetPreviousState(target.SimDescription, actor.SimDescription, newState); break; default: if (!relation.AreRomantic()) { List <SocialRuleRHS> list = SocialRuleRHS.Get(socialEvent.SocialName); if (list != null) { bool romantic = false; foreach (SocialRuleRHS rhs in list) { if ((rhs.InteractionBitsAdded & LongTermRelationship.InteractionBits.Romantic) == LongTermRelationship.InteractionBits.Romantic) { romantic = true; break; } } if (romantic) { msg += Common.NewLine + "A"; newState = LongTermRelationshipTypes.RomanticInterest; } } } else { msg += Common.NewLine + "C"; newState = relation.CurrentLTR; } break; } msg += Common.NewLine + newState; if (newState != LongTermRelationshipTypes.Undefined) { Perform(relation, newState); } //Common.DebugStackLog(msg); } } }
public SocialInteractionCandidateCollectionEx(Sim actor, Sim target, Relationship r, Conversation c, bool isAutonomous, ref string msg) : base (actor, target, r, c, isAutonomous) { using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, "SocialInteractionCandidateCollectionEx", Common.DebugLevel.Stats)) { mCommodityDictionary = new Dictionary<CommodityTypes, SocialInteractionCandidateForCommodity>(); mTraitDictionary = new Dictionary<TraitNames, SocialInteractionCandidateForCommodity>(); mActor = actor; mTarget = target; List<SocialInteractionCandidate> candidates = Conversation.GetActiveTopicInteractions(r.LTR.CurrentLTR, actor, target, c, isAutonomous); CreateFromCandidates(CommodityTypes.Undefined, candidates); if (actor.IsHuman && target.IsHuman) { foreach (CommodityTypes types in CommodityData.AllPlayableCommodities) { msg += Common.NewLine + "Commodity: " + types; List<SocialInteractionCandidate> list2 = GetSocialsForSTC(types, actor, target, r, c, isAutonomous, ref msg); using (Common.TestSpan span2 = new Common.TestSpan(TimeSpanLogger.Bin, "CreateFromCandidates: " + types, Common.DebugLevel.Stats)) { CreateFromCandidates(types, list2); } } } } }
public override bool Run() { bool pieMenuShowFailureReason = PieMenu.PieMenuShowFailureReason; try { PieMenu.PieMenuShowFailureReason = true; Common.StringBuilder msg = new Common.StringBuilder(); Common.StringBuilder unused = new Common.StringBuilder(); Common.ExceptionLogger.Convert(Actor, unused, msg); Common.ExceptionLogger.Convert(Target, unused, msg); msg += Common.NewLine + Common.NewLine + "Injected Interactions" + Common.NewLine; foreach (InteractionObjectPair interaction in Target.mInteractions) { Common.TestSpan span = Common.TestSpan.CreateSimple(); try { msg += Common.NewLine + interaction.InteractionDefinition.GetType(); msg += Common.NewLine + " " + interaction.InteractionDefinition.GetType().Assembly.FullName; InteractionInstanceParameters parameters = new InteractionInstanceParameters(interaction, Actor, new InteractionPriority(InteractionPriorityLevel.UserDirected), true, true); try { msg += Common.NewLine + " " + interaction.InteractionDefinition.GetInteractionName(ref parameters); } catch { msg += Common.NewLine + " (Exception)"; } } finally { long duration = span.Duration; if (duration > 1) { msg += Common.NewLine + " Duration: " + duration; } } } msg += Common.NewLine + Common.NewLine + "All Interactions" + Common.NewLine; List <InteractionObjectPair> interactions = null; Common.TestSpan interactionSpan = Common.TestSpan.CreateSimple(); try { interactions = Target.GetAllInteractionsForActor(Actor); interactions.AddRange(Target.GetAllInventoryInteractionsForActor(Actor)); } finally { long duration = interactionSpan.Duration; if (duration > 1) { msg += Common.NewLine + "All Interactions Duration: " + duration; } } foreach (InteractionObjectPair interaction in interactions) { Common.TestSpan span = Common.TestSpan.CreateSimple(); try { msg += Common.NewLine + interaction.InteractionDefinition.GetType(); msg += Common.NewLine + " " + interaction.InteractionDefinition.GetType().Assembly.FullName; GreyedOutTooltipCallback callback = null; InteractionInstanceParameters userDirected = new InteractionInstanceParameters(interaction, Actor, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true); InteractionTestResult result = InteractionTestResult.GenericUnknown; try { result = interaction.InteractionDefinition.Test(ref userDirected, ref callback); } catch (Exception e) { msg += Common.NewLine + e.ToString(); } try { msg += Common.NewLine + " " + interaction.InteractionDefinition.GetInteractionName(ref userDirected); SocialInteractionA.Definition socialInteractionA = interaction.InteractionDefinition as SocialInteractionA.Definition; if (socialInteractionA != null) { msg += Common.NewLine + " ActionKey=" + socialInteractionA.ActionKey; msg += Common.NewLine + " ChecksToSkip=" + socialInteractionA.ChecksToSkip; msg += Common.NewLine + " mIsInitialGreeting=" + socialInteractionA.mIsInitialGreeting; msg += Common.NewLine + " mTrait=" + socialInteractionA.mTrait; } } catch (Exception e) { // Only dispaly GetInteractionName() errors if that call is actually used by EA if (IUtil.IsPass(result)) { msg += Common.NewLine + e.ToString(); } else { msg += Common.NewLine + " (Exception)"; } } msg += Common.NewLine + " User Directed = " + result; if (callback != null) { msg += Common.NewLine + " Tooltip: " + callback(); } callback = null; InteractionInstanceParameters autonomous = new InteractionInstanceParameters(interaction, Actor, new InteractionPriority(InteractionPriorityLevel.UserDirected), true, true); result = InteractionTestResult.GenericUnknown; try { result = interaction.InteractionDefinition.Test(ref autonomous, ref callback); } catch (Exception e) { msg += Common.NewLine + e.ToString(); } msg += Common.NewLine + " Autonomous = " + result; if (callback != null) { msg += Common.NewLine + " Tooltip: " + callback(); } } finally { long duration = span.Duration; if (duration > 1) { msg += Common.NewLine + " Duration: " + duration; } } } Common.WriteLog(msg); SimpleMessageDialog.Show(Common.Localize("TestInteractions:MenuName"), Common.Localize("TestInteractions:Success")); } finally { PieMenu.PieMenuShowFailureReason = pieMenuShowFailureReason; } return(true); }
// From SocialComponent private static List<InteractionObjectPair> GetUnfilteredSocials(SocialComponent ths, Sim actor, Sim target, Relationship r) { string msg = actor.FullName; msg += Common.NewLine + target.FullName; bool isAutonomous = false; List<InteractionObjectPair> results = new List<InteractionObjectPair>(); if (actor != target) { bool flag2; int numSocials = STCData.GetNumSocials(ths.Conversation); SocialInteractionCandidateCollection candidates = new SocialInteractionCandidateCollectionEx(actor, target, r, ths.Conversation, isAutonomous, ref msg); Conversation.GetCurrentSTC(actor, target, r, ths.Conversation, out flag2); foreach (CommodityTypes str in CommodityData.AllPlayableCommodities) { using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, "Commodity: " + str, Common.DebugLevel.Stats)) { msg += Common.NewLine + "1 " + str; switch (str) { case CommodityTypes.Amorous: { if ((actor.CanGetRomantic(target, false) || !actor.SimDescription.IsHuman) || !target.SimDescription.IsHuman) { break; } results.Add(new InteractionObjectPair(Sim.BetrayedSimsFutileRomance.Singleton, target)); continue; } case CommodityTypes.Steamed: { if (!r.STC.IsPositive) { break; } continue; } case CommodityTypes.Insulting: if (isAutonomous && actor.BuffManager.HasElement(BuffNames.Admonished)) { continue; } break; } msg += Common.NewLine + "2 " + str; int num2 = numSocials; if (CommodityData.AppearsAsSubMenu(str)) { msg += Common.NewLine + "AppearsAsSubMenu " + str; List<SocialInteractionCandidate> socialsFor = candidates.GetSocialsFor(str); if (socialsFor != null) { msg += Common.NewLine + "socialsFor " + str + " " + socialsFor.Count; string changeToneText = CommodityData.Get(str).GetChangeToneText(); AddSocials(ths, actor, target, socialsFor, isAutonomous, num2, results, new string[] { changeToneText }, TraitNames.Unknown, ref msg); if (str == CommodityTypes.Friendly) { List<SocialInteractionCandidate> socials = candidates.GetSocialsFor(CommodityTypes.Neutral); if (socials != null) { AddSocials(ths, actor, target, socials, isAutonomous, num2, results, new string[] { changeToneText }, TraitNames.Unknown, ref msg); } } } } } } string str3 = Localization.LocalizeString("Gameplay/Socializing:Special", new object[0x0]); foreach (Trait trait in actor.TraitManager.List) { List<SocialInteractionCandidate> list4 = candidates.GetSocialsFor(trait.Guid); if ((list4 != null) && (list4.Count > 0x0)) { string str5 = trait.TraitName(actor.IsFemale); string[] inlineParentMenu = new string[] { str3, str5 + Localization.Ellipsis }; AddSocials(ths, actor, target, list4, isAutonomous, numSocials, results, inlineParentMenu, trait.Guid, ref msg); } } if (((ths.Conversation != null) && (actor.Household != target.Household)) && ((!actor.IsAtHome || target.IsAtHome) && (actor.IsAtHome || !target.IsAtHome))) { SocialInteractionCandidate candidate = new SocialInteractionCandidate(ths.GetGoodbyeSocial(actor, target), new string[0], null); ths.AddSocials(actor, target, new List<SocialInteractionCandidate>(new SocialInteractionCandidate[] { candidate }), isAutonomous, numSocials, results, new string[0x0], TraitNames.Unknown); } } Common.WriteLog(msg); return results; }
public static void AddSocials(SocialComponent ths, Sim actor, Sim target, List <SocialInteractionCandidate> socials, bool isAutonomous, int maxNumSocials, List <InteractionObjectPair> results, string[] inlineParentMenu, TraitNames trait, ref string msg) { int num = 0x0; InteractionPriority priority = new InteractionPriority(isAutonomous ? InteractionPriorityLevel.Autonomous : InteractionPriorityLevel.UserDirected); GreyedOutTooltipCallback greyedOutTooltipCallback = null; foreach (SocialInteractionCandidate candidate in socials) { using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, candidate.Name, Common.DebugLevel.Stats)) { string[] strArray = inlineParentMenu; bool flag = true; if (num >= maxNumSocials) { break; } ActiveTopic topic = candidate.Topic; if (topic != null) { ActiveTopicData data = topic.Data; if (data.HasPieMenuOverride()) { flag = false; strArray = new string[] { data.GetText(actor, new object[0x0]) }; } } ActionData data2 = ActionData.Get(candidate.Name); if (data2.AppearsOnTopLevel) { strArray = new string[0x0]; } if (!ths.DoesSocialAppear(candidate.Name, results, strArray)) { InteractionObjectPair iop = null; if (((data2.IntendedCommodityString == CommodityTypes.Friendly) && ((actor.Posture is ISeatedSocialPosture) || (target.Posture is ISeatedSocialPosture))) && data2.AllowCarryChild) { InteractionDefinition interaction = new SeatedSocialInteractionA.SeatedDefinition(candidate.Name, strArray, candidate.Topic, false, trait, false); iop = new InteractionObjectPair(interaction, target); InteractionInstanceParameters parameters = new InteractionInstanceParameters(iop, actor, priority, isAutonomous, true); if (!IUtil.IsPass(interaction.Test(ref parameters, ref greyedOutTooltipCallback))) { iop = null; } if (((candidate.Name == "Chat") && !actor.CanBeInSameGroupTalkAsMe(target)) && (actor.Posture is ISeatedSocialPosture)) { string[] strArray2 = new string[0x0]; if (!ths.DoesSocialAppear(candidate.Name, results, strArray2)) { interaction = new SeatedSocialInteractionA.SeatedDefinition(candidate.Name, strArray2, candidate.Topic, false, trait, true); InteractionObjectPair pair2 = new InteractionObjectPair(interaction, target); parameters = new InteractionInstanceParameters(pair2, actor, priority, isAutonomous, true); if (IUtil.IsPass(interaction.Test(ref parameters, ref greyedOutTooltipCallback))) { results.Add(pair2); } } } } if (iop == null) { iop = new InteractionObjectPair(new SocialInteractionA.Definition(candidate.Name, strArray, candidate.Topic, false, trait), target); } InteractionInstanceParameters parameters2 = new InteractionInstanceParameters(iop, actor, priority, isAutonomous, true); InteractionTestResult result = iop.InteractionDefinition.Test(ref parameters2, ref greyedOutTooltipCallback); msg += Common.NewLine + parameters2.InteractionDefinition.GetInteractionName(ref parameters2) + ": " + result; if ((IUtil.IsPass(result) || (greyedOutTooltipCallback != null)) || Sims3.Gameplay.UI.PieMenu.PieMenuShowFailureReason) { results.Add(iop); if (flag) { num++; } } } } } }
// From Conversation public static List<SocialInteractionCandidate> GetSocialsForSTC(CommodityTypes commodity, Sim actor, Sim target, Relationship r, Conversation c, bool isAutonomous, ref string msg) { using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, "GetSocialsForSTC: " + commodity, Common.DebugLevel.Stats)) { ShortTermContextTypes str2; List<SocialInteractionCandidate> list3; LongTermRelationshipTypes group = LongTermRelationshipTypes.Stranger; if (r != null) { group = r.LTR.CurrentLTR; } bool flag = (r != null) && ((r.STC == null) || (commodity == r.STC.CurrentCommodity)); if (!SocialComponent.SocialCommodityIsAvailable(commodity, target, actor, r)) { return null; } if (flag) { bool flag2; str2 = Conversation.GetCurrentSTC(actor, target, r, c, out flag2); } else { str2 = STCData.FirstSTC(commodity); } List<SocialInteractionCandidate> collection = ActionAvailabilityData.Get(actor, target, str2, group, true, null, isAutonomous); if ((isAutonomous && (r != null)) && (r.STC.CurrentCommodity == commodity)) { ShortTermContextTypes str4; collection = new List<SocialInteractionCandidate>(collection); ShortTermContextTypes str3 = STCData.PreviousSTC(str2); do { collection.AddRange(ActionAvailabilityData.Get(actor, target, str3, group, true, null, isAutonomous)); str4 = str3; str3 = STCData.PreviousSTC(str3); } while (!(str4 == str3)); } if (isAutonomous) { goto Label_0167; } ShortTermContextTypes category = STCData.FirstSTC(commodity); Label_00D5: msg += Common.NewLine + "GetSocialsForSTC " + category; foreach (SocialInteractionCandidate candidate in Get(actor, target, category, group, true, null, isAutonomous, ref msg)) { ActionData action = ActionData.Get(candidate.Name); if (Conversation.SimHasTraitEncouragingOrRequiringSocial(actor, action)) { if (category != STCData.FirstSTC(commodity)) { candidate.OnlyAppearsInTraitMenu = true; } collection.Add(candidate); } } ShortTermContextTypes str6 = STCData.NextSTC(category); if (str6 != category) { category = str6; goto Label_00D5; } Label_0167: msg += Common.NewLine + "Collection " + collection.Count; list3 = new List<SocialInteractionCandidate>(); foreach (SocialInteractionCandidate candidate2 in collection) { ActionData data2 = ActionData.Get(candidate2.Name); if (flag || !data2.DoesSocialOnlyAppearWhenSTCIsCurrent) { msg += Common.NewLine + " " + candidate2.Name; list3.Add(candidate2); } } return list3; } }
// From SocialComponent private static List <InteractionObjectPair> GetUnfilteredSocials(SocialComponent ths, Sim actor, Sim target, Relationship r) { string msg = actor.FullName; msg += Common.NewLine + target.FullName; bool isAutonomous = false; List <InteractionObjectPair> results = new List <InteractionObjectPair>(); if (actor != target) { bool flag2; int numSocials = STCData.GetNumSocials(ths.Conversation); SocialInteractionCandidateCollection candidates = new SocialInteractionCandidateCollectionEx(actor, target, r, ths.Conversation, isAutonomous, ref msg); Conversation.GetCurrentSTC(actor, target, r, ths.Conversation, out flag2); foreach (CommodityTypes str in CommodityData.AllPlayableCommodities) { using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, "Commodity: " + str, Common.DebugLevel.Stats)) { msg += Common.NewLine + "1 " + str; switch (str) { case CommodityTypes.Amorous: { if ((actor.CanGetRomantic(target, false) || !actor.SimDescription.IsHuman) || !target.SimDescription.IsHuman) { break; } results.Add(new InteractionObjectPair(Sim.BetrayedSimsFutileRomance.Singleton, target)); continue; } case CommodityTypes.Steamed: { if (!r.STC.IsPositive) { break; } continue; } case CommodityTypes.Insulting: if (isAutonomous && actor.BuffManager.HasElement(BuffNames.Admonished)) { continue; } break; } msg += Common.NewLine + "2 " + str; int num2 = numSocials; if (CommodityData.AppearsAsSubMenu(str)) { msg += Common.NewLine + "AppearsAsSubMenu " + str; List <SocialInteractionCandidate> socialsFor = candidates.GetSocialsFor(str); if (socialsFor != null) { msg += Common.NewLine + "socialsFor " + str + " " + socialsFor.Count; string changeToneText = CommodityData.Get(str).GetChangeToneText(); AddSocials(ths, actor, target, socialsFor, isAutonomous, num2, results, new string[] { changeToneText }, TraitNames.Unknown, ref msg); if (str == CommodityTypes.Friendly) { List <SocialInteractionCandidate> socials = candidates.GetSocialsFor(CommodityTypes.Neutral); if (socials != null) { AddSocials(ths, actor, target, socials, isAutonomous, num2, results, new string[] { changeToneText }, TraitNames.Unknown, ref msg); } } } } } } string str3 = Localization.LocalizeString("Gameplay/Socializing:Special", new object[0x0]); foreach (Trait trait in actor.TraitManager.List) { List <SocialInteractionCandidate> list4 = candidates.GetSocialsFor(trait.Guid); if ((list4 != null) && (list4.Count > 0x0)) { string str5 = trait.TraitName(actor.IsFemale); string[] inlineParentMenu = new string[] { str3, str5 + Localization.Ellipsis }; AddSocials(ths, actor, target, list4, isAutonomous, numSocials, results, inlineParentMenu, trait.Guid, ref msg); } } if (((ths.Conversation != null) && (actor.Household != target.Household)) && ((!actor.IsAtHome || target.IsAtHome) && (actor.IsAtHome || !target.IsAtHome))) { SocialInteractionCandidate candidate = new SocialInteractionCandidate(ths.GetGoodbyeSocial(actor, target), new string[0], null); ths.AddSocials(actor, target, new List <SocialInteractionCandidate>(new SocialInteractionCandidate[] { candidate }), isAutonomous, numSocials, results, new string[0x0], TraitNames.Unknown); } } Common.WriteLog(msg); return(results); }
public static void AddSocials(SocialComponent ths, Sim actor, Sim target, List<SocialInteractionCandidate> socials, bool isAutonomous, int maxNumSocials, List<InteractionObjectPair> results, string[] inlineParentMenu, TraitNames trait, ref string msg) { int num = 0x0; InteractionPriority priority = new InteractionPriority(isAutonomous ? InteractionPriorityLevel.Autonomous : InteractionPriorityLevel.UserDirected); GreyedOutTooltipCallback greyedOutTooltipCallback = null; foreach (SocialInteractionCandidate candidate in socials) { using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, candidate.Name, Common.DebugLevel.Stats)) { string[] strArray = inlineParentMenu; bool flag = true; if (num >= maxNumSocials) { break; } ActiveTopic topic = candidate.Topic; if (topic != null) { ActiveTopicData data = topic.Data; if (data.HasPieMenuOverride()) { flag = false; strArray = new string[] { data.GetText(actor, new object[0x0]) }; } } ActionData data2 = ActionData.Get(candidate.Name); if (data2.AppearsOnTopLevel) { strArray = new string[0x0]; } if (!ths.DoesSocialAppear(candidate.Name, results, strArray)) { InteractionObjectPair iop = null; if (((data2.IntendedCommodityString == CommodityTypes.Friendly) && ((actor.Posture is ISeatedSocialPosture) || (target.Posture is ISeatedSocialPosture))) && data2.AllowCarryChild) { InteractionDefinition interaction = new SeatedSocialInteractionA.SeatedDefinition(candidate.Name, strArray, candidate.Topic, false, trait, false); iop = new InteractionObjectPair(interaction, target); InteractionInstanceParameters parameters = new InteractionInstanceParameters(iop, actor, priority, isAutonomous, true); if (!IUtil.IsPass(interaction.Test(ref parameters, ref greyedOutTooltipCallback))) { iop = null; } if (((candidate.Name == "Chat") && !actor.CanBeInSameGroupTalkAsMe(target)) && (actor.Posture is ISeatedSocialPosture)) { string[] strArray2 = new string[0x0]; if (!ths.DoesSocialAppear(candidate.Name, results, strArray2)) { interaction = new SeatedSocialInteractionA.SeatedDefinition(candidate.Name, strArray2, candidate.Topic, false, trait, true); InteractionObjectPair pair2 = new InteractionObjectPair(interaction, target); parameters = new InteractionInstanceParameters(pair2, actor, priority, isAutonomous, true); if (IUtil.IsPass(interaction.Test(ref parameters, ref greyedOutTooltipCallback))) { results.Add(pair2); } } } } if (iop == null) { iop = new InteractionObjectPair(new SocialInteractionA.Definition(candidate.Name, strArray, candidate.Topic, false, trait), target); } InteractionInstanceParameters parameters2 = new InteractionInstanceParameters(iop, actor, priority, isAutonomous, true); InteractionTestResult result = iop.InteractionDefinition.Test(ref parameters2, ref greyedOutTooltipCallback); msg += Common.NewLine + parameters2.InteractionDefinition.GetInteractionName(ref parameters2) + ": " + result; if ((IUtil.IsPass(result) || (greyedOutTooltipCallback != null)) || Sims3.Gameplay.UI.PieMenu.PieMenuShowFailureReason) { results.Add(iop); if (flag) { num++; } } } } } }
public static bool CanTryForBaby(Sim a, Sim target, bool autonomous, CommonWoohoo.WoohooStyle style, ref GreyedOutTooltipCallback greyedOutTooltipCallback, out string reason) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CanTryForBaby", Common.DebugLevel.Stats)) { int chance = 0; bool teenCanTry = false; int speciesIndex = PersistedSettings.GetSpeciesIndex(a); PregnancyChoice pregnancyChoice = PregnancyChoice.Either; switch (style) { case CommonWoohoo.WoohooStyle.Risky: if ((a.SimDescription.Teen) || (target.SimDescription.Teen)) { chance = Woohooer.Settings.mRiskyTeenBabyMadeChance; } else { chance = Woohooer.Settings.mRiskyBabyMadeChanceV2[speciesIndex]; } teenCanTry = Woohooer.Settings.mTeenRiskyAutonomous; pregnancyChoice = Woohooer.Settings.mRiskyPregnancyChoice; break; case CommonWoohoo.WoohooStyle.TryForBaby: if ((a.SimDescription.Teen) || (target.SimDescription.Teen)) { chance = Woohooer.Settings.mTryForBabyTeenBabyMadeChance; } else { chance = Woohooer.Settings.mTryForBabyMadeChanceV2[speciesIndex]; } teenCanTry = Woohooer.Settings.mTeenTryForBabyAutonomous; pregnancyChoice = Woohooer.Settings.mTryForBabyPregnancyChoice; break; } if (chance <= 0) { greyedOutTooltipCallback = Common.DebugTooltip("Chance Fail"); reason = "Chance Fail"; return false; } if (!CommonSocials.CanGetRomantic(a, target, autonomous, true, true, ref greyedOutTooltipCallback, out reason)) { return false; } if (autonomous) { if ((sStoryProgressionAllowPregnancy.Valid) && (Woohooer.Settings.TestStoryProgression(autonomous))) { reason = sStoryProgressionAllowPregnancy.Invoke<string>(new object[] { a.SimDescription, target.SimDescription, autonomous }); if (reason != null) { greyedOutTooltipCallback = Woohooer.StoryProgressionTooltip(reason, false); return false; } } } if (a.SimDescription.Gender == target.SimDescription.Gender) { if (!Woohooer.Settings.mAllowSameSexTryForBabyV2[speciesIndex]) { greyedOutTooltipCallback = Common.DebugTooltip("Same Sex Fail"); reason = "Same Sex Fail"; return false; } if ((!CanGetPreggers(a, autonomous, ref greyedOutTooltipCallback, out reason)) && (!CanGetPreggers(target, autonomous, ref greyedOutTooltipCallback, out reason))) { return false; } } else { if (a.IsFemale) { if (!CanGetPreggers(a, autonomous, ref greyedOutTooltipCallback, out reason)) { return false; } } else { if (!CanGetPreggers(target, autonomous, ref greyedOutTooltipCallback, out reason)) { return false; } } } if ((autonomous) || (Woohooer.Settings.mTestAllConditionsForUserDirected[speciesIndex])) { if (HasBlockingBuff(a)) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:BuffBlock"); }; reason = "BuffBlock"; return false; } if (HasBlockingBuff(target)) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:BuffBlock"); }; reason = "BuffBlock"; return false; } if ((a.SimDescription.Gender != target.SimDescription.Gender) || (pregnancyChoice != PregnancyChoice.Either)) { if (autonomous) { if (a.SimDescription.IsPregnant) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:Pregnant"); }; reason = "Pregnant"; return false; } if (target.SimDescription.IsPregnant) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:Pregnant"); }; reason = "Pregnant"; return false; } } else { if (a.SimDescription.IsVisuallyPregnant) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:Pregnant"); }; reason = "Pregnant"; return false; } if (target.SimDescription.IsVisuallyPregnant) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:Pregnant"); }; reason = "Pregnant"; return false; } } } if ((a.SimDescription.IsMale) && (target.SimDescription.IsMale)) { if (!Woohooer.Settings.mAutonomousMaleMaleTryForBabyV2[speciesIndex]) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:SameSexDenied"); }; reason = "SameSexDenied"; return false; } if (a.SimDescription.Elder) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:Elder"); }; reason = "Elder"; return false; } if (target.SimDescription.Elder) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:Elder"); }; return false; } } if ((a.SimDescription.IsFemale) && (target.SimDescription.IsFemale)) { if (!Woohooer.Settings.mAutonomousFemaleFemaleTryForBabyV2[speciesIndex]) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:SameSexDenied"); }; reason = "SameSexDenied"; return false; } } if ((a.SimDescription.Elder) && (a.SimDescription.IsFemale)) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:Elder"); }; reason = "Elder"; return false; } if ((target.SimDescription.Elder) && (target.SimDescription.IsFemale)) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:Elder"); }; reason = "Elder"; return false; } if ((a.SimDescription.Teen) || (target.SimDescription.Teen)) { if ((!teenCanTry) && (autonomous)) { greyedOutTooltipCallback = delegate { return Common.LocalizeEAString("NRaas.Woohooer:Teenagers"); }; reason = "Teenagers"; return false; } } if ((SimTypes.IsSkinJob(a.SimDescription)) || (SimTypes.IsSkinJob(target.SimDescription))) { greyedOutTooltipCallback = delegate { return Common.Localize("TryForBaby:SkinJob"); }; reason = "SkinJob"; return false; } } return true; } }
private static bool CanGetPreggers(Sim sim, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback, out string reason) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CanGetPreggers", Common.DebugLevel.Stats)) { if (SimTypes.IsPassporter(sim.SimDescription)) { greyedOutTooltipCallback = Common.DebugTooltip("Passporter"); reason = "Passporter"; return(false); } CASAgeGenderFlags species = sim.SimDescription.Species; int numHumans, numPets; sim.SimDescription.Household.GetNumberOfSimsAndPets(true, out numHumans, out numPets); if (!Household.CanSpeciesGetAddedToHousehold(species, numHumans, numPets)) { greyedOutTooltipCallback = Common.DebugTooltip("House Full"); reason = "House Full"; return(false); } if (SimTypes.IsSkinJob(sim.SimDescription)) { greyedOutTooltipCallback = Common.DebugTooltip("Skin Job Fail"); reason = "Skin Job Fail"; return(false); } else if (sim.BuffManager.HasTransformBuff()) { greyedOutTooltipCallback = Common.DebugTooltip("Transform Buff"); reason = "Transform Buff"; return(false); } else if (sim.SimDescription.IsPregnant || sim.SimDescription.IsVisuallyPregnant) { greyedOutTooltipCallback = Common.DebugTooltip("Already Pregnant"); reason = "Already Pregnant"; return(false); } if ((sim.Household != null) && sim.Household.IsTouristHousehold) { MiniSimDescription description = MiniSimDescription.Find(sim.SimDescription.SimDescriptionId); if (description == null) { greyedOutTooltipCallback = delegate { return(Common.LocalizeEAString(sim.IsFemale, "Gameplay/Actors/Sim/TryForBaby:TooManySims", new object[] { sim })); }; reason = "TooManySims"; return(false); } } else if (sim.LotHome == null) { greyedOutTooltipCallback = delegate { if (sim.Household.IsAlienHousehold) { return(Common.LocalizeEAString(sim.IsFemale, "Gameplay/Actors/Sim/TryForBaby:AlienNPCs", new object[] { sim })); } else { return(Common.LocalizeEAString(sim.IsFemale, "Gameplay/Actors/Sim/TryForBaby:TooManySims", new object[] { sim })); } }; reason = "TooManySims"; return(false); } else if (sim.SimDescription.IsDueToAgeUp() || (sim.SimDescription.AgingState != null && sim.SimDescription.AgingState.IsAgingInProgress())) { greyedOutTooltipCallback = Common.DebugTooltip("Aging Up Fail"); reason = "Aging Up Fail"; return(false); } else if (SimTypes.IsLampGenie(sim.SimDescription)) { greyedOutTooltipCallback = Common.DebugTooltip("Lamp Genie"); reason = "Lamp Genie"; return(false); } if (sStoryProgressionAllowImpregnation.Valid && Abductor.Settings.LinkToStoryProgression(isAutonomous)) { reason = sStoryProgressionAllowImpregnation.Invoke <string>(new object[] { sim.SimDescription, isAutonomous }); if (reason != null) { greyedOutTooltipCallback = Abductor.StoryProgessionTooltip(reason, false); return(false); } } reason = null; return(true); } }
public static bool SatisfiesTryForBaby(Sim actor, Sim target, string logName, bool isAutonomous, bool scoreTarget, ref GreyedOutTooltipCallback callback) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration " + logName, Common.DebugLevel.Stats)) { int speciesIndex = PersistedSettings.GetSpeciesIndex(actor); if (isAutonomous) { if (!Woohooer.Settings.mTryForBabyAutonomousV2[speciesIndex]) { return false; } if (!Woohooer.Settings.mAllowOffLotTryForBabyAutonomous[speciesIndex]) { if (actor.LotCurrent != Household.ActiveHousehold.LotHome) { return false; } } } if ((!scoreTarget) && (!CommonWoohoo.SatisfiesUserLikingGate(actor, target, isAutonomous, true, logName))) { callback = Common.DebugTooltip("Liking Gate Fail"); return false; } if (!CommonSocials.SatisfiedInteractionLevel(actor, target, isAutonomous, ref callback)) { return false; } if (!WoohooInteractionLevelSetting.Satisfies(actor, target, true)) { ScoringLookup.IncStat(logName + " Interaction Level Fail"); callback = Common.DebugTooltip("Interaction Level Fail"); return false; } if (!CommonWoohoo.SatisfiesCooldown(actor, target, isAutonomous, ref callback)) { return false; } string reason; if (!CanTryForBaby(actor, target, isAutonomous, CommonWoohoo.WoohooStyle.TryForBaby, ref callback, out reason)) { ScoringLookup.IncStat(logName + " " + reason); return false; } WoohooScoring.ScoreTestResult result = WoohooScoring.ScoreActor(logName, actor, target, isAutonomous, "InterestInTryForBaby", true); if (result != WoohooScoring.ScoreTestResult.Success) { ScoringLookup.IncStat(logName + " " + result); callback = Common.DebugTooltip("Actor Scoring Fail " + result); return false; } if (scoreTarget) { result = WoohooScoring.ScoreTarget(logName, target, actor, isAutonomous, "InterestInTryForBaby", true); if (result != WoohooScoring.ScoreTestResult.Success) { ScoringLookup.IncStat(logName + " " + result); callback = Common.DebugTooltip("Target Scoring Fail " + result); return false; } } ScoringLookup.IncStat(logName + " Success"); return true; } }
public List<SimDescription> GetAllowedSims() { List<SimDescription> results = new List<SimDescription>(); if (Sim != null) { if (Test(Sim)) { results.Add(Sim); } } else { ICollection<SimDescription> sims = null; using (Common.TestSpan span = new Common.TestSpan(Scenarios, "GetSims " + UnlocalizedName)) { sims = GetSims(); } if (sims != null) { AddStat("Sim Potentials", sims.Count); foreach (SimDescription sim in new List<SimDescription> (sims)) { Sim = sim; if (Test(sim)) { IncStat("Included"); results.Add(sim); } Main.Sleep("SimScenario:GetAllowedSims"); } AddStat("Sim Allowed", results.Count); } } return results; }
public static bool SatisfiesTryForBaby(Sim actor, Sim target, string logName, bool isAutonomous, bool scoreTarget, ref GreyedOutTooltipCallback callback) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration " + logName, Common.DebugLevel.Stats)) { int speciesIndex = PersistedSettings.GetSpeciesIndex(actor); if (isAutonomous) { if (!Woohooer.Settings.mTryForBabyAutonomousV2[speciesIndex]) { return(false); } if (!Woohooer.Settings.mAllowOffLotTryForBabyAutonomous[speciesIndex]) { if (actor.LotCurrent != Household.ActiveHousehold.LotHome) { return(false); } } } if ((!scoreTarget) && (!CommonWoohoo.SatisfiesUserLikingGate(actor, target, isAutonomous, true, logName))) { callback = Common.DebugTooltip("Liking Gate Fail"); return(false); } if (!CommonSocials.SatisfiedInteractionLevel(actor, target, isAutonomous, ref callback)) { return(false); } if (!WoohooInteractionLevelSetting.Satisfies(actor, target, true)) { ScoringLookup.IncStat(logName + " Interaction Level Fail"); callback = Common.DebugTooltip("Interaction Level Fail"); return(false); } if (!CommonWoohoo.SatisfiesCooldown(actor, target, isAutonomous, ref callback)) { return(false); } string reason; if (!CanTryForBaby(actor, target, isAutonomous, CommonWoohoo.WoohooStyle.TryForBaby, ref callback, out reason)) { ScoringLookup.IncStat(logName + " " + reason); return(false); } WoohooScoring.ScoreTestResult result = WoohooScoring.ScoreActor(logName, actor, target, isAutonomous, "InterestInTryForBaby", true); if (result != WoohooScoring.ScoreTestResult.Success) { ScoringLookup.IncStat(logName + " " + result); callback = Common.DebugTooltip("Actor Scoring Fail " + result); return(false); } if (scoreTarget) { result = WoohooScoring.ScoreTarget(logName, target, actor, isAutonomous, "InterestInTryForBaby", true); if (result != WoohooScoring.ScoreTestResult.Success) { ScoringLookup.IncStat(logName + " " + result); callback = Common.DebugTooltip("Target Scoring Fail " + result); return(false); } } ScoringLookup.IncStat(logName + " Success"); 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); }
public List<SimDescription> GetAllowedTargets(SimDescription sim) { List<SimDescription> results = new List<SimDescription>(); if (Target != null) { if (TargetTest(Target)) { results.Add(Target); } } else { ICollection<SimDescription> sims = null; using (Common.TestSpan span = new Common.TestSpan(Scenarios, "GetTargets " + UnlocalizedName)) { sims = GetTargets(sim); } if (sims != null) { AddStat("Target Potentials", sims.Count); foreach (SimDescription target in new List<SimDescription> (sims)) { Target = target; if (TargetTest(target)) { IncStat("Included"); results.Add(target); } Main.Sleep("DualSimScenario:GetAllowedTargets"); } AddStat("Target Allowed", results.Count); } else { IncStat("Empty Target List"); } } return results; }
public static bool OnDefaultNonRomanticTest(Sim actor, Sim target, ActiveTopic topic, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { try { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration OnDefaultNonRomanticTest", Common.DebugLevel.Stats)) { string autoString = null; if (isAutonomous) { autoString = "Autonomous "; } ScoringLookup.IncStat(autoString + "OnDefaultNonRomanticTest Try"); if ((sStoryProgressionCanFriendInteract.Valid) && (Woohooer.Settings.TestStoryProgression(isAutonomous))) { string reason = sStoryProgressionCanFriendInteract.Invoke<string>(new object[] { actor.SimDescription, target.SimDescription, isAutonomous }); if (reason != null) { greyedOutTooltipCallback = Woohooer.StoryProgressionTooltip(reason, true); ScoringLookup.IncStat(autoString + "OnDefaultNonRomanticTest StoryProgression"); return false; } } if (isAutonomous) { Relationship relation = Relationship.Get(actor, target, false); if (relation != null) { try { if (relation.STC.IsRomantic) { greyedOutTooltipCallback = Common.DebugTooltip("Romantic STC"); ScoringLookup.IncStat(autoString + "OnDefaultNonRomanticTest RomanticSTC"); return false; } } catch (Exception e) { Common.DebugException(actor, target, e); relation.STC.mCurrentStc = ShortTermContextTypes.Friendly; return true; } } } ScoringLookup.IncStat(autoString + "OnDefaultNonRomanticTest Success"); //ScoringLookup.IncStat(autoString + "OnDefaultNonRomanticTest Success " + actor.FullName + " " + target.FullName); return true; } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(actor, target, e); return false; } }
public static bool CanTryForBaby(Sim actor, Sim target, bool autonomous, CommonWoohoo.WoohooStyle style, ref GreyedOutTooltipCallback callback, out string reason) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CanTryForBaby", Common.DebugLevel.Stats)) { int chance = 0; bool teenCanTry = false; int speciesIndex = PersistedSettings.GetSpeciesIndex(actor); switch (style) { case CommonWoohoo.WoohooStyle.Risky: case CommonWoohoo.WoohooStyle.TryForBaby: if (actor.SimDescription.Teen || target.SimDescription.Teen) { chance = Woohooer.Settings.mTryForBabyTeenBabyMadeChance; } else { chance = Woohooer.Settings.mTryForBabyMadeChanceV2[speciesIndex]; } teenCanTry = Woohooer.Settings.mTeenTryForBabyAutonomous; break; } if (chance <= 0) { reason = "Chance Fail"; callback = Common.DebugTooltip(reason); return(false); } if (!CommonSocials.CanGetRomantic(actor, target, autonomous, true, true, ref callback, out reason)) { return(false); } if (autonomous || Woohooer.Settings.TestStoryProgression(autonomous)) { if (sStoryProgressionAllowPregnancy.Valid && Woohooer.Settings.TestStoryProgression(autonomous)) { if (actor.SimDescription.Gender == target.SimDescription.Gender) { reason = "Surrogate: Same Sex Fail"; callback = Common.DebugTooltip(reason); return(false); } else { SimDescription male, female; if (actor.IsFemale) { female = actor.SimDescription; male = target.SimDescription; } else { male = actor.SimDescription; female = target.SimDescription; } reason = sStoryProgressionAllowPregnancy.Invoke <string>(new object[] { female, male, autonomous }); if (reason != null) { callback = Woohooer.StoryProgressionTooltip(reason, false); return(false); } } } } if (actor.SimDescription.Gender == target.SimDescription.Gender) { reason = "Surrogate: Same Sex Fail"; callback = Common.DebugTooltip(reason); return(false); } else { if (actor.IsFemale && !CanGetPreggers(actor, autonomous, ref callback, out reason)) { return(false); } else if (!CanGetPreggers(target, autonomous, ref callback, out reason)) { return(false); } } if (autonomous || Woohooer.Settings.mTestAllConditionsForUserDirected[speciesIndex]) { if (HasBlockingBuff(actor)) { reason = "Actor Buff Block"; callback = delegate { return(Common.Localize("TryForBaby:BuffBlock")); }; return(false); } if (HasBlockingBuff(target)) { reason = "Target Buff Block"; callback = delegate { return(Common.Localize("TryForBaby:BuffBlock")); }; return(false); } if (autonomous) { if (actor.SimDescription.IsPregnant || target.SimDescription.IsPregnant) { reason = "Pregnant"; callback = delegate { return(Common.Localize("TryForBaby:Pregnant")); }; return(false); } } else { if ((actor.IsRobot && actor.SimDescription.IsPregnant) || actor.SimDescription.IsVisuallyPregnant) { reason = "Pregnant"; callback = delegate { return(Common.Localize("TryForBaby:Pregnant")); }; return(false); } if ((target.IsRobot && target.SimDescription.IsPregnant) || target.SimDescription.IsVisuallyPregnant) { if (actor.SimDescription.IsVisuallyPregnant || target.SimDescription.IsVisuallyPregnant) { reason = "Pregnant"; callback = delegate { return(Common.Localize("TryForBaby:Pregnant")); }; return(false); } } } } if (actor.IsFemale && !actor.IsRobot && actor.SimDescription.Elder) { reason = "Elder"; callback = delegate { return(Common.Localize("TryForBaby:Elder")); }; return(false); } if (target.IsFemale && !target.IsRobot && target.SimDescription.Elder) { reason = "Elder"; callback = delegate { return(Common.Localize("TryForBaby:Elder")); }; return(false); } if (actor.SimDescription.Teen || target.SimDescription.Teen) { if (!teenCanTry && autonomous) { reason = "Teenagers"; callback = delegate { return(Common.LocalizeEAString("NRaas.Woohooer:Teenagers")); }; return(false); } } if ((!actor.IsRobot && SimTypes.IsSkinJob(actor.SimDescription)) || (!target.IsRobot && SimTypes.IsSkinJob(target.SimDescription))) { reason = "Skin Job"; callback = delegate { return(Common.Localize("TryForBaby:SkinJob")); }; return(false); } return(true); } }
public void OnDelayedWorldLoadFinished() { sObjectsOfInterest.Clear(); List <ICheck> checks = DerivativeSearch.Find <ICheck>(); foreach (ICheck check in checks) { check.Finish(); } EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = false; new CheckRoleManager().Perform(RoleManager.sRoleManager, true); CheckRecovery(); CheckOutfits(); CheckLotObjects(); Inventories.CheckInventories(LogCorrection, DebugLogCorrection, true); List <IDereferenceController> controllers = DerivativeSearch.Find <IDereferenceController>(); foreach (IDereferenceController controller in controllers) { controller.Clear(); foreach (KeyValuePair <Type, List <ObjectLookup.Item> > list in ObjectLookup.List) { controller.Add(list.Key, list.Value); } controller.PreProcess(); } if (ErrorTrapTuning3.kLogCounting) { using (TestSpan span = new TestSpan(ExternalTimeSpanLogger.sLogger, "Log Counts")) { ObjectLookup.LogCounts(); } } DereferenceManager.Logger.OnWorldQuit = false; try { DereferenceManager.Logger.sCollecting = true; using (Common.TestSpan totalSpan = new Common.TestSpan(TimeSpanLogger.Bin, "Dereferencing", DebugLevel.Stats)) { foreach (IDereferenceController controller in controllers) { controller.Perform(); if (DereferenceManager.Logger.OnWorldQuit) { break; } } } } finally { DereferenceManager.Logger.sCollecting = false; } using (Common.TestSpan totalSpan = new Common.TestSpan(TimeSpanLogger.Bin, "Dereferencing", DebugLevel.Stats)) { foreach (IDereferenceController controller in controllers) { controller.PostPerform(); if (DereferenceManager.Logger.OnWorldQuit) { break; } } } // Possibly loaded by Dereference sResidents = null; ProcessToBeDeleted(sToBeDeleted, true); ProcessToBeDeleted(sSilentToBeDeleted, false); ObjectLookup.Clear(); //sDelayLoading = false; RecordErrors(); }
public static bool DefaultTest(Sim actor, Sim target, ActiveTopic topic, bool isAutonomous, bool forWoohoo, bool testLiking, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { try { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration DefaultTest", Common.DebugLevel.Stats)) { string autoString = null; if (isAutonomous) { autoString = "Autonomous "; } ScoringLookup.IncStat(autoString + "OnDefaultTest Try"); if (!SatisfiedInteractionLevel(actor, target, isAutonomous, ref greyedOutTooltipCallback)) { ScoringLookup.IncStat(autoString + "OnDefaultTest SatisfiedInteractionLevel"); return false; } string reason = null; if (!CanGetRomantic(actor, target, isAutonomous, forWoohoo, testLiking, ref greyedOutTooltipCallback, out reason)) { ScoringLookup.IncStat(autoString + "OnDefaultTest " + reason); return false; } if ((isAutonomous) && (!Woohooer.Settings.mAllowAutonomousRomanceCommLot)) { if ((actor.IsSelectable) || (target.IsSelectable)) { if ((actor.LotCurrent == null) || (actor.LotCurrent.IsCommunityLot)) { greyedOutTooltipCallback = Common.DebugTooltip("OnDefaultTest CommunityLot"); ScoringLookup.IncStat(autoString + "OnDefaultTest CommunityLot"); return false; } } } if (Woohooer.Settings.UsingTraitScoring) { if ((isAutonomous) || (Woohooer.Settings.TraitScoringForUserDirected)) { if (!WoohooScoring.IsSafeFromJealousy(actor, target, false)) { ScoringLookup.IncStat(autoString + "OnDefaultTest Jealousy"); greyedOutTooltipCallback = Common.DebugTooltip("OnDefaultTest Jealousy"); return false; } WoohooScoring.ScoreTestResult result = WoohooScoring.ScoreActor("DefaultTest", actor, target, isAutonomous, "InterestInRomance", false); if (result != WoohooScoring.ScoreTestResult.Success) { ScoringLookup.IncStat(autoString + "OnDefaultTest " + result); greyedOutTooltipCallback = Common.DebugTooltip("OnDefaultTest " + result); return false; } } } ScoringLookup.IncStat(autoString + "OnDefaultTest Success"); //ScoringLookup.IncStat(autoString + "OnDefaultTest Success " + actor.FullName + " " + target.FullName); if ((Common.kDebugging) && (Woohooer.Settings.mVerboseDebugging)) { if (isAutonomous) { Common.DebugNotify("OnDefaultTest Success" + Common.NewLine + actor.FullName + Common.NewLine + target.FullName, actor, target); } } return true; } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(actor, target, e); return false; } }
public static bool CanGetPregnant(Sim sim, bool isAutonomous, out string reason) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CanGetPregnant", Common.DebugLevel.Stats)) { if (SimTypes.IsPassporter(sim.SimDescription)) { reason = "Passporter"; return(false); } int numHumans, numPets; sim.SimDescription.Household.GetNumberOfSimsAndPets(true, out numHumans, out numPets); if (!Household.CanSpeciesGetAddedToHousehold(sim.SimDescription.Species, numHumans, numPets)) { reason = "House Full"; return(false); } if (sim.SimDescription.Teen && !Aliens.Settings.mAllowTeens) { reason = "Teens Not Allowed"; return(false); } else if (SimTypes.IsSkinJob(sim.SimDescription)) { reason = "Skin Job Fail"; return(false); } else if (sim.BuffManager.HasTransformBuff()) { reason = "Transform Buff"; return(false); } else if (sim.SimDescription.IsPregnant || sim.SimDescription.IsVisuallyPregnant) { reason = "Already Pregnant"; return(false); } if (sim.Household != null && sim.Household.IsTouristHousehold) { MiniSimDescription description = MiniSimDescription.Find(sim.SimDescription.SimDescriptionId); if (description == null) { reason = "House Full"; return(false); } } else if (sim.LotHome == null) { reason = "House Full"; return(false); } else if (sim.SimDescription.IsDueToAgeUp() || (sim.SimDescription.AgingState != null && sim.SimDescription.AgingState.IsAgingInProgress())) { reason = "Aging Up Fail"; return(false); } else if (SimTypes.IsLampGenie(sim.SimDescription)) { reason = "Lamp Genie"; return(false); } if (sStoryProgressionAllowImpregnation.Valid && Aliens.Settings.LinkToStoryProgression(isAutonomous)) { reason = sStoryProgressionAllowImpregnation.Invoke <string>(new object[] { sim.SimDescription, isAutonomous }); if (reason != null) { return(false); } } reason = null; return(true); } }
// From Conversation public static List <SocialInteractionCandidate> GetSocialsForSTC(CommodityTypes commodity, Sim actor, Sim target, Relationship r, Conversation c, bool isAutonomous, ref string msg) { using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, "GetSocialsForSTC: " + commodity, Common.DebugLevel.Stats)) { ShortTermContextTypes str2; List <SocialInteractionCandidate> list3; LongTermRelationshipTypes group = LongTermRelationshipTypes.Stranger; if (r != null) { group = r.LTR.CurrentLTR; } bool flag = (r != null) && ((r.STC == null) || (commodity == r.STC.CurrentCommodity)); if (!SocialComponent.SocialCommodityIsAvailable(commodity, target, actor, r)) { return(null); } if (flag) { bool flag2; str2 = Conversation.GetCurrentSTC(actor, target, r, c, out flag2); } else { str2 = STCData.FirstSTC(commodity); } List <SocialInteractionCandidate> collection = ActionAvailabilityData.Get(actor, target, str2, group, true, null, isAutonomous); if ((isAutonomous && (r != null)) && (r.STC.CurrentCommodity == commodity)) { ShortTermContextTypes str4; collection = new List <SocialInteractionCandidate>(collection); ShortTermContextTypes str3 = STCData.PreviousSTC(str2); do { collection.AddRange(ActionAvailabilityData.Get(actor, target, str3, group, true, null, isAutonomous)); str4 = str3; str3 = STCData.PreviousSTC(str3); }while (!(str4 == str3)); } if (isAutonomous) { goto Label_0167; } ShortTermContextTypes category = STCData.FirstSTC(commodity); Label_00D5: msg += Common.NewLine + "GetSocialsForSTC " + category; foreach (SocialInteractionCandidate candidate in Get(actor, target, category, group, true, null, isAutonomous, ref msg)) { ActionData action = ActionData.Get(candidate.Name); if (Conversation.SimHasTraitEncouragingOrRequiringSocial(actor, action)) { if (category != STCData.FirstSTC(commodity)) { candidate.OnlyAppearsInTraitMenu = true; } collection.Add(candidate); } } ShortTermContextTypes str6 = STCData.NextSTC(category); if (str6 != category) { category = str6; goto Label_00D5; } Label_0167: msg += Common.NewLine + "Collection " + collection.Count; list3 = new List <SocialInteractionCandidate>(); foreach (SocialInteractionCandidate candidate2 in collection) { ActionData data2 = ActionData.Get(candidate2.Name); if (flag || !data2.DoesSocialOnlyAppearWhenSTCIsCurrent) { msg += Common.NewLine + " " + candidate2.Name; list3.Add(candidate2); } } return(list3); } }
public List <ScenarioFrame> Run() { if (StoryProgression.Main == null) { return(null); } using (Common.TestSpan span = new Common.TestSpan(StoryProgression.Main.Scenarios, "ScenarioFrameRun", Common.DebugLevel.Stats)) { if (mCountdown > 0) { return(null); } if (mChildren.Count > 0) { return(null); } ScenarioResult lastResult = LastResult; List <ScenarioFrame> frames = new List <ScenarioFrame>(); while (Count > 0) { Scenario.ScenarioRun run = this[0]; string test = UnlocalizedName; if ((frames.Count > 0) && ((!run.IsInstant) || (!ChildOfRoot))) { break; } RemoveAt(0); ScenarioFrame frame = new ScenarioFrame(this, run); ScenarioResult prevResult = lastResult; //lastResult = Scenario.ScenarioRun.RunTask.Wait(run, lastResult, frame); lastResult = run.Run(lastResult, frame); if (frame.Count > 0) { if ((StoryProgression.Main != null) && (StoryProgression.Main.Scenarios.TrackingID == ID)) { StoryProgression.Main.Scenarios.Track("Before: " + prevResult + Common.NewLine + "After: Nested" + Common.NewLine + run.ToString() + Common.NewLine + ToString()); } frame.ID = run.ID; frames.Add(frame); } else { if ((StoryProgression.Main != null) && (StoryProgression.Main.Scenarios.TrackingID == ID)) { StoryProgression.Main.Scenarios.Track("Before: " + prevResult + Common.NewLine + "After: " + lastResult + Common.NewLine + run.ToString() + Common.NewLine + ToString()); } LastResult = lastResult; } } if (Count == 0) { RemoveFromParent(this); } if (frames.Count > 0) { AddChildren(frames); } return(frames); } }
public static void OnWoohooed(Event e) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CommonWoohoo:OnWoohooed")) { WooHooEvent wEvent = e as WooHooEvent; if (wEvent == null) { return; } Sim actor = wEvent.Actor as Sim; if (actor == null) { return; } SimDescription targetDesc = null; Sim target = wEvent.TargetObject as Sim; if (target != null) { targetDesc = target.SimDescription; } else if (actor.SimDescription.IsPregnant) { targetDesc = SimDescription.Find(actor.SimDescription.Pregnancy.DadDescriptionId); } if (targetDesc == null) { return; } CommonWoohoo.WoohooLocation location = WoohooLocation.Bed; CommonWoohoo.WoohooStyle style = WoohooStyle.Safe; IWooHooDefinition woohoo = null; NRaasWooHooEvent customEvent = wEvent as NRaasWooHooEvent; if (customEvent != null) { location = customEvent.Location; style = customEvent.Style; } else { if (actor.CurrentInteraction != null) { woohoo = actor.CurrentInteraction.InteractionDefinition as IWooHooDefinition; if (woohoo == null) { if (actor.CurrentInteraction is Shower.TakeShower) { foreach (Sim sim in actor.LotCurrent.GetAllActors()) { if ((sim.CurrentInteraction != null) && (sim.CurrentInteraction.Target == actor)) { woohoo = sim.CurrentInteraction.InteractionDefinition as IWooHooDefinition; if (woohoo != null) { break; } } } } } if (woohoo != null) { location = woohoo.GetLocation(wEvent.ObjectUsed); style = woohoo.GetStyle(actor.CurrentInteraction); if ((style == WoohooStyle.Safe) && (Woohooer.Settings.ReplaceWithRisky)) { style = WoohooStyle.Risky; } } } if (wEvent.BedUsed != null) { if (wEvent.BedUsed is Tent) { location = WoohooLocation.Tent; } else if (wEvent.BedUsed is Igloo) { location = WoohooLocation.Igloo; } else if (wEvent.BedUsed is FairyHouse) { location = WoohooLocation.FairyHouse; } } else if ((woohoo == null) && (wEvent.ObjectUsed != null)) { foreach (WoohooLocationControl check in Common.DerivativeSearch.Find <WoohooLocationControl>()) { if (check.Matches(wEvent.ObjectUsed)) { location = check.Location; break; } } } } KamaSimtra.AddNotch(actor.SimDescription, targetDesc, actor.LotCurrent, location, style); Woohooer.Settings.AddCount(actor); WoohooBuffs.Apply(actor, target, style == WoohooStyle.Risky); KamaSimtraSettings.ServiceData data = KamaSimtra.Settings.GetServiceData(targetDesc.SimDescriptionId, true); if (data != null) { data.Dispose(); } } }
protected override OptionResult Run(GameHitParameters<GameObject> parameters) { try { Sim target = parameters.mTarget as Sim; using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, "Total", Common.DebugLevel.Stats)) { GetUnfilteredSocials(parameters.mActor.SocialComponent, parameters.mActor as Sim, target, Relationship.Get(parameters.mActor as Sim, target, false)); } Common.RecordErrors(); } catch (Exception e) { GameHitParameters<GameObject>.Exception(parameters, e); } return OptionResult.SuccessClose; }
protected ICollection<SimDescription> FindPotentialMothers(int additionalBabyCount) { List<SimDescription> choices = new List<SimDescription>(); foreach (SimDescription sim in Sims.All) { using (Common.TestSpan span = new Common.TestSpan(Scenarios, "FindPotentialMothers")) { if (!AllowSpecies(sim)) continue; IncStat(sim.FullName, Common.DebugLevel.Logging); if ((sim.IsHuman) && (sim.Partner == null)) { IncStat("Unpartnered"); } else if (sim.IsPregnant) { IncStat("Already Pregnant"); } else if (!Pregnancies.Allow(this, sim, sim.Partner, Managers.Manager.AllowCheck.Active)) { //IncStat("Allow Fail"); continue; } else if (!TestPreferredBaby(this, sim, additionalBabyCount)) { //IncStat("Preferred Fail"); continue; } else if (!Pregnancies.TestCooldown(this, sim)) { //IncStat("Cooldown Fail"); continue; } else { choices.Add(sim); } } } AddStat("Fertile Choices", choices.Count); return new SimScoringList(this, "PotentialMother", choices, false).GetBestByMinScore(0); }
public static bool SatisfiesWoohoo(Sim actor, Sim target, string logName, bool isAutonomous, bool scoreTarget, bool testLiking, ref GreyedOutTooltipCallback callback) { using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration " + logName, Common.DebugLevel.Stats)) { if (isAutonomous) { if (!Woohooer.Settings.mWoohooAutonomousV2[PersistedSettings.GetSpeciesIndex(actor)]) { callback = Common.DebugTooltip("Autonomous Denied"); ScoringLookup.IncStat(logName + " Autonomous Denied"); return(false); } } if (!Woohooer.Settings.mAllowZombie) { if ((actor.SimDescription.IsZombie) || (target.SimDescription.IsZombie)) { callback = Common.DebugTooltip("Zombie"); ScoringLookup.IncStat(logName + " Zombie"); return(false); } } if (testLiking) { if (Woohooer.Settings.mHideWoohoo) { callback = Common.DebugTooltip("Hide Woohoo"); ScoringLookup.IncStat(logName + " Hide Woohoo"); return(false); } if ((!scoreTarget) && (!SatisfiesUserLikingGate(actor, target, isAutonomous, true, logName))) { callback = Common.DebugTooltip("Liking Gate Fail"); ScoringLookup.IncStat(logName + " Liking Gate Fail"); return(false); } if (!WoohooInteractionLevelSetting.Satisfies(actor, target, true)) { ScoringLookup.IncStat(logName + " Interaction Level Fail"); callback = Common.DebugTooltip("Interaction Level Fail"); return(false); } } if (!CommonSocials.SatisfiedInteractionLevel(actor, target, isAutonomous, ref callback)) { ScoringLookup.IncStat(logName + " InteractionLevel Fail"); return(false); } if (!SatisfiesCooldown(actor, target, isAutonomous, ref callback)) { ScoringLookup.IncStat(logName + " Cooldown Fail"); return(false); } string reason; if (!CommonSocials.CanGetRomantic(actor, target, isAutonomous, true, testLiking, ref callback, out reason)) { ScoringLookup.IncStat(logName + " " + reason); return(false); } WoohooScoring.ScoreTestResult result = WoohooScoring.ScoreActor(logName, actor, target, isAutonomous, "InterestInWoohoo", true); if (result != WoohooScoring.ScoreTestResult.Success) { ScoringLookup.IncStat(logName + " " + result); callback = Common.DebugTooltip("Actor Scoring Fail " + result); return(false); } if (scoreTarget) { result = WoohooScoring.ScoreTarget(logName, target, actor, isAutonomous, "InterestInWoohoo", true); if (result != WoohooScoring.ScoreTestResult.Success) { ScoringLookup.IncStat(logName + " " + result); callback = Common.DebugTooltip("Target Scoring Fail " + result); return(false); } } ScoringLookup.IncStat(logName + " Success"); return(true); } }