using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCFriendlyFireSettingsMod.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LCFriendlyFireSettingsMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCFriendlyFireSettingsMod")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4d189b00-3d1c-4f3f-a953-03a7dbee6e97")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LCFriendlyFireSettingsMod
{
[BepInPlugin("Snowlance.LCFriendlyFireSettingsMod", "Friendly Fire Settings Mod", "1.0.4")]
public class LCFriendlyFireSettingsModBase : BaseUnityPlugin
{
private const string modGUID = "Snowlance.LCFriendlyFireSettingsMod";
private const string modName = "Friendly Fire Settings Mod";
private const string modVersion = "1.0.4";
private readonly Harmony harmony = new Harmony("Snowlance.LCFriendlyFireSettingsMod");
private static LCFriendlyFireSettingsModBase Instance;
public static ConfigEntry<bool> configShip;
public static ConfigEntry<bool> configOutside;
public static ConfigEntry<bool> configFacility;
public static ManualLogSource LoggerInstance { get; private set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
LoggerInstance = ((BaseUnityPlugin)this).Logger;
LoggerInstance.LogInfo((object)"Plugin Friendly Fire Settings Mod loaded successfully.");
configShip = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShipFriendlyFire", false, "Can crewmates damage each other inside the ship?");
configOutside = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OutsideFriendlyFire", false, "Can crewmates damage each other outside the ship?");
configFacility = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FacilityFriendlyFire", false, "Can crewmates damage each other inside the facility?");
harmony.PatchAll(typeof(LCFriendlyFireSettingsModBase));
harmony.PatchAll(typeof(PlayerControllerBPatch));
}
}
}
namespace LCFriendlyFireSettingsMod.Patches
{
[HarmonyPatch]
internal class PlayerControllerBPatch
{
[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientServerRpc")]
[HarmonyPrefix]
public static void DamagePlayerFromOtherClientServerRpc(PlayerControllerB __instance, ref int damageAmount, Vector3 hitDirection, int playerWhoHit)
{
if (__instance.isInHangarShipRoom && !LCFriendlyFireSettingsModBase.configShip.Value)
{
LCFriendlyFireSettingsModBase.LoggerInstance.LogDebug((object)$"Player{playerWhoHit} attempted to friendly fire in the ship, setting damage amount to 0.");
damageAmount = 0;
}
if (!__instance.isInHangarShipRoom && !__instance.isInsideFactory && !LCFriendlyFireSettingsModBase.configOutside.Value)
{
LCFriendlyFireSettingsModBase.LoggerInstance.LogDebug((object)$"Player{playerWhoHit} attempted to friendly fire outside the ship, setting damage amount to 0.");
damageAmount = 0;
}
if (__instance.isInsideFactory && !LCFriendlyFireSettingsModBase.configFacility.Value)
{
LCFriendlyFireSettingsModBase.LoggerInstance.LogDebug((object)$"Player{playerWhoHit} attempted to friendly fire in facility, setting damage amount to 0.");
damageAmount = 0;
}
}
}
}