Decompiled source of FFU Extended v0.5.381

monomod/Assembly-CSharp.FFU_BR_Extended.mm.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 MonoMod;
using Ostranauts.Core;
using Ostranauts.Core.Models;
using Ostranauts.Objectives;
using Ostranauts.Tools;
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]
public class patch_CondTrigger : CondTrigger
{
	private string[] _aMultOps;

	public int nMaxDepth { get; set; }

	public string strMathCond { get; set; }

	public int nMathOp { get; set; }

	public double fMathVal { get; set; }

	public string strMultCond { get; set; }

	public string[] aMultOps
	{
		get
		{
			return _aMultOps;
		}
		set
		{
			base._valuesWereChanged = true;
			_aMultOps = value;
		}
	}

	public string RulesInfo
	{
		[MonoModReplace]
		get
		{
			if (base.strFailReason != null)
			{
				return base.strFailReason;
			}
			Condition val = null;
			StringBuilder stringBuilder = new StringBuilder();
			if (base.bAND)
			{
				for (int i = 0; i < ((CondTrigger)this).aReqs.Length; i++)
				{
					if (i == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is ");
					}
					else if (i == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(", and ");
					}
					else if (i > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aReqs[i]);
					stringBuilder.Append(val.strNameFriendly);
					if (i == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				for (int j = 0; j < ((CondTrigger)this).aForbids.Length; j++)
				{
					if (j == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is NOT ");
					}
					else if (j == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(", and ");
					}
					else if (j > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aForbids[j]);
					stringBuilder.Append(val.strNameFriendly);
					if (j == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				if (strMathCond != null && nMathOp > 0)
				{
					val = DataHandler.GetCond(strMathCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					stringBuilder.Append(val.strNameFriendly + " is ");
					stringBuilder.Append(MathToString(nMathOp) + " " + fMathVal);
					stringBuilder.Append(".");
				}
				if (strMultCond != null && aMultOps.Length != 0 && aMultOps.Length % 3 == 0)
				{
					val = DataHandler.GetCond(strMultCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					stringBuilder.Append(val.strNameFriendly + " is");
					for (int k = 0; k < aMultOps.Length; k += 3)
					{
						if (k == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (k == aMultOps.Length - 3)
						{
							stringBuilder.Append(", and ");
						}
						else if (k > 0)
						{
							stringBuilder.Append(", ");
						}
						if (aMultOps[k] == null)
						{
							int.TryParse(aMultOps[k + 1], out var result);
							stringBuilder.Append(MathToString(result) + " ");
							double.TryParse(aMultOps[k + 2], out var result2);
							stringBuilder.Append(result2);
						}
						else
						{
							val = DataHandler.GetCond(aMultOps[k]);
							int.TryParse(aMultOps[k + 1], out var result3);
							stringBuilder.Append(MathToString(result3) + " ");
							double.TryParse(aMultOps[k + 2], out var result4);
							if (result4 != 1.0)
							{
								stringBuilder.Append(FormatTwoDecimals(result4 * 100.0) + "% of ");
							}
							stringBuilder.Append(val.strNameFriendly);
						}
						if (k == aMultOps.Length - 3)
						{
							stringBuilder.Append(".");
						}
					}
				}
				if (((CondTrigger)this).strHigherCond != null && ((CondTrigger)this).aLowerConds.Length != 0)
				{
					val = DataHandler.GetCond(((CondTrigger)this).strHigherCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					stringBuilder.Append(val.strNameFriendly + " is higher than");
					for (int l = 0; l < ((CondTrigger)this).aLowerConds.Length; l++)
					{
						if (l == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (l == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(", and ");
						}
						else if (l > 0)
						{
							stringBuilder.Append(", ");
						}
						val = DataHandler.GetCond(((CondTrigger)this).aLowerConds[l]);
						stringBuilder.Append(val.strNameFriendly);
						if (l == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(".");
						}
					}
				}
				string[] aTriggers = ((CondTrigger)this).aTriggers;
				string[] array = aTriggers;
				foreach (string text in array)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					CondTrigger trigger = ((CondTrigger)this).GetTrigger(text, (CTDict)0);
					stringBuilder.Append("{" + trigger.RulesInfo + "}");
				}
			}
			else
			{
				for (int n = 0; n < ((CondTrigger)this).aForbids.Length; n++)
				{
					if (n == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is NOT ");
					}
					else if (n == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(", or ");
					}
					else if (n > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aForbids[n]);
					stringBuilder.Append(val.strNameFriendly);
					if (n == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				for (int num = 0; num < ((CondTrigger)this).aReqs.Length; num++)
				{
					if (num == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is ");
					}
					else if (num == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(", or ");
					}
					else if (num > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aReqs[num]);
					stringBuilder.Append(val.strNameFriendly);
					if (num == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				if (strMathCond != null && nMathOp > 0)
				{
					val = DataHandler.GetCond(strMathCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					stringBuilder.Append(val.strNameFriendly + " is ");
					stringBuilder.Append(MathToString(nMathOp) + " " + fMathVal);
					stringBuilder.Append(".");
				}
				if (strMultCond != null && aMultOps.Length != 0 && aMultOps.Length % 3 == 0)
				{
					val = DataHandler.GetCond(strMultCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					stringBuilder.Append(val.strNameFriendly + " is");
					for (int num2 = 0; num2 < aMultOps.Length; num2 += 3)
					{
						if (num2 == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (num2 == aMultOps.Length - 3)
						{
							stringBuilder.Append(", or ");
						}
						else if (num2 > 0)
						{
							stringBuilder.Append(", ");
						}
						if (aMultOps[num2] == null)
						{
							int.TryParse(aMultOps[num2 + 1], out var result5);
							stringBuilder.Append(MathToString(result5) + " ");
							double.TryParse(aMultOps[num2 + 2], out var result6);
							stringBuilder.Append(result6);
						}
						else
						{
							val = DataHandler.GetCond(aMultOps[num2]);
							int.TryParse(aMultOps[num2 + 1], out var result7);
							stringBuilder.Append(MathToString(result7) + " ");
							double.TryParse(aMultOps[num2 + 2], out var result8);
							if (result8 != 1.0)
							{
								stringBuilder.Append(FormatTwoDecimals(result8 * 100.0) + "% of ");
							}
							stringBuilder.Append(val.strNameFriendly);
						}
						if (num2 == aMultOps.Length - 3)
						{
							stringBuilder.Append(".");
						}
					}
				}
				if (((CondTrigger)this).strHigherCond != null && ((CondTrigger)this).aLowerConds.Length != 0)
				{
					val = DataHandler.GetCond(((CondTrigger)this).strHigherCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					stringBuilder.Append(val.strNameFriendly + " is higher than");
					for (int num3 = 0; num3 < ((CondTrigger)this).aLowerConds.Length; num3++)
					{
						if (num3 == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (num3 == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(", or ");
						}
						else if (num3 > 0)
						{
							stringBuilder.Append(", ");
						}
						val = DataHandler.GetCond(((CondTrigger)this).aLowerConds[num3]);
						stringBuilder.Append(val.strNameFriendly);
						if (num3 == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(".");
						}
					}
				}
				string[] aTriggers2 = ((CondTrigger)this).aTriggers;
				string[] array2 = aTriggers2;
				foreach (string text2 in array2)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					CondTrigger trigger2 = ((CondTrigger)this).GetTrigger(text2, (CTDict)0);
					stringBuilder.Append("{" + trigger2.RulesInfo + "}");
				}
				string[] aTriggersForbid = ((CondTrigger)this).aTriggersForbid;
				string[] array3 = aTriggersForbid;
				foreach (string text3 in array3)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Not ");
					}
					else
					{
						stringBuilder.Append("Not ");
					}
					CondTrigger trigger3 = ((CondTrigger)this).GetTrigger(text3, (CTDict)1);
					stringBuilder.Append("{" + trigger3.RulesInfo + "}");
				}
			}
			base.strFailReason = stringBuilder.ToString();
			return base.strFailReason;
		}
	}

	public string RulesInfo_Dev
	{
		get
		{
			Condition val = null;
			StringBuilder stringBuilder = new StringBuilder();
			if (base.bAND)
			{
				for (int i = 0; i < ((CondTrigger)this).aReqs.Length; i++)
				{
					if (i == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is ");
					}
					else if (i == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(", and ");
					}
					else if (i > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aReqs[i]);
					stringBuilder.Append(val.strName);
					if (i == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				for (int j = 0; j < ((CondTrigger)this).aForbids.Length; j++)
				{
					if (j == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is NOT ");
					}
					else if (j == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(", and ");
					}
					else if (j > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aForbids[j]);
					stringBuilder.Append(val.strName);
					if (j == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				if (strMathCond != null && nMathOp > 0)
				{
					val = DataHandler.GetCond(strMathCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					stringBuilder.Append(val.strName + " is ");
					stringBuilder.Append(MathToString(nMathOp) + " " + fMathVal);
					stringBuilder.Append(".");
				}
				if (strMultCond != null && aMultOps.Length != 0 && aMultOps.Length % 3 == 0)
				{
					val = DataHandler.GetCond(strMultCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					stringBuilder.Append(val.strName + " is");
					for (int k = 0; k < aMultOps.Length; k += 3)
					{
						if (k == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (k == aMultOps.Length - 3)
						{
							stringBuilder.Append(", and ");
						}
						else if (k > 0)
						{
							stringBuilder.Append(", ");
						}
						if (aMultOps[k] == null)
						{
							int.TryParse(aMultOps[k + 1], out var result);
							stringBuilder.Append(MathToString(result) + " ");
							double.TryParse(aMultOps[k + 2], out var result2);
							stringBuilder.Append(result2);
						}
						else
						{
							val = DataHandler.GetCond(aMultOps[k]);
							int.TryParse(aMultOps[k + 1], out var result3);
							stringBuilder.Append(MathToString(result3) + " ");
							double.TryParse(aMultOps[k + 2], out var result4);
							if (result4 != 1.0)
							{
								stringBuilder.Append(FormatTwoDecimals(result4 * 100.0) + "% of ");
							}
							stringBuilder.Append(val.strName);
						}
						if (k == aMultOps.Length - 3)
						{
							stringBuilder.Append(".");
						}
					}
				}
				if (((CondTrigger)this).strHigherCond != null && ((CondTrigger)this).aLowerConds.Length != 0)
				{
					val = DataHandler.GetCond(((CondTrigger)this).strHigherCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					stringBuilder.Append(val.strName + " is higher than");
					for (int l = 0; l < ((CondTrigger)this).aLowerConds.Length; l++)
					{
						if (l == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (l == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(", and ");
						}
						else if (l > 0)
						{
							stringBuilder.Append(", ");
						}
						val = DataHandler.GetCond(((CondTrigger)this).aLowerConds[l]);
						stringBuilder.Append(val.strName);
						if (l == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(".");
						}
					}
				}
				string[] aTriggers = ((CondTrigger)this).aTriggers;
				string[] array = aTriggers;
				foreach (string text in array)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					patch_CondTrigger patch_CondTrigger2 = ((CondTrigger)this).GetTrigger(text, (CTDict)0) as patch_CondTrigger;
					stringBuilder.Append("{" + patch_CondTrigger2.RulesInfo_Dev + "}");
				}
			}
			else
			{
				for (int n = 0; n < ((CondTrigger)this).aForbids.Length; n++)
				{
					if (n == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is NOT ");
					}
					else if (n == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(", or ");
					}
					else if (n > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aForbids[n]);
					stringBuilder.Append(val.strName);
					if (n == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				for (int num = 0; num < ((CondTrigger)this).aReqs.Length; num++)
				{
					if (num == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is ");
					}
					else if (num == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(", or ");
					}
					else if (num > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aReqs[num]);
					stringBuilder.Append(val.strName);
					if (num == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				if (strMathCond != null && nMathOp > 0)
				{
					val = DataHandler.GetCond(strMathCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					stringBuilder.Append(val.strName + " is ");
					stringBuilder.Append(MathToString(nMathOp) + " " + fMathVal);
					stringBuilder.Append(".");
				}
				if (strMultCond != null && aMultOps.Length != 0 && aMultOps.Length % 3 == 0)
				{
					val = DataHandler.GetCond(strMultCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					stringBuilder.Append(val.strName + " is");
					for (int num2 = 0; num2 < aMultOps.Length; num2 += 3)
					{
						if (num2 == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (num2 == aMultOps.Length - 3)
						{
							stringBuilder.Append(", or ");
						}
						else if (num2 > 0)
						{
							stringBuilder.Append(", ");
						}
						if (aMultOps[num2] == null)
						{
							int.TryParse(aMultOps[num2 + 1], out var result5);
							stringBuilder.Append(MathToString(result5) + " ");
							double.TryParse(aMultOps[num2 + 2], out var result6);
							stringBuilder.Append(result6);
						}
						else
						{
							val = DataHandler.GetCond(aMultOps[num2]);
							int.TryParse(aMultOps[num2 + 1], out var result7);
							stringBuilder.Append(MathToString(result7) + " ");
							double.TryParse(aMultOps[num2 + 2], out var result8);
							if (result8 != 1.0)
							{
								stringBuilder.Append(FormatTwoDecimals(result8 * 100.0) + "% of ");
							}
							stringBuilder.Append(val.strName);
						}
						if (num2 == aMultOps.Length - 3)
						{
							stringBuilder.Append(".");
						}
					}
				}
				if (((CondTrigger)this).strHigherCond != null && ((CondTrigger)this).aLowerConds.Length != 0)
				{
					val = DataHandler.GetCond(((CondTrigger)this).strHigherCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					stringBuilder.Append(val.strName + " is higher than");
					for (int num3 = 0; num3 < ((CondTrigger)this).aLowerConds.Length; num3++)
					{
						if (num3 == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (num3 == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(", or ");
						}
						else if (num3 > 0)
						{
							stringBuilder.Append(", ");
						}
						val = DataHandler.GetCond(((CondTrigger)this).aLowerConds[num3]);
						stringBuilder.Append(val.strName);
						if (num3 == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(".");
						}
					}
				}
				string[] aTriggers2 = ((CondTrigger)this).aTriggers;
				string[] array2 = aTriggers2;
				foreach (string text2 in array2)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					patch_CondTrigger patch_CondTrigger3 = ((CondTrigger)this).GetTrigger(text2, (CTDict)0) as patch_CondTrigger;
					stringBuilder.Append("{" + patch_CondTrigger3.RulesInfo_Dev + "}");
				}
				string[] aTriggersForbid = ((CondTrigger)this).aTriggersForbid;
				string[] array3 = aTriggersForbid;
				foreach (string text3 in array3)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Not ");
					}
					else
					{
						stringBuilder.Append("Not ");
					}
					patch_CondTrigger patch_CondTrigger4 = ((CondTrigger)this).GetTrigger(text3, (CTDict)1) as patch_CondTrigger;
					stringBuilder.Append("{" + patch_CondTrigger4.RulesInfo_Dev + "}");
				}
			}
			return stringBuilder.ToString();
		}
	}

	public string RulesInfo_Txt
	{
		get
		{
			Condition val = null;
			StringBuilder stringBuilder = new StringBuilder();
			if (base.bAND)
			{
				for (int i = 0; i < ((CondTrigger)this).aReqs.Length; i++)
				{
					if (i == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is ");
					}
					else if (i == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(", and ");
					}
					else if (i > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aReqs[i]);
					stringBuilder.Append(val.strNameFriendly);
					if (i == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				for (int j = 0; j < ((CondTrigger)this).aForbids.Length; j++)
				{
					if (j == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is NOT ");
					}
					else if (j == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(", and ");
					}
					else if (j > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aForbids[j]);
					stringBuilder.Append(val.strNameFriendly);
					if (j == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				if (strMathCond != null && nMathOp > 0)
				{
					val = DataHandler.GetCond(strMathCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					stringBuilder.Append(val.strNameFriendly + " is ");
					stringBuilder.Append(MathToString(nMathOp) + " " + fMathVal);
					stringBuilder.Append(".");
				}
				if (strMultCond != null && aMultOps.Length != 0 && aMultOps.Length % 3 == 0)
				{
					val = DataHandler.GetCond(strMultCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					stringBuilder.Append(val.strNameFriendly + " is");
					for (int k = 0; k < aMultOps.Length; k += 3)
					{
						if (k == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (k == aMultOps.Length - 3)
						{
							stringBuilder.Append(", and ");
						}
						else if (k > 0)
						{
							stringBuilder.Append(", ");
						}
						if (aMultOps[k] == null)
						{
							int.TryParse(aMultOps[k + 1], out var result);
							stringBuilder.Append(MathToString(result) + " ");
							double.TryParse(aMultOps[k + 2], out var result2);
							stringBuilder.Append(result2);
						}
						else
						{
							val = DataHandler.GetCond(aMultOps[k]);
							int.TryParse(aMultOps[k + 1], out var result3);
							stringBuilder.Append(MathToString(result3) + " ");
							double.TryParse(aMultOps[k + 2], out var result4);
							if (result4 != 1.0)
							{
								stringBuilder.Append(FormatTwoDecimals(result4 * 100.0) + "% of ");
							}
							stringBuilder.Append(val.strNameFriendly);
						}
						if (k == aMultOps.Length - 3)
						{
							stringBuilder.Append(".");
						}
					}
				}
				if (((CondTrigger)this).strHigherCond != null && ((CondTrigger)this).aLowerConds.Length != 0)
				{
					val = DataHandler.GetCond(((CondTrigger)this).strHigherCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					stringBuilder.Append(val.strNameFriendly + " is higher than");
					for (int l = 0; l < ((CondTrigger)this).aLowerConds.Length; l++)
					{
						if (l == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (l == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(", and ");
						}
						else if (l > 0)
						{
							stringBuilder.Append(", ");
						}
						val = DataHandler.GetCond(((CondTrigger)this).aLowerConds[l]);
						stringBuilder.Append(val.strNameFriendly);
						if (l == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(".");
						}
					}
				}
				string[] aTriggers = ((CondTrigger)this).aTriggers;
				string[] array = aTriggers;
				foreach (string text in array)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" And ");
					}
					patch_CondTrigger patch_CondTrigger2 = ((CondTrigger)this).GetTrigger(text, (CTDict)0) as patch_CondTrigger;
					stringBuilder.Append("{" + patch_CondTrigger2.RulesInfo_Txt + "}");
				}
			}
			else
			{
				for (int n = 0; n < ((CondTrigger)this).aForbids.Length; n++)
				{
					if (n == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is NOT ");
					}
					else if (n == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(", or ");
					}
					else if (n > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aForbids[n]);
					stringBuilder.Append(val.strNameFriendly);
					if (n == ((CondTrigger)this).aForbids.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				for (int num = 0; num < ((CondTrigger)this).aReqs.Length; num++)
				{
					if (num == 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(" ");
						}
						stringBuilder.Append("Is ");
					}
					else if (num == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(", or ");
					}
					else if (num > 0)
					{
						stringBuilder.Append(", ");
					}
					val = DataHandler.GetCond(((CondTrigger)this).aReqs[num]);
					stringBuilder.Append(val.strNameFriendly);
					if (num == ((CondTrigger)this).aReqs.Length - 1)
					{
						stringBuilder.Append(".");
					}
				}
				if (strMathCond != null && nMathOp > 0)
				{
					val = DataHandler.GetCond(strMathCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					stringBuilder.Append(val.strNameFriendly + " is ");
					stringBuilder.Append(MathToString(nMathOp) + " " + fMathVal);
					stringBuilder.Append(".");
				}
				if (strMultCond != null && aMultOps.Length != 0 && aMultOps.Length % 3 == 0)
				{
					val = DataHandler.GetCond(strMultCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					stringBuilder.Append(val.strNameFriendly + " is");
					for (int num2 = 0; num2 < aMultOps.Length; num2 += 3)
					{
						if (num2 == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (num2 == aMultOps.Length - 3)
						{
							stringBuilder.Append(", or ");
						}
						else if (num2 > 0)
						{
							stringBuilder.Append(", ");
						}
						if (aMultOps[num2] == null)
						{
							int.TryParse(aMultOps[num2 + 1], out var result5);
							stringBuilder.Append(MathToString(result5) + " ");
							double.TryParse(aMultOps[num2 + 2], out var result6);
							stringBuilder.Append(result6);
						}
						else
						{
							val = DataHandler.GetCond(aMultOps[num2]);
							int.TryParse(aMultOps[num2 + 1], out var result7);
							stringBuilder.Append(MathToString(result7) + " ");
							double.TryParse(aMultOps[num2 + 2], out var result8);
							if (result8 != 1.0)
							{
								stringBuilder.Append(FormatTwoDecimals(result8 * 100.0) + "% of ");
							}
							stringBuilder.Append(val.strNameFriendly);
						}
						if (num2 == aMultOps.Length - 3)
						{
							stringBuilder.Append(".");
						}
					}
				}
				if (((CondTrigger)this).strHigherCond != null && ((CondTrigger)this).aLowerConds.Length != 0)
				{
					val = DataHandler.GetCond(((CondTrigger)this).strHigherCond);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					stringBuilder.Append(val.strNameFriendly + " is higher than");
					for (int num3 = 0; num3 < ((CondTrigger)this).aLowerConds.Length; num3++)
					{
						if (num3 == 0)
						{
							stringBuilder.Append(" ");
						}
						else if (num3 == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(", or ");
						}
						else if (num3 > 0)
						{
							stringBuilder.Append(", ");
						}
						val = DataHandler.GetCond(((CondTrigger)this).aLowerConds[num3]);
						stringBuilder.Append(val.strNameFriendly);
						if (num3 == ((CondTrigger)this).aLowerConds.Length - 1)
						{
							stringBuilder.Append(".");
						}
					}
				}
				string[] aTriggers2 = ((CondTrigger)this).aTriggers;
				string[] array2 = aTriggers2;
				foreach (string text2 in array2)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Or ");
					}
					patch_CondTrigger patch_CondTrigger3 = ((CondTrigger)this).GetTrigger(text2, (CTDict)0) as patch_CondTrigger;
					stringBuilder.Append("{" + patch_CondTrigger3.RulesInfo_Txt + "}");
				}
				string[] aTriggersForbid = ((CondTrigger)this).aTriggersForbid;
				string[] array3 = aTriggersForbid;
				foreach (string text3 in array3)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(" Not ");
					}
					else
					{
						stringBuilder.Append("Not ");
					}
					patch_CondTrigger patch_CondTrigger4 = ((CondTrigger)this).GetTrigger(text3, (CTDict)1) as patch_CondTrigger;
					stringBuilder.Append("{" + patch_CondTrigger4.RulesInfo_Txt + "}");
				}
			}
			return stringBuilder.ToString();
		}
	}

	private extern void orig_Init();

	private void Init()
	{
		orig_Init();
		aMultOps = CondTrigger._aDefault;
		base._valuesWereChanged = false;
	}

	public extern CondTrigger orig_Clone();

	public CondTrigger Clone()
	{
		patch_CondTrigger patch_CondTrigger2 = orig_Clone() as patch_CondTrigger;
		patch_CondTrigger2.nMaxDepth = nMaxDepth;
		patch_CondTrigger2.strMathCond = strMathCond;
		patch_CondTrigger2.nMathOp = nMathOp;
		patch_CondTrigger2.fMathVal = fMathVal;
		patch_CondTrigger2.strMultCond = strMultCond;
		patch_CondTrigger2.aMultOps = aMultOps;
		return (CondTrigger)(object)patch_CondTrigger2;
	}

	public extern CondTrigger orig_CloneDeep(string strFind, string strReplace);

	public CondTrigger CloneDeep(string strFind, string strReplace)
	{
		patch_CondTrigger patch_CondTrigger2 = orig_CloneDeep(strFind, strReplace) as patch_CondTrigger;
		if (aMultOps != null)
		{
			patch_CondTrigger2.aMultOps = new string[aMultOps.Length];
			for (int i = 0; i < aMultOps.Length; i++)
			{
				patch_CondTrigger2.aMultOps[i] = CondTrigger.CloneDeep(aMultOps[i], strReplace, strFind);
				((CondTrigger)patch_CondTrigger2)._isBlank = false;
			}
		}
		return (CondTrigger)(object)patch_CondTrigger2;
	}

	[MonoModReplace]
	public bool IsBlank()
	{
		if ((base._isBlank || base._valuesWereChanged) && ((double)((CondTrigger)this).fChance < 1.0 || ((CondTrigger)this).aReqs.Length != 0 || ((CondTrigger)this).aForbids.Length != 0 || ((CondTrigger)this).aTriggers.Length != 0 || ((CondTrigger)this).aTriggersForbid.Length != 0 || ((CondTrigger)this).aLowerConds.Length != 0 || aMultOps.Length != 0))
		{
			base._isBlank = false;
		}
		return base._isBlank;
	}

	[MonoModReplace]
	public bool Triggered(CondOwner objOwner, string strIAStatsName = null, bool logOutcome = true)
	{
		if (base.logReason)
		{
			base.logReason = logOutcome;
		}
		base.strFailReasonLast = string.Empty;
		if ((Object)(object)objOwner == (Object)null)
		{
			return false;
		}
		if (nMaxDepth > 0 && GetDepth(objOwner) > nMaxDepth)
		{
			return false;
		}
		if (IsBlank())
		{
			return true;
		}
		objOwner.ValidateParent();
		SocialStats value = null;
		if (strIAStatsName != null && DataHandler.dictSocialStats.TryGetValue(strIAStatsName, out value))
		{
			SocialStats obj = value;
			obj.nChecked++;
		}
		if (!CondTrigger.bChanceSkip && ((CondTrigger)this).fChance < 1f)
		{
			float num = MathUtils.Rand(0f, 1f, (RandType)0, (string)null);
			if (num > ((CondTrigger)this).fChance)
			{
				if (value != null)
				{
					SocialStats obj2 = value;
					obj2.nChecked++;
				}
				if (base.logReason)
				{
					base.strFailReasonLast = $"Chance: {num} / {((CondTrigger)this).fChance}";
				}
				return false;
			}
		}
		Condition value2;
		if (base.bAND)
		{
			if (strMathCond != null)
			{
				value2 = null;
				double num2 = 0.0;
				objOwner.mapConds.TryGetValue(strMathCond, out value2);
				if (value2 != null)
				{
					num2 = value2.fCount;
				}
				if (!MathTrigger(nMathOp, num2, fMathVal))
				{
					if (base.logReason)
					{
						base.strFailReasonLast = "Math Lacking: " + strMathCond + " " + $"({num2}) is {MathToString(nMathOp)} {fMathVal}";
					}
					return false;
				}
			}
			if (strMultCond != null)
			{
				value2 = null;
				double num3 = 0.0;
				objOwner.mapConds.TryGetValue(strMultCond, out value2);
				if (value2 != null)
				{
					num3 = value2.fCount;
				}
				if (aMultOps.Length % 3 == 0)
				{
					string[] array = aMultOps;
					for (int i = 0; i < array.Length; i += 3)
					{
						if (array[i] == null)
						{
							int.TryParse(array[i + 1], out var result);
							double.TryParse(array[i + 2], out var result2);
							if (!MathTrigger(result, num3, result2))
							{
								if (base.logReason)
								{
									base.strFailReasonLast = "Mult Lacking: " + $"{strMultCond} ({num3}) is {MathToString(result)} {result2}";
								}
								return false;
							}
						}
						else
						{
							if (!objOwner.mapConds.TryGetValue(array[i], out value2))
							{
								continue;
							}
							int.TryParse(array[i + 1], out var result3);
							double.TryParse(array[i + 2], out var result4);
							double num4 = value2.fCount * result4;
							if (!MathTrigger(result3, num3, num4))
							{
								if (base.logReason)
								{
									base.strFailReasonLast = "Mult Lacking: " + $"{strMultCond} ({num3}) is {MathToString(result3)} " + $"{FormatTwoDecimals(result4 * 100.0)}% of {array[i]} ({num4})";
								}
								return false;
							}
						}
					}
				}
			}
			if (((CondTrigger)this).strHigherCond != null)
			{
				value2 = null;
				double num5 = 0.0;
				double num6 = 0.0;
				objOwner.mapConds.TryGetValue(((CondTrigger)this).strHigherCond, out value2);
				if (value2 != null)
				{
					num5 = value2.fCount;
				}
				string[] aLowerConds = ((CondTrigger)this).aLowerConds;
				string[] array2 = aLowerConds;
				foreach (string text in array2)
				{
					value2 = null;
					num6 = (objOwner.mapConds.TryGetValue(text, out value2) ? value2.fCount : 0.0);
					if (num6 > num5)
					{
						if (base.logReason)
						{
							base.strFailReasonLast = "Higher Lacking: " + $"{((CondTrigger)this).strHigherCond} ({num5}) is higher than {text} ({num6})";
						}
						return false;
					}
				}
			}
			string[] aReqs = ((CondTrigger)this).aReqs;
			string[] array3 = aReqs;
			foreach (string text2 in array3)
			{
				if (!objOwner.mapConds.TryGetValue(text2, out value2))
				{
					((CondTrigger)this).StatsTrackReqs(strIAStatsName, text2, 1f);
					if (base.logReason)
					{
						base.strFailReasonLast = "Lacking: " + text2;
					}
					return false;
				}
				if (value2 == null || value2.fCount <= 0.0)
				{
					((CondTrigger)this).StatsTrackReqs(strIAStatsName, text2, 1f);
					if (base.logReason)
					{
						base.strFailReasonLast = "Lacking: " + text2;
					}
					return false;
				}
			}
			value2 = null;
			string[] aForbids = ((CondTrigger)this).aForbids;
			string[] array4 = aForbids;
			foreach (string text3 in array4)
			{
				if (objOwner.mapConds.TryGetValue(text3, out value2) && value2.fCount > 0.0)
				{
					((CondTrigger)this).StatsTrackForbids(strIAStatsName, text3, 1f);
					if (base.logReason)
					{
						base.strFailReasonLast = "Forbidden: " + text3;
					}
					return false;
				}
			}
			string[] aTriggers = ((CondTrigger)this).aTriggers;
			string[] array5 = aTriggers;
			foreach (string text4 in array5)
			{
				CondTrigger trigger = ((CondTrigger)this).GetTrigger(text4, (CTDict)0);
				if (!trigger.Triggered(objOwner, strIAStatsName, base.logReason))
				{
					if (base.logReason)
					{
						base.strFailReasonLast = trigger.strFailReasonLast;
					}
					return false;
				}
			}
			return true;
		}
		string[] aForbids2 = ((CondTrigger)this).aForbids;
		string[] array6 = aForbids2;
		foreach (string text5 in array6)
		{
			if (objOwner.mapConds.TryGetValue(text5, out value2) && value2.fCount > 0.0)
			{
				((CondTrigger)this).StatsTrackForbids(strIAStatsName, text5, 1f);
				if (base.logReason)
				{
					base.strFailReasonLast = "Forbidden: " + text5;
				}
				return false;
			}
		}
		string[] aTriggersForbid = ((CondTrigger)this).aTriggersForbid;
		string[] array7 = aTriggersForbid;
		foreach (string text6 in array7)
		{
			CondTrigger trigger2 = ((CondTrigger)this).GetTrigger(text6, (CTDict)1);
			if (!trigger2.Triggered(objOwner, strIAStatsName, base.logReason))
			{
				if (base.logReason)
				{
					base.strFailReasonLast = trigger2.strFailReasonLast;
				}
				return false;
			}
		}
		bool flag = false;
		if (strMathCond != null)
		{
			value2 = null;
			double num8 = 0.0;
			objOwner.mapConds.TryGetValue(strMathCond, out value2);
			if (value2 != null)
			{
				num8 = value2.fCount;
			}
			if (MathTrigger(nMathOp, num8, fMathVal))
			{
				return true;
			}
			if (base.logReason)
			{
				base.strFailReasonLast = "Math Lacking: " + $"{strMathCond} ({num8}) is {MathToString(nMathOp)} {fMathVal}";
			}
		}
		else
		{
			flag = true;
		}
		string text7 = "Mult Lacking: (";
		bool flag2 = false;
		bool flag3 = false;
		if (strMultCond != null)
		{
			value2 = null;
			int result5 = 0;
			double result6 = 0.0;
			double mTarget = 0.0;
			objOwner.mapConds.TryGetValue(strMultCond, out value2);
			if (value2 != null)
			{
				mTarget = value2.fCount;
			}
			if (aMultOps.Length % 3 == 0)
			{
				string[] array8 = aMultOps;
				for (int num9 = 0; num9 < array8.Length; num9 += 3)
				{
					if (array8[num9] == null)
					{
						int.TryParse(array8[num9 + 1], out var result7);
						double.TryParse(array8[num9 + 2], out var result8);
						if (MathTrigger(result7, mTarget, result8))
						{
							return true;
						}
					}
					else if (objOwner.mapConds.TryGetValue(array8[num9], out value2))
					{
						int.TryParse(array8[num9 + 1], out result5);
						double.TryParse(array8[num9 + 2], out result6);
						double mValue = value2.fCount * result6;
						if (MathTrigger(result5, mTarget, mValue))
						{
							return true;
						}
					}
					if (base.logReason)
					{
						text7 = ((array8[num9] != null) ? ((!flag2) ? (text7 + strMultCond + " is " + MathToString(result5) + " " + FormatTwoDecimals(result6 * 100.0) + "% of " + array8[num9]) : (text7 + ", " + strMultCond + " is " + MathToString(result5) + " " + FormatTwoDecimals(result6 * 100.0) + "% of " + array8[num9])) : ((!flag2) ? (text7 + strMultCond + " is " + MathToString(result5) + " " + array8[num9 + 2]) : (text7 + ", " + strMultCond + " is " + MathToString(result5) + " " + array8[num9 + 2])));
					}
					flag2 = true;
				}
			}
		}
		else
		{
			flag3 = true;
		}
		if (flag2 && base.logReason)
		{
			base.strFailReasonLast = base.strFailReasonLast + ((base.strFailReasonLast.Length > 0) ? " " : "") + text7 + ")";
		}
		if (base.logReason)
		{
			text7 = "Higher Lacking: (";
		}
		flag2 = false;
		bool flag4 = false;
		if (((CondTrigger)this).strHigherCond != null)
		{
			value2 = null;
			double num10 = 0.0;
			objOwner.mapConds.TryGetValue(((CondTrigger)this).strHigherCond, out value2);
			if (value2 != null)
			{
				num10 = value2.fCount;
			}
			string[] aLowerConds2 = ((CondTrigger)this).aLowerConds;
			string[] array9 = aLowerConds2;
			foreach (string text8 in array9)
			{
				value2 = null;
				if (objOwner.mapConds.TryGetValue(text8, out value2) && value2.fCount <= num10)
				{
					return true;
				}
				if (base.logReason)
				{
					text7 = ((!flag2) ? (text7 + ((CondTrigger)this).strHigherCond + " is higher than " + text8) : (text7 + ", " + ((CondTrigger)this).strHigherCond + " is higher than " + text8));
				}
				flag2 = true;
			}
		}
		else
		{
			flag4 = true;
		}
		if (flag2 && base.logReason)
		{
			base.strFailReasonLast = base.strFailReasonLast + ((base.strFailReasonLast.Length > 0) ? " " : "") + text7 + ")";
		}
		if (base.logReason)
		{
			text7 = "Reqs Lacking: (";
		}
		flag2 = false;
		string[] aReqs2 = ((CondTrigger)this).aReqs;
		string[] array10 = aReqs2;
		foreach (string text9 in array10)
		{
			if (objOwner.mapConds.TryGetValue(text9, out value2) && value2 != null && value2.fCount > 0.0)
			{
				return true;
			}
			if (base.logReason)
			{
				text7 = ((!flag2) ? (text7 + text9) : (text7 + ", " + text9));
			}
			flag2 = true;
		}
		if (flag2 && base.logReason)
		{
			base.strFailReasonLast = base.strFailReasonLast + ((base.strFailReasonLast.Length > 0) ? " " : "") + text7 + ")";
		}
		if (base.logReason)
		{
			text7 = "Triggers Lacking: (";
		}
		flag2 = false;
		string[] aTriggers2 = ((CondTrigger)this).aTriggers;
		string[] array11 = aTriggers2;
		foreach (string text10 in array11)
		{
			CondTrigger trigger3 = ((CondTrigger)this).GetTrigger(text10, (CTDict)0);
			if (trigger3.Triggered(objOwner, strIAStatsName, base.logReason))
			{
				return true;
			}
			if (base.logReason)
			{
				text7 = ((!flag2) ? (text7 + text10 + " (" + trigger3.strFailReasonLast + ")") : (text7 + ", " + text10 + " (" + trigger3.strFailReasonLast + ")"));
			}
			flag2 = true;
		}
		if (flag2 && base.logReason)
		{
			base.strFailReasonLast = base.strFailReasonLast + ((base.strFailReasonLast.Length > 0) ? " " : "") + text7 + ")";
		}
		if (((CondTrigger)this).aReqs.Length + ((CondTrigger)this).aTriggers.Length == 0 && flag && flag3 && flag4)
		{
			return true;
		}
		string[] aReqs3 = ((CondTrigger)this).aReqs;
		string[] array12 = aReqs3;
		foreach (string text11 in array12)
		{
			((CondTrigger)this).StatsTrackReqs(strIAStatsName, text11, 1f / (float)((CondTrigger)this).aReqs.Length);
		}
		return false;
	}

	public static int GetDepth(CondOwner objCO)
	{
		int num = 1;
		CondOwner objCOParent = objCO.objCOParent;
		while ((Object)(object)objCOParent != (Object)null)
		{
			objCOParent = objCOParent.objCOParent;
			num++;
		}
		return num;
	}

	public static bool MathTrigger(int mOperation, double mTarget, double mValue)
	{
		return mOperation switch
		{
			1 => mTarget != mValue, 
			2 => mTarget == mValue, 
			3 => mTarget > mValue, 
			4 => mTarget >= mValue, 
			5 => mTarget < mValue, 
			6 => mTarget <= mValue, 
			_ => true, 
		};
	}

	public static string MathToString(int mOperation)
	{
		return mOperation switch
		{
			1 => "not equal to", 
			2 => "equal to", 
			3 => "greater than", 
			4 => "greater or equal to", 
			5 => "less than", 
			6 => "less or equal to", 
			_ => "invalid for", 
		};
	}

	public static string FormatTwoDecimals(double dVal)
	{
		double num = Math.Abs(dVal);
		if (num >= 1.0)
		{
			return dVal.ToString("0.##");
		}
		if (dVal == 0.0)
		{
			return "0";
		}
		int num2 = 0;
		int num3 = 0;
		double num4 = num;
		bool flag = false;
		while (num2 < 1 && num4 > 0.0 && !flag)
		{
			num4 *= 10.0;
			num3++;
			int num5 = (int)num4 % 10;
			if (num3 == 20)
			{
				flag = true;
			}
			if (num5 != 0)
			{
				num2++;
				num3++;
			}
		}
		if (flag)
		{
			return "0";
		}
		string text = "0." + new string('#', num3);
		return dVal.ToString(text);
	}
}
public class patch_Heater : Heater
{
	[MonoModReplace]
	private void Heat(double fTimePassed)
	{
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		bool flag = false;
		CondOwner val = null;
		if (base.coUs.HasCond("IsOverrideOn"))
		{
			flag = true;
		}
		else if (base.coUs.HasCond("IsOverrideOff"))
		{
			flag = false;
		}
		else if (base.strRemoteID == null || base.strRemoteID == base.coUs.strID)
		{
			flag = base.coUs.HasCond(base.strSignalCond);
			val = base.coUs;
		}
		else
		{
			CondOwner cOByID = base.coUs.ship.GetCOByID(base.strRemoteID);
			if ((Object)(object)cOByID != (Object)null && cOByID.HasCond(base.strSignalCond))
			{
				flag = true;
				val = cOByID;
			}
		}
		base.coUs.mapInfo.Remove("Status");
		if (flag)
		{
			CondOwner val2 = null;
			CondOwner val3 = null;
			double num = 1.0;
			if (base.strAddPoint != "ignore")
			{
				List<CondOwner> list = new List<CondOwner>();
				base.coUs.ship.GetCOsAtWorldCoords1(base.coUs.GetPos(base.strAddPoint, false), base.ct, false, false, list);
				if (list.Count != 0)
				{
					val2 = ((!list.Contains(base.coUs)) ? list[0] : base.coUs);
				}
			}
			if (base.strSubPoint != "ignore")
			{
				List<CondOwner> list2 = new List<CondOwner>();
				base.coUs.ship.GetCOsAtWorldCoords1(base.coUs.GetPos(base.strSubPoint, false), base.ct, false, false, list2);
				if (list2.Count != 0)
				{
					val3 = ((!list2.Contains(base.coUs)) ? list2[0] : base.coUs);
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = val3;
				num = 0.0 - num;
				val3 = null;
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			string strCODef = val2.strCODef;
			if ((Object)(object)val3 != (Object)null)
			{
				strCODef = val3.strCODef;
			}
			double num2 = 20.7;
			double num3 = 0.9;
			double num4 = 5.67E-08;
			double num5 = 101.30000305175781;
			GasContainer gasContainer = val2.GasContainer;
			double condAmount = val2.GetCondAmount("StatGasTemp");
			double condAmount2 = base.coUs.GetCondAmount("StatEmittedTemp");
			if (condAmount2 == 0.0)
			{
				condAmount2 = base.coUs.GetCondAmount("StatSolidTemp");
			}
			double condAmount3 = base.coUs.GetCondAmount("StatHeatArea");
			double num6 = gasContainer.mapGasMols1["StatGasMolTotal"];
			if (num6 == 0.0)
			{
				num6 = double.PositiveInfinity;
			}
			double num7 = condAmount2 * condAmount2 * condAmount2 * condAmount2 - condAmount * condAmount * condAmount * condAmount;
			double num8 = num3 * num4 * condAmount3 * num7;
			double condAmount4 = base.coUs.GetCondAmount("StatHeatVol");
			double num9 = val2.GetCondAmount("StatVolume");
			if (num9 == 0.0)
			{
				num9 = double.PositiveInfinity;
			}
			double num10 = condAmount4 / num9;
			double num11 = num8 / num2 / num6 * num10 * fTimePassed * num;
			double condAmount5 = val2.GetCondAmount("StatGasPressure");
			if (condAmount5 < num5)
			{
				num11 *= condAmount5 / num5;
			}
			GasContainer obj = gasContainer;
			obj.fDGasTemp += num11;
			if ((Object)(object)val3 == (Object)null)
			{
				base.coUs.mapInfo["Status"] = "Heating";
				return;
			}
			num = 0.0 - num;
			gasContainer = val3.GasContainer;
			condAmount = val3.GetCondAmount("StatGasTemp");
			num6 = gasContainer.mapGasMols1["StatGasMolTotal"];
			if (num6 == 0.0)
			{
				num6 = double.PositiveInfinity;
			}
			num9 = val3.GetCondAmount("StatVolume");
			if (num9 == 0.0)
			{
				num9 = double.PositiveInfinity;
			}
			num10 = condAmount4 / num9;
			num11 = num8 / num2 / num6 * num10 * fTimePassed * num;
			condAmount5 = val3.GetCondAmount("StatGasPressure");
			if (condAmount5 < num5)
			{
				num11 *= condAmount5 / num5;
			}
			GasContainer obj2 = gasContainer;
			obj2.fDGasTemp += num11;
			base.coUs.mapInfo["Status"] = "Cooling";
		}
		else
		{
			base.coUs.mapInfo["Status"] = "Idle";
		}
	}
}
public class patch_JsonInteraction : JsonInteraction
{
	public bool bForceVerbose { get; set; }

	public bool bRoomLookup { get; set; }
}
public class patch_Interaction : Interaction
{
	public bool bForceVerbose;

	public bool bRoomLookup;

	public bool bWriteToLog;

	private extern void orig_SetData(JsonInteraction jsonIn, JsonInteractionSave jis = null);

	private void SetData(JsonInteraction jsonIn, JsonInteractionSave jis = null)
	{
		orig_SetData(jsonIn, jis);
		if (jsonIn != null)
		{
			bForceVerbose = (jsonIn as patch_JsonInteraction).bForceVerbose;
			bRoomLookup = (jsonIn as patch_JsonInteraction).bRoomLookup;
			bWriteToLog = FFU_BR_Defs.ActLogging >= FFU_BR_Defs.ActLogs.Interactions && bForceVerbose;
		}
	}

	private extern void orig_AddFailReason(string strKey, string strReason);

	private void AddFailReason(string strKey, string strReason)
	{
		if (bWriteToLog && strReason != Interaction.STR_IA_FAIL_DEFAULT)
		{
			Debug.Log((object)("#Interaction# " + base.strName + " (US: " + (((Interaction)this).objUs?.strName ?? "N/A") + ", THEM: " + (((Interaction)this).objThem?.strName ?? "N/A") + ", 3RD: " + (((Interaction)this).obj3rd?.strName ?? "N/A") + ") => [Failed] " + strKey + ": " + (string.IsNullOrEmpty(strReason) ? "N/A" : strReason)));
		}
		orig_AddFailReason(strKey, strReason);
	}

	private extern bool orig_TriggeredInternal(CondOwner objUs, CondOwner objThem, bool bStats = false, bool bIgnoreItems = false, bool bCheckPath = false, bool bFetchItems = true, List<string> aForbid3rds = null);

	private bool TriggeredInternal(CondOwner objUs, CondOwner objThem, bool bStats = false, bool bIgnoreItems = false, bool bCheckPath = false, bool bFetchItems = true, List<string> aForbid3rds = null)
	{
		if (bForceVerbose)
		{
			base.bVerboseTrigger = true;
		}
		return orig_TriggeredInternal(objUs, objThem, bStats, bIgnoreItems, bCheckPath, bFetchItems, aForbid3rds);
	}

	[MonoModReplace]
	public void ApplyLogging(string strOwner, bool bTraitSuffix)
	{
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Expected I4, but got Unknown
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		string text = null;
		if (bWriteToLog)
		{
			text = GrammarUtils.GenerateDescription((Interaction)(object)this, true);
			Debug.Log((object)("#Interaction# " + base.strName + " (US: " + (((Interaction)this).objUs?.strName ?? "N/A") + ", THEM: " + (((Interaction)this).objThem?.strName ?? "N/A") + ", 3RD: " + (((Interaction)this).obj3rd?.strName ?? "N/A") + ") => " + text));
		}
		if ((int)base.nLogging == 0 || base.bLogged)
		{
			return;
		}
		text = text ?? GrammarUtils.GenerateDescription((Interaction)(object)this, true);
		List<CondOwner> list = new List<CondOwner>();
		Logging nLogging = base.nLogging;
		Logging val = nLogging;
		switch (val - 1)
		{
		case 0:
			list.Add(((Interaction)this).objUs);
			if (base.strThemType == Interaction.TARGET_OTHER)
			{
				list.Add(((Interaction)this).objThem);
			}
			break;
		case 1:
			if (((Interaction)this).objUs.currentRoom != null)
			{
				list.AddRange(((Interaction)this).objUs.ship.GetPeopleInRoom(((Interaction)this).objUs.currentRoom, (CondTrigger)null));
			}
			else if (bRoomLookup)
			{
				List<CondOwner> list2 = new List<CondOwner>();
				CondTrigger condTrigger = DataHandler.GetCondTrigger("TIsRoom");
				((Interaction)this).objUs.ship.GetCOsAtWorldCoords1(((Interaction)this).objUs.GetPos((string)null, false), condTrigger, false, false, list2);
				((Interaction)this).objUs.currentRoom = list2.First().currentRoom;
				list.AddRange(((Interaction)this).objUs.ship.GetPeopleInRoom(((Interaction)this).objUs.currentRoom, (CondTrigger)null));
			}
			if (!list.Contains(((Interaction)this).objUs))
			{
				list.Add(((Interaction)this).objUs);
			}
			if (!list.Contains(((Interaction)this).objThem))
			{
				list.Add(((Interaction)this).objThem);
			}
			break;
		case 2:
			if (((Interaction)this).objUs.ship != null)
			{
				list.AddRange(((Interaction)this).objUs.ship.GetPeople(true));
			}
			break;
		}
		foreach (CondOwner item in list)
		{
			item.LogMessage(text, base.strColor, strOwner);
		}
		base.bLogged = true;
	}
}
public class patch_JsonSlot : JsonSlot
{
	public int? nSlotOrder { get; set; }
}
public class patch_Slot : Slot
{
	public int nSlotOrder;

	[MonoModIgnore]
	public extern patch_Slot(JsonSlot jslot);

	[MonoModOriginal]
	public extern void orig_Slot(JsonSlot jslot);

	[MonoModConstructor]
	public void Slot(patch_JsonSlot jslot)
	{
		orig_Slot((JsonSlot)(object)jslot);
		nSlotOrder = (jslot.nSlotOrder.HasValue ? jslot.nSlotOrder.Value : ((JsonSlot)jslot).nDepth);
	}

	[MonoModReplace]
	public bool CanFit(CondOwner coFit, bool bAuto = true)
	{
		if (base.aCOs == null)
		{
			return false;
		}
		CondOwner[] aCOs = base.aCOs;
		foreach (CondOwner val in aCOs)
		{
			if (base.bHoldSlot && (Object)(object)val == (Object)null && coFit.mapSlotEffects.ContainsKey(base.strName) && (!bAuto || ((Slot)this).CanAutoSlot(coFit)))
			{
				return true;
			}
			CondOwner val2 = val;
			while ((Object)(object)val2 != (Object)null)
			{
				if ((Object)(object)coFit == (Object)(object)val2)
				{
					return false;
				}
				val2 = val2.objCOParent;
			}
			if ((Object)(object)val != (Object)null && (Object)(object)val.objContainer != (Object)null && (val.objContainer.ctAllowed == null || val.objContainer.ctAllowed.Triggered(coFit, (string)null, true)) && val.objContainer.GetSpaceAvailable() > 0)
			{
				return true;
			}
		}
		return false;
	}
}
public class patch_GUIInventory : GUIInventory
{
	[MonoModReplace]
	public void SpawnInventoryWindow(patch_CondOwner CO, InventoryWindowType type, bool bFlyIn)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)CO == (Object)null)
		{
			return;
		}
		CanvasManager.ShowCanvasGroup(base.canvasGroup);
		bool flag = (int)type == 0 || (Object)(object)((CondOwner)CO).objContainer != (Object)null;
		for (int i = 0; i < base.activeWindows.Count; i++)
		{
			if (!flag)
			{
				break;
			}
			if ((Object)(object)base.activeWindows[i].CO == (Object)(object)CO && type == base.activeWindows[i].type)
			{
				flag = false;
			}
		}
		if (flag)
		{
			GameObject val = Object.Instantiate<GameObject>(base.inventoryGridPrefab, ((Component)this).transform);
			GUIInventoryWindow component = val.GetComponent<GUIInventoryWindow>();
			base.activeWindows.Add(component);
			component.SetData((CondOwner)(object)CO, type);
			int num = base.activeWindows.IndexOf(component);
			GUIInventoryWindow val2 = null;
			if (num > 0)
			{
				val2 = base.activeWindows[num - 1];
			}
			((Component)component).transform.localPosition = Vector2.op_Implicit(((GUIInventory)this).GetWindowPosition(component, val2) * 1.5f * CanvasManager.CanvasRatio);
			CanvasManager.SetAnchorsToCorners(((Component)component).transform);
			((MonoBehaviour)this).StartCoroutine(((GUIInventory)this).FlyIn(component));
		}
		List<Slot> list = (FFU_BR_Defs.StrictInvSorting ? CO.GetSortedSlots() : ((CondOwner)CO).GetSlots(true, (SortOrder)1));
		foreach (Slot item in list)
		{
			if (item.strName == "social")
			{
				CondOwner val3 = item.aCOs.FirstOrDefault();
				((GUIInventory)this).SpawnSocialMovesWindow(val3);
			}
			else
			{
				if (item.bHide)
				{
					continue;
				}
				CondOwner[] aCOs = item.aCOs;
				CondOwner[] array = aCOs;
				foreach (CondOwner val4 in array)
				{
					if ((Object)(object)val4 != (Object)null && (Object)(object)val4.objContainer != (Object)null && GUIInventory.CTOpenInv.Triggered(val4, (string)null, true))
					{
						((GUIInventory)this).SpawnInventoryWindow(val4, (InventoryWindowType)1, bFlyIn);
					}
				}
			}
		}
		if (CrewSim.coPlayer.HasCond("TutorialLockerWaiting") && GUIInventory.instance.IsCOShown(CrewSim.coPlayer) && (((CondOwner)CO).HasCond("TutorialLockerTarget") || (((CondOwner)CO).HasCond("IsStorageFurniture") && CrewSim.coPlayer.HasCond("IsENCFirstDockOKLG"))))
		{
			CrewSim.coPlayer.ZeroCondAmount("TutorialLockerWaiting");
			MonoSingleton<ObjectiveTracker>.Instance.CheckObjective(CrewSim.coPlayer.strID);
		}
	}
}
public class patch_CondOwner : CondOwner
{
	public JsonSlotEffects jsInvSlotEffect;

	public List<Slot> GetSortedSlots()
	{
		if ((Object)(object)((CondOwner)this).compSlots == (Object)null)
		{
			return CondOwner._emptySlotsResult ?? (CondOwner._emptySlotsResult = new List<Slot>());
		}
		List<Slot> srtSlots2 = new List<Slot>();
		GetSlotsRecursive(ref srtSlots2, ((IEnumerable<Slot>)((CondOwner)this).compSlots?.aSlots)?.ToList(), FFU_BR_Defs.ActLogging >= FFU_BR_Defs.ActLogs.Runtime);
		return srtSlots2;
		static void GetSlotsRecursive(ref List<Slot> srtSlots, List<Slot> refSlots, bool dLog, bool dSort = true, int sDepth = 0)
		{
			if (refSlots != null && refSlots.Count > 0)
			{
				refSlots.Sort(SortByDepth);
				foreach (Slot refSlot in refSlots)
				{
					if (dLog)
					{
						Debug.Log((object)("#Info# Sorted Slot " + string.Empty.PadLeft(sDepth, '=') + "> " + refSlot.strName));
					}
					srtSlots.Add(refSlot);
					CondOwner[] aCOs = refSlot.aCOs;
					foreach (CondOwner val in aCOs)
					{
						List<Slot> refSlots2 = ((val != null) ? ((IEnumerable<Slot>)val.compSlots?.aSlots)?.ToList() : null);
						GetSlotsRecursive(ref srtSlots, refSlots2, dLog, dSort, sDepth + 1);
					}
				}
			}
		}
		static int SortByDepth(Slot s1, Slot s2)
		{
			if (!(s1 is patch_Slot) || !(s2 is patch_Slot))
			{
				return 0;
			}
			return (s1 as patch_Slot).nSlotOrder.CompareTo((s2 as patch_Slot).nSlotOrder);
		}
	}

	public extern void orig_SetData(JsonCondOwner jid, bool bLoot, JsonCondOwnerSave jCOSIn);

	public void SetData(patch_JsonCondOwner jid, bool bLoot, JsonCondOwnerSave jCOSIn)
	{
		orig_SetData((JsonCondOwner)(object)jid, bLoot, jCOSIn);
		ParseInvEffects(jid);
	}

	public void ParseInvEffects(patch_JsonCondOwner jid)
	{
		if (jid.strInvSlotEffect == null)
		{
			return;
		}
		JsonSlotEffects slotEffect = DataHandler.GetSlotEffect(jid.strInvSlotEffect);
		if (slotEffect != null)
		{
			if (Container.GetSpace((CondOwner)(object)this) < 1)
			{
				Debug.LogWarning((object)("Can't assign 'invSlotEffect' for [" + base.strName + "] without inventory grid."));
			}
			else
			{
				jsInvSlotEffect = slotEffect;
			}
		}
	}
}
public class patch_Container : Container
{
	[MonoModIgnore]
	private patch_CondOwner CO => (patch_CondOwner)(object)((Container)this).CO;

	[MonoModReplace]
	public bool AllowedCO(CondOwner coIn)
	{
		if ((Object)(object)coIn == (Object)null || (Object)(object)coIn == (Object)(object)CO)
		{
			return false;
		}
		CondOwner val = (CondOwner)(object)CO;
		while ((Object)(object)val != (Object)null)
		{
			if ((Object)(object)coIn == (Object)(object)val)
			{
				return false;
			}
			val = val.objCOParent;
		}
		if (base.ctAllowed != null)
		{
			return base.ctAllowed.Triggered(coIn, (string)null, true);
		}
		return true;
	}

	[MonoModReplace]
	public void SetIsInContainer(CondOwner co)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Expected O, but got Unknown
		if ((Object)(object)CO == (Object)(object)this)
		{
			Debug.Log((object)"ERROR: Assigning self as own parent.");
		}
		co.objCOParent = (CondOwner)(object)CO;
		if ((Object)(object)co.coStackHead == (Object)null)
		{
			co.tf.SetParent(((CondOwner)CO).tf);
			co.tf.localPosition = new Vector3(0f, 0f, Container.fZSubOffset);
			co.Visible = false;
		}
		if (!((CondOwner)CO).HasCond("IsHuman"))
		{
			if (CO.jsInvSlotEffect != null)
			{
				ApplyContainerEffects(co, CO.jsInvSlotEffect);
			}
			co.AddCondAmount("IsInContainer", 1.0, 0.0, 0f);
		}
		CondOwner val = (CondOwner)(object)CO;
		while ((Object)(object)val != (Object)null)
		{
			if (val.HasCond("IsHuman") || val.HasCond("IsRobot"))
			{
				co.AddCondAmount("IsCarried", 1.0, 0.0, 0f);
				CondOwnerVisitorAddCond val2 = new CondOwnerVisitorAddCond();
				val2.strCond = "IsCarried";
				val2.fAmount = 1.0;
				co.VisitCOs((CondOwnerVisitor)(object)val2, true);
				break;
			}
			val = val.objCOParent;
		}
	}

	[MonoModReplace]
	public void ClearIsInContainer(CondOwner co)
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		if (CO.jsInvSlotEffect != null)
		{
			ApplyContainerEffects(co, CO.jsInvSlotEffect, bRemove: true);
		}
		co.ZeroCondAmount("IsInContainer");
		co.ZeroCondAmount("IsCarried");
		CondOwnerVisitorZeroCond val = new CondOwnerVisitorZeroCond();
		val.strCond = "IsCarried";
		co.VisitCOs((CondOwnerVisitor)(object)val, true);
		co.objCOParent = null;
	}

	private void ApplyContainerEffects(CondOwner co, JsonSlotEffects jse, bool bRemove = false)
	{
		if (!((Object)(object)CO == (Object)null) && !((Object)(object)co == (Object)null) && jse != null)
		{
			co.ValidateParent();
			Slots.ApplyIAEffects((CondOwner)(object)CO, co, jse, bRemove, false);
		}
	}
}
public class patch_JsonCondOwner : JsonCondOwner
{
	public string strInvSlotEffect { get; set; }
}
public class patch_Loot : Loot
{
	[MonoModReplace]
	public List<CondTrigger> GetCTLoot(CondTrigger objUs, string strRandID = null)
	{
		List<CondTrigger> list = new List<CondTrigger>();
		int num = 0;
		float num2 = 0f;
		float num3 = 1f;
		foreach (List<LootUnit> aCOLootUnit in base.aCOLootUnits)
		{
			num2 = 0f;
			string text = strRandID;
			if (text != null)
			{
				text += num;
			}
			num++;
			if (FFU_BR_Defs.DynamicRandomRange)
			{
				float num4 = 0f;
				foreach (LootUnit item in aCOLootUnit)
				{
					num4 += item.fChance;
				}
				num3 = ((num4 > 1f) ? num4 : 1f);
			}
			float num5 = MathUtils.Rand(0f, num3, (RandType)0, text);
			foreach (LootUnit item2 in aCOLootUnit)
			{
				float num6 = item2.GetAmount(num2, num5);
				if (!item2.bPositive)
				{
					num6 = 0f - num6;
				}
				num2 += item2.fChance;
				if (num6 > 0f)
				{
					CondTrigger val = null;
					val = ((objUs == null || !(item2.strName == "[us]")) ? DataHandler.GetCondTrigger(item2.strName) : objUs.Clone());
					CondTrigger obj = val;
					obj.fCount *= num6;
					list.Add(val);
					break;
				}
			}
		}
		num = 0;
		num3 = 1f;
		foreach (List<LootUnit> aOtherLootUnit in base.aOtherLootUnits)
		{
			num2 = 0f;
			string text2 = strRandID;
			if (text2 != null)
			{
				text2 += num;
			}
			num++;
			if (FFU_BR_Defs.DynamicRandomRange)
			{
				float num7 = 0f;
				foreach (LootUnit item3 in aOtherLootUnit)
				{
					num7 += item3.fChance;
				}
				num3 = ((num7 > 1f) ? num7 : 1f);
			}
			float num8 = MathUtils.Rand(0f, num3, (RandType)0, text2);
			foreach (LootUnit item4 in aOtherLootUnit)
			{
				float num9 = item4.GetAmount(num2, num8);
				if (!item4.bPositive)
				{
					num9 = 0f - num9;
				}
				num2 += item4.fChance;
				if (num9 <= 0f)
				{
					continue;
				}
				List<CondTrigger> cTLoot = DataHandler.GetLoot(item4.strName).GetCTLoot(objUs, strRandID);
				foreach (CondTrigger item5 in cTLoot)
				{
					item5.fCount *= num9;
				}
				list.AddRange(cTLoot);
				break;
			}
		}
		return list;
	}

	[MonoModReplace]
	public List<CondOwner> GetCOLoot(CondOwner objUs, bool bSuppressOverride, string strRandID = null)
	{
		List<CondOwner> list = new List<CondOwner>();
		int num = 0;
		float num2 = 0f;
		float num3 = 1f;
		foreach (List<LootUnit> aCOLootUnit in base.aCOLootUnits)
		{
			num2 = 0f;
			string text = strRandID;
			if (text != null)
			{
				text += num;
			}
			num++;
			if (FFU_BR_Defs.DynamicRandomRange)
			{
				float num4 = 0f;
				foreach (LootUnit item in aCOLootUnit)
				{
					num4 += item.fChance;
				}
				num3 = ((num4 > 1f) ? num4 : 1f);
			}
			float num5 = MathUtils.Rand(0f, num3, (RandType)0, text);
			foreach (LootUnit item2 in aCOLootUnit)
			{
				float num6 = item2.GetAmount(num2, num5);
				if (!item2.bPositive)
				{
					num6 = 0f - num6;
				}
				num2 += item2.fChance;
				if (num6 <= 0f)
				{
					continue;
				}
				int num7 = Mathf.FloorToInt(num6);
				for (int i = 0; i < num7; i++)
				{
					if ((Object)(object)objUs != (Object)null && item2.strName == "[us]")
					{
						list.Add(objUs);
					}
					else
					{
						list.Add(DataHandler.GetCondOwner(item2.strName, (string)null, (string)null, !base.bSuppress || !bSuppressOverride, (string)null, (JsonCondOwnerSave)null, (string)null, (Transform)null));
					}
				}
				break;
			}
		}
		num = 0;
		num3 = 1f;
		foreach (List<LootUnit> aOtherLootUnit in base.aOtherLootUnits)
		{
			num2 = 0f;
			string text2 = strRandID;
			if (text2 != null)
			{
				text2 += num;
			}
			num++;
			if (FFU_BR_Defs.DynamicRandomRange)
			{
				float num8 = 0f;
				foreach (LootUnit item3 in aOtherLootUnit)
				{
					num8 += item3.fChance;
				}
				num3 = ((num8 > 1f) ? num8 : 1f);
			}
			float num9 = MathUtils.Rand(0f, num3, (RandType)0, text2);
			foreach (LootUnit item4 in aOtherLootUnit)
			{
				float num10 = item4.GetAmount(num2, num9);
				if (!item4.bPositive)
				{
					num10 = 0f - num10;
				}
				num2 += item4.fChance;
				if (num10 <= 0f)
				{
					continue;
				}
				for (int j = 0; (float)j < num10; j++)
				{
					Loot loot = DataHandler.GetLoot(item4.strName);
					if (loot.strName != item4.strName)
					{
						Debug.Log((object)(((Loot)this).strName + " expected loot: " + item4.strName + " but got " + loot.strName));
					}
					list.AddRange(loot.GetCOLoot(objUs, base.bSuppress && bSuppressOverride, strRandID));
				}
				break;
			}
		}
		if (base.bNested)
		{
			for (int num11 = list.Count - 1; num11 > 0; num11--)
			{
				for (int num12 = num11 - 1; num12 >= 0; num12--)
				{
					list[num11] = list[num12].AddCO(list[num11], true, true, true);
					if ((Object)(object)list[num11] == (Object)null)
					{
						list.RemoveAt(num11);
						break;
					}
				}
			}
		}
		return list;
	}

	[MonoModReplace]
	public List<string> GetLootNames(string strRandID = null, bool bOnlyCOs = false, string type = null)
	{
		List<string> list = new List<string>();
		int num = 0;
		float num2 = 0f;
		float num3 = 1f;
		foreach (List<LootUnit> aCOLootUnit in base.aCOLootUnits)
		{
			if (!string.IsNullOrEmpty(type) && base.strType != type)
			{
				break;
			}
			num2 = 0f;
			string text = strRandID;
			if (text != null)
			{
				text += num;
			}
			num++;
			if (FFU_BR_Defs.DynamicRandomRange)
			{
				float num4 = 0f;
				foreach (LootUnit item in aCOLootUnit)
				{
					num4 += item.fChance;
				}
				num3 = ((num4 > 1f) ? num4 : 1f);
			}
			float num5 = MathUtils.Rand(0f, num3, (RandType)0, text);
			foreach (LootUnit item2 in aCOLootUnit)
			{
				float num6 = item2.GetAmount(num2, num5);
				num2 += item2.fChance;
				string text2 = item2.strName;
				if (num6 < 0f)
				{
					text2 = "-" + text2;
					num6 = 0f - num6;
				}
				if (num6 > 0f)
				{
					for (int i = 0; (float)i < num6; i++)
					{
						list.Add(text2);
					}
					break;
				}
			}
		}
		if (bOnlyCOs)
		{
			return list;
		}
		num = 0;
		num3 = 1f;
		foreach (List<LootUnit> aOtherLootUnit in base.aOtherLootUnits)
		{
			num2 = 0f;
			string text3 = strRandID;
			if (text3 != null)
			{
				text3 += num;
			}
			num++;
			if (FFU_BR_Defs.DynamicRandomRange)
			{
				float num7 = 0f;
				foreach (LootUnit item3 in aOtherLootUnit)
				{
					num7 += item3.fChance;
				}
				num3 = ((num7 > 1f) ? num7 : 1f);
			}
			float num8 = MathUtils.Rand(0f, num3, (RandType)0, text3);
			foreach (LootUnit item4 in aOtherLootUnit)
			{
				float num9 = item4.GetAmount(num2, num8);
				num2 += item4.fChance;
				string strName = item4.strName;
				if (num9 < 0f)
				{
					strName = "-" + strName;
					num9 = 0f - num9;
				}
				if (num9 <= 0f)
				{
					continue;
				}
				for (int j = 0; (float)j < num9; j++)
				{
					Loot loot = DataHandler.GetLoot(item4.strName);
					if (string.IsNullOrEmpty(type) || !(loot.strType != type))
					{
						list.AddRange(loot.GetLootNames(text3, false, (string)null));
					}
				}
				break;
			}
		}
		return list;
	}

	[MonoModReplace]
	public void ApplyCondLoot(CondOwner coUs, float fCoeff, string strRandID = null, float fCondRuleTrack = 0f)
	{
		if ((Object)(object)coUs == (Object)null || base.strType != "condition")
		{
			return;
		}
		string[] aCOs = ((Loot)this).aCOs;
		string[] array = aCOs;
		foreach (string text in array)
		{
			coUs.ParseCondEquation(text, (double)fCoeff, fCondRuleTrack);
		}
		int num = 0;
		float num2 = 1f;
		foreach (List<LootUnit> aOtherLootUnit in base.aOtherLootUnits)
		{
			float num3 = 0f;
			string text2 = strRandID;
			if (text2 != null)
			{
				text2 += num;
			}
			num++;
			if (FFU_BR_Defs.DynamicRandomRange)
			{
				float num4 = 0f;
				foreach (LootUnit item in aOtherLootUnit)
				{
					num4 += item.fChance;
				}
				num2 = ((num4 > 1f) ? num4 : 1f);
			}
			float num5 = MathUtils.Rand(0f, num2, (RandType)0, text2);
			foreach (LootUnit item2 in aOtherLootUnit)
			{
				float num6 = item2.GetAmount(num3, num5);
				if (!item2.bPositive)
				{
					num6 = 0f - num6;
				}
				num3 += item2.fChance;
				if (num6 > 0f)
				{
					for (int j = 0; (float)j < num6; j++)
					{
						Loot loot = DataHandler.GetLoot(item2.strName);
						loot.ApplyCondLoot(coUs, fCoeff, (string)null, fCondRuleTrack);
					}
					break;
				}
			}
		}
	}

	[MonoModReplace]
	public Dictionary<string, double> GetCondLoot(float fCoeff, Dictionary<string, double> dictOut, string strRandID = null)
	{
		if (dictOut == null)
		{
			dictOut = new Dictionary<string, double>();
		}
		if (base.strType != "condition")
		{
			return dictOut;
		}
		string[] aCOs = ((Loot)this).aCOs;
		string[] array = aCOs;
		foreach (string text in array)
		{
			KeyValuePair<string, Tuple<double, double>> keyValuePair = Loot.ParseCondEquation(text);
			double num = keyValuePair.Value.Item1;
			if (keyValuePair.Value.Item2 != num)
			{
				num = MathUtils.Rand(keyValuePair.Value.Item1, keyValuePair.Value.Item2, (RandType)0, (string)null);
			}
			if (keyValuePair.Key != string.Empty && num != 0.0)
			{
				if (!dictOut.ContainsKey(keyValuePair.Key))
				{
					dictOut[keyValuePair.Key] = num * (double)fCoeff;
				}
				else
				{
					dictOut[keyValuePair.Key] += num * (double)fCoeff;
				}
			}
		}
		int num2 = 0;
		float num3 = 1f;
		foreach (List<LootUnit> aOtherLootUnit in base.aOtherLootUnits)
		{
			float num4 = 0f;
			string text2 = strRandID;
			if (text2 != null)
			{
				text2 += num2;
			}
			num2++;
			if (FFU_BR_Defs.DynamicRandomRange)
			{
				float num5 = 0f;
				foreach (LootUnit item in aOtherLootUnit)
				{
					num5 += item.fChance;
				}
				num3 = ((num5 > 1f) ? num5 : 1f);
			}
			float num6 = MathUtils.Rand(0f, num3, (RandType)0, text2);
			foreach (LootUnit item2 in aOtherLootUnit)
			{
				float num7 = item2.GetAmount(num4, num6);
				if (!item2.bPositive)
				{
					num7 = 0f - num7;
				}
				num4 += item2.fChance;
				if (num7 > 0f)
				{
					for (int j = 0; (float)j < num7; j++)
					{
						Loot loot = DataHandler.GetLoot(item2.strName);
						loot.GetCondLoot(fCoeff, dictOut, (string)null);
					}
					break;
				}
			}
		}
		return dictOut;
	}

	[MonoModReplace]
	private List<List<LootUnit>> ParseLootDef(string[] aIn)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Expected O, but got Unknown
		List<List<LootUnit>> list = new List<List<LootUnit>>();
		foreach (string text in aIn)
		{
			string[] array = text.Split(new char[1] { '|' });
			List<LootUnit> list2 = new List<LootUnit>();
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				LootUnit val = new LootUnit();
				val.bPositive = true;
				string text3 = text2;
				if (text[0] == '-')
				{
					val.bPositive = false;
					text3 = text2.Substring(1);
				}
				string[] array3 = text3.Split(new char[1] { '=' });
				val.strName = array3[0];
				if (array3.Length < 2)
				{
					if (FFU_BR_Defs.SyncLogging >= FFU_BR_Defs.SyncLogs.ModChanges)
					{
						Debug.Log((object)("#Info# Loot entry '" + ((Loot)this).strName + "' is for patching only and not saved as permanent data."));
					}
					return new List<List<LootUnit>>();
				}
				array3 = array3[1].Split(new char[1] { 'x' });
				float.TryParse(array3[0], out val.fChance);
				if (val.fChance < 0f)
				{
					JsonLogger.ReportProblem("[" + ((Loot)this).strName + "] " + text2 + " (loot definition chance can't be negative)", (ReportTypes)1);
					continue;
				}
				if (array3.Length < 2)
				{
					JsonLogger.ReportProblem("[" + ((Loot)this).strName + "] " + text2 + " (loot definition is shorter than expected)", (ReportTypes)1);
					continue;
				}
				float result = 0f;
				if (array3[1].StartsWith("-"))
				{
					JsonLogger.ReportProblem("[" + ((Loot)this).strName + "] " + text2 + " (loot definition base value can't be negative)", (ReportTypes)1);
					continue;
				}
				array3 = array3[1].Split(new char[1] { '-' });
				if (float.TryParse(array3[0], out result))
				{
					val.fMin = result;
				}
				if (array3.Length > 1)
				{
					result = 0f;
					if (array3.Length > 2)
					{
						JsonLogger.ReportProblem("[" + ((Loot)this).strName + "] " + text2 + " (loot definition value is longer than expected)", (ReportTypes)1);
						continue;
					}
					if (float.TryParse(array3[1], out result))
					{
						val.fMax = result;
					}
				}
				if (val.fMax < val.fMin)
				{
					val.fMax = val.fMin;
				}
				list2.Add(val);
			}
			list.Add(list2);
		}
		return list;
	}
}
public class patch_Sensor : Sensor
{
	[MonoModReplace]
	public void Run()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)base.coUs == (Object)null || base.coUs.ship == null)
		{
			return;
		}
		bool flag = string.IsNullOrEmpty(base.strPoint);
		List<CondOwner> list = new List<CondOwner>();
		if (!flag)
		{
			base.coUs.ship.GetCOsAtWorldCoords1(base.coUs.GetPos(base.strPoint, false), (CondTrigger)null, false, false, list);
		}
		foreach (KeyValuePair<string, string> mapTest in base.mapTests)
		{
			CondTrigger condTrigger = DataHandler.GetCondTrigger(mapTest.Key);
			if (!flag)
			{
				foreach (CondOwner item in list)
				{
					if (condTrigger.Triggered(item, (string)null, true))
					{
						Interaction interaction = DataHandler.GetInteraction(mapTest.Value, (JsonInteractionSave)null, false);
						if (interaction != null && interaction.CTTestUs.Triggered(base.coUs, (string)null, true))
						{
							base.coUs.QueueInteraction(item, interaction, false);
						}
					}
				}
			}
			else if (condTrigger.Triggered(base.coUs, (string)null, true))
			{
				Interaction interaction2 = DataHandler.GetInteraction(mapTest.Value, (JsonInteractionSave)null, false);
				if (interaction2 != null && interaction2.CTTestUs.Triggered(base.coUs, (string)null, true))
				{
					base.coUs.QueueInteraction(base.coUs, interaction2, false);
				}
			}
		}
		base.dfEpochLast = StarSystem.fEpoch;
	}

	[MonoModReplace]
	public void SetData(Dictionary<string, string> gpm)
	{
		if (gpm == null)
		{
			return;
		}
		base.strPoint = gpm["strPoint"];
		string[] array = gpm["mapTests"].Split(new char[1] { ',' });
		if (gpm.TryGetValue("dfUpdateInterval", out var value))
		{
			double.TryParse(value, out var result);
			if (result > 0.0)
			{
				base.dfUpdateInterval = result;
			}
		}
		base.mapTests = DataHandler.ConvertStringArrayToDict(array, (Dictionary<string, string>)null);
	}
}
public class patch_JsonShipSpec : JsonShipSpec
{
	public int nIsSameShipCO { get; set; }

	public extern bool orig_Matches(Ship ship, CondOwner coUs = null);

	public bool Matches(Ship ship, CondOwner coUs = null)
	{
		bool flag = orig_Matches(ship, coUs);
		if (flag && nIsSameShipCO != 0)
		{
			if ((Object)(object)coUs == (Object)null)
			{
				return false;
			}
			if (!((JsonShipSpec)this).IntMatchesBool(nIsSameShipCO, coUs.ship == ship))
			{
				return false;
			}
		}
		return flag;
	}
}
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)
		{
		}
	}
}