public static string Perform <NEWCLASS>(string action, string oldFunction, string newFunction) { try { MethodInfo oldFunc = typeof(SocialCallback).GetMethod(oldFunction); if (oldFunc == null) { return(oldFunction + ": Old Not Found"); } MethodInfo newFunc = typeof(NEWCLASS).GetMethod(newFunction); if (newFunc == null) { return(newFunction + ": New Not Found"); } List <SocialRuleRHS> rules = SocialRuleRHS.Get(action); if (rules == null) { return(action + ": Action Not Found"); } bool found = false; foreach (SocialRuleRHS rule in rules) { if ((rule.ProceduralEffectBeforeUpdate != null) && (rule.ProceduralEffectBeforeUpdate.ToString() == oldFunc.ToString())) { rule.mProceduralEffectBeforeUpdate = newFunc; found = true; } if ((rule.ProceduralEffectAfterUpdate != null) && (rule.ProceduralEffectAfterUpdate.ToString() == oldFunc.ToString())) { rule.mProceduralEffectAfterUpdate = newFunc; found = true; } } if (found) { return(null); } else { return(action + " - " + oldFunction + " - " + newFunction + ": No Change"); } } catch (Exception e) { Common.Exception(action + " - " + oldFunction + " - " + newFunction, e); return(action + " - " + oldFunction + " - " + newFunction + ": Exception"); } }
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); } } }