(1.3.0) Added ServerSync compatibility
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using BepInEx;
|
using BepInEx;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using ServerSync;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -9,24 +10,46 @@ 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.2.0";
|
private const string ModVersion = "1.3.0";
|
||||||
|
|
||||||
public static ConfigEntry<int> OreMultiplier;
|
private static readonly ConfigSync configSync = new ConfigSync(ModGUID)
|
||||||
public static ConfigEntry<float> rangeMultiplier;
|
{
|
||||||
public static ConfigEntry<float> bowDrawSpeedBonusPerLevel;
|
DisplayName = ModName,
|
||||||
public static ConfigEntry<bool> rainDamage;
|
CurrentVersion = ModVersion,
|
||||||
|
MinimumRequiredVersion = ModVersion
|
||||||
|
};
|
||||||
|
|
||||||
// Set your multiplier here
|
public static ConfigEntry<bool> Config_Locked;
|
||||||
public static int Multiplier = 3;
|
public static ConfigEntry<int> Config_OreMultiplier;
|
||||||
|
public static ConfigEntry<float> Config_rangeMultiplier;
|
||||||
|
public static ConfigEntry<float> Config_bowDrawSpeedBonusPerLevel;
|
||||||
|
public static ConfigEntry<bool> Config_rainDamage;
|
||||||
|
public static ConfigEntry<float> Config_boatSpeed;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
OreMultiplier = Config.Bind("General","OreMultiplier",3,"How many items should drop for every 1 ore/scrap found.");
|
Config_Locked = BindSyncConfig("General", "Lock Configuration", true, "If obsession is on, only admins can change settings.");
|
||||||
rangeMultiplier = Config.Bind("General", "CraftingRangeMultiplier",2.0f,"Multiplier for the workbench build/crafting range. Default is 2x.");
|
configSync.AddLockingConfigEntry(Config_Locked);
|
||||||
bowDrawSpeedBonusPerLevel = Config.Bind("General", "BowDrawSpeedBonusPercentPerLevel", 0.20f, "Shorten the bow draw speed by this percent for every bow upgrade level.");
|
Config_OreMultiplier = BindSyncConfig("General","OreMultiplier",3,"How many items should drop for every 1 ore/scrap found.");
|
||||||
rainDamage = Config.Bind("General", "RainDamage", true, "Set to true to stop rain damage, false to return to vanilla behavior.");
|
Config_rangeMultiplier = BindSyncConfig("General", "CraftingRangeMultiplier",2.0f,"Multiplier for the workbench build/crafting range. Default is 2x.");
|
||||||
|
Config_bowDrawSpeedBonusPerLevel = BindSyncConfig("General", "BowDrawSpeedBonusPercentPerLevel", 1.0f, "Shorten the bow draw speed by this percent for every bow upgrade level.");
|
||||||
|
Config_rainDamage = BindSyncConfig("General", "RainDamage", true, "Set to true to stop rain damage, false to return to vanilla behavior.");
|
||||||
|
Config_boatSpeed = BindSyncConfig("General", "BoatSpeedMultiplier", 2.0f, "Your boat/raft will move without wind at a speed multiplied by this value.");
|
||||||
|
|
||||||
Harmony harmony = new Harmony(ModGUID);
|
Harmony harmony = new Harmony(ModGUID);
|
||||||
harmony.PatchAll();
|
harmony.PatchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper method to bind a config and register it for server syncing.
|
||||||
|
/// </summary>
|
||||||
|
private ConfigEntry<T> BindSyncConfig<T>(string group, string name, T value, string description, bool synchronizedSetting = true)
|
||||||
|
{
|
||||||
|
ConfigEntry<T> configEntry = this.Config.Bind(group, name, value, description);
|
||||||
|
|
||||||
|
SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry(configEntry);
|
||||||
|
syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
|
||||||
|
|
||||||
|
return configEntry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -37,12 +37,15 @@
|
|||||||
<Reference Include="Assembly-CSharp-publicized">
|
<Reference Include="Assembly-CSharp-publicized">
|
||||||
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\Valheim_Data\Managed\Assembly-CSharp-publicized.dll</HintPath>
|
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\Valheim_Data\Managed\Assembly-CSharp-publicized.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="assembly_valheim">
|
<Reference Include="assembly_valheim-publicized">
|
||||||
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\Valheim_Data\Managed\assembly_valheim.dll</HintPath>
|
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\Valheim_Data\Managed\assembly_valheim-publicized.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="BepInEx">
|
<Reference Include="BepInEx">
|
||||||
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\BepInEx\core\BepInEx.dll</HintPath>
|
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\BepInEx\core\BepInEx.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="ServerSync">
|
||||||
|
<HintPath>C:\Users\blood\Downloads\ServerSync.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace MxValheim.Patch
|
|||||||
if (___m_attackDrawTime >= 0f && ___m_attackHold)
|
if (___m_attackDrawTime >= 0f && ___m_attackHold)
|
||||||
{
|
{
|
||||||
int quality = weapon.m_quality;
|
int quality = weapon.m_quality;
|
||||||
___m_attackDrawTime += UnityEngine.Time.fixedDeltaTime * (MxValheimMod.bowDrawSpeedBonusPerLevel.Value*quality);
|
___m_attackDrawTime += UnityEngine.Time.fixedDeltaTime * (MxValheimMod.Config_bowDrawSpeedBonusPerLevel.Value*quality);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace MxValheim.Patch
|
|||||||
if (rangeField.FieldExists())
|
if (rangeField.FieldExists())
|
||||||
{
|
{
|
||||||
float currentRange = rangeField.GetValue<float>();
|
float currentRange = rangeField.GetValue<float>();
|
||||||
rangeField.SetValue(currentRange * MxValheimMod.rangeMultiplier.Value);
|
rangeField.SetValue(currentRange * MxValheimMod.Config_rangeMultiplier.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace MxValheim.Patch
|
|||||||
{
|
{
|
||||||
if (__result == null || __result.Count == 0) return;
|
if (__result == null || __result.Count == 0) return;
|
||||||
|
|
||||||
int countToAdd = MxValheimMod.OreMultiplier.Value - 1;
|
int countToAdd = MxValheimMod.Config_OreMultiplier.Value - 1;
|
||||||
if (countToAdd <= 0) return;
|
if (countToAdd <= 0) return;
|
||||||
|
|
||||||
List<GameObject> extraDrops = new List<GameObject>();
|
List<GameObject> extraDrops = new List<GameObject>();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace MxValheim.Patch
|
|||||||
{
|
{
|
||||||
static void Postfix(WearNTear __instance, ref bool __result)
|
static void Postfix(WearNTear __instance, ref bool __result)
|
||||||
{
|
{
|
||||||
if (!MxValheimMod.rainDamage.Value) return;
|
if (!MxValheimMod.Config_rainDamage.Value) return;
|
||||||
|
|
||||||
__result = true;
|
__result = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
Official Mx Valheim Mod.
|
Official Mx Valheim Mod.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
- **NEW** Now using SaveSync when used on a server.
|
||||||
- Ore drop multiplier. (Value available in the generated config.)
|
- Ore drop multiplier. (Value available in the generated config.)
|
||||||
- Workbench crafting range multiplier. (Value available in the generated config.)
|
- Workbench crafting range multiplier. (Value available in the generated config.)
|
||||||
- Reduce Bow draw time for each upgrade level. (Value available in the generated config.)
|
- Reduce Bow draw time for each upgrade level. (Value available in the generated config.)
|
||||||
|
|||||||
Reference in New Issue
Block a user