|
|
|
@@ -28,7 +28,7 @@ public class MxValheimMod : BaseUnityPlugin
|
|
|
|
|
|
|
|
|
|
|
|
private const string ModGUID = "ovh.mxdev.mxvalheim";
|
|
|
|
private const string ModGUID = "ovh.mxdev.mxvalheim";
|
|
|
|
private const string ModName = "MxValheim";
|
|
|
|
private const string ModName = "MxValheim";
|
|
|
|
private const string ModVersion = "1.6.4";
|
|
|
|
private const string ModVersion = "1.6.5";
|
|
|
|
|
|
|
|
|
|
|
|
public static ConfigEntry<bool> Config_Locked;
|
|
|
|
public static ConfigEntry<bool> Config_Locked;
|
|
|
|
public static ConfigEntry<int> Config_OreMultiplier;
|
|
|
|
public static ConfigEntry<int> Config_OreMultiplier;
|
|
|
|
@@ -43,10 +43,12 @@ public class MxValheimMod : BaseUnityPlugin
|
|
|
|
public static string internalConfigsPath = Path.Combine(modPath, "Configs");
|
|
|
|
public static string internalConfigsPath = Path.Combine(modPath, "Configs");
|
|
|
|
public static string internalDataPath = Path.Combine(modPath, "Data");
|
|
|
|
public static string internalDataPath = Path.Combine(modPath, "Data");
|
|
|
|
public static string internalDataEventSystem = Path.Combine(internalDataPath, "EventSystem.json");
|
|
|
|
public static string internalDataEventSystem = Path.Combine(internalDataPath, "EventSystem.json");
|
|
|
|
|
|
|
|
public static string DropConfigPath => Path.Combine(internalConfigsPath, "items_drop.json");
|
|
|
|
public static string WeightConfigPath => Path.Combine(internalConfigsPath, "items_weight.json");
|
|
|
|
public static string WeightConfigPath => Path.Combine(internalConfigsPath, "items_weight.json");
|
|
|
|
public static string AutoDoorConfigPath => Path.Combine(internalConfigsPath, "auto_doors.json");
|
|
|
|
public static string AutoDoorConfigPath => Path.Combine(internalConfigsPath, "auto_doors.json");
|
|
|
|
public static DoorRoot CachedConfig;
|
|
|
|
public static DoorRoot CachedConfig;
|
|
|
|
public static Dictionary<string, float> WeightSettings = new Dictionary<string, float>();
|
|
|
|
public static Dictionary<string, float> WeightSettings = new Dictionary<string, float>();
|
|
|
|
|
|
|
|
public static Dictionary<string, int> DropSettings = new Dictionary<string, int>();
|
|
|
|
|
|
|
|
|
|
|
|
public static bool initExpBar = true;
|
|
|
|
public static bool initExpBar = true;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -314,32 +316,34 @@ public class MxValheimMod : BaseUnityPlugin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool LoadJsonConfig()
|
|
|
|
private void LoadJsonConfig()
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
string json = "";
|
|
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(WeightConfigPath))
|
|
|
|
if (!File.Exists(WeightConfigPath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WeightSettings = new Dictionary<string, float> { { "Wood", 1.0f }, { "Stone", 1.0f } };
|
|
|
|
WeightSettings = new Dictionary<string, float> { { "Wood", 1.0f }, { "Stone", 1.0f } };
|
|
|
|
File.WriteAllText(WeightConfigPath, JsonConvert.SerializeObject(WeightSettings, Newtonsoft.Json.Formatting.Indented));
|
|
|
|
File.WriteAllText(WeightConfigPath, JsonConvert.SerializeObject(WeightSettings, Newtonsoft.Json.Formatting.Indented));
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string json = File.ReadAllText(WeightConfigPath);
|
|
|
|
json = File.ReadAllText(WeightConfigPath);
|
|
|
|
WeightSettings = JsonConvert.DeserializeObject<Dictionary<string, float>>(json);
|
|
|
|
WeightSettings = JsonConvert.DeserializeObject<Dictionary<string, float>>(json);
|
|
|
|
Logger.LogInfo($"Successfully parsed {WeightSettings.Count} items.");
|
|
|
|
Logger.LogInfo($"Successfully parsed {WeightSettings.Count} items.");
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!File.Exists(DropConfigPath))
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.LogWarning($"Could not read JSON (might be busy): {ex.Message}");
|
|
|
|
DropSettings = new Dictionary<string, int> { { "Wood", 3 }, { "CopperOre", 3 }, { "TinOre", 3 }, { "IronScrap", 3 }, { "SilverOre", 3 }, { "Obsidian", 3 }, { "BlackMetalScrap", 3 }, { "BlackMarble", 3 }, { "FlametalOreNew", 3 } };
|
|
|
|
return false;
|
|
|
|
File.WriteAllText(DropConfigPath, JsonConvert.SerializeObject(DropSettings, Newtonsoft.Json.Formatting.Indented));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json = File.ReadAllText(DropConfigPath);
|
|
|
|
|
|
|
|
DropSettings = JsonConvert.DeserializeObject<Dictionary<string, int>>(json);
|
|
|
|
|
|
|
|
Logger.LogInfo($"Successfully parsed {DropSettings.Count} items.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void LoadDoorConfig()
|
|
|
|
public void LoadDoorConfig()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (System.IO.File.Exists(AutoDoorConfigPath))
|
|
|
|
if (File.Exists(AutoDoorConfigPath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string json = System.IO.File.ReadAllText(AutoDoorConfigPath);
|
|
|
|
string json = System.IO.File.ReadAllText(AutoDoorConfigPath);
|
|
|
|
CachedConfig = JsonConvert.DeserializeObject<DoorRoot>(json);
|
|
|
|
CachedConfig = JsonConvert.DeserializeObject<DoorRoot>(json);
|
|
|
|
|