using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace HowToFishTeamDamage;
[BepInPlugin("com.lh.howtofish.hostteamdamage", "How To Fish - Team Damage Multiplier", "1.0.0")]
public sealed class TeamDamagePlugin : BaseUnityPlugin
{
internal const string PluginGuid = "com.lh.howtofish.hostteamdamage";
internal const string PluginName = "How To Fish - Team Damage Multiplier";
internal const string PluginVersion = "1.0.0";
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<float> Multiplier;
internal static ConfigEntry<bool> LogAppliedHits;
private void Awake()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Apply the multiplier only after the host has enabled the game's Friendly Fire setting.");
Multiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Multiplier", 2f, new ConfigDescription("Damage multiplier for player-on-player damage. 1.0 leaves damage unchanged.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), new object[0]));
LogAppliedHits = ((BaseUnityPlugin)this).Config.Bind<bool>("Diagnostics", "LogAppliedHits", false, "Write each modified hit to BepInEx/LogOutput.log.");
new Harmony("com.lh.howtofish.hostteamdamage").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"How To Fish - Team Damage Multiplier loaded. It operates only on the lobby host after Friendly Fire is enabled.");
}
}
[HarmonyPatch(typeof(Server), "HitPlayer")]
internal static class ServerHitPlayerPatch
{
[HarmonyPrefix]
private static void Prefix(Player player, ref int damage, Player playerWhoHit)
{
if (TeamDamagePlugin.Enabled != null && TeamDamagePlugin.Enabled.Value && damage > 0 && playerWhoHit != null && !object.ReferenceEquals(player, playerWhoHit) && object.ReferenceEquals(playerWhoHit, Player.LocalPlayer))
{
int num = damage;
damage = Math.Max(1, (int)Math.Round((float)num * TeamDamagePlugin.Multiplier.Value, MidpointRounding.AwayFromZero));
if (TeamDamagePlugin.LogAppliedHits.Value)
{
Logger.CreateLogSource("How To Fish - Team Damage Multiplier").LogInfo((object)("Modified friendly-fire damage: " + num + " -> " + damage + "."));
}
}
}
}