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 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("e4d3ad7d-1c27-4e0d-9735-5f6cb4c57f28")]
[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> cVal16;
public static ConfigEntry<int> cVal17;
public static ConfigEntry<bool> cNotification;
public static ConfigEntry<bool> cQuota;
public Config(ConfigFile cfg)
{
cVal1 = cfg.Bind<int>("Values", "SnareFleaReward", 25, "Credit reward for killing Snare Flea");
cVal2 = cfg.Bind<int>("Values", "BunkerSpiderReward", 80, "Credit reward for killing Bunker Spider");
cVal3 = cfg.Bind<int>("Values", "HoardingBugReward", 25, "Credit reward for killing Hoarding Bug");
cVal4 = cfg.Bind<int>("Values", "BrackenReward", 140, "Credit reward for killing Bracken");
cVal5 = cfg.Bind<int>("Values", "ThumperReward", 125, "Credit reward for killing Thumper");
cVal6 = cfg.Bind<int>("Values", "NutcrackerReward", 100, "Credit reward for killing Nutcracker");
cVal7 = cfg.Bind<int>("Values", "MaskedReward", 75, "Credit reward for killing Masked");
cVal8 = cfg.Bind<int>("Values", "ButlerReward", 100, "Credit reward for killing Butler");
cVal9 = cfg.Bind<int>("Values", "EyelessDogReward", 125, "Credit reward for killing Eyeless Dog");
cVal10 = cfg.Bind<int>("Values", "ForestKeeperReward", 300, "Credit reward for killing Forest Keeper");
cVal11 = cfg.Bind<int>("Values", "BaboonHawkReward", 25, "Credit reward for killing Baboon Hawk");
cVal12 = cfg.Bind<int>("Values", "ManticoilReward", 10, "Credit reward for killing Manticoil");
cVal13 = cfg.Bind<int>("Values", "TulipSnakeReward", 15, "Credit reward for killing Tulip Snake");
cVal14 = cfg.Bind<int>("Modded Values", "ModdedReward0", 10, "Credit reward for killing any modded monster whose power level is < 1");
cVal15 = cfg.Bind<int>("Modded Values", "ModdedReward1", 25, "Credit reward for killing any modded monster whose power level is > 1 and < 2");
cVal16 = cfg.Bind<int>("Modded Values", "ModdedReward2", 75, "Credit reward for killing any modded monster whose power level is > 2 and < 3");
cVal17 = cfg.Bind<int>("Modded Values", "ModdedReward3", 150, "Credit reward for killing any modded monster whose power level is >= 3");
cNotification = cfg.Bind<bool>("General", "PlayNotification", true, "Toggles notifications for killing a monster and the credits received");
cQuota = cfg.Bind<bool>("General", "AddToQuota", false, "Adds credit reward towards fulfilling the quota instead (false = add to balance, true = add to quota)");
}
}
namespace LC_MoneyForKills
{
[BepInPlugin("Jack.MoneyForKills", "MoneyForKills", "1.3.0")]
public class MFKBase : BaseUnityPlugin
{
private const string modGUID = "Jack.MoneyForKills";
private const string modName = "MoneyForKills";
private const string modVersion = "1.3.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 ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Jack.MoneyForKills");
mls.LogInfo((object)"Successfully loaded MoneyForKills ver. 1.3.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
},
{
"PL0",
Config.cVal14.Value
},
{
"PL1",
Config.cVal15.Value
},
{
"PL2",
Config.cVal16.Value
},
{
"PL3",
Config.cVal17.Value
}
};
private static readonly List<string> VanillaList = new List<string>
{
"Flowerman", "Crawler", "Hoarding bug", "Centipede", "Bunker Spider", "Puffer", "Jester", "Blob", "Girl", "Spring",
"Nutcracker", "Masked", "Butler", "MouthDog", "Earth Leviathan", "ForestGiant", "Baboon hawk", "RadMech", "Red Locust Bees", "Docile Locust Bees",
"Manticoil"
};
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 (!VanillaList.Contains(obj.enemyName))
{
if (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 (!VanillaList.Contains(obj.enemyName))
{
return "Modded Entity";
}
return "";
}
[HarmonyPatch(typeof(EnemyAI))]
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch(EnemyAI __instance)
{
EnemyType enemyType = __instance.enemyType;
if (Config.cNotification.Value && !Config.cQuota.Value)
{
HUDManager.Instance.DisplayTip(getName(enemyType) + " killed!", getBounty(enemyType) + " credits have been added to your balance", false, false, "LC_Tip1");
}
else if (Config.cNotification.Value && Config.cQuota.Value)
{
HUDManager.Instance.DisplayTip(getName(enemyType) + " killed!", getBounty(enemyType) + " credits have been added towards the quota", false, false, "LC_Tip1");
}
if (!Config.cQuota.Value)
{
Terminal val = Object.FindObjectOfType<Terminal>();
val.groupCredits += getBounty(enemyType);
}
else
{
TimeOfDay instance = TimeOfDay.Instance;
instance.quotaFulfilled += getBounty(enemyType);
TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
}
}
}
}