-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
812 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31019.35 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{E2DE2B39-165F-4D75-A9B3-6B53C0B08B9A}") = "CraftingSkill", "CraftingSkill\CraftingSkill.csproj", "{92F90B77-522E-4A67-AAEF-E5B593F1B7C5}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{92F90B77-522E-4A67-AAEF-E5B593F1B7C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{92F90B77-522E-4A67-AAEF-E5B593F1B7C5}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{92F90B77-522E-4A67-AAEF-E5B593F1B7C5}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{92F90B77-522E-4A67-AAEF-E5B593F1B7C5}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {EA61C0C0-D5BC-4B47-982B-F31DE743218D} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using BepInEx.Configuration; | ||
using HarmonyLib; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CraftingSkill | ||
{ | ||
class ConfigVariable <T> | ||
{ | ||
object backingStore; | ||
|
||
private string configSection; | ||
private string varName; | ||
private T defaultValue; | ||
private string configDescription; | ||
private bool localOnly; | ||
|
||
public T Value | ||
{ | ||
get | ||
{ | ||
return Traverse.Create(backingStore).Property("Value").GetValue<T>(); | ||
} | ||
} | ||
|
||
public ConfigVariable(string configSection, string varName, T defaultValue, string configDescription = "", bool localOnly = false) | ||
{ | ||
this.configSection = configSection; | ||
this.varName = varName; | ||
this.defaultValue = defaultValue; | ||
this.configDescription = configDescription; | ||
this.localOnly = localOnly; | ||
} | ||
|
||
public void init(Assembly assembly, ConfigFile config, string id) { | ||
if (assembly != null) | ||
{ | ||
var method = assembly.GetType("ModConfigEnforcer.ConfigManager") | ||
.GetMethods() | ||
.First(x => x.Name == "RegisterModConfigVariable" && x.IsGenericMethod) | ||
.MakeGenericMethod(typeof(T)); | ||
backingStore = method.Invoke(null, new object[] { id, varName, defaultValue, configSection, configDescription, localOnly }); | ||
} | ||
else | ||
{ | ||
backingStore = config.Bind(configSection, varName, defaultValue, configDescription); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Reflection; | ||
using BepInEx.Configuration; | ||
using HarmonyLib; | ||
using UnityEngine; | ||
|
||
// This code and associated ConfigVariable is largely copied from the sailing_skill mod | ||
// It allows us to have the modconfigenforcer mod as a soft dependency | ||
// https://github.com/gaijinx/valheim_mods/tree/main/sailing_skill | ||
|
||
namespace CraftingSkill | ||
{ | ||
public class CraftingConfig | ||
{ | ||
// public int NEXUS_ID = 0; | ||
|
||
// Experience for crafting | ||
|
||
private ConfigVariable<float> __ExpScapeTier = new ConfigVariable<float>("ExpGain", "ExpScapeTier", 1.0f); | ||
private ConfigVariable<float> __ExpScapePower = new ConfigVariable<float>("ExpGain", "ExpScapePower", 2.0f); | ||
private ConfigVariable<float> __ExpScapeLinear = new ConfigVariable<float>("ExpGain", "ExpScapeLinear", 0.16f); | ||
|
||
// Effects of quality | ||
private ConfigVariable<float> __ArmorStart = new ConfigVariable<float>("Attributes", "ArmorStart", 0.8f); | ||
private ConfigVariable<float> __ArmorStop = new ConfigVariable<float>("Attributes", "ArmorStop", 1.3f); | ||
private ConfigVariable<float> __WeightStart = new ConfigVariable<float>("Attributes", "WeightStart", 1.1f); | ||
private ConfigVariable<float> __WeightStop = new ConfigVariable<float>("Attributes", "WeightStop", 0.7f); | ||
private ConfigVariable<float> __MaxDurabilityStart = new ConfigVariable<float>("Attributes", "MaxDurabilityStart", 0.8f); | ||
private ConfigVariable<float> __MaxDurabilityStop = new ConfigVariable<float>("Attributes", "MaxDurabilityStop", 1.6f); | ||
private ConfigVariable<float> __BaseBlockPowerStart = new ConfigVariable<float>("Attributes", "BaseBlockPowerStart", 0.8f); | ||
private ConfigVariable<float> __BaseBlockPowerStop = new ConfigVariable<float>("Attributes", "BaseBlockPowerStop", 1.3f); | ||
private ConfigVariable<float> __DeflectionForceStart = new ConfigVariable<float>("Attributes", "DeflectionForceStart", 0.8f); | ||
private ConfigVariable<float> __DeflectionForceStop = new ConfigVariable<float>("Attributes", "DeflectionForceStop", 1.3f); | ||
private ConfigVariable<float> __DamageStart = new ConfigVariable<float>("Attributes", "DamageStart", 0.8f); | ||
private ConfigVariable<float> __DamageStop = new ConfigVariable<float>("Attributes", "DamageStop", 1.3f); | ||
|
||
// Cauldron: It's not crafting so no experience, but if we did | ||
// Stonecutter: should probably be 2 or 3, but only thing right now is shitty sharpening stone | ||
// Artisan: is used by Epic Loot?, will likely have vanilla items in future | ||
// Guessing at 2 for now | ||
private ConfigVariable<int> __TierModifierInventory = new ConfigVariable<int>("StationBalancing", "TierModifierInventory", 0); | ||
private ConfigVariable<int> __TierModifierWorkbench = new ConfigVariable<int>("StationBalancing", "TierModifierWorkbench", 0); | ||
private ConfigVariable<int> __TierModifierForge = new ConfigVariable<int>("StationBalancing", "TierModifierForge", 2); | ||
private ConfigVariable<int> __TierModifierCauldron = new ConfigVariable<int>("StationBalancing", "TierModifierCauldron", 3); | ||
private ConfigVariable<int> __TierModifierStonecutter = new ConfigVariable<int>("StationBalancing", "TierModifierStonecutter", 1); | ||
private ConfigVariable<int> __TierModifierArtisan = new ConfigVariable<int>("StationBalancing", "TierModifierArtisan", 2); | ||
private ConfigVariable<int> __TierModifierDefault = new ConfigVariable<int>("StationBalancing", "TierModifierDefault", 0); | ||
|
||
// Utility getters | ||
public float ExpScapeTier {get => __ExpScapeTier.Value; } | ||
public float ExpScapePower {get => __ExpScapePower.Value; } | ||
public float ExpScapeLinear {get => __ExpScapeLinear.Value; } | ||
public float ArmorStart {get => __ArmorStart.Value; } | ||
public float ArmorStop {get => __ArmorStop.Value; } | ||
public float WeightStart {get => __WeightStart.Value; } | ||
public float WeightStop {get => __WeightStop.Value; } | ||
public float MaxDurabilityStart {get => __MaxDurabilityStart.Value; } | ||
public float MaxDurabilityStop {get => __MaxDurabilityStop.Value; } | ||
public float BaseBlockPowerStart {get => __BaseBlockPowerStart.Value; } | ||
public float BaseBlockPowerStop {get => __BaseBlockPowerStop.Value; } | ||
public float DeflectionForceStart {get => __DeflectionForceStart.Value; } | ||
public float DeflectionForceStop {get => __DeflectionForceStop.Value; } | ||
public float DamageStart {get => __DamageStart.Value; } | ||
public float DamageStop {get => __DamageStop.Value; } | ||
public int TierModifierInventory {get => __TierModifierInventory.Value; } | ||
public int TierModifierWorkbench {get => __TierModifierWorkbench.Value; } | ||
public int TierModifierForge {get => __TierModifierForge.Value; } | ||
public int TierModifierCauldron {get => __TierModifierCauldron.Value; } | ||
public int TierModifierStonecutter {get => __TierModifierStonecutter.Value; } | ||
public int TierModifierArtisan {get => __TierModifierArtisan.Value; } | ||
public int TierModifierDefault {get => __TierModifierDefault.Value; } | ||
|
||
public CraftingConfig() | ||
{ | ||
|
||
} | ||
|
||
public void InitConfig(string mod_id, ConfigFile config) | ||
{ | ||
// Bind<int>("General", "NexusID", NEXUS_ID, "Nexus mod ID for updates"); | ||
|
||
Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == "ModConfigEnforcer"); | ||
|
||
if (assembly != null) | ||
{ | ||
Debug.Log("[CraftingSkill] Mod Config Enforcer detected, registering mod..."); | ||
var configManagerType = assembly.GetType("ModConfigEnforcer.ConfigManager"); | ||
Traverse.Create(configManagerType).Method("RegisterMod", mod_id, config).GetValue(mod_id, config); | ||
} | ||
else | ||
{ | ||
Debug.Log("Mod Config Enforcer not detected."); | ||
} | ||
|
||
__ExpScapeTier.init(assembly, config, mod_id); | ||
__ExpScapePower.init(assembly, config, mod_id); | ||
__ExpScapeLinear.init(assembly, config, mod_id); | ||
__ArmorStart.init(assembly, config, mod_id); | ||
__ArmorStop.init(assembly, config, mod_id); | ||
__WeightStart.init(assembly, config, mod_id); | ||
__WeightStop.init(assembly, config, mod_id); | ||
__MaxDurabilityStart.init(assembly, config, mod_id); | ||
__MaxDurabilityStop.init(assembly, config, mod_id); | ||
__BaseBlockPowerStart.init(assembly, config, mod_id); | ||
__BaseBlockPowerStop.init(assembly, config, mod_id); | ||
__DeflectionForceStart.init(assembly, config, mod_id); | ||
__DeflectionForceStop.init(assembly, config, mod_id); | ||
__DamageStart.init(assembly, config, mod_id); | ||
__DamageStop.init(assembly, config, mod_id); | ||
__TierModifierInventory.init(assembly, config, mod_id); | ||
__TierModifierWorkbench.init(assembly, config, mod_id); | ||
__TierModifierForge.init(assembly, config, mod_id); | ||
__TierModifierCauldron.init(assembly, config, mod_id); | ||
__TierModifierStonecutter.init(assembly, config, mod_id); | ||
__TierModifierArtisan.init(assembly, config, mod_id); | ||
__TierModifierDefault.init(assembly, config, mod_id); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.