public static void LogOnce(MineRock5 m) { if (PluginConfig.EnableResourceLogging && _loggedMineRock5.Add(m.m_name)) { LogString(StringHelper.MineRock5ToString(m)); } }
public static void MineRock5_DamageArea_Patch(MineRock5 __instance, HitData hit, float __state, bool __result) { if (Input.GetKey(VeinMine.veinMineKey.Value)) { if (__state > 0f && hit.m_attacker == Player.m_localPlayer.GetZDOID() && !VeinMine.progressiveMode.Value) { Player.m_localPlayer.RaiseSkill(Skills.SkillType.Pickaxes, GetSkillIncreaseStep(Player.m_localPlayer.GetSkills(), Skills.SkillType.Pickaxes)); if (VeinMine.veinMineDurability.Value && Player.m_localPlayer.GetCurrentWeapon().m_shared.m_useDurability) { Player.m_localPlayer.GetCurrentWeapon().m_durability -= Player.m_localPlayer.GetCurrentWeapon().m_shared.m_useDurabilityDrain; } } else if (__state > 0f && hit.m_attacker == Player.m_localPlayer.GetZDOID() && VeinMine.progressiveMode.Value) { Player.m_localPlayer.RaiseSkill(Skills.SkillType.Pickaxes, GetSkillIncreaseStep(Player.m_localPlayer.GetSkills(), Skills.SkillType.Pickaxes) * VeinMine.xpMult.Value); if (Player.m_localPlayer.GetCurrentWeapon().m_shared.m_useDurability) { float durabilityLoss = Player.m_localPlayer.GetCurrentWeapon().m_shared.m_useDurabilityDrain *((120 - GetSkillLevel(Player.m_localPlayer.GetSkills(), Skills.SkillType.Pickaxes)) / (20 * VeinMine.durabilityMult.Value)); Player.m_localPlayer.GetCurrentWeapon().m_durability -= durabilityLoss; } } } }
private static void MineRock5_Prefix(ref MineRock5 __instance) { Log.LogOnce(__instance); if (__instance.m_name == "$piece_deposit_copper" && PluginConfig.Copper.Enabled) { if (__instance.m_dropItems != null) { try { PluginConfig.Copper.ModifyDropTable(__instance.m_dropItems); } catch (Exception ex) { ConfigurableHarvestPlugin.LogInfo(BepInEx.Logging.LogLevel.Error, $"Failed applying modification to Copper: {ex.ToString()}"); } } } //name=mudpile2_frac(Clone), m_name=$piece_mudpile, m_dropItems=m_dropChance=0.2, m_dropMin=1, m_dropMax=1, m_oneOfEach=False, m_drops=[m_item=IronScrap, m_stackMin=1, m_stackMax=1, m_weight=5],[m_item=WitheredBone, m_stackMin=1, m_stackMax=1, m_weight=1],[m_item=LeatherScraps, m_stackMin=1, m_stackMax=1, m_weight=1] if (__instance.m_name == "$piece_mudpile" && PluginConfig.Iron.Enabled) { if (__instance.m_dropItems != null) { try { PluginConfig.Iron.ModifyDropTable(__instance.m_dropItems); } catch (Exception ex) { ConfigurableHarvestPlugin.LogInfo(BepInEx.Logging.LogLevel.Error, $"Failed applying modification to Iron: {ex.ToString()}"); } } } }
public static void AllDestroyed(MineRock5 __instance, bool __result) { if (!Configs.EnableAutoPin.Value || !__result) { return; } if (__instance.name.Contains("Copper", StringComparison.OrdinalIgnoreCase)) { if (PinAuto.RemovePin(__instance.transform.position, PinAuto.CopData)) { Main.Log.LogInfo($"Removing Copper pin at '{__instance.transform.position.ToString("F0")}'\n"); } return; } if (__instance.name.Contains("Silver", StringComparison.OrdinalIgnoreCase)) { if (PinAuto.RemovePin(__instance.transform.position, PinAuto.SilData)) { Main.Log.LogInfo($"Removing Silver pin at '{__instance.transform.position.ToString("F0")}'\n"); } return; } }
static void Prefix(MineRock5 __instance, ref HitData hit) { //Dbgl($"Damaging {__instance.gameObject.name}"); hit.m_damage.m_pickaxe *= damageMult.Value; hit.m_damage.m_blunt *= damageMult.Value; hit.m_damage.m_chop *= damageMult.Value; hit.m_damage.m_pierce *= damageMult.Value; }
static void Postfix(ref MineRock5 __instance) { if (Environment.StackTrace.Contains("MineRock")) { __instance.m_dropItems.m_dropMin = Mathf.RoundToInt(dropMinMult.Value * __instance.m_dropItems.m_dropMin); __instance.m_dropItems.m_dropMax = Mathf.RoundToInt(dropMaxMult.Value * __instance.m_dropItems.m_dropMax); __instance.m_dropItems.m_dropChance *= dropChanceMult.Value; } }
static bool Prefix(MineRock5 __instance, HitData hit, ZNetView ___m_nview) { if (!modEnabled.Value) { return(true); } if (!___m_nview.IsValid() || !___m_nview.IsOwner()) { return(false); } return(CheckCanDamage(__instance.gameObject, hit)); }
public static void MineRock5_Damage_Patch(MineRock5 __instance, ZNetView ___m_nview, List <HitArea> ___m_hitAreas, HitData hit, Dictionary <int, Vector3> __state) { 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) { foreach (var index in __state) { hit.m_point = index.Value; if (Player.m_localPlayer.GetCurrentWeapon().m_durability > 0 || !Player.m_localPlayer.GetCurrentWeapon().m_shared.m_useDurability) { try { ___m_nview.InvokeRPC("Damage", new object[] { hit, index.Key }); } catch { VeinMine.logger.LogInfo("Skipping section: " + index.Key + "."); } } } } } }
private static bool Prefix(ref MineRock5 __instance, ref long sender, ref HitData hit) { if (VACPlugin.AntiParams_IsEnabled.Value) { if (VACPlugin.debugmode.Value) { ZLog.LogWarning("Damage to MineRock5"); } return(Damage_Rule.Execute(hit)); } else { return(true); } }
public static void MineRock5_Damage_Prefix(MineRock5 __instance, HitData hit, out Dictionary <int, Vector3> __state) { __instance.SetupColliders(); __state = new Dictionary <int, Vector3>(); if (Input.GetKey(VeinMine.veinMineKey.Value) && VeinMine.progressiveMode.Value) { 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); } } } } }
static void Postfix(ref MineRock5 __instance) { __instance.m_dropItems.m_dropMin = Mathf.RoundToInt(dropMinMult.Value * __instance.m_dropItems.m_dropMin); __instance.m_dropItems.m_dropMax = Mathf.RoundToInt(dropMaxMult.Value * __instance.m_dropItems.m_dropMax); __instance.m_dropItems.m_dropChance *= dropChanceMult.Value; }
private static void SetLink(MineRock5 __instance) { CreateLink(__instance.m_dropItems, __instance.gameObject); }
public static string MineRock5ToString(MineRock5 x) { return($"[{x.GetType().Name}] name={x.name}, m_name={x.m_name}, m_dropItems={DropTableToString(x.m_dropItems)}"); }
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) { bool isVeinmined = false; MineRock5.HitArea hitArea = __instance.GetHitArea(hitAreaIndex); __state = hitArea.m_health; if (VeinMine.enableSpreadDamage.Value) { hit = SpreadDamage(hit); } if (Input.GetKey(VeinMine.veinMineKey.Value)) { isVeinmined = true; } ZLog.Log("hit mine rock " + hitAreaIndex); if (hitArea == null) { ZLog.Log("Missing hit area " + hitAreaIndex); __result = false; return(false); } __instance.LoadHealth(); if (hitArea.m_health <= 0f) { ZLog.Log("Already destroyed"); __result = false; return(false); } HitData.DamageModifier type; hit.ApplyResistance(__instance.m_damageModifiers, out type); float totalDamage = hit.GetTotalDamage(); if (hit.m_toolTier < __instance.m_minToolTier) { DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false); __result = false; return(false); } DamageText.instance.ShowText(type, hit.m_point, totalDamage, false); if (totalDamage <= 0f) { __result = false; return(false); } hitArea.m_health -= totalDamage; __instance.SaveHealth(); if (!VeinMine.removeEffects.Value) { __instance.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f); } Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f); if (closestPlayer) { closestPlayer.AddNoise(100f); } if (hitArea.m_health <= 0f) { __instance.m_nview.InvokeRPC(ZNetView.Everybody, "SetAreaHealth", new object[] { hitAreaIndex, hitArea.m_health }); if (!VeinMine.removeEffects.Value) { __instance.m_destroyedEffect.Create(hit.m_point, Quaternion.identity, null, 1f); } 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; UnityEngine.Object.Instantiate <GameObject>(gameObject, position, Quaternion.identity); hit.m_point = Player.m_localPlayer.GetTransform().position + new Vector3 { x = 0, y = 2, z = 0 }; } else if (!isVeinmined) { Vector3 position = hit.m_point + UnityEngine.Random.insideUnitSphere * 0.3f; UnityEngine.Object.Instantiate <GameObject>(gameObject, position, Quaternion.identity); } } if (__instance.AllDestroyed()) { __instance.m_nview.Destroy(); } __result = true; return(false); } __result = false; return(false); }