Decompiled source of RavenM v0.7.0
RavenM.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Lua; using Lua.Proxy; using Lua.Wrapper; using MapEditor; using Microsoft.CodeAnalysis; using MoonSharp.Interpreter; using RavenM.Commands; using RavenM.DiscordGameSDK; using RavenM.RSPatch; using RavenM.RSPatch.Proxy; using RavenM.RSPatch.Wrapper; using RavenM.UI; using RavenM.rspatch; using RavenM.rspatch.Proxy; using RavenM.rspatch.Wrapper; using Ravenfield.Mutator.Configuration; using Ravenfield.SpecOps; using Ravenfield.Trigger; using SimpleJSON; using Steamworks; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("RavenM")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A Ravenfield multiplayer mod.")] [assembly: AssemblyFileVersion("0.7.0.0")] [assembly: AssemblyInformationalVersion("0.7+9cc4718b1ef377ccdb2094d44215d87b2e765c01")] [assembly: AssemblyProduct("RavenM")] [assembly: AssemblyTitle("RavenM")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.7.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SimpleJSON { public enum JSONNodeType { Array = 1, Object = 2, String = 3, Number = 4, NullValue = 5, Boolean = 6, None = 7, Custom = 255 } public enum JSONTextMode { Compact, Indent } public abstract class JSONNode { public struct Enumerator { private enum Type { None, Array, Object } private Type type; private Dictionary<string, JSONNode>.Enumerator m_Object; private List<JSONNode>.Enumerator m_Array; public bool IsValid => type != Type.None; public KeyValuePair<string, JSONNode> Current { get { if (type == Type.Array) { return new KeyValuePair<string, JSONNode>(string.Empty, m_Array.Current); } if (type == Type.Object) { return m_Object.Current; } return new KeyValuePair<string, JSONNode>(string.Empty, null); } } public Enumerator(List<JSONNode>.Enumerator aArrayEnum) { type = Type.Array; m_Object = default(Dictionary<string, JSONNode>.Enumerator); m_Array = aArrayEnum; } public Enumerator(Dictionary<string, JSONNode>.Enumerator aDictEnum) { type = Type.Object; m_Object = aDictEnum; m_Array = default(List<JSONNode>.Enumerator); } public bool MoveNext() { if (type == Type.Array) { return m_Array.MoveNext(); } if (type == Type.Object) { return m_Object.MoveNext(); } return false; } } public struct ValueEnumerator { private Enumerator m_Enumerator; public JSONNode Current => m_Enumerator.Current.Value; public ValueEnumerator(List<JSONNode>.Enumerator aArrayEnum) : this(new Enumerator(aArrayEnum)) { } public ValueEnumerator(Dictionary<string, JSONNode>.Enumerator aDictEnum) : this(new Enumerator(aDictEnum)) { } public ValueEnumerator(Enumerator aEnumerator) { m_Enumerator = aEnumerator; } public bool MoveNext() { return m_Enumerator.MoveNext(); } public ValueEnumerator GetEnumerator() { return this; } } public struct KeyEnumerator { private Enumerator m_Enumerator; public string Current => m_Enumerator.Current.Key; public KeyEnumerator(List<JSONNode>.Enumerator aArrayEnum) : this(new Enumerator(aArrayEnum)) { } public KeyEnumerator(Dictionary<string, JSONNode>.Enumerator aDictEnum) : this(new Enumerator(aDictEnum)) { } public KeyEnumerator(Enumerator aEnumerator) { m_Enumerator = aEnumerator; } public bool MoveNext() { return m_Enumerator.MoveNext(); } public KeyEnumerator GetEnumerator() { return this; } } public class LinqEnumerator : IEnumerator<KeyValuePair<string, JSONNode>>, IDisposable, IEnumerator, IEnumerable<KeyValuePair<string, JSONNode>>, IEnumerable { private JSONNode m_Node; private Enumerator m_Enumerator; public KeyValuePair<string, JSONNode> Current => m_Enumerator.Current; object IEnumerator.Current => m_Enumerator.Current; internal LinqEnumerator(JSONNode aNode) { m_Node = aNode; if (m_Node != null) { m_Enumerator = m_Node.GetEnumerator(); } } public bool MoveNext() { return m_Enumerator.MoveNext(); } public void Dispose() { m_Node = null; m_Enumerator = default(Enumerator); } public IEnumerator<KeyValuePair<string, JSONNode>> GetEnumerator() { return new LinqEnumerator(m_Node); } public void Reset() { if (m_Node != null) { m_Enumerator = m_Node.GetEnumerator(); } } IEnumerator IEnumerable.GetEnumerator() { return new LinqEnumerator(m_Node); } } public static bool forceASCII = false; public static bool longAsString = false; public static bool allowLineComments = true; [ThreadStatic] private static StringBuilder m_EscapeBuilder; public abstract JSONNodeType Tag { get; } public virtual JSONNode this[int aIndex] { get { return null; } set { } } public virtual JSONNode this[string aKey] { get { return null; } set { } } public virtual string Value { get { return ""; } set { } } public virtual int Count => 0; public virtual bool IsNumber => false; public virtual bool IsString => false; public virtual bool IsBoolean => false; public virtual bool IsNull => false; public virtual bool IsArray => false; public virtual bool IsObject => false; public virtual bool Inline { get { return false; } set { } } public virtual IEnumerable<JSONNode> Children { get { yield break; } } public IEnumerable<JSONNode> DeepChildren { get { foreach (JSONNode child in Children) { foreach (JSONNode deepChild in child.DeepChildren) { yield return deepChild; } } } } public IEnumerable<KeyValuePair<string, JSONNode>> Linq => new LinqEnumerator(this); public KeyEnumerator Keys => new KeyEnumerator(GetEnumerator()); public ValueEnumerator Values => new ValueEnumerator(GetEnumerator()); public virtual double AsDouble { get { double result = 0.0; if (double.TryParse(Value, NumberStyles.Float, CultureInfo.InvariantCulture, out result)) { return result; } return 0.0; } set { Value = value.ToString(CultureInfo.InvariantCulture); } } public virtual int AsInt { get { return (int)AsDouble; } set { AsDouble = value; } } public virtual float AsFloat { get { return (float)AsDouble; } set { AsDouble = value; } } public virtual bool AsBool { get { bool result = false; if (bool.TryParse(Value, out result)) { return result; } return !string.IsNullOrEmpty(Value); } set { Value = (value ? "true" : "false"); } } public virtual long AsLong { get { long result = 0L; if (long.TryParse(Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) { return result; } return 0L; } set { Value = value.ToString(CultureInfo.InvariantCulture); } } public virtual ulong AsULong { get { ulong result = 0uL; if (ulong.TryParse(Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) { return result; } return 0uL; } set { Value = value.ToString(CultureInfo.InvariantCulture); } } public virtual JSONArray AsArray => this as JSONArray; public virtual JSONObject AsObject => this as JSONObject; internal static StringBuilder EscapeBuilder { get { if (m_EscapeBuilder == null) { m_EscapeBuilder = new StringBuilder(); } return m_EscapeBuilder; } } public virtual void Add(string aKey, JSONNode aItem) { } public virtual void Add(JSONNode aItem) { Add("", aItem); } public virtual JSONNode Remove(string aKey) { return null; } public virtual JSONNode Remove(int aIndex) { return null; } public virtual JSONNode Remove(JSONNode aNode) { return aNode; } public virtual void Clear() { } public virtual JSONNode Clone() { return null; } public virtual bool HasKey(string aKey) { return false; } public virtual JSONNode GetValueOrDefault(string aKey, JSONNode aDefault) { return aDefault; } public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); WriteToStringBuilder(stringBuilder, 0, 0, JSONTextMode.Compact); return stringBuilder.ToString(); } public virtual string ToString(int aIndent) { StringBuilder stringBuilder = new StringBuilder(); WriteToStringBuilder(stringBuilder, 0, aIndent, JSONTextMode.Indent); return stringBuilder.ToString(); } internal abstract void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode); public abstract Enumerator GetEnumerator(); public static implicit operator JSONNode(string s) { if (s != null) { return new JSONString(s); } return JSONNull.CreateOrGet(); } public static implicit operator string(JSONNode d) { if (!(d == null)) { return d.Value; } return null; } public static implicit operator JSONNode(double n) { return new JSONNumber(n); } public static implicit operator double(JSONNode d) { if (!(d == null)) { return d.AsDouble; } return 0.0; } public static implicit operator JSONNode(float n) { return new JSONNumber(n); } public static implicit operator float(JSONNode d) { if (!(d == null)) { return d.AsFloat; } return 0f; } public static implicit operator JSONNode(int n) { return new JSONNumber(n); } public static implicit operator int(JSONNode d) { if (!(d == null)) { return d.AsInt; } return 0; } public static implicit operator JSONNode(long n) { if (longAsString) { return new JSONString(n.ToString(CultureInfo.InvariantCulture)); } return new JSONNumber(n); } public static implicit operator long(JSONNode d) { if (!(d == null)) { return d.AsLong; } return 0L; } public static implicit operator JSONNode(ulong n) { if (longAsString) { return new JSONString(n.ToString(CultureInfo.InvariantCulture)); } return new JSONNumber(n); } public static implicit operator ulong(JSONNode d) { if (!(d == null)) { return d.AsULong; } return 0uL; } public static implicit operator JSONNode(bool b) { return new JSONBool(b); } public static implicit operator bool(JSONNode d) { if (!(d == null)) { return d.AsBool; } return false; } public static implicit operator JSONNode(KeyValuePair<string, JSONNode> aKeyValue) { return aKeyValue.Value; } public static bool operator ==(JSONNode a, object b) { if ((object)a == b) { return true; } bool flag = a is JSONNull || (object)a == null || a is JSONLazyCreator; bool flag2 = b is JSONNull || b == null || b is JSONLazyCreator; if (flag && flag2) { return true; } if (!flag) { return a.Equals(b); } return false; } public static bool operator !=(JSONNode a, object b) { return !(a == b); } public override bool Equals(object obj) { return (object)this == obj; } public override int GetHashCode() { return base.GetHashCode(); } internal static string Escape(string aText) { StringBuilder escapeBuilder = EscapeBuilder; escapeBuilder.Length = 0; if (escapeBuilder.Capacity < aText.Length + aText.Length / 10) { escapeBuilder.Capacity = aText.Length + aText.Length / 10; } foreach (char c in aText) { switch (c) { case '\\': escapeBuilder.Append("\\\\"); continue; case '"': escapeBuilder.Append("\\\""); continue; case '\n': escapeBuilder.Append("\\n"); continue; case '\r': escapeBuilder.Append("\\r"); continue; case '\t': escapeBuilder.Append("\\t"); continue; case '\b': escapeBuilder.Append("\\b"); continue; case '\f': escapeBuilder.Append("\\f"); continue; } if (c < ' ' || (forceASCII && c > '\u007f')) { ushort num = c; escapeBuilder.Append("\\u").Append(num.ToString("X4")); } else { escapeBuilder.Append(c); } } string result = escapeBuilder.ToString(); escapeBuilder.Length = 0; return result; } private static JSONNode ParseElement(string token, bool quoted) { if (quoted) { return token; } if (token.Length <= 5) { string text = token.ToLower(); switch (text) { case "false": case "true": return text == "true"; case "null": return JSONNull.CreateOrGet(); } } if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return result; } return token; } public static JSONNode Parse(string aJSON) { Stack<JSONNode> stack = new Stack<JSONNode>(); JSONNode jSONNode = null; int i = 0; StringBuilder stringBuilder = new StringBuilder(); string aKey = ""; bool flag = false; bool flag2 = false; bool flag3 = false; for (; i < aJSON.Length; i++) { switch (aJSON[i]) { case '{': if (flag) { stringBuilder.Append(aJSON[i]); break; } stack.Push(new JSONObject()); if (jSONNode != null) { jSONNode.Add(aKey, stack.Peek()); } aKey = ""; stringBuilder.Length = 0; jSONNode = stack.Peek(); flag3 = false; break; case '[': if (flag) { stringBuilder.Append(aJSON[i]); break; } stack.Push(new JSONArray()); if (jSONNode != null) { jSONNode.Add(aKey, stack.Peek()); } aKey = ""; stringBuilder.Length = 0; jSONNode = stack.Peek(); flag3 = false; break; case ']': case '}': if (flag) { stringBuilder.Append(aJSON[i]); break; } if (stack.Count == 0) { throw new Exception("JSON Parse: Too many closing brackets"); } stack.Pop(); if (stringBuilder.Length > 0 || flag2) { jSONNode.Add(aKey, ParseElement(stringBuilder.ToString(), flag2)); } if (jSONNode != null) { jSONNode.Inline = !flag3; } flag2 = false; aKey = ""; stringBuilder.Length = 0; if (stack.Count > 0) { jSONNode = stack.Peek(); } break; case ':': if (flag) { stringBuilder.Append(aJSON[i]); break; } aKey = stringBuilder.ToString(); stringBuilder.Length = 0; flag2 = false; break; case '"': flag = !flag; flag2 = flag2 || flag; break; case ',': if (flag) { stringBuilder.Append(aJSON[i]); break; } if (stringBuilder.Length > 0 || flag2) { jSONNode.Add(aKey, ParseElement(stringBuilder.ToString(), flag2)); } flag2 = false; aKey = ""; stringBuilder.Length = 0; flag2 = false; break; case '\n': case '\r': flag3 = true; break; case '\t': case ' ': if (flag) { stringBuilder.Append(aJSON[i]); } break; case '\\': i++; if (flag) { char c = aJSON[i]; switch (c) { case 't': stringBuilder.Append('\t'); break; case 'r': stringBuilder.Append('\r'); break; case 'n': stringBuilder.Append('\n'); break; case 'b': stringBuilder.Append('\b'); break; case 'f': stringBuilder.Append('\f'); break; case 'u': { string s = aJSON.Substring(i + 1, 4); stringBuilder.Append((char)int.Parse(s, NumberStyles.AllowHexSpecifier)); i += 4; break; } default: stringBuilder.Append(c); break; } } break; case '/': if (allowLineComments && !flag && i + 1 < aJSON.Length && aJSON[i + 1] == '/') { while (++i < aJSON.Length && aJSON[i] != '\n' && aJSON[i] != '\r') { } } else { stringBuilder.Append(aJSON[i]); } break; default: stringBuilder.Append(aJSON[i]); break; case '\ufeff': break; } } if (flag) { throw new Exception("JSON Parse: Quotation marks seems to be messed up."); } if (jSONNode == null) { return ParseElement(stringBuilder.ToString(), flag2); } return jSONNode; } } public class JSONArray : JSONNode { private List<JSONNode> m_List = new List<JSONNode>(); private bool inline; public override bool Inline { get { return inline; } set { inline = value; } } public override JSONNodeType Tag => JSONNodeType.Array; public override bool IsArray => true; public override JSONNode this[int aIndex] { get { if (aIndex < 0 || aIndex >= m_List.Count) { return new JSONLazyCreator(this); } return m_List[aIndex]; } set { if (value == null) { value = JSONNull.CreateOrGet(); } if (aIndex < 0 || aIndex >= m_List.Count) { m_List.Add(value); } else { m_List[aIndex] = value; } } } public override JSONNode this[string aKey] { get { return new JSONLazyCreator(this); } set { if (value == null) { value = JSONNull.CreateOrGet(); } m_List.Add(value); } } public override int Count => m_List.Count; public override IEnumerable<JSONNode> Children { get { foreach (JSONNode item in m_List) { yield return item; } } } public override Enumerator GetEnumerator() { return new Enumerator(m_List.GetEnumerator()); } public override void Add(string aKey, JSONNode aItem) { if (aItem == null) { aItem = JSONNull.CreateOrGet(); } m_List.Add(aItem); } public override JSONNode Remove(int aIndex) { if (aIndex < 0 || aIndex >= m_List.Count) { return null; } JSONNode result = m_List[aIndex]; m_List.RemoveAt(aIndex); return result; } public override JSONNode Remove(JSONNode aNode) { m_List.Remove(aNode); return aNode; } public override void Clear() { m_List.Clear(); } public override JSONNode Clone() { JSONArray jSONArray = new JSONArray(); jSONArray.m_List.Capacity = m_List.Capacity; foreach (JSONNode item in m_List) { if (item != null) { jSONArray.Add(item.Clone()); } else { jSONArray.Add(null); } } return jSONArray; } internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) { aSB.Append('['); int count = m_List.Count; if (inline) { aMode = JSONTextMode.Compact; } for (int i = 0; i < count; i++) { if (i > 0) { aSB.Append(','); } if (aMode == JSONTextMode.Indent) { aSB.AppendLine(); } if (aMode == JSONTextMode.Indent) { aSB.Append(' ', aIndent + aIndentInc); } m_List[i].WriteToStringBuilder(aSB, aIndent + aIndentInc, aIndentInc, aMode); } if (aMode == JSONTextMode.Indent) { aSB.AppendLine().Append(' ', aIndent); } aSB.Append(']'); } } public class JSONObject : JSONNode { private Dictionary<string, JSONNode> m_Dict = new Dictionary<string, JSONNode>(); private bool inline; public override bool Inline { get { return inline; } set { inline = value; } } public override JSONNodeType Tag => JSONNodeType.Object; public override bool IsObject => true; public override JSONNode this[string aKey] { get { if (m_Dict.ContainsKey(aKey)) { return m_Dict[aKey]; } return new JSONLazyCreator(this, aKey); } set { if (value == null) { value = JSONNull.CreateOrGet(); } if (m_Dict.ContainsKey(aKey)) { m_Dict[aKey] = value; } else { m_Dict.Add(aKey, value); } } } public override JSONNode this[int aIndex] { get { if (aIndex < 0 || aIndex >= m_Dict.Count) { return null; } return m_Dict.ElementAt(aIndex).Value; } set { if (value == null) { value = JSONNull.CreateOrGet(); } if (aIndex >= 0 && aIndex < m_Dict.Count) { string key = m_Dict.ElementAt(aIndex).Key; m_Dict[key] = value; } } } public override int Count => m_Dict.Count; public override IEnumerable<JSONNode> Children { get { foreach (KeyValuePair<string, JSONNode> item in m_Dict) { yield return item.Value; } } } public override Enumerator GetEnumerator() { return new Enumerator(m_Dict.GetEnumerator()); } public override void Add(string aKey, JSONNode aItem) { if (aItem == null) { aItem = JSONNull.CreateOrGet(); } if (aKey != null) { if (m_Dict.ContainsKey(aKey)) { m_Dict[aKey] = aItem; } else { m_Dict.Add(aKey, aItem); } } else { m_Dict.Add(Guid.NewGuid().ToString(), aItem); } } public override JSONNode Remove(string aKey) { if (!m_Dict.ContainsKey(aKey)) { return null; } JSONNode result = m_Dict[aKey]; m_Dict.Remove(aKey); return result; } public override JSONNode Remove(int aIndex) { if (aIndex < 0 || aIndex >= m_Dict.Count) { return null; } KeyValuePair<string, JSONNode> keyValuePair = m_Dict.ElementAt(aIndex); m_Dict.Remove(keyValuePair.Key); return keyValuePair.Value; } public override JSONNode Remove(JSONNode aNode) { try { KeyValuePair<string, JSONNode> keyValuePair = m_Dict.Where((KeyValuePair<string, JSONNode> k) => k.Value == aNode).First(); m_Dict.Remove(keyValuePair.Key); return aNode; } catch { return null; } } public override void Clear() { m_Dict.Clear(); } public override JSONNode Clone() { JSONObject jSONObject = new JSONObject(); foreach (KeyValuePair<string, JSONNode> item in m_Dict) { jSONObject.Add(item.Key, item.Value.Clone()); } return jSONObject; } public override bool HasKey(string aKey) { return m_Dict.ContainsKey(aKey); } public override JSONNode GetValueOrDefault(string aKey, JSONNode aDefault) { if (m_Dict.TryGetValue(aKey, out var value)) { return value; } return aDefault; } internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) { aSB.Append('{'); bool flag = true; if (inline) { aMode = JSONTextMode.Compact; } foreach (KeyValuePair<string, JSONNode> item in m_Dict) { if (!flag) { aSB.Append(','); } flag = false; if (aMode == JSONTextMode.Indent) { aSB.AppendLine(); } if (aMode == JSONTextMode.Indent) { aSB.Append(' ', aIndent + aIndentInc); } aSB.Append('"').Append(JSONNode.Escape(item.Key)).Append('"'); if (aMode == JSONTextMode.Compact) { aSB.Append(':'); } else { aSB.Append(" : "); } item.Value.WriteToStringBuilder(aSB, aIndent + aIndentInc, aIndentInc, aMode); } if (aMode == JSONTextMode.Indent) { aSB.AppendLine().Append(' ', aIndent); } aSB.Append('}'); } } public class JSONString : JSONNode { private string m_Data; public override JSONNodeType Tag => JSONNodeType.String; public override bool IsString => true; public override string Value { get { return m_Data; } set { m_Data = value; } } public override Enumerator GetEnumerator() { return default(Enumerator); } public JSONString(string aData) { m_Data = aData; } public override JSONNode Clone() { return new JSONString(m_Data); } internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) { aSB.Append('"').Append(JSONNode.Escape(m_Data)).Append('"'); } public override bool Equals(object obj) { if (base.Equals(obj)) { return true; } if (obj is string text) { return m_Data == text; } JSONString jSONString = obj as JSONString; if (jSONString != null) { return m_Data == jSONString.m_Data; } return false; } public override int GetHashCode() { return m_Data.GetHashCode(); } public override void Clear() { m_Data = ""; } } public class JSONNumber : JSONNode { private double m_Data; public override JSONNodeType Tag => JSONNodeType.Number; public override bool IsNumber => true; public override string Value { get { return m_Data.ToString(CultureInfo.InvariantCulture); } set { if (double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { m_Data = result; } } } public override double AsDouble { get { return m_Data; } set { m_Data = value; } } public override long AsLong { get { return (long)m_Data; } set { m_Data = value; } } public override ulong AsULong { get { return (ulong)m_Data; } set { m_Data = value; } } public override Enumerator GetEnumerator() { return default(Enumerator); } public JSONNumber(double aData) { m_Data = aData; } public JSONNumber(string aData) { Value = aData; } public override JSONNode Clone() { return new JSONNumber(m_Data); } internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) { aSB.Append(Value); } private static bool IsNumeric(object value) { if (!(value is int) && !(value is uint) && !(value is float) && !(value is double) && !(value is decimal) && !(value is long) && !(value is ulong) && !(value is short) && !(value is ushort) && !(value is sbyte)) { return value is byte; } return true; } public override bool Equals(object obj) { if (obj == null) { return false; } if (base.Equals(obj)) { return true; } JSONNumber jSONNumber = obj as JSONNumber; if (jSONNumber != null) { return m_Data == jSONNumber.m_Data; } if (IsNumeric(obj)) { return Convert.ToDouble(obj) == m_Data; } return false; } public override int GetHashCode() { return m_Data.GetHashCode(); } public override void Clear() { m_Data = 0.0; } } public class JSONBool : JSONNode { private bool m_Data; public override JSONNodeType Tag => JSONNodeType.Boolean; public override bool IsBoolean => true; public override string Value { get { return m_Data.ToString(); } set { if (bool.TryParse(value, out var result)) { m_Data = result; } } } public override bool AsBool { get { return m_Data; } set { m_Data = value; } } public override Enumerator GetEnumerator() { return default(Enumerator); } public JSONBool(bool aData) { m_Data = aData; } public JSONBool(string aData) { Value = aData; } public override JSONNode Clone() { return new JSONBool(m_Data); } internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) { aSB.Append(m_Data ? "true" : "false"); } public override bool Equals(object obj) { if (obj == null) { return false; } if (obj is bool) { return m_Data == (bool)obj; } return false; } public override int GetHashCode() { return m_Data.GetHashCode(); } public override void Clear() { m_Data = false; } } public class JSONNull : JSONNode { private static JSONNull m_StaticInstance = new JSONNull(); public static bool reuseSameInstance = true; public override JSONNodeType Tag => JSONNodeType.NullValue; public override bool IsNull => true; public override string Value { get { return "null"; } set { } } public override bool AsBool { get { return false; } set { } } public static JSONNull CreateOrGet() { if (reuseSameInstance) { return m_StaticInstance; } return new JSONNull(); } private JSONNull() { } public override Enumerator GetEnumerator() { return default(Enumerator); } public override JSONNode Clone() { return CreateOrGet(); } public override bool Equals(object obj) { if ((object)this == obj) { return true; } return obj is JSONNull; } public override int GetHashCode() { return 0; } internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) { aSB.Append("null"); } } internal class JSONLazyCreator : JSONNode { private JSONNode m_Node; private string m_Key; public override JSONNodeType Tag => JSONNodeType.None; public override JSONNode this[int aIndex] { get { return new JSONLazyCreator(this); } set { Set(new JSONArray()).Add(value); } } public override JSONNode this[string aKey] { get { return new JSONLazyCreator(this, aKey); } set { Set(new JSONObject()).Add(aKey, value); } } public override int AsInt { get { Set(new JSONNumber(0.0)); return 0; } set { Set(new JSONNumber(value)); } } public override float AsFloat { get { Set(new JSONNumber(0.0)); return 0f; } set { Set(new JSONNumber(value)); } } public override double AsDouble { get { Set(new JSONNumber(0.0)); return 0.0; } set { Set(new JSONNumber(value)); } } public override long AsLong { get { if (JSONNode.longAsString) { Set(new JSONString("0")); } else { Set(new JSONNumber(0.0)); } return 0L; } set { if (JSONNode.longAsString) { Set(new JSONString(value.ToString(CultureInfo.InvariantCulture))); } else { Set(new JSONNumber(value)); } } } public override ulong AsULong { get { if (JSONNode.longAsString) { Set(new JSONString("0")); } else { Set(new JSONNumber(0.0)); } return 0uL; } set { if (JSONNode.longAsString) { Set(new JSONString(value.ToString(CultureInfo.InvariantCulture))); } else { Set(new JSONNumber(value)); } } } public override bool AsBool { get { Set(new JSONBool(aData: false)); return false; } set { Set(new JSONBool(value)); } } public override JSONArray AsArray => Set(new JSONArray()); public override JSONObject AsObject => Set(new JSONObject()); public override Enumerator GetEnumerator() { return default(Enumerator); } public JSONLazyCreator(JSONNode aNode) { m_Node = aNode; m_Key = null; } public JSONLazyCreator(JSONNode aNode, string aKey) { m_Node = aNode; m_Key = aKey; } private T Set<T>(T aVal) where T : JSONNode { if (m_Key == null) { m_Node.Add(aVal); } else { m_Node.Add(m_Key, aVal); } m_Node = null; return aVal; } public override void Add(JSONNode aItem) { Set(new JSONArray()).Add(aItem); } public override void Add(string aKey, JSONNode aItem) { Set(new JSONObject()).Add(aKey, aItem); } public static bool operator ==(JSONLazyCreator a, object b) { if (b == null) { return true; } return (object)a == b; } public static bool operator !=(JSONLazyCreator a, object b) { return !(a == b); } public override bool Equals(object obj) { if (obj == null) { return true; } return (object)this == obj; } public override int GetHashCode() { return 0; } internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) { aSB.Append("null"); } } public static class JSON { public static JSONNode Parse(string aJSON) { return JSONNode.Parse(aJSON); } } } namespace RavenM { public class ActorPacket { public int Id; public string Name; public Vector3 Position; public float Lean; public Vector4? AirplaneInput; public Vector2? BoatInput; public Vector2? CarInput; public Vector3 FacingDirection; public Vector4? HelicopterInput; public float LadderInput; public Vector2 ParachuteInput; public float RangeInput; public Vector3 Velocity; public int ActiveWeaponHash; public int Team; public Vector3? MarkerPosition; public int Flags; public int Ammo; public float Health; public int VehicleId; public int Seat; public int MovingPlatformVehicleId; public float TargetDetectionProgress; } public enum ActorStateFlags { AiControlled = 1, DeployParachute = 2, Fire = 4, Aiming = 8, IsMoving = 0x10, IdlePose = 0x20, OnGround = 0x40, ProjectToGround = 0x80, IsAlert = 0x100, HoldingSprint = 0x200, IsSprinting = 0x400, Crouch = 0x800, IsAirborne = 0x1000, IsOnPlayerSquad = 0x2000, IsReadyToPickUpPassengers = 0x4000, IsTakingFire = 0x8000, Jump = 0x10000, Prone = 0x20000, Reload = 0x40000, Dead = 0x80000 } public class ActorFlagsPacket { public int Id; public int StateVector; } public class BulkActorUpdate { public List<ActorPacket> Updates; } public class BulkFlagsUpdate { public List<ActorFlagsPacket> Updates; } public class RemoveActorPacket { public int Id; } public class ChatCommandPacket { public int Id; public ulong SteamID; public string Command; public bool Scripted; } public class ChatManager : MonoBehaviour { private string _currentChatMessage = string.Empty; private string _fullChatLink = string.Empty; private Vector2 _chatScrollPosition = Vector2.zero; private List<string> _chatPositionOptions = new List<string> { "Left", "Right" }; private int _selectedChatPosition; private Texture2D _greyBackground = new Texture2D(1, 1); private bool _justFocused; private bool _typeIntention; private bool _chatMode; private CommandManager _commandManager; private KeyCode _globalChatKeybind = (KeyCode)121; private KeyCode _teamChatKeybind = (KeyCode)117; private CSteamID _steamId; private string _steamUsername; public static ChatManager instance; public string CurrentChatMessage { get { return _currentChatMessage; } set { _currentChatMessage = value; } } public string FullChatLink { get { return _fullChatLink; } set { _fullChatLink = value; } } public Vector2 ChatScrollPosition { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _chatScrollPosition; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _chatScrollPosition = value; } } public List<string> ChatPositionOptions => _chatPositionOptions; public int SelectedChatPosition { get { return _selectedChatPosition; } set { _selectedChatPosition = value; } } public Texture2D GreyBackground { get { return _greyBackground; } set { _greyBackground = value; } } public bool JustFocused { get { return _justFocused; } set { _justFocused = value; } } public bool TypeIntention { get { return _typeIntention; } set { _typeIntention = value; } } public bool ChatMode { get { return _chatMode; } set { _chatMode = value; } } public CommandManager CommandManager { get { return _commandManager; } set { _commandManager = value; } } public KeyCode GlobalChatKeybind { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _globalChatKeybind; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _globalChatKeybind = value; } } public KeyCode TeamChatKeybind { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _teamChatKeybind; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _teamChatKeybind = value; } } public CSteamID SteamId { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _steamId; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _steamId = value; } } public string SteamUsername { get { return _steamUsername; } private set { _steamUsername = value; } } private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) instance = this; GreyBackground.SetPixel(0, 0, Color.grey * 0.3f); GreyBackground.Apply(); CommandManager = new CommandManager(); SteamId = SteamUser.GetSteamID(); } private void Start() { Callback<PersonaStateChange_t>.Create((DispatchDelegate<PersonaStateChange_t>)OnPersonaStateChange); Callback<LobbyChatMsg_t>.Create((DispatchDelegate<LobbyChatMsg_t>)OnLobbyChatMessage); Callback<LobbyChatUpdate_t>.Create((DispatchDelegate<LobbyChatUpdate_t>)OnLobbyChatUpdate); } private void OnPersonaStateChange(PersonaStateChange_t pCallback) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (SteamId == (CSteamID)pCallback.m_ulSteamID) { SteamUsername = SteamFriends.GetFriendPersonaName(SteamId); } } private void OnLobbyChatMessage(LobbyChatMsg_t pCallback) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) ulong ulSteamIDUser = pCallback.m_ulSteamIDUser; byte[] array = new byte[4096]; CSteamID val = default(CSteamID); EChatEntryType val2 = default(EChatEntryType); int lobbyChatEntry = SteamMatchmaking.GetLobbyChatEntry(LobbySystem.instance.ActualLobbyID, (int)pCallback.m_iChatID, ref val, array, array.Length, ref val2); string text = DecodeLobbyChat(array, lobbyChatEntry); if (ulSteamIDUser != SteamId.m_SteamID) { if (text.StartsWith("/") && val == LobbySystem.instance.OwnerID) { ProcessLobbyChatCommand(text, SteamId.m_SteamID, local: true); } else { PushLobbyChatMessage(text, SteamFriends.GetFriendPersonaName((CSteamID)ulSteamIDUser)); } } } private void OnLobbyChatUpdate(LobbyChatUpdate_t pCallback) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if ((pCallback.m_rgfChatMemberStateChange & 1) == 0) { CSteamID val = default(CSteamID); ((CSteamID)(ref val))..ctor(pCallback.m_ulSteamIDUserChanged); if (LobbySystem.instance.OwnerID == val) { LobbySystem.instance.NotificationText = "Lobby closed by host."; SteamMatchmaking.LeaveLobby(LobbySystem.instance.ActualLobbyID); } } else { CSteamID val2 = default(CSteamID); ((CSteamID)(ref val2))..ctor(pCallback.m_ulSteamIDUserChanged); if (LobbySystem.instance.CurrentKickedMembers.Contains(val2)) { SendLobbyChat($"/kick {val2}"); } } } public void PushChatMessage(Actor actor, string message, bool global, int team) { string text = ((!((Object)(object)actor != (Object)null)) ? "" : actor.name); if (global || GameManager.PlayerTeam() == team) { if (team == -1) { FullChatLink = FullChatLink + "<color=#eeeeee>" + message + "</color>\n"; } else { string text2 = ((!global) ? "green" : ((team == 0) ? "blue" : "red")); FullChatLink = FullChatLink + "<color=" + text2 + "><b><" + text + "></b></color> " + message + "\n"; RavenscriptEventsManagerPatch.events.onReceiveChatMessage.Invoke(actor, message); } _chatScrollPosition.y = float.PositiveInfinity; } } public void PushLobbyChatMessage(string message, string steamUsername) { string text = "white"; FullChatLink = FullChatLink + "<color=" + text + "><b><" + steamUsername + "></b></color> " + message + "\n"; _chatScrollPosition.y = float.PositiveInfinity; } public void PushLobbyChatMessage(string message) { FullChatLink = FullChatLink + message + "\n"; _chatScrollPosition.y = float.PositiveInfinity; } public void PushLobbyCommandChatMessage(string message, Color color, bool teamOnly, bool sendToAll) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) FullChatLink = FullChatLink + "<color=#" + ColorUtility.ToHtmlStringRGB(color) + "><b>" + message + "</b></color>\n"; _chatScrollPosition.y = float.PositiveInfinity; if (sendToAll) { SendLobbyChat(message); } } public void PushCommandChatMessage(string message, Color color, bool teamOnly, bool sendToAll) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) FullChatLink = FullChatLink + "<color=#" + ColorUtility.ToHtmlStringRGB(color) + "><b>" + message + "</b></color>\n"; _chatScrollPosition.y = float.PositiveInfinity; if (!sendToAll) { return; } using MemoryStream memoryStream = new MemoryStream(); ChatPacket value = new ChatPacket { Id = ((Component)ActorManager.instance.player).GetComponent<GuidComponent>().guid, Message = message, TeamOnly = teamOnly }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.Chat, 8); } public void ProcessLobbyChatCommand(string message, ulong id, bool local) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) string[] array = message.Trim().Substring(1, message.Length - 1).Split(new char[1] { ' ' }); string text = array[0]; if (string.IsNullOrEmpty(text)) { return; } if (!CommandManager.ContainsCommand(text)) { PushLobbyCommandChatMessage("No command with the name " + text + " found.\nFor more information use Command /help", Color.red, teamOnly: false, sendToAll: false); return; } Command commandFromName = CommandManager.GetCommandFromName(text); if (commandFromName == null) { Plugin.logger.LogError((object)("Command " + text + " is not a registered Command!")); return; } if (!commandFromName.AllowInLobby) { PushLobbyCommandChatMessage(commandFromName.AllowInGame ? "This command is not allowed in the lobby!" : "This command is disabled!", Color.red, teamOnly: true, sendToAll: false); return; } bool flag = CommandManager.HasPermission(commandFromName, id, local); bool flag2 = true; if (commandFromName.reqArgs[0] != null) { flag2 = CommandManager.HasRequiredArgs(commandFromName, array); } switch (commandFromName.CommandName) { case "nametags": { if (!local) { GameUI.instance.ToggleNameTags(); PushLobbyCommandChatMessage("Set nametags to " + array[1], Color.green, teamOnly: false, sendToAll: false); return; } if (!flag || !flag2) { return; } if (bool.TryParse(array[1], out var result2)) { LobbySystem.instance.SetLobbyDataDedup("nameTags", result2.ToString()); PushLobbyCommandChatMessage("Set nameTags to " + result2, Color.green, teamOnly: false, sendToAll: false); GameUI.instance.ToggleNameTags(); } break; } case "nametagsteamonly": { if (!local) { GameUI.instance.ToggleNameTags(); PushLobbyCommandChatMessage("Set nameTags for Team only to " + array[1], Color.green, teamOnly: false, sendToAll: false); return; } if (!flag || !flag2) { return; } if (bool.TryParse(array[1], out var result3)) { LobbySystem.instance.SetLobbyDataDedup("nameTagsForTeamOnly", result3.ToString()); PushLobbyCommandChatMessage("Set nameTags for Team only to " + result3, Color.green, teamOnly: false, sendToAll: false); GameUI.instance.ToggleNameTags(); } break; } case "help": foreach (Command allLobbyCommand in CommandManager.GetAllLobbyCommands()) { PushLobbyCommandChatMessage($"{CommandManager.GetRequiredArgTypes(allLobbyCommand)} Host Only: {allLobbyCommand.HostOnly}", allLobbyCommand.Scripted ? Color.green : Color.yellow, teamOnly: true, sendToAll: false); } break; case "kick": { if (ulong.TryParse(array[1], out var result)) { CSteamID val = default(CSteamID); ((CSteamID)(ref val))..ctor(result); if (val == SteamId) { LobbySystem.instance.NotificationText = "You were kicked from the lobby! You can no longer join this lobby."; SteamMatchmaking.LeaveLobby(LobbySystem.instance.ActualLobbyID); } else if (!LobbySystem.instance.CurrentKickedMembers.Contains(val)) { LobbySystem.instance.CurrentKickedMembers.Add(val); } } break; } default: Plugin.logger.LogInfo((object)("Lobby onReceiveCommand " + text)); break; } if (!commandFromName.Global != local) { SendLobbyChat(message); } } public void ProcessChatCommand(string message, Actor actor, ulong id, bool local) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) string[] array = message.Trim().Substring(1, message.Length - 1).Split(new char[1] { ' ' }); string text = array[0]; if (string.IsNullOrEmpty(text)) { return; } if (!CommandManager.ContainsCommand(text)) { PushCommandChatMessage("No Command with name " + text + " found.\nFor more information use Command /help", Color.red, teamOnly: false, sendToAll: false); return; } Command commandFromName = CommandManager.GetCommandFromName(text); if (commandFromName == null) { Plugin.logger.LogError((object)("Command " + text + " is not a registered Command!")); return; } bool flag = CommandManager.HasPermission(commandFromName, id, local); bool flag2 = true; if (commandFromName.reqArgs[0] != null) { flag2 = CommandManager.HasRequiredArgs(commandFromName, array); } switch (commandFromName.CommandName) { case "nametags": { if (!local) { GameUI.instance.ToggleNameTags(); PushCommandChatMessage("Set nametags to " + array[1], Color.green, teamOnly: false, sendToAll: false); return; } if (!flag || !flag2) { return; } if (bool.TryParse(array[1], out var result3)) { LobbySystem.instance.SetLobbyDataDedup("nameTags", result3.ToString()); PushCommandChatMessage("Set nameTags to " + result3, Color.green, teamOnly: false, sendToAll: false); GameUI.instance.ToggleNameTags(); } break; } case "nametagsteamonly": { if (!local) { GameUI.instance.ToggleNameTags(); PushCommandChatMessage("Set nameTags for Team only to " + array[1], Color.green, teamOnly: false, sendToAll: false); return; } if (!flag || !flag2) { return; } if (bool.TryParse(array[1], out var result2)) { LobbySystem.instance.SetLobbyDataDedup("nameTagsForTeamOnly", result2.ToString()); PushCommandChatMessage("Set nameTags for Team only to " + result2, Color.green, teamOnly: false, sendToAll: false); GameUI.instance.ToggleNameTags(); } break; } case "help": foreach (Command allIngameCommand in CommandManager.GetAllIngameCommands()) { PushCommandChatMessage($"{CommandManager.GetRequiredArgTypes(allIngameCommand)} Host Only: {allIngameCommand.HostOnly}", allIngameCommand.Scripted ? Color.green : Color.yellow, teamOnly: true, sendToAll: false); } break; case "kill": { if (!flag || !flag2) { return; } string name = array[1]; Actor actorByName = CommandManager.GetActorByName(name); if ((Object)(object)actorByName == (Object)null) { return; } actorByName.Kill(new DamageInfo((DamageSourceType)6, actor, (Weapon)null)); PushCommandChatMessage("Killed actor " + actorByName.name, Color.green, teamOnly: false, sendToAll: false); break; } case "kick": { if (ulong.TryParse(array[1], out var result)) { CSteamID val = default(CSteamID); ((CSteamID)(ref val))..ctor(result); if (val == SteamId) { LobbySystem.instance.NotificationText = "You were kicked from the lobby! You can no longer join this lobby."; SteamMatchmaking.LeaveLobby(LobbySystem.instance.ActualLobbyID); } else if (!LobbySystem.instance.CurrentKickedMembers.Contains(val)) { LobbySystem.instance.CurrentKickedMembers.Add(val); } } break; } default: Plugin.logger.LogInfo((object)("Ingame onReceiveCommand " + text)); RavenscriptEventsManagerPatch.events.onReceiveCommand.Invoke(actor, array, new bool[3] { flag, flag2, !local }); break; } if (!commandFromName.Global == local) { return; } using MemoryStream memoryStream = new MemoryStream(); ChatCommandPacket value = new ChatCommandPacket { Id = ((Component)ActorManager.instance.player).GetComponent<GuidComponent>().guid, SteamID = SteamId.m_SteamID, Command = CurrentChatMessage, Scripted = commandFromName.Scripted }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.ChatCommand, 8); } public void SendLobbyChat(string message) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) byte[] bytes = Encoding.UTF8.GetBytes(message); SteamMatchmaking.SendLobbyChatMsg(LobbySystem.instance.ActualLobbyID, bytes, bytes.Length); } public string DecodeLobbyChat(byte[] bytes, int len) { try { return Encoding.UTF8.GetString(bytes, 0, len); } catch { return string.Empty; } } public void InitializeChatArea(bool isLobbyChat = false, float chatWidth = 500f, float yOffset = 160f, float xOffset = 10f) { //IL_0011: 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_004a: Invalid comparison between Unknown and I4 //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Invalid comparison between Unknown and I4 //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Invalid comparison between Unknown and I4 //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) if (Event.current.isKey && (int)Event.current.keyCode == 0 && JustFocused) { Event.current.Use(); JustFocused = false; return; } if (Event.current.isKey && ((int)Event.current.keyCode == 9 || Event.current.character == '\t')) { Event.current.Use(); } if (TypeIntention) { GUI.SetNextControlName("chat"); CurrentChatMessage = GUI.TextField(new Rect(xOffset, (float)Screen.height - 160f, chatWidth - 70f, 25f), CurrentChatMessage); GUI.FocusControl("chat"); string text = ((!ChatMode) ? "green" : ((GameManager.PlayerTeam() == 0) ? "blue" : "red")); string text2 = (ChatMode ? "GLOBAL" : "TEAM"); GUI.Label(new Rect(xOffset + (chatWidth - 60f), (float)Screen.height - yOffset, 70f, 25f), "<color=" + text + "><b>" + text2 + "</b></color>"); if (Event.current.isKey && (int)Event.current.keyCode == 27 && TypeIntention) { TypeIntention = false; } if (Event.current.isKey && (int)Event.current.keyCode == 13) { if (!string.IsNullOrEmpty(CurrentChatMessage)) { if (CurrentChatMessage.Trim().StartsWith("/")) { if (isLobbyChat) { ProcessLobbyChatCommand(CurrentChatMessage, SteamId.m_SteamID, local: true); } else { ProcessChatCommand(CurrentChatMessage, ActorManager.instance.player, SteamId.m_SteamID, local: true); } CurrentChatMessage = string.Empty; } else { if (isLobbyChat) { PushLobbyChatMessage(CurrentChatMessage, SteamUsername); SendLobbyChat(CurrentChatMessage); } else { PushChatMessage(ActorManager.instance.player, CurrentChatMessage, ChatMode, GameManager.PlayerTeam()); using MemoryStream memoryStream = new MemoryStream(); ChatPacket value = new ChatPacket { Id = ((Component)ActorManager.instance.player).GetComponent<GuidComponent>().guid, Message = CurrentChatMessage, TeamOnly = !ChatMode }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.Chat, 8); } CurrentChatMessage = string.Empty; } } TypeIntention = false; } } if (Event.current.isKey && Event.current.keyCode == GlobalChatKeybind && !TypeIntention) { TypeIntention = true; JustFocused = true; ChatMode = true; } if (Event.current.isKey && Event.current.keyCode == TeamChatKeybind && !TypeIntention && !isLobbyChat) { TypeIntention = true; JustFocused = true; ChatMode = false; } } public void CreateChatArea(bool isLobbyChat = false, float chatWidth = 500f, float chatHeight = 200f, float chatYOffset = 370f, float chatXOffset = 10f, bool wordWrap = true, bool resetScrollPosition = true) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) InitializeChatArea(isLobbyChat, chatWidth, 160f, chatXOffset); GUIStyle val = new GUIStyle(); val.normal.background = GreyBackground; GUIStyle val2 = new GUIStyle(); val2.wordWrap = wordWrap; val2.normal.textColor = Color.white; if (!wordWrap) { val2.wordWrap = false; } GUILayout.BeginArea(new Rect(chatXOffset, (float)Screen.height - chatYOffset, chatWidth, chatHeight), string.Empty, val); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); ChatScrollPosition = GUILayout.BeginScrollView(ChatScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(chatWidth), GUILayout.Height(chatHeight - 15f) }); GUILayout.Label(FullChatLink, val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(chatWidth - 30f) }); GUILayout.EndScrollView(); GUILayout.Space(10f); GUILayout.EndVertical(); GUILayout.EndArea(); if (resetScrollPosition) { _chatScrollPosition.y = float.PositiveInfinity; } } public void ResetChat() { FullChatLink = string.Empty; } } public class ChatPacket { public int Id; public string Message; public bool TeamOnly; } [HarmonyPatch(typeof(Vehicle), "PopCountermeasures")] public class CountermeasuresPatch { private static void Prefix(Vehicle __instance) { if (!IngameNetManager.instance.IsClient) { return; } GuidComponent component = ((Component)__instance).GetComponent<GuidComponent>(); if ((Object)(object)component == (Object)null) { return; } int guid = component.guid; if (!IngameNetManager.instance.OwnedVehicles.Contains(guid)) { return; } using MemoryStream memoryStream = new MemoryStream(); CountermeasuresPacket value = new CountermeasuresPacket { VehicleId = guid }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.Countermeasures, 8); } } public class CountermeasuresPacket { public int VehicleId; } [HarmonyPatch(typeof(Actor), "Damage")] public class DamagePatch { private static void Postfix(Actor __instance, DamageInfo info, bool __result) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_00f4: Unknown result type (might be due to invalid IL or missing references) if (!IngameNetManager.instance.IsClient || !__result) { return; } int num = (((Object)(object)info.sourceActor == (Object)null) ? (-1) : ((Component)info.sourceActor).GetComponent<GuidComponent>().guid); int guid = ((Component)__instance).GetComponent<GuidComponent>().guid; if ((num == -1 && !IngameNetManager.instance.OwnedActors.Contains(guid)) || !IngameNetManager.instance.OwnedActors.Contains(num)) { return; } Plugin.logger.LogInfo((object)("Sending damage from: " + __instance.name)); using MemoryStream memoryStream = new MemoryStream(); DamagePacket value = new DamagePacket { Type = info.type, HealthDamage = info.healthDamage, BalanceDamage = info.balanceDamage, IsSplashDamage = info.isSplashDamage, IsPiercing = info.isPiercing, IsCriticalHit = info.isCriticalHit, Point = info.point, Direction = info.direction, ImpactForce = info.impactForce, SourceActor = num, Target = guid, Silent = false }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.Damage, 8); } } [HarmonyPatch(typeof(Actor), "Die")] public class DiePatch { private static void Postfix(Actor __instance, DamageInfo info, bool isSilentKill) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (!IngameNetManager.instance.IsClient) { return; } int num = (((Object)(object)info.sourceActor == (Object)null) ? (-1) : ((Component)info.sourceActor).GetComponent<GuidComponent>().guid); int guid = ((Component)__instance).GetComponent<GuidComponent>().guid; if ((num == -1 && !IngameNetManager.instance.OwnedActors.Contains(guid)) || !IngameNetManager.instance.OwnedActors.Contains(num)) { return; } Plugin.logger.LogInfo((object)("Sending death from: " + __instance.name)); using MemoryStream memoryStream = new MemoryStream(); DamagePacket value = new DamagePacket { Type = info.type, HealthDamage = info.healthDamage, BalanceDamage = info.balanceDamage, IsSplashDamage = info.isSplashDamage, IsPiercing = info.isPiercing, IsCriticalHit = info.isCriticalHit, Point = info.point, Direction = info.direction, ImpactForce = info.impactForce, SourceActor = num, Target = guid, Silent = isSilentKill }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.Death, 8); } } [HarmonyPatch(typeof(Vehicle), "Damage")] public class VehicleDamagePatch { private static void Postfix(Vehicle __instance, DamageInfo info) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (!IngameNetManager.instance.IsClient) { return; } int num = (((Object)(object)info.sourceActor == (Object)null) ? (-1) : ((Component)info.sourceActor).GetComponent<GuidComponent>().guid); int guid = ((Component)__instance).GetComponent<GuidComponent>().guid; if ((num == -1 && !IngameNetManager.instance.OwnedVehicles.Contains(guid)) || !IngameNetManager.instance.OwnedActors.Contains(num)) { return; } Plugin.logger.LogInfo((object)("Sending vehicle damage from: " + __instance.name)); using MemoryStream memoryStream = new MemoryStream(); DamagePacket value = new DamagePacket { Type = info.type, HealthDamage = info.healthDamage, BalanceDamage = info.balanceDamage, IsSplashDamage = info.isSplashDamage, IsPiercing = info.isPiercing, IsCriticalHit = info.isCriticalHit, Point = info.point, Direction = info.direction, ImpactForce = info.impactForce, SourceActor = num, Target = guid, Silent = false }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.VehicleDamage, 8); } } public class DamagePacket { public DamageSourceType Type; public float HealthDamage; public float BalanceDamage; public bool IsSplashDamage; public bool IsPiercing; public bool IsCriticalHit; public Vector3 Point; public Vector3 Direction; public Vector3 ImpactForce; public int SourceActor; public int Target; public bool Silent; } [HarmonyPatch(typeof(Destructible), "Die")] public class DestructibleDiePatch { private static void Prefix(Destructible __instance) { if (!IngameNetManager.instance.IsClient) { return; } GameObject obj = DestructiblePacket.Root(__instance); int guid = obj.GetComponent<GuidComponent>().guid; int num = Array.IndexOf(DestructiblePacket.GetDestructibles(obj), __instance); using MemoryStream memoryStream = new MemoryStream(); DestructibleDiePacket value = new DestructibleDiePacket { Id = guid, Index = num }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.DestroyDestructible, 8); Plugin.logger.LogInfo((object)$"Destroy {((Object)__instance).name} id {guid} idx {num}"); } } public class DestructiblePacket { public int Id; public bool FullUpdate; public int NameHash; public ulong Mod; public Vector3 Position; public Quaternion Rotation; public BitArray States; public static GameObject Root(Destructible destructible) { return ((Component)((Component)destructible).transform.root).gameObject; } public static Destructible[] GetDestructibles(GameObject root) { return root.GetComponentsInChildren<Destructible>(true); } } public class BulkDestructiblePacket { public List<DestructiblePacket> Updates; } public class DestructibleDiePacket { public int Id; public int Index; } public class DiscordIntegration : MonoBehaviour { public enum Activities { InitialActivity, InMenu, InLobby, InSinglePlayerGame } public static DiscordIntegration instance; public Discord Discord; public long discordClientID = 1007054793220571247L; public long startSessionTime; private ActivityManager _activityManager; private TimedAction _timer = new TimedAction(5f, false); private string _gameMode = "Insert Game Mode"; private bool _isInGame; private bool _isInLobby; [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern IntPtr LoadLibrary(string lpPathName); private void Start() { if (Environment.OSVersion.Platform == PlatformID.Win32NT && !Environment.Is64BitProcess) { LoadLibrary("BepInEx/plugins/lib/x86/discord_game_sdk"); } else if (Environment.OSVersion.Platform == PlatformID.Unix) { if (Directory.Exists("ravenfield_Data")) { if (!File.Exists("ravenfield_Data/Plugins/discord_game_sdk.so")) { Plugin.logger.LogWarning((object)"Linux Discord Library Not Found, Attempting to Copy it from lib folder"); File.Copy("BepInEx/plugins/lib/discord_game_sdk.so", "ravenfield_Data/Plugins/discord_game_sdk.so"); } } else if (Directory.Exists("ravenfield.app")) { if (!File.Exists("ravenfield.app/Contents/Plugins/discord_game_sdk.dylib")) { Plugin.logger.LogWarning((object)"MacOS Discord Library Not Found, Attempting to Copy it from lib folder"); File.Copy("BepInEx/plugins/lib/discord_game_sdk.dylib", "ravenfield.app/Contents/Plugins/discord_game_sdk.dylib"); } if (!File.Exists("ravenfield.app/Contents/Plugins/discord_game_sdk.bundle")) { Plugin.logger.LogWarning((object)"MacOS Discord Library Not Found, Attempting to Copy it from lib folder"); File.Copy("BepInEx/plugins/lib/discord_game_sdk.bundle", "ravenfield.app/Contents/Plugins/discord_game_sdk.bundle"); } } } try { Discord = new Discord(discordClientID, 1uL); } catch { Plugin.logger.LogError((object)"Failed to initialize Discord pipe."); return; } Plugin.logger.LogInfo((object)"Discord Instance created"); startSessionTime = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds(); _activityManager = Discord.GetActivityManager(); ((MonoBehaviour)this).StartCoroutine(StartActivities()); _activityManager.OnActivityJoin += delegate(string secret) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) secret = secret.Replace("_join", ""); Plugin.logger.LogInfo((object)("OnJoin " + secret)); CSteamID val = new CSteamID(ulong.Parse(secret)); if (_isInGame) { GameManager.ReturnToMenu(); } SteamMatchmaking.JoinLobby(val); LobbySystem.instance.InLobby = true; LobbySystem.instance.IsLobbyOwner = false; LobbySystem.instance.LobbyDataReady = false; }; _activityManager.OnActivityJoinRequest += delegate(ref User user) { Plugin.logger.LogInfo((object)$"OnJoinRequest {user.Username} {user.Id}"); }; } private IEnumerator StartActivities() { UpdateActivity(Discord, Activities.InitialActivity); yield return (object)new WaitUntil((Func<bool>)GameManager.IsInMainMenu); UpdateActivity(Discord, Activities.InMenu); } private void FixedUpdate() { if (Discord != null) { Discord.RunCallbacks(); if (((TimedAction)(ref _timer)).TrueDone()) { ChangeActivityDynamically(); ((TimedAction)(ref _timer)).Start(); } } } private void ChangeActivityDynamically() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameManager.instance == (Object)null) { return; } _isInGame = GameManager.instance.ingame; _isInLobby = LobbySystem.instance.InLobby; if (_isInGame && !_isInLobby) { Dropdown gameModeDropdown = InstantActionMaps.instance.gameModeDropdown; _gameMode = gameModeDropdown.options[gameModeDropdown.value].text; UpdateActivity(Discord, Activities.InSinglePlayerGame, inGame: true, _gameMode); } else if (_isInLobby) { int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(LobbySystem.instance.ActualLobbyID); int lobbyMemberLimit = SteamMatchmaking.GetLobbyMemberLimit(LobbySystem.instance.ActualLobbyID); if (!_isInGame) { Dropdown gameModeDropdown2 = InstantActionMaps.instance.gameModeDropdown; _gameMode = gameModeDropdown2.options[gameModeDropdown2.value].text; UpdateActivity(Discord, Activities.InLobby, inGame: false, _gameMode, numLobbyMembers, lobbyMemberLimit, ((object)(CSteamID)(ref LobbySystem.instance.ActualLobbyID)).ToString()); } else { UpdateActivity(Discord, Activities.InLobby, inGame: true, _gameMode, numLobbyMembers, lobbyMemberLimit, ((object)(CSteamID)(ref LobbySystem.instance.ActualLobbyID)).ToString()); } } else { UpdateActivity(Discord, Activities.InMenu); } } public void UpdateActivity(Discord discord, Activities activity, bool inGame = false, string gameMode = "None", int currentPlayers = 1, int maxPlayers = 2, string lobbyID = "None") { ActivityManager activityManager = discord.GetActivityManager(); Activity activity2 = default(Activity); switch (activity) { case Activities.InitialActivity: { Activity activity3 = default(Activity); activity3.State = "Just Started Playing"; activity3.Assets.LargeImage = "rfimg_1_"; activity3.Assets.LargeText = "RavenM"; activity3.Instance = true; activity2 = activity3; break; } case Activities.InMenu: { Activity activity3 = default(Activity); activity3.State = "Waiting In Menu"; activity3.Assets.LargeImage = "rfimg_1_"; activity3.Assets.LargeText = "RavenM"; activity3.Instance = true; activity2 = activity3; break; } case Activities.InLobby: { string state = (inGame ? "Playing Multiplayer" : "Waiting In Lobby"); Activity activity3 = default(Activity); activity3.State = state; activity3.Details = "Game Mode: " + gameMode; activity3.Timestamps.Start = startSessionTime; activity3.Assets.LargeImage = "rfimg_1_"; activity3.Assets.LargeText = "RavenM"; activity3.Party.Id = lobbyID; activity3.Party.Size.CurrentSize = currentPlayers; activity3.Party.Size.MaxSize = maxPlayers; activity3.Secrets.Join = lobbyID + "_join"; activity3.Instance = true; activity2 = activity3; break; } case Activities.InSinglePlayerGame: { Activity activity3 = default(Activity); activity3.State = "Playing Singleplayer"; activity3.Timestamps.Start = startSessionTime; activity3.Assets.LargeImage = "rfimg_1_"; activity3.Assets.LargeText = "RavenM"; activity3.Instance = true; activity2 = activity3; break; } } activityManager.UpdateActivity(activity2, delegate(Result result) { if (result != 0) { Plugin.logger.LogWarning((object)$"Update Discord Activity Err {result}"); } }); } } [HarmonyPatch(typeof(AiActorController), "CreateRougeSquad")] public class RogueSquadPatch { private static bool Prefix(AiActorController __instance) { if (!IngameNetManager.instance.IsClient) { return true; } if (!IngameNetManager.instance.OwnedActors.Contains(((Component)((ActorController)__instance).actor).GetComponent<GuidComponent>().guid)) { return false; } return true; } } [HarmonyPatch(typeof(Actor), "SwitchSeat")] public class SwitchSeatPatch { private static void Prefix(Actor __instance, int seatIndex, ref bool swapIfOccupied) { if (!swapIfOccupied || !__instance.IsSeated()) { return; } Seat val = __instance.seat.vehicle.seats[seatIndex]; if (!val.IsOccupied()) { return; } Actor occupant = val.occupant; GuidComponent component = ((Component)occupant).GetComponent<GuidComponent>(); if (!((Object)(object)component == (Object)null)) { int guid = component.guid; if (!IngameNetManager.instance.OwnedActors.Contains(guid) && ((occupant.controller as NetActorController).Targets.Flags & 1) == 0) { swapIfOccupied = false; } } } } [HarmonyPatch(typeof(Actor), "EnterSeat")] public class EnterSeatPatch { private static void Prefix(ref Seat seat, bool kickOutOccupant) { if (!kickOutOccupant || !seat.IsOccupied()) { return; } Actor occupant = seat.occupant; GuidComponent component = ((Component)occupant).GetComponent<GuidComponent>(); if ((Object)(object)component == (Object)null) { return; } int guid = component.guid; if (IngameNetManager.instance.OwnedActors.Contains(guid) || ((uint)(occupant.controller as NetActorController).Targets.Flags & (true ? 1u : 0u)) != 0) { return; } foreach (Seat seat2 in seat.vehicle.seats) { if (!seat2.IsOccupied()) { seat = seat2; return; } occupant = seat2.occupant; component = ((Component)occupant).GetComponent<GuidComponent>(); if (!((Object)(object)component == (Object)null)) { guid = component.guid; if (!IngameNetManager.instance.OwnedActors.Contains(guid) && ((uint)(occupant.controller as NetActorController).Targets.Flags & (true ? 1u : 0u)) != 0) { seat = seat2; return; } } } seat = null; } private static void Postfix(Actor __instance, Seat seat, bool kickOutOccupant, bool __result) { if (!IngameNetManager.instance.IsClient || !__result) { return; } GuidComponent component = ((Component)__instance).GetComponent<GuidComponent>(); if ((Object)(object)component == (Object)null) { return; } int guid = component.guid; if (!IngameNetManager.instance.OwnedActors.Contains(guid)) { return; } Vehicle vehicle = seat.vehicle; GuidComponent component2 = ((Component)vehicle).GetComponent<GuidComponent>(); if ((Object)(object)component2 == (Object)null) { return; } int guid2 = component2.guid; int num = vehicle.seats.IndexOf(seat); if (num == -1) { return; } Plugin.logger.LogInfo((object)$"Entering vehicle from: {__instance.name}. Seat ID: {num}"); if (!IngameNetManager.instance.IsHost && seat.IsDriverSeat()) { IngameNetManager.instance.OwnedVehicles.Add(guid2); vehicle.isInvulnerable = false; } using MemoryStream memoryStream = new MemoryStream(); EnterSeatPacket value = new EnterSeatPacket { ActorId = guid, VehicleId = guid2, SeatId = num }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.EnterSeat, 8); } } public class EnterSeatPacket { public int ActorId; public int VehicleId; public int SeatId; } [HarmonyPatch(typeof(ExplodingProjectile), "Explode")] public class ProjectileExplodePatch { private static void Prefix(ExplodingProjectile __instance, Vector3 position, Vector3 up) { if (!IngameNetManager.instance.IsClient) { return; } GuidComponent component = ((Component)__instance).GetComponent<GuidComponent>(); if ((Object)(object)component == (Object)null) { return; } int guid = component.guid; if (!IngameNetManager.instance.OwnedProjectiles.Contains(guid)) { return; } using MemoryStream memoryStream = new MemoryStream(); ExplodeProjectilePacket value = new ExplodeProjectilePacket { Id = guid }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.Explode, 8); } } public class ExplodeProjectilePacket { public int Id; } [HarmonyPatch(typeof(BattleMode), "DrainTicket")] public class NoDrainPatch { private static bool Prefix(BattleMode __instance, int team) { if (!IngameNetManager.instance.IsClient) { return true; } if (!IngameNetManager.instance.IsHost) { return false; } return true; } } public class BattleStatePacket { public int[] RemainingBattalions; public int[] Tickets; public int[] SpawnPointOwners; } [HarmonyPatch(typeof(DominationMode), "EndDominationRound")] public class EndDominationRoundPatch { public static bool CanEndRound; private static bool Prefix() { if (!IngameNetManager.instance.IsClient || IngameNetManager.instance.IsHost) { return true; } return CanEndRound; } } public class DominationStatePacket { public int[] RemainingBattalions; public float[] DominationRatio; public int[] SpawnPointOwners; public int[] ActiveFlagSet; public int TimeToStart; } [HarmonyPatch(typeof(SpookOpsMode), "ActivateGameMode")] public class NoAltarPatch { private static void Prefix(SpookOpsMode __instance) { if (LobbySystem.instance.InLobby) { __instance.altarPrefab = null; } } } [HarmonyPatch(typeof(SpookOpsMode), "SpawnSkeleton")] public class SpawnSkeletonPatch { private static bool Prefix() { if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost) { return true; } return false; } } [HarmonyPatch(typeof(SpookOpsMode), "SpawnPlayerSquad")] public class SpawnPlayerSquadPatch { private static bool Prefix() { if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost) { return true; } return false; } } [HarmonyPatch(typeof(SpookOpsMode), "PrepareNextPhase")] public class PrepareNextPhasePatch { private static bool Prefix() { if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost) { return true; } typeof(SpookOpsMode).GetField("currentSpawnPoint", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(GameModeBase.activeGameMode, ActorManager.instance.spawnPoints[0]); return false; } } [HarmonyPatch(typeof(SpookOpsMode), "ActorDied")] public class HauntedActorDiedPatch { private static bool Prefix() { if (!LobbySystem.instance.InLobby) { return true; } if (((ActorController)FpsActorController.instance).actor.dead) { typeof(FpsActorController).GetMethod("TogglePhotoMode", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(FpsActorController.instance, null); } if (IngameNetManager.instance.IsHost) { return true; } return false; } public static void CheckLoseCondition() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if ((bool)typeof(SpookOpsMode).GetField("gameOver", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(GameModeBase.activeGameMode)) { return; } TimedAction val = (TimedAction)typeof(SpookOpsMode).GetField("introAction", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(GameModeBase.activeGameMode); if (!((TimedAction)(ref val)).TrueDone()) { return; } bool flag = false; foreach (Actor value in IngameNetManager.instance.ClientActors.Values) { if ((!value.aiControlled && !value.dead) || (value.controller is NetActorController && ((value.controller as NetActorController).Flags & 1) == 0 && ((value.controller as NetActorController).Flags & 0x80000) == 0)) { flag = true; break; } } if (!flag) { HauntedEndPatch.CanPerform = true; typeof(SpookOpsMode).GetMethod("EndGame", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(GameModeBase.activeGameMode, null); HauntedEndPatch.CanPerform = false; } } } [HarmonyPatch(typeof(SpookOpsMode), "StartPhase")] public class StartPhasePatch { public static bool CanPerform; private static bool Prefix() { if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost || CanPerform) { return true; } return false; } } [HarmonyPatch(typeof(SpookOpsMode), "EndGame")] public class HauntedEndPatch { public static bool CanPerform; private static bool Prefix(SpookOpsMode __instance) { if (!LobbySystem.instance.InLobby || CanPerform || (bool)typeof(SpookOpsMode).GetField("gameWon", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance)) { return true; } return false; } } public class HauntedStatePacket { public int CurrentSpawnPoint; public int PlayerSpawn; public int CurrentPhase; public int KillCount; public bool AwaitingNextPhase; public bool PhaseEnded; public float SkeletonCountModifier; } [HarmonyPatch(typeof(PointMatch), "ScoreMultiplier")] public class NoScorePatch { private static void Postfix(ref int __result) { if (IngameNetManager.instance.IsClient && !IngameNetManager.instance.IsHost) { __result = 0; } } } public class PointMatchStatePacket { public int BlueScore; public int RedScore; public int[] SpawnPointOwners; } [HarmonyPatch(typeof(SkirmishMode), "SpawnReinforcementWave")] public class SkirmishWavePatch { public static bool CanSpawnWave; private static bool Prefix() { if (!IngameNetManager.instance.IsClient || IngameNetManager.instance.IsHost) { return true; } return CanSpawnWave; } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class SkirmishDontTakeOverPlayerPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Call && (MethodInfo)instruction.operand == typeof(ActorManager).GetMethod("AliveActorsOnTeam", BindingFlags.Static | BindingFlags.Public)) { instruction.operand = typeof(SkirmishDontTakeOverPlayerPatch).GetMethod("AliveActorsDetour", BindingFlags.Static | BindingFlags.NonPublic); } yield return instruction; } } private static List<Actor> AliveActorsDetour(int team) { List<Actor> list = ActorManager.AliveActorsOnTeam(team); if (!IngameNetManager.instance.IsClient) { return list; } List<Actor> list2 = new List<Actor>(); foreach (Actor item in list) { NetActorController netActorController = item.controller as NetActorController; if ((Object)(object)netActorController == (Object)null || ((uint)netActorController.Flags & (true ? 1u : 0u)) != 0) { list2.Add(item); } } return list2; } } public class SkirmishStatePacket { public float Domination; public bool[] SpawningReinforcements; public int[] WavesRemaining; public int[] SpawnPointOwners; public int TimeToDominate; } [HarmonyPatch(typeof(SpecOpsMode), "SpawnScenarios")] public class ScenarioCreatePatch { private static bool Prefix() { if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost) { return true; } return false; } } [HarmonyPatch(typeof(SpecOpsMode), "FindAttackerSpawn")] public class AttackerSpawnPatch { private static bool Prefix() { if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost) { return true; } return false; } } [HarmonyPatch(typeof(SpecOpsMode), "SpawnAttackers")] public class SpawnAttackersPatch { private static bool Prefix(SpecOpsMode __instance) { //IL_0027: 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) if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost) { return true; } Actor actor = ((ActorController)FpsActorController.instance).actor; actor.SpawnAt(__instance.attackerSpawnPosition, __instance.attackerSpawnRotation, (LoadoutSet)null); actor.hasHeroArmor = true; List<Actor> list = new List<Actor> { ((ActorController)FpsActorController.instance).actor }; foreach (Actor value in IngameNetManager.instance.ClientActors.Values) { if (((Hurtable)value).team == ((Hurtable)actor).team) { list.Add(value); FpsActorController.instance.playerSquad.AddMember(value.controller); } } GameModeBase activeGameMode = GameModeBase.activeGameMode; GameModeBase obj = ((activeGameMode is SpecOpsMode) ? activeGameMode : null); ((SpecOpsMode)obj).attackerActors = list.ToArray(); ((SpecOpsMode)obj).attackerSquad = FpsActorController.instance.playerSquad; return false; } } [HarmonyPatch(typeof(Actor), "SpawnAt")] public class GiveAttackersHeroArmorPatch { private static void Postfix(Actor __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if (LobbySystem.instance.InLobby && (int)GameModeBase.activeGameMode.gameModeType == 3 && ((Hurtable)__instance).team == ((SpecOpsMode)/*isinst with value type is only supported in some contexts*/).attackingTeam) { __instance.hasHeroArmor = true; } } } [HarmonyPatch(typeof(ExfilHelicopter), "AllAttackersPickedUp")] public class AllPlayersPickedUpPatch { private static bool Prefix(ExfilHelicopter __instance, ref bool __result) { if (!LobbySystem.instance.InLobby) { return true; } if (FpsActorController.instance.playerSquad == null) { __result = false; return false; } object? value = typeof(ExfilHelicopter).GetField("helicopter", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); Helicopter val = (Helicopter)((value is Helicopter) ? value : null); foreach (Actor player in IngameNetManager.instance.GetPlayers()) { if (!player.dead && (!player.IsSeated() || (Object)(object)player.seat.vehicle != (Object)(object)val)) { __result = false; return false; } } __result = true; return false; } } [HarmonyPatch(typeof(ExfilHelicopter), "Update")] public class HostExfilWhenDeadPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldfld && (FieldInfo)list[i].operand == typeof(Vehicle).GetField("playerIsInside", BindingFlags.Instance | BindingFlags.Public)) { Label label = generator.DefineLabel(); list[i + 1].operand = label; list[i + 9].labels = new List<Label> { label }; } } return list.AsEnumerable(); } } [HarmonyPatch(typeof(SpecOpsMode), "Update")] public class NoEndPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { bool first = true; foreach (CodeInstruction instruction in instructions) { if (first && instruction.opcode == OpCodes.Call) { instruction.operand = typeof(NoEndPatch).GetMethod("IsSpectatingOrDefeatControl", BindingFlags.Static | BindingFlags.NonPublic); first = false; } if (instruction.opcode == OpCodes.Call && (MethodInfo)instruction.operand == typeof(SpecOpsMode).GetMethod("DefeatSequence", BindingFlags.Instance | BindingFlags.NonPublic)) { instruction.operand = typeof(NoEndPatch).GetMethod("DefeatDetour", BindingFlags.Static | BindingFlags.NonPublic); } yield return instruction; } } private static bool IsSpectatingOrDefeatControl() { if (!LobbySystem.instance.InLobby) { return GameManager.IsSpectating(); } if (((ActorController)FpsActorController.instance).actor.dead && !FpsActorController.instance.inPhotoMode) { typeof(FpsActorController).GetMethod("TogglePhotoMode", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(FpsActorController.instance, null); } if (IngameNetManager.instance.IsHost) { return !IngameNetManager.instance.GetPlayers().All((Actor actor) => actor.dead); } return true; } private static IEnumerator DefeatDetour(SpecOpsMode __instance) { return typeof(SpecOpsMode).GetMethod("DefeatSequence", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, null) as IEnumerator; } } [HarmonyPatch(typeof(SpecOpsMode), "ExfiltrationVictorySequence")] public class ExfiltrationVictorySequencePatch { public static bool CanPerform; private static bool Prefix() { if (!LobbySystem.instance.InLobby || CanPerform) { return true; } if (IngameNetManager.instance.IsHost) { using (MemoryStream memoryStream = new MemoryStream()) { SpecOpsSequencePacket value = new SpecOpsSequencePacket { Sequence = SpecOpsSequencePacket.SequenceType.ExfiltrationVictory }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.SpecOpsSequence, 8); return true; } } return false; } } [HarmonyPatch(typeof(SpecOpsMode), "StealthVictorySequence")] public class StealthVictorySequencePatch { public static bool CanPerform; private static bool Prefix() { if (!LobbySystem.instance.InLobby || CanPerform) { return true; } if (IngameNetManager.instance.IsHost) { using (MemoryStream memoryStream = new MemoryStream()) { SpecOpsSequencePacket value = new SpecOpsSequencePacket { Sequence = SpecOpsSequencePacket.SequenceType.StealthVictory }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.SpecOpsSequence, 8); return true; } } return false; } } [HarmonyPatch(typeof(SpecOpsMode), "DefeatSequence")] public class DefeatSequencePatch { public static bool CanPerform; private static bool Prefix() { if (!LobbySystem.instance.InLobby || CanPerform) { return true; } if (IngameNetManager.instance.IsHost) { using (MemoryStream memoryStream = new MemoryStream()) { SpecOpsSequencePacket value = new SpecOpsSequencePacket { Sequence = SpecOpsSequencePacket.SequenceType.Defeat }; using (ProtocolWriter protocolWriter = new ProtocolWriter(memoryStream)) { protocolWriter.Write(value); } byte[] data = memoryStream.ToArray(); IngameNetManager.instance.SendPacketToServer(data, PacketType.SpecOpsSequence, 8); return true; } } return false; } } [HarmonyPatch] public class PlayDialogBasicPatch { private static bool Prefix() { if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost) { return true; } return false; } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(SpecOpsDialog), "PlayDialog", new Type[1] { (Type)typeof(SpecOpsDialog).GetMember("DialogDel", BindingFlags.NonPublic).GetValue(0) }, (Type[])null); } } [HarmonyPatch] public class PlayDialogSpawnPatch { private static bool Prefix() { if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost) { return true; } return false; } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(SpecOpsDialog), "PlayDialog", new Type[2] { (Type)typeof(SpecOpsDialog).GetMember("DialogTargetSpawnDel", BindingFlags.NonPublic).GetValue(0), typeof(SpawnPoint) }, (Type[])null); } } [HarmonyPatch] public class PlayDialogPatrolPatch { private static bool Prefix() { if (!LobbySystem.instance.InLobby || IngameNetManager.instance.IsHost) { return true; } return false; } private s