Implement ExpressionConfigEntry that implements shunting yard and postfix notation to compute values based on strings
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
@@ -14,16 +15,15 @@ namespace BanquetForCyka {
|
||||
|
||||
public static ConfigEntry<bool> debug;
|
||||
public static ConfigEntry<bool> debugXp;
|
||||
|
||||
public static ConfigEntry<float> xpMultiplier;
|
||||
public static ExpressionConfigEntry xpMultiplier;
|
||||
|
||||
public void Awake() {
|
||||
debug = Config.Bind("Debug", "Global Debug", false);
|
||||
debugXp = Config.Bind("Debug", "XP Debug", false);
|
||||
|
||||
xpMultiplier =
|
||||
Config.Bind("General", "XP Multiplier", 1f,
|
||||
new ConfigDescription("XP Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
||||
new ExpressionConfigEntry(Config, "General", "XP Multiplier", "v*1",
|
||||
"XP Multiplier expression. Use 'v' to represent the original value.");
|
||||
|
||||
Logger.LogInfo("BanquetForCyka loaded");
|
||||
HarmonyFileLog.Enabled = true;
|
||||
@@ -43,7 +43,8 @@ namespace BanquetForCyka {
|
||||
public class Stats_AddXP {
|
||||
public static void Prefix(ref int amt) {
|
||||
Main.LogDebug("Original XP amount: " + amt, Main.debugXp);
|
||||
amt = (int)((float)amt * Main.xpMultiplier.Value);
|
||||
float result = Main.xpMultiplier.Evaluate(amt);
|
||||
amt = (int)result;
|
||||
Main.LogDebug("Modified XP amount: " + amt, Main.debugXp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user