using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using Microsoft.CodeAnalysis;
using MyceliumNetworking;
using Steamworks;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: StraftatMod(false)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("BepInEx")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AboubiUnbound")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Removes all invisible walls from the game")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("kestrel.straftat.aboubiunbound")]
[assembly: AssemblyTitle("AboubiUnbound")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace AboubiUnbound
{
internal static class ConfigFileExtensions
{
public static SyncedConfigEntry<T> BindSynced<T>(this ConfigFile file, ConfigDefinition configDefinition, T defaultValue, ConfigDescription configDescription = null)
{
if (!TomlTypeConverter.CanConvert(typeof(T)))
{
throw new ArgumentException(string.Format("Type {0} is not supported by the config system. Supported types: {1}", typeof(T), string.Join(", ", (from x in TomlTypeConverter.GetSupportedTypes()
select x.Name).ToArray())));
}
lock (file._ioLock)
{
if (file.Entries.TryGetValue(configDefinition, out var value))
{
return (SyncedConfigEntry<T>)(object)value;
}
SyncedConfigEntry<T> syncedConfigEntry = new SyncedConfigEntry<T>(file, configDefinition, defaultValue, configDescription);
file.Entries[configDefinition] = (ConfigEntryBase)(object)syncedConfigEntry;
if (file.OrphanedEntries.TryGetValue(configDefinition, out var value2))
{
((ConfigEntryBase)syncedConfigEntry).SetSerializedValue(value2);
file.OrphanedEntries.Remove(configDefinition);
}
if (file.SaveOnConfigSet)
{
file.Save();
}
return syncedConfigEntry;
}
}
public static SyncedConfigEntry<T> BindSynced<T>(this ConfigFile file, string section, string key, T defaultValue, ConfigDescription configDescription = null)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
return file.BindSynced(new ConfigDefinition(section, key), defaultValue, configDescription);
}
public static SyncedConfigEntry<T> BindSynced<T>(this ConfigFile file, string section, string key, T defaultValue, string description)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_001b: Expected O, but got Unknown
return file.BindSynced(new ConfigDefinition(section, key), defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("kestrel.straftat.aboubiunbound", "AboubiUnbound", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const uint c_myceliumID = 26u;
internal static ManualLogSource Logger;
private static SyncedConfigEntry<bool> m_enabled;
private static SyncedConfigEntry<bool> m_killzEnabled;
public static readonly string loadBearingColonThree = ":3";
private static readonly string[] m_whitelistedTags = new string[7] { "Killz", "Teleport", "MovingObject", "Footsteps/Water", "Footsteps/Metal/Grille", "Door/Indoor", "Door/Outdoor" };
private static readonly Type[] m_whitelistedComponents = new Type[2]
{
typeof(PostProcessVolume),
typeof(GravityZone)
};
private static readonly int[] m_whitelistedLayers = new int[3]
{
LayerMask.NameToLayer("Ragdoll"),
LayerMask.NameToLayer("Ladder"),
LayerMask.NameToLayer("InteractEnvironment")
};
public static Plugin Instance { get; private set; }
private void Awake()
{
if (loadBearingColonThree != ":3")
{
Application.Quit();
}
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
SceneManager.sceneLoaded += RemoveInvisibleWalls;
m_enabled = ((BaseUnityPlugin)this).Config.BindSynced("General", "Enabled", defaultValue: true, "[This option's value will be controlled by the lobby host]\nWhether or not the plugin is enabled. Requires a map restart to apply.");
m_killzEnabled = ((BaseUnityPlugin)this).Config.BindSynced("General", "Remove killplanes", defaultValue: false, "[This option's value will be controlled by the lobby host]\nWhether or not to also remove killplanes. Enabling this option will let you out of maps that use killplanes in place of invisible walls, but will likely cause softlocks! Requires a map restart to apply.");
Logger.LogInfo((object)"Hiiiiiiiiiiii :3");
}
private static bool IsInvisibleWall(Collider col)
{
bool flag = m_killzEnabled.Value && ((Component)col).CompareTag("Killz");
if (!flag)
{
bool flag2 = col.enabled;
if (flag2)
{
MeshRenderer component2 = ((Component)col).GetComponent<MeshRenderer>();
bool flag3 = ((component2 == null || !((Renderer)component2).enabled) ? true : false);
flag2 = flag3;
}
flag = flag2 && m_whitelistedTags.All((string tag) => ((Component)col).gameObject.tag != tag) && m_whitelistedLayers.All((int layer) => ((Component)col).gameObject.layer != layer) && m_whitelistedComponents.All((Type component) => !Object.op_Implicit((Object)(object)((Component)col).GetComponent(component))) && !((Object)((Component)col).gameObject).name.ToLower().StartsWith("stairs");
}
return flag;
}
private static void RemoveInvisibleWalls(Scene scene, LoadSceneMode mode)
{
if (!m_enabled.Value || ((Scene)(ref scene)).name == "MainMenu")
{
return;
}
float realtimeSinceStartup = Time.realtimeSinceStartup;
IEnumerable<Collider> enumerable = ((Scene)(ref scene)).GetRootGameObjects().SelectMany((GameObject obj) => obj.GetComponentsInChildren<Collider>().Where(IsInvisibleWall));
int num = 0;
foreach (Collider item in enumerable)
{
item.enabled = false;
num++;
}
Logger.LogInfo((object)$"Removed {num} invisible walls in {(Time.realtimeSinceStartup - realtimeSinceStartup) * 1000f:F2}ms");
}
}
public class SyncedConfigEntry<T> : ConfigEntryBase
{
private bool m_isOverriden;
private T m_overridenValue;
private int m_myceliumMask;
public T Value
{
get
{
if (!m_isOverriden)
{
return <Value>k__BackingField;
}
return m_overridenValue;
}
set
{
if (m_isOverriden)
{
throw new InvalidOperationException("Synced config entries' values cannot be changed when they are overriden by a value from the host!");
}
value = ((ConfigEntryBase)this).ClampValue<T>(value);
if (!object.Equals(<Value>k__BackingField, value))
{
<Value>k__BackingField = value;
((ConfigEntryBase)this).OnSettingChanged((object)this);
}
}
}
public override object BoxedValue
{
get
{
return Value;
}
set
{
Value = (T)value;
}
}
public event EventHandler SettingChanged;
internal SyncedConfigEntry(ConfigFile configFile, ConfigDefinition definition, T defaultValue, ConfigDescription configDescription)
: base(configFile, definition, typeof(T), (object)defaultValue, configDescription)
{
m_myceliumMask = string.Join(',', definition.Key, definition.Section).GetHashCode();
MyceliumNetwork.RegisterNetworkObject((object)this, 26u, m_myceliumMask);
MyceliumNetwork.LobbyLeft += ResetOverriden;
MyceliumNetwork.PlayerEntered += SyncIfHost;
configFile.SettingChanged += delegate(object sender, SettingChangedEventArgs args)
{
if (args.ChangedSetting == this)
{
this.SettingChanged?.Invoke(sender, (EventArgs)(object)args);
SyncIfHost();
}
};
}
~SyncedConfigEntry()
{
try
{
MyceliumNetwork.DeregisterNetworkObject((object)this, 26u, m_myceliumMask);
MyceliumNetwork.LobbyLeft -= ResetOverriden;
MyceliumNetwork.PlayerEntered -= SyncIfHost;
}
finally
{
((object)this).Finalize();
}
}
private void SetOverriden()
{
m_isOverriden = true;
}
private void ResetOverriden()
{
m_isOverriden = false;
}
private void SyncIfHost(CSteamID target)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if (MyceliumNetwork.InLobby && MyceliumNetwork.IsHost)
{
MyceliumNetwork.RPCTargetMasked(26u, "RPCSyncValue", target, (ReliableType)1, m_myceliumMask, new object[1] { ((ConfigEntryBase)this).BoxedValue });
}
}
private void SyncIfHost()
{
if (MyceliumNetwork.InLobby && MyceliumNetwork.IsHost)
{
MyceliumNetwork.RPCMasked(26u, "RPCSyncValue", (ReliableType)1, m_myceliumMask, new object[1] { ((ConfigEntryBase)this).BoxedValue });
}
}
[CustomRPC]
public void RPCSyncValue(T value)
{
if (!MyceliumNetwork.IsHost)
{
SetOverriden();
m_overridenValue = value;
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "kestrel.straftat.aboubiunbound";
public const string PLUGIN_NAME = "AboubiUnbound";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}