Decompiled source of FFU Console v0.5.400

monomod/Assembly-CSharp.FFU_BR_Console.mm.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using FFU_Beyond_Reach;
using Microsoft.CodeAnalysis;
using MonoMod;
using Ostranauts.UI.MegaToolTip;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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;
		}
	}
}
public class patch_ConsoleToGUI : ConsoleToGUI
{
	private string logHistoryPath = null;

	private bool configLoaded = false;

	[MonoModReplace]
	private void DrawConsole(int window)
	{
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Invalid comparison between Unknown and I4
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Invalid comparison between Unknown and I4
		//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c2: Invalid comparison between Unknown and I4
		//IL_0608: Unknown result type (might be due to invalid IL or missing references)
		//IL_060f: Invalid comparison between Unknown and I4
		if (((ConsoleToGUI)this).HandleInput())
		{
			return;
		}
		if (!configLoaded)
		{
			configLoaded = true;
			base.mChars = FFU_BR_Defs.MaxLogTextSize;
			base.scrollPos = new Vector2(0f, (float)(base.mChars / 4));
			logHistoryPath = Path.Combine(Application.dataPath, "console_history.txt");
			if (logHistoryPath != null && File.Exists(logHistoryPath))
			{
				try
				{
					base.prevInputs = File.ReadAllText(logHistoryPath, Encoding.UTF8).Split(new char[1] { '\n' }).ToList();
				}
				catch (Exception ex)
				{
					Debug.Log((object)("Failed to load console history!\n" + ex.Message + "\n" + ex.StackTrace));
				}
			}
		}
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(10f, 20f, (float)(Screen.width / 2 - 40), (float)(base.mChars / 4));
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(10f, 30f, (float)(Screen.width / 2 - 20), (float)(Screen.height / 2) - (base._textActual + 55f));
		Rect val3 = default(Rect);
		((Rect)(ref val3))..ctor(10f, ((Rect)(ref val2)).y + ((Rect)(ref val2)).height + 5f, (float)(Screen.width / 2 - 40), base._textActual + 10f);
		base.scrollPos = GUI.BeginScrollView(val2, base.scrollPos, val, false, true);
		GUI.TextArea(val, base.myLog, base.mChars, base.logStyle);
		GUI.EndScrollView();
		GUI.SetNextControlName("command");
		base.myInput = GUI.TextField(val3, base.myInput, base.txtStyle);
		if (Event.current.isKey && GUI.GetNameOfFocusedControl() == "command")
		{
			if ((int)Event.current.keyCode == 13)
			{
				string[] array = base.myInput.Split(new char[1] { ';' });
				if (!string.IsNullOrEmpty(base.myInput) && base.prevInputs.LastOrDefault() != base.myInput)
				{
					base.prevInputs.Add(base.myInput);
				}
				if (base.prevInputs.Count > base.prevMax)
				{
					base.prevInputs.RemoveRange(0, base.prevInputs.Count - base.prevMax);
				}
				if (array.Length > 1)
				{
					base.myInput = "<color=" + base.multipleColor + "><b>[Command]</b></color>: " + base.myInput;
					base.myLog = base.myLog + "\n" + base.myInput;
				}
				base.myInput = string.Empty;
				for (int i = 0; i < array.Length; i++)
				{
					if (!(array[i] == string.Empty))
					{
						array[i] = array[i].Trim();
						if (ConsoleResolver.ResolveString(ref array[i]))
						{
							array[i] = "<color=" + base.commandColor + "><b>[Command]</b></color>: " + array[i];
						}
						else
						{
							array[i] = "<color=" + base.failedColor + "><b>[Command]</b></color>: " + array[i];
						}
						base.myLog = base.myLog + "\n" + array[i];
					}
				}
				base.prevPointer = 0;
			}
			else if ((int)Event.current.keyCode == 273)
			{
				if (base.prevInputs.Count > 0)
				{
					if (base.prevPointer == 0 && base.myInput != string.Empty)
					{
						base.prevInputs.Add(base.myInput);
						if (base.prevInputs.Count > base.prevMax)
						{
							base.prevInputs.RemoveRange(0, base.prevInputs.Count - base.prevMax);
						}
						base.prevPointer++;
					}
					base.prevPointer++;
					if (base.prevPointer > base.prevInputs.Count)
					{
						base.prevPointer = 1;
					}
					base.myInput = base.prevInputs[base.prevInputs.Count - base.prevPointer];
				}
			}
			else if ((int)Event.current.keyCode == 274)
			{
				if (base.prevInputs.Count > 0)
				{
					if (base.prevPointer == 0 && base.myInput != string.Empty)
					{
						base.prevInputs.Add(base.myInput);
						if (base.prevInputs.Count > base.prevMax)
						{
							base.prevInputs.RemoveRange(0, base.prevInputs.Count - base.prevMax);
						}
						base.prevPointer--;
					}
					base.prevPointer--;
					if (base.prevPointer < 1)
					{
						base.prevPointer = base.prevInputs.Count;
					}
					base.myInput = base.prevInputs[base.prevInputs.Count - base.prevPointer];
				}
			}
			else
			{
				base.prevPointer = 0;
			}
		}
		if (base.doFocus)
		{
			GUI.FocusControl("command");
			base.doFocus = false;
		}
		if (GUI.GetNameOfFocusedControl() == "command")
		{
			CrewSim.Typing = true;
		}
		else
		{
			CrewSim.Typing = false;
		}
		if ((int)Event.current.keyCode == 13 && logHistoryPath != null)
		{
			try
			{
				File.WriteAllText(logHistoryPath, string.Join("\n", base.prevInputs.ToArray()));
			}
			catch (Exception ex2)
			{
				Debug.Log((object)("Failed to save console history!\n" + ex2.Message + "\n" + ex2.StackTrace));
			}
		}
		GUI.DragWindow();
	}
}
[MonoModIgnore]
public class patch_DataHandler
{
	public static bool TryGetCOValue(string strName, out JsonCondOwner refCO)
	{
		refCO = null;
		return false;
	}
}
public class patch_ConsoleResolver : ConsoleResolver
{
	public static bool bInvokedInventory;

	private static bool KeywordCondTrigTest(ref string strInput)
	{
		string[] array = strInput.Split(new char[1] { ' ' });
		if (array.Length < 3)
		{
			strInput += "\nMissing command arguments.";
			return false;
		}
		string text = array[1];
		if (!DataHandler.dictCTs.ContainsKey(text))
		{
			strInput += "\nCondition trigger not found.";
			return false;
		}
		if ((Object)(object)CrewSim.objInstance == (Object)null)
		{
			strInput += "\nCrewSim instance not found.";
			return false;
		}
		CondTrigger val = DataHandler.dictCTs[text].Clone();
		string text2 = array[2];
		if (text2 == "[them]")
		{
			if ((Object)(object)GUIMegaToolTip.Selected == (Object)null)
			{
				strInput += "\nNo target selected or highlighted.";
				return false;
			}
			CondOwner selected = GUIMegaToolTip.Selected;
			strInput = strInput + "\nTriggering '" + text + "' against '" + selected.strName + ":" + selected.strID + "' object.";
			if (!val.Triggered(selected, (string)null, true))
			{
				strInput = strInput + "\nOutcome => " + val.strFailReasonLast;
			}
			else
			{
				strInput += "\nOutcome => Success!";
			}
			val.Destroy();
		}
		else
		{
			if (!patch_DataHandler.TryGetCOValue(text2, out var _))
			{
				strInput += "\nCondition owner template not found.";
				return false;
			}
			CondOwner condOwner = DataHandler.GetCondOwner(text2);
			strInput = strInput + "\nTriggering '" + text + "' against '" + text2 + "' template.";
			if (!val.Triggered(condOwner, (string)null, true))
			{
				strInput = strInput + "\nOutcome => " + val.strFailReasonLast;
			}
			else
			{
				strInput += "\nOutcome => Success!";
			}
			condOwner.Destroy();
			val.Destroy();
		}
		return true;
	}

	private static bool KeywordFindCondCOs(ref string strInput)
	{
		string[] array = (from x in strInput.Split(new char[1] { ' ' }).Skip(1)
			where !x.StartsWith("!")
			select x).ToArray();
		string[] array2 = (from x in strInput.Split(new char[1] { ' ' }).Skip(1)
			where x.StartsWith("!")
			select x.Substring(1)).ToArray();
		if (array.Length != 0 || array2.Length != 0)
		{
			int num = 0;
			strInput += "\nCOs with corresponding conditions:";
			if (array2.Length == 0)
			{
				foreach (JsonCondOwner value4 in DataHandler.dictCOs.Values)
				{
					string[] aCondsList6 = value4.aStartingConds.Select((string x) => x.Split(new char[1] { '=' })[0]).ToArray();
					if (array.All((string x) => aCondsList6.Contains(x)))
					{
						strInput = strInput + "\n> " + value4.strNameFriendly + " (" + value4.strName + ")";
						num++;
					}
				}
				foreach (JsonCOOverlay value5 in DataHandler.dictCOOverlays.Values)
				{
					if (DataHandler.dictCOs.TryGetValue(value5.strCOBase, out var value))
					{
						string[] aCondsList5 = value.aStartingConds.Select((string x) => x.Split(new char[1] { '=' })[0]).ToArray();
						if (array.All((string x) => aCondsList5.Contains(x)))
						{
							strInput = strInput + "\n> " + value5.strNameFriendly + " (" + value5.strName + ")";
							num++;
						}
					}
				}
			}
			else if (array.Length == 0)
			{
				foreach (JsonCondOwner value6 in DataHandler.dictCOs.Values)
				{
					string[] aCondsList4 = value6.aStartingConds.Select((string x) => x.Split(new char[1] { '=' })[0]).ToArray();
					if (!array2.Any((string x) => aCondsList4.Contains(x)))
					{
						strInput = strInput + "\n> " + value6.strNameFriendly + " (" + value6.strName + ")";
						num++;
					}
				}
				foreach (JsonCOOverlay value7 in DataHandler.dictCOOverlays.Values)
				{
					if (DataHandler.dictCOs.TryGetValue(value7.strCOBase, out var value2))
					{
						string[] aCondsList3 = value2.aStartingConds.Select((string x) => x.Split(new char[1] { '=' })[0]).ToArray();
						if (!array2.Any((string x) => aCondsList3.Contains(x)))
						{
							strInput = strInput + "\n> " + value7.strNameFriendly + " (" + value7.strName + ")";
							num++;
						}
					}
				}
			}
			else
			{
				foreach (JsonCondOwner value8 in DataHandler.dictCOs.Values)
				{
					string[] aCondsList2 = value8.aStartingConds.Select((string x) => x.Split(new char[1] { '=' })[0]).ToArray();
					if (array.All((string x) => aCondsList2.Contains(x)) && !array2.Any((string x) => aCondsList2.Contains(x)))
					{
						strInput = strInput + "\n> " + value8.strNameFriendly + " (" + value8.strName + ")";
						num++;
					}
				}
				foreach (JsonCOOverlay value9 in DataHandler.dictCOOverlays.Values)
				{
					if (DataHandler.dictCOs.TryGetValue(value9.strCOBase, out var value3))
					{
						string[] aCondsList = value3.aStartingConds.Select((string x) => x.Split(new char[1] { '=' })[0]).ToArray();
						if (array.All((string x) => aCondsList.Contains(x)) && !array2.Any((string x) => aCondsList.Contains(x)))
						{
							strInput = strInput + "\n> " + value9.strNameFriendly + " (" + value9.strName + ")";
							num++;
						}
					}
				}
			}
			strInput += $"\nFound {num} COs in total.";
		}
		return true;
	}

	[MonoModReplace]
	private static bool KeywordGetCond(ref string strInput, string[] strings)
	{
		if ((Object)(object)CrewSim.objInstance == (Object)null)
		{
			strInput += "\nCrewSim instance not found.";
			return false;
		}
		CondOwner value = null;
		string text = string.Empty;
		if (strings.Length == 2)
		{
			value = CrewSim.GetSelectedCrew();
			if ((Object)(object)value == (Object)null)
			{
				strInput += "\nCondOwner not found.";
			}
			text = strings[1];
		}
		else if (strings.Length == 3)
		{
			if (strings[1] == "[us]" || strings[1] == "player")
			{
				value = CrewSim.GetSelectedCrew();
			}
			else if (strings[1].Contains("[them]"))
			{
				if (!((Object)(object)GUIMegaToolTip.Selected != (Object)null))
				{
					strInput += "\nNo target selected for [them].";
					return false;
				}
				value = GUIMegaToolTip.Selected;
				if (strings[1].Contains("-"))
				{
					string text2 = strings[1].Split(new char[1] { '-' })[1];
					int.TryParse(text2, out var result);
					if (result > 0)
					{
						CondOwner val = value;
						while ((Object)(object)val != (Object)null && result > 0)
						{
							val = val.objCOParent;
							result--;
						}
						if ((Object)(object)val == (Object)null)
						{
							strInput = strInput + "\nNo parent exists for [them] at depth " + text2 + ".";
							return false;
						}
						value = val;
					}
				}
			}
			else
			{
				string text3 = strings[1].Replace('_', ' ');
				if (!DataHandler.mapCOs.TryGetValue(text3, out value))
				{
					List<CondOwner> cOs = CrewSim.shipCurrentLoaded.GetCOs((CondTrigger)null, true, true, true);
					foreach (CondOwner item in cOs)
					{
						if (item.strNameFriendly == strings[1] || item.strNameFriendly == text3 || item.strName == strings[1] || item.strName == text3 || item.strID == strings[1])
						{
							value = item;
							break;
						}
					}
				}
			}
			text = strings[2];
			if ((Object)(object)value == (Object)null)
			{
				strInput += "\nCondOwner not found.";
			}
		}
		else
		{
			if (strings.Length < 2)
			{
				strInput += "\nNot enough parameters.";
				return false;
			}
			if (strings.Length > 3)
			{
				strInput += "\nToo many parameters.";
				return false;
			}
		}
		if ((Object)(object)value != (Object)null && text != string.Empty)
		{
			bool flag = false;
			switch (text)
			{
			case "*coParents":
			{
				strInput = strInput + "\nFound condowner " + value.strNameFriendly + " (" + value.strName + ")";
				CondOwner objCOParent = value.objCOParent;
				while ((Object)(object)objCOParent != (Object)null)
				{
					strInput = strInput + "\nIn condowner " + objCOParent.strNameFriendly + " (" + objCOParent.strName + ")";
					objCOParent = objCOParent.objCOParent;
				}
				return true;
			}
			case "*coRules":
				if (value.mapCondRules.Count > 0)
				{
					strInput = strInput + "\nFound condrules for " + value.strNameFriendly + " (" + value.strName + "):";
					foreach (KeyValuePair<string, CondRule> mapCondRule in value.mapCondRules)
					{
						if (mapCondRule.Value != null)
						{
							CondRule value2 = mapCondRule.Value;
							strInput = strInput + "\n" + value2.strName + ": " + Array.IndexOf(value2.aThresholds, value2.GetCurrentThresh(value)) + " (" + mapCondRule.Key + ")";
						}
					}
				}
				else
				{
					strInput = strInput + "\nThe condowner " + value.strNameFriendly + " (" + value.strName + ") has no attached condrules.";
				}
				return true;
			case "*coTickers":
				if (value.aTickers.Count > 0)
				{
					strInput = strInput + "\nFound tickers for " + value.strNameFriendly + " (" + value.strName + "):";
					foreach (JsonTicker aTicker in value.aTickers)
					{
						if (aTicker != null)
						{
							strInput = strInput + "\n" + aTicker.strName + ": " + SmartString(aTicker.fTimeLeft * 3600.0) + "s (" + SmartString(aTicker.fPeriod * 3600.0) + "s)";
						}
					}
				}
				else
				{
					strInput = strInput + "\nThe condowner " + value.strNameFriendly + " (" + value.strName + ") has no attached tickers.";
				}
				return true;
			default:
			{
				if (value.IsThreshold(text))
				{
					string text4 = text.Substring(6);
					CondRule condRule = value.GetCondRule(text4);
					if (condRule != null)
					{
						strInput += $"\n{value.strNameFriendly} ({value.strName}) {text} = x{condRule.Modifier}";
						return true;
					}
				}
				bool flag2 = true;
				foreach (Condition value3 in value.mapConds.Values)
				{
					if (text == "*" || value3.strName.IndexOf(text) >= 0)
					{
						if (flag2)
						{
							strInput = strInput + "\nFound stats for " + value.strNameFriendly + " (" + value.strName + "):";
							flag2 = false;
						}
						strInput += $"\n{value3.strName} = {value3.fCount}";
						flag = true;
					}
				}
				if (!flag)
				{
					strInput = strInput + "\nNo matching cond(s) on " + value.strNameFriendly;
				}
				return flag;
			}
			}
		}
		return false;
	}

	public static string SmartString(double number)
	{
		int num = ((number % 1.0 != 0.0) ? 1 : 0);
		string text;
		do
		{
			text = number.ToString($"N{num}");
			num++;
		}
		while (number < 0.1 && text.EndsWith("0") && num <= 5);
		return text;
	}

	public static extern bool orig_ResolveString(ref string strInput);

	public static bool ResolveString(ref string strInput)
	{
		strInput = strInput.Trim();
		string[] array = strInput.Split(new char[1] { ' ' });
		array[0] = array[0].ToLower();
		return array[0] switch
		{
			"findcondcos" => KeywordFindCondCOs(ref strInput), 
			"repairship" => KeywordRepairShip(ref strInput), 
			"openinventory" => KeywordOpenInventory(ref strInput), 
			"triggerinfo" => KeywordCondTrigInfo(ref strInput), 
			"triggertest" => KeywordCondTrigTest(ref strInput), 
			_ => orig_ResolveString(ref strInput), 
		};
	}

	private static extern bool orig_KeywordHelp(ref string strInput, string[] strings);

	private static bool KeywordHelp(ref string strInput, string[] strings)
	{
		if (strings.Length == 1)
		{
			strInput += "\nWelcome to the Ostranauts console.";
			strInput += "\nAvailable Commands:";
			strInput += "\nhelp";
			strInput += "\necho";
			strInput += "\ncrewsim";
			strInput += "\naddcond";
			strInput += "\ngetcond (FFU modified)";
			strInput += "\nspawn";
			strInput += "\nunlockdebug";
			strInput += "\nbugform";
			strInput += "\nclear";
			strInput += "\nverify";
			strInput += "\nkill";
			strInput += "\naddcrew";
			strInput += "\naddnpc";
			strInput += "\ndamageship";
			strInput += "\nbreakinship";
			strInput += "\noxygen";
			strInput += "\nmeteor";
			strInput += "\nlookup";
			strInput += "\ntoggle";
			strInput += "\nship";
			strInput += "\nrel";
			strInput += "\nsummon";
			strInput += "\nskywalk";
			strInput += "\nplot";
			strInput += "\nmeatstate";
			strInput += "\nrename";
			strInput += "\nfindcondcos (FFU only)";
			strInput += "\nrepairship (FFU only)";
			strInput += "\nopeninventory (FFU only)";
			strInput += "\ntriggerinfo (FFU only)";
			strInput += "\ntriggertest (FFU only)";
			strInput += "\n\ntype command name after help to see more details about command";
			strInput += "\n";
			return true;
		}
		if (strings.Length == 2)
		{
			switch (strings[1])
			{
			case "getcond":
				strInput += "\ngetcond lists a condition's value on a condowner";
				strInput += "\ne.g. 'getcond Joshu IsHuman'";
				strInput += "\nwill find condowner with name/friendlyName/ID of 'Joshu'";
				strInput += "\nwill check for all condtions including partial string 'IsHuman'";
				strInput += "\nif condowner is valid and conditions are found, it will list their current names and values on Joshu";
				strInput += "\n<i>spaces within names must be replaced with underscores: '_'</i>";
				strInput += "\n'getcond *' will list all stats that condowner has";
				strInput += "\n'getcond-NUM' will execute command for NUM parent of the condowner";
				strInput += "\n'getcond *coParents' will list all parents of the condowner";
				strInput += "\n'getcond *coRules' will list all rules attached to the condowner";
				strInput += "\n'getcond *coTickers' will list all tickers attached to the condowner";
				strInput += "\n";
				return true;
			case "findcondcos":
				strInput += "\nfindcondcos lists all condowner templates that meet listed conditions";
				strInput += "\nworks from main menu and can support any amount of conditions";
				strInput += "\n'IsCondition' will only list templates that have that condition";
				strInput += "\n'!IsCondition' will only list templates that don't have that condition";
				strInput += "\n'using both will only list templates that meet both conditions";
				strInput += "\ne.g. 'findcondcos IsScrap !IsFlexible'";
				return true;
			case "repairship":
				strInput += "\nrepairship zeroes all StatDamage values on all IsInstalled condowners of all loaded ships";
				return true;
			case "openinventory":
				strInput += "\nopeninventory opens inventory window from the perspective of the selected condowner";
				strInput += "\ne.g. select target with right mouse button and enter 'openinventory' command";
				return true;
			case "triggerinfo":
				strInput += "\ntriggerinfo shows rules of condition trigger either as JSON (0) or as friendly (1) text";
				strInput += "\ne.g. triggerinfo TIsYourConditionTriggerName 0";
				strInput += "\nor triggerinfo TIsYourConditionTriggerName 1";
				return true;
			case "triggertest":
				strInput += "\ntriggertest fires condition trigger against template or selected object and logs outcome";
				strInput += "\n<i>works only if there is initialized CrewSim instance (i.e. only when game was loaded)</i>";
				strInput += "\ne.g. triggertest TIsYourConditionTriggerName [them] (only in-game and with selected object)";
				strInput += "\ne.g. triggertest TIsYourConditionTriggerName ItmYourCondownerName";
				return true;
			default:
				return orig_KeywordHelp(ref strInput, strings);
			}
		}
		return false;
	}

	private static string GetRulesInfoDev(CondTrigger refTrigger)
	{
		Type type = ((object)refTrigger).GetType();
		return (type.GetProperty("RulesInfo_Dev")?.GetValue(refTrigger, null) as string) ?? refTrigger.RulesInfo;
	}

	private static string GetRulesInfoTxt(CondTrigger refTrigger)
	{
		Type type = ((object)refTrigger).GetType();
		return (type.GetProperty("RulesInfo_Txt")?.GetValue(refTrigger, null) as string) ?? refTrigger.RulesInfo;
	}

	private static bool KeywordCondTrigInfo(ref string strInput)
	{
		string[] array = strInput.Split(new char[1] { ' ' });
		if (array.Length < 3)
		{
			strInput += "\nMissing command arguments.";
			return false;
		}
		string text = array[1];
		if (!DataHandler.dictCTs.ContainsKey(text))
		{
			strInput += "\nCondition trigger not found.";
			return false;
		}
		int.TryParse(array[2], out var result);
		CondTrigger refTrigger = DataHandler.dictCTs[text].Clone();
		switch (result)
		{
		case 0:
			strInput = strInput + "\nCondition Trigger '" + text + "' Rules: " + GetRulesInfoDev(refTrigger);
			break;
		case 1:
			strInput = strInput + "\nCondition Trigger '" + text + "' Rules: " + GetRulesInfoTxt(refTrigger);
			break;
		default:
			strInput += "\nInvalid rule info rendering option.";
			return false;
		}
		return true;
	}

	private static bool KeywordOpenInventory(ref string strInput)
	{
		if ((Object)(object)CrewSim.objInstance == (Object)null)
		{
			strInput += "\nCrewSim instance not found.";
			return false;
		}
		if ((Object)(object)GUIMegaToolTip.Selected == (Object)null)
		{
			strInput += "\nNo target selected or highlighted.";
			return false;
		}
		CondOwner selected = GUIMegaToolTip.Selected;
		if (Container.GetSpace(selected) < 1 && !((IEnumerable<Slot>)selected.compSlots.aSlots).Any())
		{
			strInput += "\nTarget is not valid or has no inventory.";
			return false;
		}
		strInput = strInput + "\nAccessed inventory: " + selected.FriendlyName + " (" + selected.strName + ") " + selected.strID;
		if (selected.HasCond("IsHuman") || selected.HasCond("IsRobot"))
		{
			CommandInventory.ToggleInventory(selected);
		}
		else
		{
			CrewSim.inventoryGUI.SpawnInventoryWindow(selected, (InventoryWindowType)1, true);
			CrewSim.inventoryGUI.SpawnInventoryWindow(selected, (InventoryWindowType)0, true);
		}
		bInvokedInventory = true;
		return true;
	}

	private static bool KeywordRepairShip(ref string strInput)
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		if ((Object)(object)CrewSim.objInstance == (Object)null)
		{
			strInput += "\nCrewSim instance not found.";
			return false;
		}
		if (CrewSim.shipCurrentLoaded == null)
		{
			strInput += "\nNo ship currently loaded.";
			return false;
		}
		CondTrigger val = new CondTrigger("TIsInstalledObject", new string[1] { "IsInstalled" }, (string[])null, (string[])null, (string[])null);
		List<CondOwner> cOs = CrewSim.shipCurrentLoaded.GetCOs(val, true, false, true);
		foreach (CondOwner item in cOs)
		{
			item.SetUpBehaviours();
			item.ZeroCondAmount("StatDamage");
			if ((Object)(object)item.Item != (Object)null)
			{
				item.Item.VisualizeOverlays(false);
			}
			item.UpdateStats();
		}
		strInput += $"\nRepaired {cOs.Count} installed COs on the ship.";
		return true;
	}
}
public class patch_GUIInventoryWindow : GUIInventoryWindow
{
	[MonoModReplace]
	public Vector3 WorldPosFromPair(PairXY where)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		if ((int)base.type == 0)
		{
			Vector3 val = ((patch_ConsoleResolver.bInvokedInventory && (Object)(object)GUIMegaToolTip.Selected != (Object)null) ? GUIMegaToolTip.Selected.tf.position : CrewSim.GetSelectedCrew().tf.position);
			val.x = MathUtils.RoundToInt(val.x) + where.x - 2;
			val.y = MathUtils.RoundToInt(val.y) + 2 - where.y;
			return val;
		}
		return ((GUIInventoryWindow)this).CO.tf.position;
	}
}
public class patch_GUIInventory : GUIInventory
{
	public extern void orig_Reset(GUIInventoryWindow window = null);

	public void Reset(GUIInventoryWindow window = null)
	{
		patch_ConsoleResolver.bInvokedInventory = false;
		orig_Reset(window);
	}
}
namespace FFU_Beyond_Reach
{
	[MonoModIgnore]
	public class FFU_BR_Defs
	{
		public enum SyncLogs
		{
			None,
			ModChanges,
			DeepCopy,
			ModdedDump,
			ExtendedDump,
			ContentDump,
			SourceDump
		}

		public enum ActLogs
		{
			None,
			Interactions,
			Runtime
		}

		public static SyncLogs SyncLogging;

		public static ActLogs ActLogging;

		public static bool DynamicRandomRange;

		public static int MaxLogTextSize;

		public static bool ModSyncLoading;

		public static bool EnableCodeFixes;

		public static bool ModifyUpperLimit;

		public static float BonusUpperLimit;

		public static float SuitOxygenNotify;

		public static float SuitPowerNotify;

		public static bool ShowEachO2Battery;

		public static bool StrictInvSorting;

		public static bool AltTempEnabled;

		public static string AltTempSymbol;

		public static float AltTempMult;

		public static float AltTempShift;

		public static bool TowBraceAllowsKeep;

		public static bool OrgInventoryMode;

		public static float[] OrgInventoryTweaks;

		public static bool BetterInvTransfer;

		public static bool QuickBarPinning;

		public static float[] QuickBarTweaks;

		public static bool NoSkillTraitCost;

		public static bool AllowSuperChars;

		public static float SuperCharMultiplier;

		public static string[] SuperCharacters;
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}