using System;
using System.Collections.Generic;
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 LC_MoneyForKills.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("LC_MoneyForKills")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LC_MoneyForKills")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2551316e-6c64-4d85-84a1-828f551ed695")]
[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")]
public class Config
{
public static ConfigEntry<int> cVal1;
public static ConfigEntry<int> cVal2;
public static ConfigEntry<int> cVal3;
public static ConfigEntry<int> cVal4;
public static ConfigEntry<int> cVal5;
public static ConfigEntry<int> cVal6;
public static ConfigEntry<int> cVal7;
public static ConfigEntry<int> cVal8;
public static ConfigEntry<int> cVal9;
public static ConfigEntry<int> cVal10;
public static ConfigEntry<int> cVal11;
public static ConfigEntry<int> cVal12;
public static ConfigEntry<int> cVal13;
public static ConfigEntry<int> cVal14;
public static ConfigEntry<int> cVal15;
public static ConfigEntry<int> cValMod1;
public static ConfigEntry<int> cValMod2;
public static ConfigEntry<int> cValMod3;
public static ConfigEntry<int> cValMod4;
public static ConfigEntry<int> cValPlayer;
public static ConfigEntry<bool> cNotification;
public static ConfigEntry<bool> cPlayerNotification;
public static ConfigEntry<bool> cQuota;
public static ConfigEntry<bool> cBank;
public Config(ConfigFile cfg)
{
cVal1 = cfg.Bind<int>("Values", "SnareFlea Reward", 25, "Credit reward for killing Snare Flea");
cVal2 = cfg.Bind<int>("Values", "BunkerSpider Reward", 80, "Credit reward for killing Bunker Spider");
cVal3 = cfg.Bind<int>("Values", "HoardingBug Reward", 25, "Credit reward for killing Hoarding Bug");
cVal4 = cfg.Bind<int>("Values", "Bracken Reward", 150, "Credit reward for killing Bracken");
cVal5 = cfg.Bind<int>("Values", "Thumper Reward", 125, "Credit reward for killing Thumper");
cVal6 = cfg.Bind<int>("Values", "Nutcracker Reward", 100, "Credit reward for killing Nutcracker");
cVal7 = cfg.Bind<int>("Values", "Masked Reward", 75, "Credit reward for killing Masked");
cVal8 = cfg.Bind<int>("Values", "Butler Reward", 100, "Credit reward for killing Butler");
cVal9 = cfg.Bind<int>("Values", "EyelessDog Reward", 125, "Credit reward for killing Eyeless Dog");
cVal10 = cfg.Bind<int>("Values", "ForestKeeper Reward", 300, "Credit reward for killing Forest Keeper");
cVal11 = cfg.Bind<int>("Values", "BaboonHawk Reward", 25, "Credit reward for killing Baboon Hawk");
cVal12 = cfg.Bind<int>("Values", "Manticoil Reward", 10, "Credit reward for killing Manticoil");
cVal13 = cfg.Bind<int>("Values", "TulipSnake Reward", 15, "Credit reward for killing Tulip Snake");
cVal14 = cfg.Bind<int>("Values", "KidnapperFox Reward", 140, "Credit reward for killing Kidnapper Fox");
cVal15 = cfg.Bind<int>("Values", "Maneater Reward", 300, "Credit reward for killing Maneater");
cValMod1 = cfg.Bind<int>("Modded Values", "Modded Reward 0", 25, "Credit reward for killing any modded entity whose power level is >= 0 and < 1");
cValMod2 = cfg.Bind<int>("Modded Values", "Modded Reward 1", 75, "Credit reward for killing any modded entity whose power level is >= 1 and < 2");
cValMod3 = cfg.Bind<int>("Modded Values", "Modded Reward 2", 150, "Credit reward for killing any modded entity whose power level is >= 2 and < 3");
cValMod4 = cfg.Bind<int>("Modded Values", "Modded Reward 3", 250, "Credit reward for killing any modded entity whose power level is >= 3");
cValPlayer = cfg.Bind<int>("Miscellaneous Values", "Player Reward", 0, "Credits received for player deaths in general");
cNotification = cfg.Bind<bool>("General", "Play Notification", true, "Toggles notifications for killing an entity and the credits received, or deducted if negative. Visible to all players.");
cPlayerNotification = cfg.Bind<bool>("General", "Play Player Death Notification", false, "Toggles notifications for player deaths/kills and credits received, or deducted if negative. Visible to all players.");
cQuota = cfg.Bind<bool>("General", "Add To Quota", false, "Add credit reward towards the quota (May cause problems when exceeding current quota goal, Quota Rollover reccommended)");
cBank = cfg.Bind<bool>("General", "Add To Bank", true, "Add credit reward towards the bank");
}
}
namespace LC_MoneyForKills
{
[BepInPlugin("Jack.MoneyForKills", "MoneyForKills", "1.4.0")]
public class MFKBase : BaseUnityPlugin
{
private const string modGUID = "Jack.MoneyForKills";
private const string modName = "MoneyForKills";
private const string modVersion = "1.4.0";
private readonly Harmony harmony = new Harmony("Jack.MoneyForKills");
private static MFKBase Instance;
internal ManualLogSource mls;
public static Config myConfig { get; internal set; }
private void Awake()
{
myConfig = new Config(((BaseUnityPlugin)this).Config);
if (Instance == null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Jack.MoneyForKills");
mls.LogInfo((object)("Successfully loaded " + "MoneyForKills v.1.4.0"));
harmony.PatchAll(typeof(MFKBase));
harmony.PatchAll(typeof(MoneyPatch));
}
}
}
namespace LC_MoneyForKills.Patches
{
[HarmonyPatch]
internal class MoneyPatch
{
private static Dictionary<string, int> enemyBounties = new Dictionary<string, int>
{
{
"SnareFlea",
Config.cVal1.Value
},
{
"BunkerSpider",
Config.cVal2.Value
},
{
"HoardingBug",
Config.cVal3.Value
},
{
"Bracken",
Config.cVal4.Value
},
{
"Thumper",
Config.cVal5.Value
},
{
"Nutcracker",
Config.cVal6.Value
},
{
"Masked",
Config.cVal7.Value
},
{
"Butler",
Config.cVal8.Value
},
{
"EyelessDog",
Config.cVal9.Value
},
{
"ForestKeeper",
Config.cVal10.Value
},
{
"BaboonHawk",
Config.cVal11.Value
},
{
"Manticoil",
Config.cVal12.Value
},
{
"TulipSnake",
Config.cVal13.Value
},
{
"KidnapperFox",
Config.cVal14.Value
},
{
"Maneater",
Config.cVal15.Value
},
{
"PL0",
Config.cValMod1.Value
},
{
"PL1",
Config.cValMod2.Value
},
{
"PL2",
Config.cValMod3.Value
},
{
"PL3",
Config.cValMod4.Value
}
};
private static readonly List<string> vanillaList = new List<string>
{
"Red Locust Bees", "Manticoil", "Docile Locust Bees", "MouthDog", "ForestGiant", "Earth Leviathan", "RadMech", "Bush Wolf", "Tulip Snake", "Baboon hawk",
"Centipede", "Bunker Spider", "Hoarding bug", "Flowerman", "Crawler", "Blob", "Girl", "Puffer", "Nutcracker", "Clay Surgeon",
"Spring", "Jester", "Lasso", "Masked", "Butler", "Maneater"
};
private static int getBounty(EnemyType obj)
{
if (obj.enemyName == "Centipede")
{
return enemyBounties["SnareFlea"];
}
if (obj.enemyName == "Bunker Spider")
{
return enemyBounties["BunkerSpider"];
}
if (obj.enemyName == "Hoarding bug")
{
return enemyBounties["HoardingBug"];
}
if (obj.enemyName == "Flowerman")
{
return enemyBounties["Bracken"];
}
if (obj.enemyName == "Crawler")
{
return enemyBounties["Thumper"];
}
if (obj.enemyName == "Nutcracker")
{
return enemyBounties["Nutcracker"];
}
if (obj.enemyName == "Masked")
{
return enemyBounties["Masked"];
}
if (obj.enemyName == "Butler")
{
return enemyBounties["Butler"];
}
if (obj.enemyName == "MouthDog")
{
return enemyBounties["EyelessDog"];
}
if (obj.enemyName == "ForestGiant")
{
return enemyBounties["ForestKeeper"];
}
if (obj.enemyName == "Baboon hawk")
{
return enemyBounties["BaboonHawk"];
}
if (obj.enemyName == "Manticoil")
{
return enemyBounties["Manticoil"];
}
if (obj.enemyName == "Tulip Snake")
{
return enemyBounties["TulipSnake"];
}
if (obj.enemyName == "BushWolf")
{
return enemyBounties["KidnapperFox"];
}
if (obj.enemyName == "Maneater")
{
return enemyBounties["Maneater"];
}
if (obj.PowerLevel >= 0f && obj.PowerLevel < 1f)
{
return enemyBounties["PL0"];
}
if (obj.PowerLevel >= 1f && obj.PowerLevel < 2f)
{
return enemyBounties["PL1"];
}
if (obj.PowerLevel >= 2f && obj.PowerLevel < 3f)
{
return enemyBounties["PL2"];
}
if (obj.PowerLevel >= 3f)
{
return enemyBounties["PL3"];
}
return 0;
}
private static string getName(EnemyType obj)
{
if (obj.enemyName == "Centipede")
{
return "Centipede";
}
if (obj.enemyName == "Bunker Spider")
{
return "Bunker Spider";
}
if (obj.enemyName == "Hoarding bug")
{
return "Hoarding Bug";
}
if (obj.enemyName == "Flowerman")
{
return "Bracken";
}
if (obj.enemyName == "Crawler")
{
return "Thumper";
}
if (obj.enemyName == "Nutcracker")
{
return "Nutcracker";
}
if (obj.enemyName == "Masked")
{
return "Masked";
}
if (obj.enemyName == "Butler")
{
return "Butler";
}
if (obj.enemyName == "MouthDog")
{
return "Eyeless Dog";
}
if (obj.enemyName == "ForestGiant")
{
return "Forest Giant";
}
if (obj.enemyName == "Baboon hawk")
{
return "Baboon Hawk";
}
if (obj.enemyName == "Manticoil")
{
return "Manticoil";
}
if (obj.enemyName == "Tulip Snake")
{
return "Tulip Snake";
}
if (obj.enemyName == "BushWolf")
{
return "Kidnapper Fox";
}
if (obj.enemyName == "Maneater")
{
return "Maneater";
}
if (!vanillaList.Contains(obj.enemyName))
{
return obj.enemyName;
}
return "";
}
[HarmonyPatch(typeof(EnemyAI))]
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch(EnemyAI __instance)
{
EnemyType enemyType = __instance.enemyType;
int bounty = getBounty(enemyType);
string name = getName(enemyType);
if (bounty == 0)
{
return;
}
if (Config.cNotification.Value)
{
if (!Config.cQuota.Value && Config.cBank.Value)
{
if (bounty > 0)
{
HUDManager.Instance.DisplayTip(name + " killed!", bounty + " credits have been added to your balance", false, false, "LC_Tip1");
}
else
{
HUDManager.Instance.DisplayTip(name + " killed. Yikes!", Math.Abs(bounty) + " credits have been deducted from your balance", false, false, "LC_Tip1");
}
}
else if (Config.cQuota.Value && !Config.cBank.Value)
{
if (bounty > 0)
{
HUDManager.Instance.DisplayTip(getName(enemyType) + " killed!", bounty + " credits have been added towards the quota", false, false, "LC_Tip1");
}
else
{
HUDManager.Instance.DisplayTip(name + " killed. Yikes!", Math.Abs(bounty) + " credits have been deducted from your quota", false, false, "LC_Tip1");
}
}
else if (Config.cQuota.Value && Config.cBank.Value)
{
if (bounty > 0)
{
HUDManager.Instance.DisplayTip(getName(enemyType) + " killed!", bounty + " credits have been added to your balance and quota", false, false, "LC_Tip1");
}
else
{
HUDManager.Instance.DisplayTip(name + " killed. Yikes!", Math.Abs(bounty) + " credits have been deducted from your balance and quota", false, false, "LC_Tip1");
}
}
}
if (Config.cBank.Value)
{
Terminal val = Object.FindObjectOfType<Terminal>();
int num = val.groupCredits + bounty;
val.groupCredits = ((num >= 0) ? num : 0);
}
if (Config.cQuota.Value)
{
TimeOfDay instance = TimeOfDay.Instance;
int num2 = instance.quotaFulfilled + bounty;
instance.quotaFulfilled = ((num2 >= 0) ? num2 : 0);
TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
}
}
[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
[HarmonyPostfix]
private static void KillPlayerPatch(PlayerControllerB __instance)
{
int value = Config.cValPlayer.Value;
if (value != 0 && Config.cPlayerNotification.Value)
{
if (!Config.cQuota.Value && Config.cBank.Value)
{
if (value > 0)
{
HUDManager.Instance.DisplayTip("A player has died.", value + " credits have been added to your balance", false, false, "LC_Tip1");
}
else
{
HUDManager.Instance.DisplayTip("A player has died.", Math.Abs(value) + " credits have been deducted from your balance", false, false, "LC_Tip1");
}
}
else if (Config.cQuota.Value && !Config.cBank.Value)
{
if (value > 0)
{
HUDManager.Instance.DisplayTip("A player has died.", value + " credits have been added to your quota", false, false, "LC_Tip1");
}
else
{
HUDManager.Instance.DisplayTip("A player has died.", Math.Abs(value) + " credits have been deducted from your quota", false, false, "LC_Tip1");
}
}
else if (Config.cQuota.Value && Config.cBank.Value)
{
if (value > 0)
{
HUDManager.Instance.DisplayTip("A player has died.", value + " credits have been added to your balance and quota", false, false, "LC_Tip1");
}
else
{
HUDManager.Instance.DisplayTip("A player has died.", Math.Abs(value) + " credits have been deducted from your balance and quota", false, false, "LC_Tip1");
}
}
}
if (Config.cBank.Value)
{
Terminal val = Object.FindObjectOfType<Terminal>();
int num = val.groupCredits + value;
val.groupCredits = ((num >= 0) ? num : 0);
}
if (Config.cQuota.Value)
{
TimeOfDay instance = TimeOfDay.Instance;
int num2 = instance.quotaFulfilled + value;
instance.quotaFulfilled = ((num2 >= 0) ? num2 : 0);
TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
}
}
[HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")]
[HarmonyPrefix]
private static bool ResetQuota(ref int ___quotaFulfilled, ref int ___profitQuota, out int __state)
{
if (TimeOfDay.Instance.timeUntilDeadline <= 0f)
{
__state = ___quotaFulfilled - ___profitQuota;
return true;
}
__state = ___quotaFulfilled;
return false;
}
[HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")]
[HarmonyPostfix]
private static void SetQuotaFulfilledHost(ref int ___quotaFulfilled, int __state)
{
___quotaFulfilled = __state;
}
}
}