diff --git a/Player2VRM/MainPlugin.cs b/Player2VRM/MainPlugin.cs index b5488d2..ec507be 100644 --- a/Player2VRM/MainPlugin.cs +++ b/Player2VRM/MainPlugin.cs @@ -15,7 +15,7 @@ public class MainPlugin : BaseUnityPlugin { public const string PluginGuid = "com.yoship1639.plugins.player2vrm"; public const string PluginName = "Player2VRM"; - public const string PluginVersion = "1.3.5.0"; + public const string PluginVersion = "1.3.6.0"; void Awake() { diff --git a/Player2VRM/Player2VRM.cs b/Player2VRM/Player2VRM.cs index 6ae941e..848beee 100644 --- a/Player2VRM/Player2VRM.cs +++ b/Player2VRM/Player2VRM.cs @@ -71,9 +71,6 @@ static class EquipAdjustPos_OcPlEquipCtrl_lateMove //{ OcEquipSlot.WpMain, "EquipMain" }, // これの位置を変えると、ピッケル・斧の所持位置と、壁などの設置場所(!!)が変わる。 }; - // 装備位置変更設定をキャッシュするか(毎フレームパースするのは無駄)。この設定自体はキャッシュしない。 - static bool CachingEnabled => !Settings.ReadBool("DynamicEquipAdjustment", false); - // 装備位置変更設定のキャッシュ(VRMモデルに合わせるかどうか、オフセット値) static readonly Dictionary equipPositionIsAdujstedToVrmModel = new Dictionary(); static readonly Dictionary equipPositionOffsets = new Dictionary(); @@ -108,10 +105,17 @@ internal static HashSet GetPlEquips(OcPlEquipCtrl plEquipCtrl) } } + static bool CachingEnabled(string playername) + { + var cache = !Settings.ReadBool(playername, "DynamicEquipAdjustment", false); + return cache; + } + static Vector3 GetOffset(OcEquipSlot equipSlot, string playername = null) { + var cache = CachingEnabled(playername); Vector3 offset; - if (equipPositionOffsets.TryGetValue(equipSlot, out offset) && CachingEnabled) + if (equipPositionOffsets.TryGetValue(equipSlot, out offset) && cache) { return offset; } @@ -119,14 +123,15 @@ static Vector3 GetOffset(OcEquipSlot equipSlot, string playername = null) offset = equipSlot2Key.TryGetValue(equipSlot, out var key) ? Settings.ReadVector3(playername, $"{key}Offset", Vector3.zero, false) : Vector3.zero; - if (CachingEnabled) equipPositionOffsets.Add(equipSlot, offset); + if (cache) equipPositionOffsets.Add(equipSlot, offset); return offset; } - static bool IsAdujstedToVrmModel(OcEquipSlot equipSlot) + static bool IsAdujstedToVrmModel(OcEquipSlot equipSlot, string playername) { + var cache = CachingEnabled(playername); bool result; - if (equipPositionIsAdujstedToVrmModel.TryGetValue(equipSlot, out result) && CachingEnabled) + if (equipPositionIsAdujstedToVrmModel.TryGetValue(equipSlot, out result) && cache) { return result; } @@ -134,7 +139,7 @@ static bool IsAdujstedToVrmModel(OcEquipSlot equipSlot) result = equipSlot2Key.TryGetValue(equipSlot, out var key) ? Settings.ReadBool($"{key}FollowsModel", false, false) : false; - if (CachingEnabled) equipPositionIsAdujstedToVrmModel.Add(equipSlot, result); + if (cache) equipPositionIsAdujstedToVrmModel.Add(equipSlot, result); return result; } @@ -154,7 +159,7 @@ static Animator GetPlRelatedModelAnimator(OcPl pl) static void AdjustEquipPos(OcPlEquip plEquip, string playername = null) { - if (IsAdujstedToVrmModel(plEquip.EquipSlot) && epuipBaseBones.TryGetValue(plEquip.EquipSlot, out var bone)) + if (IsAdujstedToVrmModel(plEquip.EquipSlot, playername) && epuipBaseBones.TryGetValue(plEquip.EquipSlot, out var bone)) { var modelHeadTrans = GetPlRelatedModelAnimator(plEquip.OwnerPl).GetBoneTransform(bone); plEquip.transform.SetParent(modelHeadTrans, false); @@ -175,7 +180,8 @@ static void AdjustEquipPos(OcPlEquip plEquip, string playername = null) static Vector3 GetQuiverOffset(string playername = null) { - if (quiverOffset.HasValue && CachingEnabled) return quiverOffset.Value; + var cache = CachingEnabled(playername); + if (quiverOffset.HasValue && cache) return quiverOffset.Value; quiverOffset = Settings.ReadVector3(playername, "EquipArrowOffset", Vector3.zero, false); return quiverOffset.Value; } @@ -521,7 +527,6 @@ class AdjustPlCam : MonoBehaviour private bool enableAdjustDoF; private Bloom bloom; - private ColorGrading colorGrading; private AmbientOcclusion ambientOcclusion; private Vignette vignette; @@ -627,11 +632,12 @@ private System.Collections.IEnumerator CheckPlayerName(int max_count) } OcPlVRM.DelayedPostfix(ocpl); } - } + + [HarmonyPatch(typeof(OcPl))] - [HarmonyPatch("charaChangeSteup")] + [HarmonyPatch(nameof(OcPl.charaChangeSteup))] static class OcPlVRM { static Dictionary dic_vrmModel = new Dictionary(); diff --git a/Player2VRM/Properties/AssemblyInfo.cs b/Player2VRM/Properties/AssemblyInfo.cs index ecf73b8..7934c15 100644 --- a/Player2VRM/Properties/AssemblyInfo.cs +++ b/Player2VRM/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.5.0")] -[assembly: AssemblyFileVersion("1.3.5.0")] +[assembly: AssemblyVersion("1.3.6.0")] +[assembly: AssemblyFileVersion("1.3.6.0")] diff --git a/Player2VRM/Settings.cs b/Player2VRM/Settings.cs index 74e1150..7f5eab8 100644 --- a/Player2VRM/Settings.cs +++ b/Player2VRM/Settings.cs @@ -184,7 +184,7 @@ public static string ReadSettings(string playername, string key, bool useCache = { return null; } - dic_players_settings.Add(playername, new Dictionary()); + if (useCache) dic_players_settings.Add(playername, new Dictionary()); var lines = File.ReadAllLines(_SettingsPath); foreach (var line in lines) { @@ -194,7 +194,7 @@ public static string ReadSettings(string playername, string key, bool useCache = var args = line.Split('='); if (args.Length != 2) continue; - dic_players_settings[playername][args[0]] = args[1]; + if (useCache) dic_players_settings[playername][args[0]] = args[1]; if (args[0] == key) { @@ -211,7 +211,7 @@ public static string ReadSettings(string playername, string key, bool useCache = public static int ReadInt(string playername, string key, int defaultValue = 0, bool useCache = true) { - var str = ReadSettings(playername, key); + var str = ReadSettings(playername, key, useCache); var res = defaultValue; if (int.TryParse(str, out res)) return res; return defaultValue; @@ -219,7 +219,7 @@ public static int ReadInt(string playername, string key, int defaultValue = 0, b public static float ReadFloat(string playername, string key, float defaultValue = 0.0f, bool useCache = true) { - var str = ReadSettings(playername, key); + var str = ReadSettings(playername, key, useCache); var res = defaultValue; if (float.TryParse(str, out res)) return res; return defaultValue; @@ -227,7 +227,7 @@ public static float ReadFloat(string playername, string key, float defaultValue public static bool ReadBool(string playername, string key, bool defaultValue = false, bool useCache = true) { - var str = ReadSettings(playername, key); + var str = ReadSettings(playername, key, useCache); var res = defaultValue; if (bool.TryParse(str, out res)) return res; return defaultValue; @@ -235,7 +235,7 @@ public static bool ReadBool(string playername, string key, bool defaultValue = f public static Vector3 ReadVector3(string playername, string key, Vector3 defaultValue = default, bool useCache = true) { - var str = ReadSettings(playername, key); + var str = ReadSettings(playername, key, useCache); if (str == null) return defaultValue; var match = new Regex("\\((?[^,]*?),(?[^,]*?),(?[^,]*?)\\)").Match(str); if (match.Success == false) return defaultValue; @@ -274,7 +274,7 @@ public static string ReadSettings(string key, bool useCache = true) var args = line.Split('='); if (args.Length != 2) continue; - dic_common_settings[args[0]] = args[1]; + if (useCache) dic_common_settings[args[0]] = args[1]; if (args[0] == key) { retval = args[1]; @@ -291,7 +291,7 @@ public static string ReadSettings(string key, bool useCache = true) public static int ReadInt(string key, int defaultValue = 0, bool useCache = true) { - var str = ReadSettings(key); + var str = ReadSettings(key, useCache); var res = defaultValue; if (int.TryParse(str, out res)) return res; return defaultValue; @@ -299,7 +299,7 @@ public static int ReadInt(string key, int defaultValue = 0, bool useCache = true public static float ReadFloat(string key, float defaultValue = 0.0f, bool useCache = true) { - var str = ReadSettings(key); + var str = ReadSettings(key, useCache); var res = defaultValue; if (float.TryParse(str, out res)) return res; return defaultValue; @@ -307,7 +307,7 @@ public static float ReadFloat(string key, float defaultValue = 0.0f, bool useCac public static bool ReadBool(string key, bool defaultValue = false, bool useCache = true) { - var str = ReadSettings(key); + var str = ReadSettings(key, useCache); var res = defaultValue; if (bool.TryParse(str, out res)) return res; return defaultValue; @@ -315,7 +315,7 @@ public static bool ReadBool(string key, bool defaultValue = false, bool useCache public static Vector3 ReadVector3(string key, Vector3 defaultValue = default, bool useCache = true) { - var str = ReadSettings(key); + var str = ReadSettings(key, useCache); if (str == null) return defaultValue; var match = new Regex("\\((?[^,]*?),(?[^,]*?),(?[^,]*?)\\)").Match(str); if (match.Success == false) return defaultValue;