Decompiled source of SODMotives v1.0.0
BepInEx/plugins/SODMotives/SODMotives.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.IO; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("SODMotives")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+dda07f0bd9ba3353362684403f2e9c70ec341996")] [assembly: AssemblyProduct("SODMotives")] [assembly: AssemblyTitle("SODMotives")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SODMotives { internal static class AffairSim { internal static void SeedForNewGame() { //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown bool flag = default(bool); try { EventStore.Clear(); MurderSelector.ResetForNewGame(); ClueInjector.ResetForNewGame(); MurderWatchdog.ResetForNewGame(); Persistence.ResetForNewGame(); CityData instance = CityData.Instance; if ((Object)(object)instance == (Object)null || instance.citizenDirectory == null) { return; } List<Citizen> citizenDirectory = instance.citizenDirectory; int count = citizenDirectory.Count; HashSet<long> hashSet = new HashSet<long>(); int num = 0; for (int i = 0; i < count; i++) { Human val = (Human)(object)citizenDirectory[i]; if ((Object)(object)val == (Object)null) { continue; } Human val2 = null; try { val2 = (Human)(object)val.paramour; } catch { } if (!((Object)(object)val2 == (Object)null)) { long item = PairKey(val.humanID, val2.humanID); if (hashSet.Add(item)) { SocialEvent e = new SocialEvent { type = SocialEventType.Affair, a = val, b = val2, placeName = PlaceHint(val, val2), time = 0f }; Gossip.Distribute(e); EventStore.Add(e); num++; } } } FeudSim.Seed(); ManualLogSource log = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(99, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SODMotives][events] seeded "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" affairs; "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(EventStore.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" events total; knowledge distributed to neighbours/coworkers."); } log.LogInfo(val3); } catch (Exception ex) { ManualLogSource log2 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[SODMotives][events] seed error: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex); } log2.LogWarning(val4); } } private static string PlaceHint(Human a, Human b) { try { if ((Object)(object)b != (Object)null && (Object)(object)b.home != (Object)null) { return ((Object)b.home).name; } } catch { } try { if ((Object)(object)a != (Object)null && (Object)(object)a.home != (Object)null) { return ((Object)a.home).name; } } catch { } return ""; } private static long PairKey(int x, int y) { int num = Math.Min(x, y); int num2 = Math.Max(x, y); return ((long)num << 32) | (uint)num2; } } [HarmonyPatch(typeof(MurderController), "OnStartGame")] internal static class Patch_OnStartGame_Seed { private static void Postfix() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown try { MurderWatchdog.ResetForNewGame(); } catch { } try { if (!Persistence.ConsumeLoadSeedSkip() && !Persistence.IsImportPending()) { AffairSim.SeedForNewGame(); } } catch (Exception ex) { ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives][events] OnStartGame seed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } } } internal static class ClueInjector { internal static bool Enable = true; internal static int MaxClues = 8; internal static bool ObviousNames = true; internal static bool ForceAllPrints = false; internal static float WorkplaceClueShare = 0.5f; internal static float EmailClueShare = 0.5f; private static readonly Random _rng = new Random(); private static InteractablePreset _notePreset; private static InteractablePreset _listPreset; private static bool _scanned; internal static readonly Dictionary<int, List<string>> CluesByVictim = new Dictionary<int, List<string>>(); private static readonly HashSet<int> _injected = new HashSet<int>(); private static int _killerId = -1; private static bool _killerLinked; private static readonly HashSet<string> _placedRooms = new HashSet<string>(); private static readonly (string id, string name)[] InfidelityTrees = new(string, string)[3] { ("9b6d2119-f1a0-4b47-880d-1ee6fb417716", "Cheaters_Letter"), ("e6cfbb79-cc0b-4848-b699-280cbe261c3e", "Cheaters_Love_Poem"), ("7b3abe1a-30dd-41b1-b0ec-8fe6e739d2a2", "Flower_Note_Affair") }; private const string RedundancyMemoTreeId = "10084020-1a7d-4048-8885-28c8985199e1"; private static FactPreset _connectFp; private static string _connectFpName; private static bool _connectSwap; private static bool _connectResolved; private static int _cloneSeq; internal static readonly HashSet<int> AnonWriterNoteIds = new HashSet<int>(); internal static readonly HashSet<int> WriterHiddenIds = new HashSet<int>(); internal static readonly HashSet<int> AnonReceiverNoteIds = new HashSet<int>(); private const string VmailTemplateTreeId = "8332e932-c0f2-4512-8de9-e3d7d8dbf36a"; private static readonly HashSet<int> _printedVmailLinked = new HashSet<int>(); internal static void ResetForNewGame() { _injected.Clear(); CluesByVictim.Clear(); } internal static List<int> GetInjectedVictimIds() { List<int> list = new List<int>(_injected.Count); foreach (int item in _injected) { list.Add(item); } return list; } internal static void RestoreInjectedOnLoad(List<int> victimIds) { _injected.Clear(); CluesByVictim.Clear(); if (victimIds != null) { for (int i = 0; i < victimIds.Count; i++) { _injected.Add(victimIds[i]); } } } private static string CloneDDSTree(string srcTreeId, string newTreeId) { //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown bool flag = default(bool); try { Dictionary<string, DDSTreeSave> val = (((Object)(object)Toolbox.Instance != (Object)null) ? Toolbox.Instance.allDDSTrees : null); if (val == null) { return srcTreeId; } DDSTreeSave val2 = default(DDSTreeSave); if (val.TryGetValue(newTreeId, ref val2) && val2 != null) { return newTreeId; } DDSTreeSave val3 = default(DDSTreeSave); if (!val.TryGetValue(srcTreeId, ref val3) || val3 == null) { return srcTreeId; } DDSTreeSave val4 = new DDSTreeSave(); ((DDSComponent)val4).id = newTreeId; ((DDSComponent)val4).name = ((DDSComponent)val3).name; val4.treeType = val3.treeType; val4.repeat = val3.repeat; val4.triggerPoint = val3.triggerPoint; val4.stopMovement = val3.stopMovement; val4.ignoreGlobalRepeat = val3.ignoreGlobalRepeat; val4.startingMessage = val3.startingMessage; val4.treeChance = val3.treeChance; val4.priority = val3.priority; val4.newspaperCategory = val3.newspaperCategory; val4.newspaperContext = val3.newspaperContext; val4.interactionCitizenLimitation = val3.interactionCitizenLimitation; val4.interactionOnePerCity = val3.interactionOnePerCity; val4.citizenAddCount = val3.citizenAddCount; val4.participantA = val3.participantA; val4.participantB = val3.participantB; val4.participantC = val3.participantC; val4.participantD = val3.participantD; val4.document = val3.document; val4.itemPool = val3.itemPool; val4.messageRef = val3.messageRef; List<DDSMessageSettings> messages = val3.messages; if (messages != null) { List<DDSMessageSettings> val5 = new List<DDSMessageSettings>(); for (int i = 0; i < messages.Count; i++) { val5.Add(messages[i]); } val4.messages = val5; } else { val4.messages = val3.messages; } val[newTreeId] = val4; ManualLogSource log = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(63, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[SODMotives] clue: registered DDS clone '"); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(newTreeId); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("' <- Probation_Notice."); } log.LogInfo(val6); return newTreeId; } catch (Exception ex) { ManualLogSource log2 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val7 = new BepInExWarningLogInterpolatedStringHandler(44, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("[SODMotives] clue: CloneDDSTree('"); ((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<string>(newTreeId); ((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("') failed: "); ((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<string>(ex.Message); } log2.LogWarning(val7); return srcTreeId; } } private static void EnsureNotePreset() { //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if (_scanned) { return; } bool flag = default(bool); try { Toolbox instance = Toolbox.Instance; List<InteractablePreset> val = (((Object)(object)instance != (Object)null) ? instance.placePerOwnerInteractables : null); if (val == null) { return; } _scanned = true; InteractablePreset val2 = null; int num = -1; for (int i = 0; i < val.Count; i++) { InteractablePreset val3 = val[i]; if (!((SoCustomComparison)(object)val3 == (SoCustomComparison)null) && !HardExclude(val3)) { int num2 = Score(val3); if (num2 > num) { num = num2; val2 = val3; } } } _notePreset = val2; MotivesPlugin.Log.LogInfo((object)(((SoCustomComparison)(object)val2 != (SoCustomComparison)null) ? $"[SODMotives] clue: chosen note preset = '{SafeName(val2)}' (src={SafeSrc(val2)} score={num})" : "[SODMotives] clue: NO clean note preset found.")); if (!((SoCustomComparison)(object)val2 != (SoCustomComparison)null)) { return; } try { string text = "?"; try { text = ((object)val2.printsSource/*cast due to .constrained prefix*/).ToString(); } catch { } InteractablePreset obj2 = Object.Instantiate<InteractablePreset>(val2); ((Object)obj2).hideFlags = (HideFlags)61; obj2.printsSource = (PrintsSource)8; _notePreset = obj2; ManualLogSource log = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(77, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[SODMotives] clue: note preset printsSource "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" -> writers (author-only prints)."); } log.LogInfo(val4); } catch (Exception ex) { ManualLogSource log2 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(82, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[SODMotives] clue: preset clone/printsSource failed ("); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("); using shared preset as-is."); } log2.LogWarning(val5); } try { InteractablePreset obj3 = Object.Instantiate<InteractablePreset>(val2); ((Object)obj3).hideFlags = (HideFlags)61; obj3.printsSource = (PrintsSource)8; obj3.readingSource = (ReadingModeSource)1; _listPreset = obj3; MotivesPlugin.Log.LogInfo((object)"[SODMotives] clue: list preset ready (multipageEvidence reading source)."); } catch (Exception ex2) { ManualLogSource log3 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(82, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[SODMotives] clue: list preset clone failed ("); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex2.Message); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("); redundancy list will use DDS body."); } log3.LogWarning(val5); } } catch (Exception ex3) { ManualLogSource log4 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(38, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[SODMotives] clue: preset scan error: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Exception>(ex3); } log4.LogWarning(val5); } } private static bool HardExclude(InteractablePreset p) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 try { if (!p.readingEnabled) { return true; } if ((SoCustomComparison)(object)p.retailItem != (SoCustomComparison)null) { return true; } if (p.alwaysPlaceAtGameLocation) { return true; } if (p.frequencyPerGamelocationMin > 0) { return true; } if (p.placeAtWork) { return true; } if (p.limitToCertainBuildings) { return true; } ReadingModeSource readingSource = p.readingSource; if ((int)readingSource != 0 && (int)readingSource != 6) { return true; } } catch { return true; } return false; } private static int Score(InteractablePreset p) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) int num = 0; try { num = (((int)p.readingSource != 0) ? (num + 5) : (num + 10)); } catch { } try { if (!p.useSubSpawning) { num += 4; } } catch { } try { if (p.folderPlacementChance <= 0f) { num += 4; } } catch { } try { if (p.placeAtHome) { num += 2; } } catch { } try { if (p.putDownAtHome) { num++; } } catch { } string text = SafeName(p).ToLowerInvariant(); if (text.Contains("note")) { num += 4; } else if (text.Contains("letter")) { num += 3; } else if (text.Contains("memo") || text.Contains("paper") || text.Contains("postit")) { num += 2; } return num; } internal static void InjectForCase(Murder murder) { //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Expected O, but got Unknown if (!Enable || murder == null) { return; } Human victim = murder.victim; if ((Object)(object)victim == (Object)null || !MurderSelector.OverriddenVictimIds.Contains(victim.humanID) || _injected.Contains(victim.humanID)) { return; } _injected.Add(victim.humanID); try { _killerId = (((Object)(object)murder.murderer != (Object)null) ? murder.murderer.humanID : (-1)); } catch { _killerId = -1; } _killerLinked = false; _placedRooms.Clear(); try { DebugTools.ClueHud.Clear(); } catch { } ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: killer = "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(MotivesPlugin.Name(murder.murderer)); } log.LogInfo(val); try { EnsureNotePreset(); if ((SoCustomComparison)(object)_notePreset == (SoCustomComparison)null) { MotivesPlugin.Log.LogInfo((object)"[SODMotives] clue: no usable note preset; skipping."); return; } if (!MurderSelector.PoolByVictim.TryGetValue(victim.humanID, out var value) || value == null || value.Count == 0) { ManualLogSource log2 = MotivesPlugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(58, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: no recorded pool for victim "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(MotivesPlugin.Name(victim)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; skipping."); } log2.LogInfo(val); return; } if (!CluesByVictim.TryGetValue(victim.humanID, out var value2)) { value2 = new List<string>(); CluesByVictim[victim.humanID] = value2; } HashSet<SocialEvent> hashSet = new HashSet<SocialEvent>(); List<SocialEvent> list = new List<SocialEvent>(); for (int i = 0; i < value.Count; i++) { SocialEvent evt = value[i].evt; if (evt != null && hashSet.Add(evt)) { list.Add(evt); } } if (_killerId >= 0) { SocialEvent socialEvent = null; for (int j = 0; j < value.Count; j++) { if ((Object)(object)value[j].suspect != (Object)null && value[j].suspect.humanID == _killerId) { socialEvent = value[j].evt; break; } } if (socialEvent != null && list.Remove(socialEvent)) { list.Insert(0, socialEvent); } } ManualLogSource log3 = MotivesPlugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(64, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: inject start state="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<MurderState>(murder.state); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" victim="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(MotivesPlugin.Name(victim)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" events="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" preset='"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(SafeName(_notePreset)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'"); } log3.LogInfo(val); int num = 0; foreach (SocialEvent item in list) { if (num < MaxClues) { switch (item.type) { case SocialEventType.Affair: num += InjectAffair(victim, item, value2, num); break; case SocialEventType.Promotion: num += InjectPromotion(victim, item, value2, num); break; case SocialEventType.Layoffs: num += InjectLayoffs(victim, item, value2, num); break; case SocialEventType.Eviction: num += InjectEviction(victim, item, value2, num); break; case SocialEventType.RentArrears: num += InjectMoneyThreat(victim, item, value2, num); break; case SocialEventType.Debt: num += InjectMoneyThreat(victim, item, value2, num); break; case SocialEventType.Feud: num += InjectFeud(victim, item, value2, num); break; } continue; } break; } ManualLogSource log4 = MotivesPlugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(85, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: placed "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" clue(s) for victim "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(MotivesPlugin.Name(victim)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" across "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" event(s); killerAuthoredClue="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_killerLinked); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log4.LogInfo(val); } catch (Exception ex) { ManualLogSource log5 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[SODMotives] clue: inject error: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } log5.LogWarning(val2); } } private static int InjectAffair(Human victim, SocialEvent ev, List<string> recList, int placed) { if (placed >= MaxClues || (Object)(object)ev.a == (Object)null || (Object)(object)ev.b == (Object)null) { return 0; } if (RollEmail()) { int linked; string text = BuildAffairEmailTree(ev.a, ev.b, out linked); if (text != null && InjectEmailClue(ev.a, ev.b, text, "affair", "affair love-letter email", linked, null, recList) > 0) { return 1; } } (string, string) tuple = InfidelityTrees[_rng.Next(InfidelityTrees.Length)]; Interactable val = PlaceClue(victim, ev.a, ev.b, tuple.Item1); if (val == null) { LogFail("affair", ev.a, ev.b); return 0; } Finish(val, victim, ev.a, ev.b, tuple.Item1, tuple.Item2, "affair " + MotivesPlugin.Name(ev.a) + "->" + MotivesPlugin.Name(ev.b), recList, unsentDoc: false, anonWriter: true, "Love Letter"); return 1; } private static int InjectPromotion(Human victim, SocialEvent ev, List<string> recList, int placed) { int num = 0; if ((Object)(object)ev.a != (Object)null && (Object)(object)ev.b != (Object)null) { int linked; string text = BuildPromotionEmailTree(ev.b, ev.a, out linked); if (text != null) { num += InjectEmailClue(ev.b, ev.a, text, "promotion", "promotion letter email", linked, null, recList); } else { LogFail("promotion letter email", ev.b, ev.a); } } List<Human> list = KillerFirst(ev.group); for (int i = 0; i < list.Count; i++) { if (placed + num >= MaxClues) { break; } Human val = list[i]; if (!((Object)(object)val == (Object)null)) { int linked2; string text2 = BuildPromotionThreatDocTree(val, victim, out linked2); if (text2 == null) { LogFail("promotion threat", val, victim); } else { num += InjectAnonThreatNote(victim, val, victim, text2, linked2, "promothreat", recList); } } } return num; } private static int InjectEviction(Human victim, SocialEvent ev, List<string> recList, int placed) { //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Expected O, but got Unknown //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) if (placed >= MaxClues || (Object)(object)ev.a == (Object)null) { return 0; } Human a = ev.a; List<Human> list = new List<Human>(); HashSet<int> hashSet = new HashSet<int>(); if (MurderSelector.PoolByVictim.TryGetValue(victim.humanID, out var value) && value != null) { for (int i = 0; i < value.Count; i++) { SuspectEdge suspectEdge = value[i]; if (suspectEdge.evt == ev && (Object)(object)suspectEdge.suspect != (Object)null && hashSet.Add(suspectEdge.suspect.humanID)) { list.Add(suspectEdge.suspect); } } } if (list.Count == 0) { for (int j = 0; j < ev.group.Count; j++) { Human val = ev.group[j]; if ((Object)(object)val != (Object)null && hashSet.Add(val.humanID)) { list.Add(val); } } } if (RollEmail()) { int linked; string text = BuildEvictionDocTree(a, list, out linked, null, asVmail: true); if (text != null && InjectEmailClue(a, a, text, "eviction", "redevelopment plan email", linked, list, recList) > 0) { return 1; } } int linked2; string text2 = BuildEvictionDocTree(a, list, out linked2); if (text2 == null) { LogFail("eviction plan", a, victim); return 0; } Interactable val2 = PlaceClue(a, a, null, text2); if (val2 == null) { LogFail("eviction plan", a, victim); return 0; } Evidence evidence = val2.evidence; try { val2.SetWriter(a); } catch { } try { if (evidence != null) { evidence.SetWriter(a); } } catch { } try { val2.SetDDSOverride(text2); } catch { } if (evidence != null) { try { evidence.SetOverrideDDS(text2); } catch { } } AddAuthorPrint(val2, a, policyOn: true); if (evidence != null) { try { evidence.AddOrSetCustomName((DataKey)0, ObviousNames ? "MODCLUE Redevelopment Plan" : "Redevelopment Plan"); try { List<DataKey> tiedKeys = evidence.GetTiedKeys((DataKey)0); if (tiedKeys != null) { for (int k = 0; k < tiedKeys.Count; k++) { DataKey val3 = tiedKeys[k]; if ((int)val3 != 0) { try { evidence.AddOrSetCustomName(val3, ""); } catch { } } } } } catch { } try { evidence.AddOrSetCustomName((DataKey)3, ""); } catch { } try { ((CaseComponent)evidence).UpdateName(); } catch { } try { val2.UpdateName(true, (DataKey)0); } catch { val2.UpdateName(false, (DataKey)0); } } catch { } } int num = 0; FactPreset fp = ResolveConnectFactPreset(evidence); for (int l = 0; l < list.Count; l++) { NewAddress val4 = SafeHome(list[l]); if ((Object)(object)val4 != (Object)null && AddLocationConnection(evidence, val4, fp)) { num++; } } string text3 = "?"; string text4 = "?"; try { NewNode node = val2.node; if (node != null) { NewGameLocation gameLocation = node.gameLocation; string text5 = (((Object)(object)gameLocation != (Object)null) ? ((Object)gameLocation).name : "?"); string text6 = ""; try { if ((Object)(object)node.room != (Object)null) { text6 = node.room.GetName(); } } catch { } text4 = (string.IsNullOrEmpty(text6) ? text5 : (text6 + ", " + text5)); text3 = ClassifyLocation(victim, text5); } } catch { } int num2 = -1; try { num2 = val2.id; } catch { } bool flag = default(bool); try { List<int> list2 = new List<int>(); for (int m = 0; m < list.Count; m++) { if ((Object)(object)list[m] != (Object)null) { list2.Add(list[m].humanID); } } Persistence.RecordNote(num2, text2, "eviction", ((Object)(object)a != (Object)null) ? a.humanID : (-1), list2, ObviousNames ? "MODCLUE Redevelopment Plan" : "Redevelopment Plan"); } catch (Exception ex) { ManualLogSource log = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[SODMotives] persist: record eviction note: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message); } log.LogWarning(val5); } string text7 = $"eviction plan [{text3}: {text4}] itemId={num2} addresses={list.Count} bodyLinks={linked2} connected={num}"; recList.Add(text7); ManualLogSource log2 = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[SODMotives] clue: INJECTED "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(text7); } log2.LogInfo(val6); try { DebugTools.AddClueHud("redevelopment plan — " + text3 + ": " + text4); } catch { } return 1; } private static int InjectMoneyThreat(Human victim, SocialEvent ev, List<string> recList, int placed) { if (placed >= MaxClues || (Object)(object)ev.a == (Object)null || (Object)(object)ev.b == (Object)null) { return 0; } Human a = ev.a; Human b = ev.b; int linked; string text = BuildRentDemandDocTree(b, a, out linked); if (text == null) { LogFail("threatening note", b, victim); return 0; } return InjectAnonThreatNote(a, b, victim, text, linked, "rentdemand", recList); } private static int InjectFeud(Human victim, SocialEvent ev, List<string> recList, int placed) { if (placed >= MaxClues || (Object)(object)ev.a == (Object)null || (Object)(object)ev.b == (Object)null) { return 0; } Human val = (Motive.Same(ev.a, victim) ? ev.b : ev.a); if ((Object)(object)val == (Object)null) { return 0; } int linked; string text = BuildFeudThreatDocTree(val, victim, out linked); if (text == null) { LogFail("threatening note", val, victim); return 0; } return InjectAnonThreatNote(victim, val, victim, text, linked, "feudthreat", recList); } private static int InjectAnonThreatNote(Human noteOwner, Human writer, Human murderVictim, string treeId, int linkedBody, string kind, List<string> recList) { //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Expected O, but got Unknown //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) bool num = Motive.Same(noteOwner, murderVictim); Interactable val = null; if (num) { val = PlaceClue(noteOwner, writer, null, treeId); } else { NewGameLocation val2 = null; try { val2 = (NewGameLocation)(object)noteOwner.home; } catch { } if ((Object)(object)val2 != (Object)null) { val = PlaceClueNote(val2, noteOwner, writer, null, treeId); } } if (val == null) { LogFail("threatening note", writer, murderVictim); return 0; } Evidence evidence = val.evidence; try { val.SetDDSOverride(treeId); } catch { } if (evidence != null) { try { evidence.SetOverrideDDS(treeId); } catch { } } AddAuthorPrint(val, writer, kind != "rentdemand"); if (evidence != null) { try { evidence.AddOrSetCustomName((DataKey)0, ObviousNames ? "MODCLUE Threatening Note" : "Threatening Note"); try { List<DataKey> tiedKeys = evidence.GetTiedKeys((DataKey)0); if (tiedKeys != null) { for (int i = 0; i < tiedKeys.Count; i++) { DataKey val3 = tiedKeys[i]; if ((int)val3 != 0) { try { evidence.AddOrSetCustomName(val3, ""); } catch { } } } } } catch { } try { evidence.AddOrSetCustomName((DataKey)3, ""); } catch { } try { ((CaseComponent)evidence).UpdateName(); } catch { } try { val.UpdateName(true, (DataKey)0); } catch { val.UpdateName(false, (DataKey)0); } } catch { } } try { int id = val.id; if (id >= 0) { AnonWriterNoteIds.Add(id); } } catch { } bool flag = default(bool); try { FactPreset val4 = ResolveConnectFactPreset(evidence); if ((SoCustomComparison)(object)val4 != (SoCustomComparison)null) { AddCitizenConnection(evidence, noteOwner, val4); } } catch (Exception ex) { ManualLogSource log = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[SODMotives] clue: threat-note To link: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message); } log.LogWarning(val5); } string text = "?"; string text2 = "?"; try { NewNode node = val.node; if (node != null) { NewGameLocation gameLocation = node.gameLocation; string text3 = (((Object)(object)gameLocation != (Object)null) ? ((Object)gameLocation).name : "?"); string text4 = ""; try { if ((Object)(object)node.room != (Object)null) { text4 = node.room.GetName(); } } catch { } text2 = (string.IsNullOrEmpty(text4) ? text3 : (text4 + ", " + text3)); text = ClassifyLocation(murderVictim, text3); } } catch { } int num2 = -1; try { num2 = val.id; } catch { } try { List<int> list = new List<int>(); try { if ((Object)(object)noteOwner != (Object)null && noteOwner.humanID >= 0) { list.Add(noteOwner.humanID); } } catch { } Persistence.RecordNote(num2, treeId, kind, ((Object)(object)writer != (Object)null) ? writer.humanID : (-1), list, ObviousNames ? "MODCLUE Threatening Note" : "Threatening Note"); } catch (Exception ex2) { ManualLogSource log2 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(45, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[SODMotives] persist: record threat note ("); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(kind); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("): "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex2.Message); } log2.LogWarning(val5); } string text5 = $"threatening note ({kind}) [{text}: {text2}] itemId={num2} writer={MotivesPlugin.Name(writer)} bodyLinks={linkedBody}"; recList.Add(text5); ManualLogSource log3 = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[SODMotives] clue: INJECTED "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(text5); } log3.LogInfo(val6); try { DebugTools.AddClueHud("threatening note — " + text + ": " + text2); } catch { } return 1; } internal static int HideWriterConnection(Evidence docEv, Human person) { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Invalid comparison between Unknown and I4 if (docEv == null || (Object)(object)person == (Object)null) { return 0; } int num = 0; bool flag2 = default(bool); try { Evidence val = null; try { val = (Evidence)(object)((Actor)person).evidenceEntry; } catch { } if (val == null) { try { ((Controller)person).CreateEvidence(); val = (Evidence)(object)((Actor)person).evidenceEntry; } catch { } } List<FactLink> allFacts = docEv.allFacts; int num2 = allFacts?.Count ?? 0; List<Fact> list = new List<Fact>(); if (allFacts != null) { for (int i = 0; i < num2; i++) { try { FactLink val2 = allFacts[i]; if (val2 == null) { continue; } Fact fact = val2.fact; if (fact == null) { continue; } bool flag = false; try { Evidence other = fact.GetOther(docEv); if (other != null && val != null && ((Il2CppObjectBase)other).Pointer == ((Il2CppObjectBase)val).Pointer) { flag = true; } } catch { } if (!flag) { try { if ((SoCustomComparison)(object)fact.preset != (SoCustomComparison)null && ((Object)fact.preset).name == "From") { flag = true; } } catch { } } if (flag) { list.Add(fact); } } catch { } } } for (int j = 0; j < list.Count; j++) { try { docEv.RemoveFactLink(list[j]); num++; } catch (Exception ex) { ManualLogSource log = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SODMotives] clue: RemoveFactLink: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } log.LogWarning(val3); } } try { List<Discovery> discoveryProgress = docEv.discoveryProgress; if (discoveryProgress != null) { for (int num3 = discoveryProgress.Count - 1; num3 >= 0; num3--) { try { if ((int)discoveryProgress[num3] == 17) { discoveryProgress.RemoveAt(num3); } } catch { } } } } catch { } if (num > 0) { ManualLogSource log2 = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(87, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[SODMotives] clue: removed "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" writer 'From' fact(s) of "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" on note (handwriting/print kept)."); } log2.LogInfo(val4); } } catch (Exception ex2) { ManualLogSource log3 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(50, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SODMotives] clue: hide writer connection failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message); } log3.LogWarning(val3); } return num; } internal static int HideReceiverConnection(Evidence docEv, Human person) { //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown if (docEv == null) { return 0; } int num = 0; bool flag2 = default(bool); try { Evidence val = null; if ((Object)(object)person != (Object)null) { try { val = (Evidence)(object)((Actor)person).evidenceEntry; } catch { } } List<FactLink> allFacts = docEv.allFacts; int num2 = allFacts?.Count ?? 0; List<Fact> list = new List<Fact>(); if (allFacts != null) { for (int i = 0; i < num2; i++) { try { FactLink val2 = allFacts[i]; if (val2 == null) { continue; } Fact fact = val2.fact; if (fact == null) { continue; } bool flag = false; try { if ((SoCustomComparison)(object)fact.preset != (SoCustomComparison)null && ((Object)fact.preset).name == "To") { flag = true; } } catch { } if (!flag && val != null) { try { Evidence other = fact.GetOther(docEv); if (other != null && ((Il2CppObjectBase)other).Pointer == ((Il2CppObjectBase)val).Pointer) { flag = true; } } catch { } } if (flag) { list.Add(fact); } } catch { } } } for (int j = 0; j < list.Count; j++) { try { docEv.RemoveFactLink(list[j]); num++; } catch (Exception ex) { ManualLogSource log = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(39, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SODMotives] clue: RemoveFactLink(To): "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } log.LogWarning(val3); } } if (num > 0) { ManualLogSource log2 = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(89, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[SODMotives] clue: removed "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" receiver 'To' fact(s) of "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" on latent letter (salutation kept)."); } log2.LogInfo(val4); } } catch (Exception ex2) { ManualLogSource log3 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(52, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SODMotives] clue: hide receiver connection failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message); } log3.LogWarning(val3); } return num; } private static int InjectLayoffs(Human victim, SocialEvent ev, List<string> recList, int placed) { if (placed >= MaxClues || (Object)(object)ev.a == (Object)null) { return 0; } Human a = ev.a; List<Human> list = new List<Human>(); HashSet<int> hashSet = new HashSet<int>(); if (MurderSelector.PoolByVictim.TryGetValue(victim.humanID, out var value) && value != null) { for (int i = 0; i < value.Count; i++) { SuspectEdge suspectEdge = value[i]; if (suspectEdge.evt == ev && (Object)(object)suspectEdge.suspect != (Object)null && hashSet.Add(suspectEdge.suspect.humanID)) { list.Add(suspectEdge.suspect); } } } if (list.Count == 0) { for (int j = 0; j < ev.group.Count; j++) { Human val = ev.group[j]; if ((Object)(object)val != (Object)null && hashSet.Add(val.humanID)) { list.Add(val); } } } if (list.Count == 0) { return 0; } if (RollEmail()) { int linked; string text = BuildRedundancyDocTree(list, a, out linked, null, asVmail: true); if (text != null && InjectEmailClue(a, a, text, "layoffs", "redundancy list email", linked, list, recList) > 0) { return 1; } } if (InjectLayoffsCustomText(victim, ev, a, list, recList)) { return 1; } return InjectLayoffsDDS(victim, ev, a, list, recList); } private static string CitizenLink(Human h, ref int linked) { string text = SocialEvent.SafeName(h); if ((Object)(object)h == (Object)null) { return text; } try { Evidence val = null; try { val = (Evidence)(object)((Actor)h).evidenceEntry; } catch { } if (val == null) { try { ((Controller)h).CreateEvidence(); val = (Evidence)(object)((Actor)h).evidenceEntry; } catch { } } if (val != null) { LinkData val2 = Strings.AddOrGetLink(val, (List<DataKey>)null); if (val2 != null) { linked++; return "<link=\"" + val2.id + "\">" + text + "</link>"; } } } catch { } return text; } private static string AddressLink(Human tenant, ref int linked) { NewAddress val = SafeHome(tenant); if ((Object)(object)val == (Object)null) { return "a property"; } string text = "a property"; try { if (!string.IsNullOrEmpty(((Object)val).name)) { text = ((Object)val).name; } } catch { } try { Evidence val2 = null; try { val2 = (Evidence)(object)((NewGameLocation)val).evidenceEntry; } catch { } if (val2 == null) { try { ((Controller)val).CreateEvidence(); val2 = (Evidence)(object)((NewGameLocation)val).evidenceEntry; } catch { } } if (val2 != null) { LinkData val3 = Strings.AddOrGetLink(val2, (List<DataKey>)null); if (val3 != null) { linked++; return "<link=\"" + val3.id + "\">" + text + "</link>"; } } } catch { } return text; } private static NewAddress SafeHome(Human h) { try { return ((Object)(object)h != (Object)null) ? h.home : null; } catch { return null; } } private static string PickVariant(int seed, params string[] variants) { return variants[(seed % variants.Length + variants.Length) % variants.Length]; } private static DDSParticipant MakeVmailParticipant(bool required) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown DDSParticipant val = new DDSParticipant(); try { val.required = required; } catch { } try { val.connection = (ConnectionType)15; } catch { } try { val.useJobs = false; } catch { } try { val.disableInbox = false; } catch { } try { val.useTraits = false; } catch { } try { val.jobs = new List<string>(); } catch { } try { val.traits = new List<string>(); } catch { } try { val.triggers = new List<TreeTriggers>(); } catch { } return val; } private static string RegisterCustomDocTree(string body, string fixedTreeId = null, string font = "TruetypewriterPolyglott SDF", float fontSize = 14f, bool isHandwriting = false, bool asVmail = false) { //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown try { Toolbox instance = Toolbox.Instance; if ((Object)(object)instance == (Object)null) { return null; } string text = Guid.NewGuid().ToString("N"); string text2 = "sodmotives.doc.block." + text; string text3 = "sodmotives.doc.msg." + text; string text4 = ((!string.IsNullOrEmpty(fixedTreeId)) ? fixedTreeId : ("sodmotives.doc.tree." + text)); List<string> list = new List<string>(); if (asVmail) { int num = body?.IndexOf('\n') ?? (-1); if (num >= 0) { list.Add(body.Substring(0, num)); list.Add(body.Substring(num + 1)); } else { list.Add(body ?? ""); } } else { list.Add(body ?? ""); } DDSMessageSave val = new DDSMessageSave(); ((DDSComponent)val).name = text3; ((DDSComponent)val).id = text3; val.blocks = new List<DDSBlockCondition>(); for (int i = 0; i < list.Count; i++) { string text5 = text2 + "." + i; int num2 = 1; try { Dictionary<string, Dictionary<string, DisplayString>> stringTable = Strings.stringTable; if (stringTable != null && stringTable.ContainsKey("dds.blocks")) { num2 = stringTable["dds.blocks"].Count + 1; } } catch { } Strings.LoadIntoDictionary("dds.blocks", num2, text5, list[i], "", 0, false, true); DDSBlockSave val2 = new DDSBlockSave(); ((DDSComponent)val2).name = text5; ((DDSComponent)val2).id = text5; try { val2.replacements = new List<DDSReplacement>(); } catch { } instance.allDDSBlocks[text5] = val2; val.AddBlock(text5); try { DDSBlockCondition val3 = val.blocks[i]; val3.alwaysDisplay = true; val3.group = 0; try { val3.useTraits = false; } catch { } try { val3.traits = new List<string>(); } catch { } } catch { } } instance.allDDSMessages[text3] = val; DDSTreeSave val4 = new DDSTreeSave(); ((DDSComponent)val4).name = text4; ((DDSComponent)val4).id = text4; val4.treeType = (TreeType)(asVmail ? 1 : 2); val4.messages = new List<DDSMessageSettings>(); val4.messageRef = new Dictionary<string, DDSMessageSettings>(); try { val4.document = new DDSDocument(); } catch { } string text6 = (val4.startingMessage = val4.AddMessage(text3)); if (asVmail) { try { val4.triggerPoint = (TriggerPoint)3; } catch { } try { val4.repeat = (RepeatSetting)1; } catch { } DDSTreeSave val5 = null; try { val5 = instance.allDDSTrees["8332e932-c0f2-4512-8de9-e3d7d8dbf36a"]; } catch { } if (val5 != null) { try { val4.participantA = val5.participantA; } catch { } try { val4.participantB = val5.participantB; } catch { } try { val4.participantC = val5.participantC; } catch { } try { val4.participantD = val5.participantD; } catch { } try { val4.stopMovement = val5.stopMovement; } catch { } try { val4.ignoreGlobalRepeat = val5.ignoreGlobalRepeat; } catch { } try { val4.priority = val5.priority; } catch { } try { val4.newspaperCategory = val5.newspaperCategory; } catch { } try { val4.newspaperContext = val5.newspaperContext; } catch { } MotivesPlugin.Log.LogInfo((object)"[SODMotives] email: copied vmail tree-level fields + participants from Work_Dinner template."); } else { try { val4.participantA = MakeVmailParticipant(required: true); } catch { } try { val4.participantB = MakeVmailParticipant(required: true); } catch { } try { val4.participantC = MakeVmailParticipant(required: false); } catch { } try { val4.participantD = MakeVmailParticipant(required: false); } catch { } MotivesPlugin.Log.LogWarning((object)"[SODMotives] email: Work_Dinner template not found; used generic participants."); } } try { DDSMessageSettings val6 = null; try { if (val4.messages != null && val4.messages.Count > 0) { val6 = val4.messages[0]; } } catch { } if (val6 != null) { try { val6.font = font; } catch { } try { val6.fontSize = fontSize; } catch { } try { val6.isHandwriting = isHandwriting; } catch { } if (asVmail) { try { val6.saidBy = 0; } catch { } try { val6.saidTo = 1; } catch { } try { val6.pos = new Vector2(0f, -64f); } catch { } try { val6.size = new Vector2(320f, 300f); } catch { } try { val6.lineSpace = 16f; } catch { } try { val6.col = new Color(0f, 0f, 0f, 1f); } catch { } try { val6.usePages = false; } catch { } } else { try { val6.pos = new Vector2(1f, -15.5f); } catch { } try { val6.size = new Vector2(316f, 397f); } catch { } try { val6.lineSpace = 4f; } catch { } try { val6.usePages = true; } catch { } } try { val6.alignH = 0; } catch { } try { val6.alignV = 0; } catch { } try { if (val4.messageRef != null && !string.IsNullOrEmpty(text6)) { val4.messageRef[text6] = val6; } } catch { } } } catch { } try { if (val4.document != null) { try { val4.document.background = (asVmail ? "" : "CrumpledPaper"); } catch { } try { if (asVmail) { val4.document.fill = (Type)1; } } catch { } try { val4.document.size = new Vector2(342f, 482f); } catch { } } } catch { } instance.allDDSTrees[text4] = val4; return text4; } catch (Exception ex) { ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val7 = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("[SODMotives] clue: RegisterCustomDocTree: "); ((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<string>(ex.Message); } log.LogWarning(val7); return null; } } private static string BuildRedundancyDocTree(List<Human> uniq, Human author, out int linked, string fixedTreeId = null, bool asVmail = false) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown linked = 0; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("REDUNDANCY NOTICE\n\n"); stringBuilder.Append("The following staff are scheduled for termination:\n\n"); if (uniq != null) { for (int i = 0; i < uniq.Count; i++) { stringBuilder.Append("- "); stringBuilder.Append(CitizenLink(uniq[i], ref linked)); stringBuilder.Append('\n'); } } if ((Object)(object)author != (Object)null) { stringBuilder.Append("\n\nIssued by: "); stringBuilder.Append(CitizenLink(author, ref linked)); } string body = stringBuilder.ToString(); string text = (asVmail ? BuildEmailBody(body, fixedTreeId) : RegisterCustomDocTree(body, fixedTreeId)); if (text != null) { ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(73, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: built custom redundancy "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(asVmail ? "email" : "doc"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" tree '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(uniq?.Count ?? 0); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" names, "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(linked); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" clickable)."); } log.LogInfo(val); } return text; } private static string BuildEvictionDocTree(Human landlord, List<Human> tenants, out int linked, string fixedTreeId = null, bool asVmail = false) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown linked = 0; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("REDEVELOPMENT PLAN — CONFIDENTIAL\n\n"); stringBuilder.Append("The following properties are to be cleared for redevelopment. All current tenancies are to be terminated and the residents moved out ahead of the works. Proceed quietly; expect complaints.\n\n"); if (tenants != null && tenants.Count > 0) { stringBuilder.Append("Properties to be vacated:\n\n"); for (int i = 0; i < tenants.Count; i++) { stringBuilder.Append("- "); stringBuilder.Append(AddressLink(tenants[i], ref linked)); stringBuilder.Append('\n'); } } if ((Object)(object)landlord != (Object)null) { stringBuilder.Append("\n\nIssued by: "); stringBuilder.Append(CitizenLink(landlord, ref linked)); } string body = stringBuilder.ToString(); string text = (asVmail ? BuildEmailBody(body, fixedTreeId) : RegisterCustomDocTree(body, fixedTreeId)); if (text != null) { ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(73, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: built eviction plan "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(asVmail ? "email" : "doc"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" tree '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (addresses="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(tenants?.Count ?? 0); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(linked); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" clickable)."); } log.LogInfo(val); } return text; } private static string BuildRentDemandDocTree(Human landlord, Human addressee, out int linked, string fixedTreeId = null) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown linked = 0; StringBuilder stringBuilder = new StringBuilder(); if ((Object)(object)addressee != (Object)null) { stringBuilder.Append(CitizenLink(addressee, ref linked) + ",\n\n"); } stringBuilder.Append("Settle your debt. Consider this your final warning."); string font = "Pacific Beach Script Font SDF"; try { if ((Object)(object)landlord != (Object)null && (SoCustomComparison)(object)landlord.handwriting != (SoCustomComparison)null && (Object)(object)landlord.handwriting.fontAsset != (Object)null) { string name = ((Object)landlord.handwriting.fontAsset).name; if (!string.IsNullOrEmpty(name)) { font = name; } } } catch { } string text = RegisterCustomDocTree(stringBuilder.ToString(), fixedTreeId, font, 30f, isHandwriting: true); if (text != null) { ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(58, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: built rent demand tree '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(linked); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" clickable)."); } log.LogInfo(val); } return text; } private static string BuildFeudThreatDocTree(Human aggressor, Human addressee, out int linked, string fixedTreeId = null) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown linked = 0; StringBuilder stringBuilder = new StringBuilder(); if ((Object)(object)addressee != (Object)null) { stringBuilder.Append(CitizenLink(addressee, ref linked) + ",\n\n"); } stringBuilder.Append("You've had your last warning. Stay out of my way, or you'll regret it."); string font = "Pacific Beach Script Font SDF"; try { if ((Object)(object)aggressor != (Object)null && (SoCustomComparison)(object)aggressor.handwriting != (SoCustomComparison)null && (Object)(object)aggressor.handwriting.fontAsset != (Object)null) { string name = ((Object)aggressor.handwriting.fontAsset).name; if (!string.IsNullOrEmpty(name)) { font = name; } } } catch { } string text = RegisterCustomDocTree(stringBuilder.ToString(), fixedTreeId, font, 30f, isHandwriting: true); if (text != null) { ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: built feud threat tree '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log.LogInfo(val); } return text; } private static string BuildPromotionThreatDocTree(Human aggressor, Human addressee, out int linked, string fixedTreeId = null) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown linked = 0; StringBuilder stringBuilder = new StringBuilder(); if ((Object)(object)addressee != (Object)null) { stringBuilder.Append(CitizenLink(addressee, ref linked) + ",\n\n"); } int seed = 0; try { if ((Object)(object)aggressor != (Object)null) { seed = aggressor.humanID; } } catch { } stringBuilder.Append(PickVariant(seed, "You'll regret taking what I earned. Enjoy it while it lasts.", "You took what was mine, and I won't forget it.", "Don't get too comfortable in that new office.", "Congratulations on the promotion. Watch yourself.", "Traitor. You took what was mine.", "Make the most of it while you still can.")); string font = "Pacific Beach Script Font SDF"; try { if ((Object)(object)aggressor != (Object)null && (SoCustomComparison)(object)aggressor.handwriting != (SoCustomComparison)null && (Object)(object)aggressor.handwriting.fontAsset != (Object)null) { string name = ((Object)aggressor.handwriting.fontAsset).name; if (!string.IsNullOrEmpty(name)) { font = name; } } } catch { } string text = RegisterCustomDocTree(stringBuilder.ToString(), fixedTreeId, font, 30f, isHandwriting: true); if (text != null) { ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: built promotion threat tree '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log.LogInfo(val); } return text; } private static string BuildEmailBody(string body, string fixedTreeId = null) { return RegisterCustomDocTree(body, fixedTreeId, "Halogen", 22f, isHandwriting: false, asVmail: true); } private static bool RollEmail() { return _rng.NextDouble() < (double)EmailClueShare; } private static string BuildAffairEmailTree(Human from, Human to, out int linked, string fixedTreeId = null) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown linked = 0; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Thinking of you\n\n"); if ((Object)(object)to != (Object)null) { stringBuilder.Append(CitizenLink(to, ref linked) + ",\n\n"); } stringBuilder.Append("I can't stop thinking about you. Being apart like this is unbearable. Let's find a way to see each other soon, somewhere quiet where no one we know will see us.\n\n"); stringBuilder.Append("Always yours,\n"); if ((Object)(object)from != (Object)null) { stringBuilder.Append(CitizenLink(from, ref linked)); } string text = BuildEmailBody(stringBuilder.ToString(), fixedTreeId); if (text != null) { ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(59, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: built affair email tree '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(linked); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" clickable)."); } log.LogInfo(val); } return text; } private static string BuildPromotionEmailTree(Human boss, Human promotee, out int linked, string fixedTreeId = null) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown linked = 0; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Your promotion\n\n"); if ((Object)(object)promotee != (Object)null) { stringBuilder.Append(CitizenLink(promotee, ref linked) + ",\n\n"); } stringBuilder.Append("I'm pleased to confirm your promotion. You've earned it, and I'm confident you'll rise to the new responsibilities. We'll announce it to the rest of the team shortly.\n\n"); stringBuilder.Append("Regards,\n"); if ((Object)(object)boss != (Object)null) { stringBuilder.Append(CitizenLink(boss, ref linked)); } string text = BuildEmailBody(stringBuilder.ToString(), fixedTreeId); if (text != null) { ManualLogSource log = MotivesPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(62, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] clue: built promotion email tree '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(linked); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" clickable)."); } log.LogInfo(val); } return text; } private static string TestEmailBody(Human from, List<Human> others, out int linked) { linked = 0; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Motive mailer test\n\n"); stringBuilder.Append("This names a few people to confirm clickable links render in the inbox:\n\n"); if (others != null) { for (int i = 0; i < others.Count; i++) { stringBuilder.Append("- "); stringBuilder.Append(CitizenLink(others[i], ref linked)); stringBuilder.Append('\n'); } } stringBuilder.Append("\nRegards,\n"); stringBuilder.Append(CitizenLink(from, ref linked)); return stringBuilder.ToString(); } private static string BuildTestEmailTree(Human from, List<Human> others, out int linked, string fixedTreeId = null) { return BuildEmailBody(TestEmailBody(from, others, out linked), fixedTreeId); } private static bool ThreadInList(List<MessageThreadSave> list, int tid) { try { if (list == null) { return false; } for (int i = 0; i < list.Count; i++) { MessageThreadSave val = list[i]; if (val != null && val.threadID == tid) { return true; } } } catch { } return false; } private static int InjectEmail(Human from, Human to, string treeId) { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected O, but got Unknown //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Expected O, but got Unknown bool flag = default(bool); try { if ((Object)(object)from == (Object)null || (Object)(object)to == (Object)null || string.IsNullOrEmpty(treeId)) { return -1; } Toolbox instance = Toolbox.Instance; if ((Object)(object)instance == (Object)null) { MotivesPlugin.Log.LogWarning((object)"[SODMotives] email: Toolbox not ready."); return -1; } float num = 0f; try { SessionData instance2 = SessionData.Instance; if ((Object)(object)instance2 != (Object)null) { float gameTime = instance2.gameTime; float num2 = 6f + (float)_rng.NextDouble() * 114f; num = gameTime - num2; if (num < 0f) { num = gameTime * (float)_rng.NextDouble(); } } } catch { } List<Human> val = new List<Human>(); MessageThreadSave val2 = instance.NewVmailThread(from, to, (Human)null, (Human)null, val, treeId, num, 999, (CustomDataSource)0, -1); if (val2 == null) { MotivesPlugin.Log.LogWarning((object)"[SODMotives] email: NewVmailThread returned null."); return -1; } int num3 = -1; try { num3 = val2.threadID; } catch { } try { int num4 = -1; try { num4 = ((val2.messages != null) ? val2.messages.Count : (-1)); } catch { } if (num4 <= 0) { try { instance.ProgressVmailThread(val2, 999); } catch (Exception ex) { ManualLogSource log = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SODMotives] email: ProgressVmailThread: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } log.LogWarning(val3); } } num4 = -1; try { num4 = ((val2.messages != null) ? val2.messages.Count : (-1)); } catch { } if (num4 <= 0) { string text = null; try { DDSTreeSave val4 = instance.allDDSTrees[treeId]; if (val4 != null) { text = val4.startingMessage; } } catch { } if (!string.IsNullOrEmpty(text)) { if (val2.messages == null) { val2.messages = new List<string>(); } if (val2.senders == null) { val2.senders = new List<int>(); } if (val2.recievers == null) { val2.recievers = new List<int>(); } if (val2.timestamps == null) { val2.timestamps = new List<float>(); } val2.messages.Add(text); val2.senders.Add(from.humanID); val2.recievers.Add(to.humanID); val2.timestamps.Add(num); MotivesPlugin.Log.LogInfo((object)"[SODMotives] email: delivery empty; hand-populated one message (fallback)."); } } List<MessageThreadSave> messageThreadFeatures = to.messageThreadFeatures; if (messageThreadFeatures != null && !ThreadInList(messageThreadFeatures, num3)) { messageThreadFeatures.Add(val2); } List<MessageThreadSave> messageThreadsStarted = from.messageThreadsStarted; if (messageThreadsStarted != null && !ThreadInList(messageThreadsStarted, num3)) { messageThreadsStarted.Add(val2); } GameplayController instance3 = GameplayController.Instance; if ((Object)(object)instance3 != (Object)null && instance3.messageThreads != null && !instance3.messageThreads.ContainsKey(num3)) { instance3.messageThreads[num3] = val2; } } catch (Exception ex2) { ManualLogSource log2 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SODMotives] email: delivery/filing fallback: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message); } log2.LogWarning(val3); } ManualLogSource log3 = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(56, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[SODMotives] email: injected vmail thread id="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num3); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" from="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(MotivesPlugin.Name(from)); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" to="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(MotivesPlugin.Name(to)); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("."); } log3.LogInfo(val5); return num3; } catch (Exception ex3) { ManualLogSource log4 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SODMotives] email: InjectEmail failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex3.Message); } log4.LogWarning(val3); return -1; } } private static int InjectEmailClue(Human from, Human to, string treeId, string kind, string label, int linkedBody, List<Human> namedCitizens, List<string> recList) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown int num = InjectEmail(from, to, treeId); if (num < 0) { LogFail(label, from, to); return 0; } bool flag = default(bool); try { List<int> list = new List<int>(); if (namedCitizens != null) { for (int i = 0; i < namedCitizens.Count; i++) { if ((Object)(object)namedCitizens[i] != (Object)null) { list.Add(namedCitizens[i].humanID); } } } Persistence.RecordEmail(treeId, kind, ((Object)(object)from != (Object)null) ? from.humanID : (-1), ((Object)(object)to != (Object)null) ? to.humanID : (-1), list); } catch (Exception ex) { ManualLogSource log = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(39, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] persist: record email ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(kind); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } string value = "?"; try { if ((Object)(object)to != (Object)null && (Object)(object)to.home != (Object)null) { value = ((Object)to.home).name; } } catch { } bool flag2 = (Object)(object)from != (Object)null && (Object)(object)to != (Object)null && from.humanID == to.humanID; string text = (flag2 ? $"{label} [inbox: {MotivesPlugin.Name(to)} @ {value} (self-draft)] threadId={num} bodyLinks={linkedBody}" : $"{label} [inbox: {MotivesPlugin.Name(to)} @ {value}] threadId={num} from={MotivesPlugin.Name(from)} bodyLinks={linkedBody}"); recList.Add(text); ManualLogSource log2 = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(55, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[SODMotives] clue: INJECTED "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (read on "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(MotivesPlugin.Name(to)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'s home computer"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(flag2 ? "" : (" or " + MotivesPlugin.Name(from) + "'s")); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")"); } log2.LogInfo(val2); try { DebugTools.AddClueHud($"{label} — inbox {MotivesPlugin.Name(to)} @ {value}"); } catch { } return 1; } internal static void ConnectPrintedVmail(EvidencePrintedVmail pv) { //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Expected O, but got Unknown bool flag = default(bool); try { if (pv == null) { return; } string text = null; try { MessageThreadSave thread = pv.thread; if (thread != null) { text = thread.treeID; } } catch { } if (string.IsNullOrEmpty(text)) { return; } List<int> list = null; List<Persistence.EmailRecord> emails = Persistence.Emails; for (int i = 0; i < emails.Count; i++) { if (emails[i].treeId == text) { list = emails[i].citizenHumanIds; break; } } if (list == null || list.Count == 0) { return; } int num = -1; try { Interactable interactable = ((Evidence)pv).interactable; if (interactable != null) { num = interactable.id; } } catch { } if (num >= 0 && !_printedVmailLinked.Add(num)) { return; } List<Citizen> val = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.citizenDirectory : null); if (val == null) { return; } HashSet<int> hashSet = new HashSet<int>(); for (int j = 0; j < list.Count; j++) { hashSet.Add(list[j]); } Dictionary<int, Human> dictionary = new Dictionary<int, Human>(); for (int k = 0; k < val.Count; k++) { Citizen val2 = val[k]; if (!((Object)(object)val2 == (Object)null)) { int humanID; try { humanID = ((Human)val2).humanID; } catch { continue; } if (hashSet.Contains(humanID)) { dictionary[humanID] = (Human)(object)val2; } } } FactPreset fp = ResolveConnectFactPreset((Evidence)(object)pv); int num2 = 0; for (int l = 0; l < list.Count; l++) { if (dictionary.TryGetValue(list[l], out var value) && AddCitizenConnection((Evidence)(object)pv, value, fp)) { num2++; } } ManualLogSource log = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(69, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SODMotives] clue: printed-vmail body connections added: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (treeId="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log.LogInfo(val3); } catch (Exception ex) { ManualLogSource log2 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[SODMotives] clue: ConnectPrintedVmail: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message); } log2.LogWarning(val4); } } internal static int RebuildEmailTree(string treeId, string kind, Human from, Human to, List<Human> citizens) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown if (string.IsNullOrEmpty(treeId)) { return -1; } int linked = 0; bool flag = default(bool); if (kind switch { "testmail" => BuildTestEmailTree(from, citizens, out linked, treeId), "promotion" => BuildPromotionEmailTree(from, to, out linked, treeId), "affair" => BuildAffairEmailTree(from, to, out linked, treeId), "eviction" => BuildEvictionDocTree(from, citizens, out linked, treeId, asVmail: true), "layoffs" => BuildRedundancyDocTree(citizens, from, out linked, treeId, asVmail: true), _ => null, } == null) { ManualLogSource log = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(68, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] persist: rebuild email tree '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(treeId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' kind="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(kind); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" FAILED (terminal)."); } log.LogWarning(val); return -1; } string text = TreeStartInst(treeId); int num = ResyncThreadsForTree(treeId, text, from, to); ManualLogSource log2 = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(93, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[SODMotives] persist: re-registered email tree '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(treeId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' kind="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(kind); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" bodyLinks="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(linked); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" startInst="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text ?? "?"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" threadsSynced="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log2.LogInfo(val2); return num; } internal static int ResyncEmailThread(string treeId) { return ResyncThreadsForTree(treeId, TreeStartInst(treeId), null, null); } private static string TreeStartInst(string treeId) { try { DDSTreeSave val = (((Object)(object)Toolbox.Instance != (Object)null) ? Toolbox.Instance.allDDSTrees[treeId] : null); if (val != null) { return val.startingMessage; } } catch { } return null; } private static int ResyncThreadsForTree(string treeId, string inst, Human from, Human to) { //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown if (string.IsNullOrEmpty(treeId) || string.IsNullOrEmpty(inst)) { return 0; } int num = 0; bool flag = default(bool); try { GameplayController instance = GameplayController.Instance; if ((Object)(object)instance == (Object)null || instance.messageThreads == null) { return 0; } Enumerator<int, MessageThreadSave> enumerator = instance.messageThreads.GetEnumerator(); while (enumerator.MoveNext()) { MessageThreadSave value = enumerator.Current.Value; if (value == null) { continue; } string text = null; try { text = value.treeID; } catch { } if (text != treeId) { continue; } try { if (value.messages == null) { value.messages = new List<string>(); } if (value.messages.Count == 0) { value.messages.Add(inst); } else { value.messages[0] = inst; } if (value.senders == null) { value.senders = new List<int>(); } if (value.senders.Count == 0) { value.senders.Add(((Object)(object)from != (Object)null) ? from.humanID : (-1)); } if (value.recievers == null) { value.recievers = new List<int>(); } if (value.recievers.Count == 0) { value.recievers.Add(((Object)(object)to != (Object)null) ? to.humanID : (-1)); } if (value.timestamps == null) { value.timestamps = new List<float>(); } if (value.timestamps.Count == 0) { value.timestamps.Add(0f); } num++; } catch (Exception ex) { ManualLogSource log = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(43, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] persist: resync thread on '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(treeId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } } } catch (Exception ex2) { ManualLogSource log2 = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(48, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] persist: ResyncThreadsForTree('"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(treeId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message); } log2.LogWarning(val); } return num; } internal static void RebuildCustomNote(Interactable note, List<Human> citizens, Human author, string treeId, string kind = null) { //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown if (note == null || string.IsNullOrEmpty(treeId)) { return; } bool flag = kind == "rentdemand" || kind == "feudthreat" || kind == "promothreat"; Human addressee = ((flag && citizens != null && citizens.Count > 0) ? citizens[0] : null); bool flag2 = default(bool); if (kind switch { "promothreat" => BuildPromotionThreatDocTree(author, addressee, out var linked, treeId), "feudthreat" => BuildFeudThreatDocTree(author, addressee, out linked, treeId), "rentdemand" => BuildRentDemandDocTree(author, addressee, out linked, treeId), "eviction" => BuildEvictionDocTree(author, citizens, out linked, treeId), _ => BuildRedundancyDocTree(citizens, author, out linked, treeId), } == null) { ManualLogSource log = MotivesPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(49, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SODMotives] persist: rebuild tree failed for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(treeId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log.LogWarning(val); return; } Evidence evidence = note.evidence; bool flag3 = flag; bool flag4 = (Object)(object)author != (Object)null && !flag3; try { if (flag4) { note.SetWriter(author); } } catch { } try { note.SetDDSOverride(treeId); } catch { } if (evidence != null) { try { evidence.SetOverrideDDS(treeId); } catch { } try { if (flag4) { evidence.SetWriter(author); } } catch { } } if (flag3) { try { int id = note.id; if (id >= 0) { AnonWriterNoteIds.Add(id); WriterHiddenIds.Remove(id); } } catch { } } int num = 0; FactPreset fp = ResolveConnectFactPreset(evidence); if (citizens != null) { for (int i = 0; i < citizens.Count; i++) { if ((kind == "eviction") ? AddLocationConnection(evidence, SafeHome(citizens[i]), fp) : AddCitizenConnection(evidence, citizens[i], fp)) { num++; } } } int num2 = -1; try { num2 = note.id; } catch { } ManualLogSource log2 = MotivesPlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(78, 5, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[SODMotives] persist: rebuilt note id="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" tree='"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(treeId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' names="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(citizens?.Count ?? 0); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" bodyLinks="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(linked); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" reconnected="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log2.LogInfo(val2); try { DebugTools.AddClueHud($"restored list (reload) — id={num2}"); } catch { } } private static bool InjectLayoffsCustomText(Human victim, SocialEvent ev, Human boss, List<Human> uniq, List<string> recList) { //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) int linked; string text = BuildRedundancyDocTree(uniq, boss, out linked); if (text == null) { return false; } Interactable val = PlaceClue(victim, boss, null, text); if (val == null) { LogFail("redundancy list (custom)", boss, victim); return false; } Evidence evidence = val.evidence; try { val.SetWriter(boss); } catch { } try { if (evidence != null && (Object)(object)boss != (Object)null) { evidence.SetWriter(boss); } } catch { } try { val.SetDDSOverride(text); } catch { } if (evidence != null) { try { evidence.SetOverrideDDS(text); } catch { } } AddAuthorPrint(val, boss, policyOn: true); if (evidence != null) { try { evidence.AddOrSetCustomName((DataKey)0, ObviousNames ? "MODCLUE Redundancy List" : "Redundancy List"); try { List<DataKey> tiedKeys = evidence.GetTiedKeys((DataKey)0); if (tiedKeys != null) { for (int i = 0; i < tiedKeys.Count; i++) { DataKey val2 = tiedKeys[i]; if ((int)val2 != 0) { try { evidence.AddOrSetCustomName(val2, ""); } catch { } } } } } catch { } try { evidence.AddOrSetCustomName((DataKey)3, ""); } catch { } try { ((CaseComponent)evidence).UpdateName(); } catch { } try { val.UpdateName(true, (DataKey)0); } catch { val.UpdateName(false, (DataKey)0); } } catch { } } int num = 0