diff --git a/VeinMine/.gitignore b/VeinMine/.gitignore new file mode 100644 index 0000000..2f36f26 --- /dev/null +++ b/VeinMine/.gitignore @@ -0,0 +1 @@ +libs/ \ No newline at end of file diff --git a/VeinMine/Patches.cs b/VeinMine/Patches.cs index 932dd40..b5ae74b 100644 --- a/VeinMine/Patches.cs +++ b/VeinMine/Patches.cs @@ -12,7 +12,6 @@ class Patches [HarmonyPatch(typeof(MineRock), "Damage")] public static void MineRock_Damage_Prefix(MineRock __instance, HitData hit) { - if (!VeinMine.progressiveMode.Value) hit.m_damage.m_pickaxe = __instance.m_health + 10; hit.m_point = __instance.GetHitArea(__instance.GetAreaIndex(hit.m_hitCollider)).bounds.center; } @@ -27,6 +26,26 @@ public static void MineRock5_Damage_Prefix(MineRock5 __instance, HitData hit, ou { var radiusColliders = Physics.OverlapSphere(hit.m_point, VeinMine.progressiveMult.Value * (float)GetSkillLevel(Player.m_localPlayer.GetSkills(), Skills.SkillType.Pickaxes)); + if (radiusColliders != null) + { + foreach (var area in radiusColliders) + { + if (__instance.GetAreaIndex(area) >= 0) + { + __state.Add(__instance.GetAreaIndex(area), __instance.GetHitArea(__instance.GetAreaIndex(area)).m_bound.m_pos + + __instance.GetHitArea(__instance.GetAreaIndex(area)).m_collider.transform.position); + } + } + } + } + if (Input.GetKey(VeinMine.veinMineKey.Value) && !VeinMine.progressiveMode.Value) + { + List radiusColliders = new List(); + foreach(var area in __instance.m_hitAreas) + { + radiusColliders.Add(area.m_collider); + } + if (radiusColliders != null) { foreach (var area in radiusColliders) @@ -47,30 +66,7 @@ public static void MineRock5_Damage_Patch(MineRock5 __instance, ZNetView ___m_nv { if (Player.m_localPlayer != null && hit.m_attacker == Player.m_localPlayer.GetZDOID()) { - if (Input.GetKey(VeinMine.veinMineKey.Value) && !VeinMine.progressiveMode.Value) - { - for (int i = 0; i < (___m_hitAreas.Count <= 128 ? ___m_hitAreas.Count : 128); i++) - { - if (Player.m_localPlayer.GetCurrentWeapon().m_durability > 0 || !Player.m_localPlayer.GetCurrentWeapon().m_shared.m_useDurability) - { - hit.m_point = __instance.GetHitArea(i).m_bound.m_pos; - hit.m_damage.m_pickaxe = __instance.m_health + 10; - try - { - ___m_nview.InvokeRPC("Damage", new object[] - { - hit, - i - }); - } - catch - { - VeinMine.logger.LogInfo("Skipping section: " + i + "."); - } - } - } - } - else if (Input.GetKey(VeinMine.veinMineKey.Value) && VeinMine.progressiveMode.Value) + if (Input.GetKey(VeinMine.veinMineKey.Value)) { foreach (var index in __state) { @@ -99,6 +95,7 @@ public static void MineRock5_Damage_Patch(MineRock5 __instance, ZNetView ___m_nv [HarmonyPatch(typeof(MineRock5), "DamageArea")] public static bool MineRock5_DamageArea_Prefix(MineRock5 __instance, HitData hit, int hitAreaIndex, ref EffectList ___m_destroyedEffect, ref EffectList ___m_hitEffect, out float __state, ref bool __result) { + if (!VeinMine.progressiveMode.Value) hit.m_damage.m_pickaxe = __instance.m_health; bool isVeinmined = false; MineRock5.HitArea hitArea = __instance.GetHitArea(hitAreaIndex); __state = hitArea.m_health; @@ -137,7 +134,7 @@ public static bool MineRock5_DamageArea_Prefix(MineRock5 __instance, HitData hit } hitArea.m_health -= totalDamage; __instance.SaveHealth(); - if (!VeinMine.removeEffects.Value) __instance.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f); + if (!VeinMine.removeEffects.Value) __instance.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f, -1); Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f); if (closestPlayer) { @@ -150,14 +147,14 @@ public static bool MineRock5_DamageArea_Prefix(MineRock5 __instance, HitData hit hitAreaIndex, hitArea.m_health }); - if (!VeinMine.removeEffects.Value) __instance.m_destroyedEffect.Create(hit.m_point, Quaternion.identity, null, 1f); + if (!VeinMine.removeEffects.Value) __instance.m_destroyedEffect.Create(hit.m_point, Quaternion.identity, null, 1f, -1); foreach (GameObject gameObject in __instance.m_dropItems.GetDropList()) { if (isVeinmined) { - Vector3 position = Player.m_localPlayer.GetTransform().position + new Vector3 { x = 0, y = 2, z = 0 } + UnityEngine.Random.insideUnitSphere * 0.3f; + Vector3 position = closestPlayer.GetTransform().localPosition + new Vector3 { x = 0, y = 2, z = 0 } + UnityEngine.Random.insideUnitSphere * 0.3f; UnityEngine.Object.Instantiate(gameObject, position, Quaternion.identity); - hit.m_point = Player.m_localPlayer.GetTransform().position + new Vector3 { x = 0, y = 2, z = 0 }; + hit.m_point = closestPlayer.GetTransform().localPosition + new Vector3 { x = 0, y = 2, z = 0 }; } else if (!isVeinmined) { diff --git a/VeinMine/Properties/AssemblyInfo.cs b/VeinMine/Properties/AssemblyInfo.cs index e3e2e89..aecf3cb 100644 --- a/VeinMine/Properties/AssemblyInfo.cs +++ b/VeinMine/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.2.1.0")] +[assembly: AssemblyFileVersion("1.2.1.0")] diff --git a/VeinMine/VeinMine.cs b/VeinMine/VeinMine.cs index 113efb3..4198b6f 100644 --- a/VeinMine/VeinMine.cs +++ b/VeinMine/VeinMine.cs @@ -14,7 +14,7 @@ public class VeinMine : BaseUnityPlugin { private const string MOD_ID = "com.wisehorror.Veinmine"; private const string MOD_NAME = "Veinmine"; - private const string VERSION = "1.2.0"; + private const string VERSION = "1.2.1"; public static ManualLogSource logger = BepInEx.Logging.Logger.CreateLogSource("Veinmine"); diff --git a/VeinMine/VeinMine.csproj b/VeinMine/VeinMine.csproj index 2bd0f01..b96a94d 100644 --- a/VeinMine/VeinMine.csproj +++ b/VeinMine/VeinMine.csproj @@ -33,20 +33,20 @@ true - - ..\packages\Lib.Harmony.2.0.4\lib\net45\0Harmony.dll + + libs\0Harmony.dll - - ..\..\ValheimMods-main\Libs\assembly_guiutils_publicized.dll + + libs\assembly_guiutils_public.dll - - ..\..\ValheimMods-main\Libs\assembly_utils_publicized.dll + + libs\assembly_utils_public.dll - - ..\..\ValheimMods-main\Libs\assembly_valheim_publicized.dll + + libs\assembly_valheim_public.dll - ..\..\MultiSmelt\MultiSmelt\Libs\BepInEx.dll + libs\BepInEx.dll @@ -57,10 +57,10 @@ - ..\..\SmeltingSkill\SmeltingSkill\Libs\UnityEngine.dll + libs\UnityEngine.dll - ..\..\MultiSmelt\MultiSmelt\Libs\UnityEngine.CoreModule.dll + libs\UnityEngine.CoreModule.dll D:\Games\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.ImageConversionModule.dll