Decompiled source of AffiliationAlteration v1.0.0

Plugins/ForceFriendShip.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using COTL_API.CustomFollowerCommand;
using COTL_API.Helpers;
using ForceFriendship.Commands;
using ForceFriendship.Helpers;
using HarmonyLib;
using Lamb.UI;
using Lamb.UI.FollowerSelect;
using Microsoft.CodeAnalysis;
using UnityEngine;
using src.Extensions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("COTL_API")]
[assembly: AssemblyCompany("ForceFriendShip")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+825c761a3403af73f4ea5ea61660887a900e777c")]
[assembly: AssemblyProduct("ForceFriendShip")]
[assembly: AssemblyTitle("ForceFriendShip")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ForceFriendship
{
	public static class Logging
	{
		public static ManualLogSource Logger => Plugin.Log;

		public static void Log(LogLevel level, string message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Logger.Log(level, (object)message);
		}

		public static void LogInfo(string message)
		{
			Logger.LogInfo((object)message);
		}

		public static void LogDebug(string message)
		{
			Logger.LogDebug((object)message);
		}

		public static void LogWarning(string message)
		{
			Logger.LogWarning((object)message);
		}

		public static void LogError(string message)
		{
			Logger.LogError((object)message);
		}

		public static void LogFatal(string message)
		{
			Logger.LogFatal((object)message);
		}
	}
	[BepInPlugin("xyz.zelzmiy.ForceFriendship", "ForceFriendship", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "xyz.zelzmiy.ForceFriendship";

		public const string PluginName = "ForceFriendship";

		public const string PluginVer = "1.0.0";

		internal static ManualLogSource Log;

		internal static readonly Harmony Harmony = new Harmony("xyz.zelzmiy.ForceFriendship");

		internal static string PluginPath;

		private void Awake()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			CustomFollowerCommandManager.Add((CustomFollowerCommand)(object)new SwoonCommand());
			CustomFollowerCommandManager.Add((CustomFollowerCommand)(object)new BefriendCommand());
			CustomFollowerCommandManager.Add((CustomFollowerCommand)(object)new EstrangeCommand());
			CustomFollowerCommandManager.Add((CustomFollowerCommand)(object)new DismayCommand());
		}

		private void OnEnable()
		{
			Harmony.PatchAll();
			Logging.LogInfo("Loaded ForceFriendship!");
		}

		private void OnDisable()
		{
			Harmony.UnpatchSelf();
			Logging.LogInfo("Unloaded ForceFriendship!");
		}
	}
}
namespace ForceFriendship.Helpers
{
	internal static class Extentions
	{
		public static bool IsSleeping(this Follower follower)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			return !TimeManager.IsNight || !((Object)(object)follower != (Object)null) || follower.Brain.CurrentTask == null || (int)follower.Brain.CurrentTask.State != 4 || ((int)follower.Brain.CurrentTaskType != 7 && (int)follower.Brain.CurrentTaskType != 49);
		}
	}
	internal static class RelationshipHelper
	{
		public static void ChangeRelationship(RelationshipState state, int relationship, Follower follower, string HeaderText = "")
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			Time.timeScale = 0f;
			Follower partner = null;
			List<FollowerSelectEntry> list = new List<FollowerSelectEntry>();
			foreach (Follower follower2 in Follower.Followers)
			{
				if (!DataManager.Instance.Followers_Recruit.Contains(follower2.Brain._directInfoAccess) && follower2.Brain.Info.ID != follower.Brain.Info.ID)
				{
					list.Add(new FollowerSelectEntry(follower2, FollowerManager.GetFollowerAvailabilityStatus(follower2.Brain, false)));
				}
			}
			UIFollowerSelectMenuController val = GameObjectExtensions.Instantiate<UIFollowerSelectMenuController>(MonoSingleton<UIManager>.Instance.FollowerSelectMenuTemplate);
			((UIFollowerSelectBase<FollowerInformationBox>)(object)val).VotingType = (VotingType)20;
			val.SetHeaderText(HeaderText);
			((UIFollowerSelectBase<FollowerInformationBox>)(object)val).Show(list, false, true, true, false);
			((UIFollowerSelectBase<FollowerInformationBox>)(object)val).OnFollowerSelected = (Action<FollowerInfo>)Delegate.Combine(((UIFollowerSelectBase<FollowerInformationBox>)(object)val).OnFollowerSelected, (Action<FollowerInfo>)delegate(FollowerInfo followerInfo)
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: 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)
				partner = FollowerManager.FindFollowerByID(followerInfo.ID);
				Logging.LogInfo("Succesfully selected follower " + ((Object)partner).name);
				IDAndRelationship orCreateRelationship = follower.Brain.Info.GetOrCreateRelationship(partner.Brain.Info.ID);
				orCreateRelationship.CurrentRelationshipState = state;
				orCreateRelationship.Relationship = relationship;
				IDAndRelationship orCreateRelationship2 = partner.Brain.Info.GetOrCreateRelationship(follower.Brain.Info.ID);
				orCreateRelationship2.CurrentRelationshipState = state;
				orCreateRelationship2.Relationship = relationship;
				Logging.LogInfo("Succesfully Edited the relationship!");
				CreateRelationshipNotification(state, follower, partner);
			});
			((UIMenuBase)val).OnHidden = (Action)Delegate.Combine(((UIMenuBase)val).OnHidden, (Action)delegate
			{
				Time.timeScale = 1f;
			});
			((UIMenuBase)val).OnCancel = (Action)Delegate.Combine(((UIMenuBase)val).OnCancel, (Action)delegate
			{
				GameManager.GetInstance().OnConversationEnd(true, true);
			});
		}

		private static void CreateRelationshipNotification(RelationshipState state, Follower follower1, Follower follower2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected I4, but got Unknown
			switch ((int)state)
			{
			case 3:
				NotificationCentre.Instance.PlayGenericNotification(follower1.Brain.Info.Name + " and " + follower2.Brain.Info.Name + " have been made lovers!", (Flair)1);
				break;
			case 2:
				NotificationCentre.Instance.PlayGenericNotification(follower1.Brain.Info.Name + " and " + follower2.Brain.Info.Name + " have been made friends!", (Flair)1);
				break;
			case 1:
				NotificationCentre.Instance.PlayGenericNotification(follower1.Brain.Info.Name + " and " + follower2.Brain.Info.Name + " have been made strangers!", (Flair)0);
				break;
			case 0:
				NotificationCentre.Instance.PlayGenericNotification(follower1.Brain.Info.Name + " and " + follower2.Brain.Info.Name + " have been made Enemies!", (Flair)2);
				break;
			}
		}
	}
}
namespace ForceFriendship.Commands
{
	internal class BefriendCommand : CustomFollowerCommand
	{
		private readonly int _levelOfFriendship = 5;

		public override string InternalName => "Make_Friends";

		public override List<FollowerCommandCategory> Categories { get; } = new List<FollowerCommandCategory> { (FollowerCommandCategory)3 };


		public override Sprite CommandIcon => TextureHelper.CreateSpriteFromPath(Path.Combine(Plugin.PluginPath, "Assets", "friendship.png"));

		public override string GetTitle(Follower follower)
		{
			return "Befriend";
		}

		public override string GetDescription(Follower follower)
		{
			return $"Force the {follower} to become friends with someone";
		}

		public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			RelationshipHelper.ChangeRelationship((RelationshipState)2, _levelOfFriendship, interaction.follower, "Select follower to befriend");
			((CustomFollowerCommand)this).Execute(interaction, finalCommand);
		}

		public override bool ShouldAppearFor(Follower follower)
		{
			return follower.IsSleeping();
		}
	}
	internal class DismayCommand : CustomFollowerCommand
	{
		private readonly int _levelOfFriendship = -10;

		public override string InternalName => "Make_Enemies";

		public override List<FollowerCommandCategory> Categories { get; } = new List<FollowerCommandCategory> { (FollowerCommandCategory)3 };


		public override Sprite CommandIcon => TextureHelper.CreateSpriteFromPath(Path.Combine(Plugin.PluginPath, "Assets", "dismay.png"));

		public override string GetTitle(Follower follower)
		{
			return "Dismay";
		}

		public override string GetDescription(Follower follower)
		{
			return $"Force the {follower} to hate someone";
		}

		public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			RelationshipHelper.ChangeRelationship((RelationshipState)0, _levelOfFriendship, interaction.follower, "Select follower to be hated");
			((CustomFollowerCommand)this).Execute(interaction, finalCommand);
		}

		public override bool ShouldAppearFor(Follower follower)
		{
			return follower.IsSleeping();
		}
	}
	internal class EstrangeCommand : CustomFollowerCommand
	{
		private readonly int _levelOfFriendship = 0;

		public override string InternalName => "Make_Strangers";

		public override List<FollowerCommandCategory> Categories { get; } = new List<FollowerCommandCategory> { (FollowerCommandCategory)3 };


		public override Sprite CommandIcon => TextureHelper.CreateSpriteFromPath(Path.Combine(Plugin.PluginPath, "Assets", "neutral.png"));

		public override string GetTitle(Follower follower)
		{
			return "Estrange";
		}

		public override string GetDescription(Follower follower)
		{
			return $"Force the {follower} to forget someone";
		}

		public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			RelationshipHelper.ChangeRelationship((RelationshipState)1, _levelOfFriendship, interaction.follower, "Select follower to be forgotten");
			((CustomFollowerCommand)this).Execute(interaction, finalCommand);
		}

		public override bool ShouldAppearFor(Follower follower)
		{
			return follower.IsSleeping();
		}
	}
	internal class SwoonCommand : CustomFollowerCommand
	{
		private readonly int _levelOfFriendship = 10;

		public override string InternalName => "Make_Lovers";

		public override List<FollowerCommandCategory> Categories { get; } = new List<FollowerCommandCategory> { (FollowerCommandCategory)3 };


		public override Sprite CommandIcon => TextureHelper.CreateSpriteFromPath(Path.Combine(Plugin.PluginPath, "Assets", "love.png"));

		public override string GetTitle(Follower follower)
		{
			return "Enthrall";
		}

		public override string GetDescription(Follower follower)
		{
			return $"Force the {follower} to become lovers with someone";
		}

		public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			RelationshipHelper.ChangeRelationship((RelationshipState)3, _levelOfFriendship, interaction.follower, "Select follower to be charmed");
			((CustomFollowerCommand)this).Execute(interaction, finalCommand);
		}

		public override bool ShouldAppearFor(Follower follower)
		{
			return follower.IsSleeping();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}