using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ArgusMagnus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("ArgusMagnus")] [assembly: AssemblyDescription("Introduces additional effects with increasing player skill levels")] [assembly: AssemblyFileVersion("1.99.8.0")] [assembly: AssemblyInformationalVersion("1.99.8-beta+328851184cc278c858ffbc70e717af9f9d7b6973")] [assembly: AssemblyProduct("ServersideQoL.Skills")] [assembly: AssemblyTitle("ServersideQoL.Skills")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")] [assembly: AssemblyVersion("1.99.8.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ServersideQoL.Skills { public sealed class Config : ConfigBase { private const string Section = "Skills"; public override ConfigEntry Enabled { get; } = ConfigBase.BindEx(cfg, "Skills", true, "Enables/disables the entire mod", (AcceptableValueBase)null, (Deprecated)null, "Enabled"); public ConfigEntry PickaxeRockCollapseThresholdAtMinSkill { get; } = ConfigBase.BindEx(cfg, "Skills", 100, "The percentage of destroyed parts required to collapse a rock or ore deposit at pickaxe skill level 0.\r\nThe actual required percentage scales linearly between this value and PickaxeRockCollapseThresholdAtMaxSkill with skill level.\r\nSet both of these values to -1 to disable this feature.", (AcceptableValueBase)null, (Deprecated)null, "PickaxeRockCollapseThresholdAtMinSkill"); public ConfigEntry PickaxeRockCollapseThresholdAtMaxSkill { get; } = ConfigBase.BindEx(cfg, "Skills", 0, "The percentage of destroyed parts required to collapse a rock or ore deposit at pickaxe skill level 100.\r\nThe actual required percentage scales linearly between this value and PickaxeRockCollapseThresholdAtMinSkill with skill level.\r\nSet both of these values to -1 to disable this feature.", (AcceptableValueBase)null, (Deprecated)null, "PickaxeRockCollapseThresholdAtMaxSkill"); public bool PickaxeRockCollapseEnabled => Math.Max(PickaxeRockCollapseThresholdAtMinSkill.Value, PickaxeRockCollapseThresholdAtMaxSkill.Value) > 0; public bool AnyEnbaled => PickaxeRockCollapseEnabled; public Config(ConfigFile cfg, Logger logger) : base(cfg, logger) { } } [Processor("df8713af-a556-4351-9726-5826e791314f")] [DependsOn] public sealed class MineRockProcessor : Processor { public sealed record PrefabInfo(MineRock5 MineRock5) : ProcessorPrefabInfo() { [CompilerGenerated] public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("PrefabInfo"); stringBuilder.Append(" { "); if (((ProcessorPrefabInfo)this).PrintMembers(stringBuilder)) { stringBuilder.Append(' '); } stringBuilder.Append('}'); return stringBuilder.ToString(); } [CompilerGenerated] protected override bool PrintMembers(StringBuilder builder) { if (((ProcessorPrefabInfo)this).PrintMembers(builder)) { builder.Append(", "); } builder.Append("MineRock5 = "); builder.Append(MineRock5); return true; } [CompilerGenerated] public override int GetHashCode() { return ((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer.Default.GetHashCode(MineRock5); } [CompilerGenerated] public sealed override bool Equals(ProcessorPrefabInfo? other) { return ((object)this).Equals((object?)other); } [CompilerGenerated] public bool Equals(PrefabInfo? other) { if ((object)this != other) { if (((ProcessorPrefabInfo)this).Equals((ProcessorPrefabInfo)(object)other)) { return EqualityComparer.Default.Equals(MineRock5, other.MineRock5); } return false; } return true; } [CompilerGenerated] private PrefabInfo(PrefabInfo original) : base((ProcessorPrefabInfo)(object)original) { MineRock5 = original.MineRock5; } } private readonly ZPackage _pkg = new ZPackage(); private readonly List<(int Idx, float Health)> _notDestroyedIndices = new List<(int, float)>(); protected override void Initialize() { Processor.Instance().EnableSkillLevelEstimation(ConfigBase.Instance.PickaxeRockCollapseEnabled, "Initialize", 17); } protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList peers, PrefabInfo prefabInfo) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Invalid comparison between Unknown and I4 //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) if (ConfigBase.Instance.PickaxeRockCollapseEnabled) { ZDOVars vars = zdo.Vars; string healthString = ((ZDOVars)(ref vars)).GetHealthString(""); if (healthString != null && healthString.Length > 0) { float num = 32f; PlayerState val = null; float num2 = float.NaN; foreach (PlayerState playerState in Processor.Instance().PlayerStates) { ItemDrop lastUsedItem = playerState.LastUsedItem; if (lastUsedItem == null) { continue; } ItemData itemData = lastUsedItem.m_itemData; if (itemData == null) { continue; } SharedData shared = itemData.m_shared; if (shared != null && (int)shared.m_skillType == 12 && !float.IsNaN(num2 = playerState.GetEstimatedSkillLevel((SkillType)12))) { float num3 = Vector3.Distance(playerState.ZDO.ZDO.GetPosition(), zdo.ZDO.GetPosition()); if (!(num3 >= num)) { val = playerState; num = num3; } } } if (val != null) { if (float.IsNaN(num2)) { num2 = 0f; } float num4 = Utils.Lerp((float)ConfigBase.Instance.PickaxeRockCollapseThresholdAtMinSkill.Value, (float)ConfigBase.Instance.PickaxeRockCollapseThresholdAtMaxSkill.Value, num2); num4 /= 100f; if (!(num4 >= 1f)) { bool flag = num4 <= 0f; if (!flag) { _pkg.Load(Convert.FromBase64String(healthString)); int num5 = _pkg.ReadInt(); _notDestroyedIndices.Clear(); for (int i = 0; i < num5; i++) { float num6 = _pkg.ReadSingle(); if (num6 > 0f) { _notDestroyedIndices.Add((i, num6)); } } float num7 = (float)(num5 - _notDestroyedIndices.Count) / (float)num5; flag = num7 >= num4; } if (flag) { HitData val2 = new HitData(); foreach (var notDestroyedIndex in _notDestroyedIndices) { int item = notDestroyedIndex.Idx; float item2 = notDestroyedIndex.Health; val2.m_damage.m_damage = item2; val2.m_toolTier = short.MaxValue; val2.m_hitType = (HitType)15; RPC.DamageMineRock5(zdo, val2, item); } } return (ProcessResult)0; } return (ProcessResult)0; } return (ProcessResult)0; } return (ProcessResult)0; } return (ProcessResult)2; } } [BepInPlugin("ArgusMagnus.ServersideQoL.Skills", "ServersideQoL.Skills", "1.99.8")] public sealed class SkillsPlugin : ServersideQoLPluginBase { public const string Author = "ArgusMagnus"; public const string PluginName = "ServersideQoL.Skills"; public const string PluginGuid = "ArgusMagnus.ServersideQoL.Skills"; public const string PluginVersion = "1.99.8"; public const string PluginInformationalVersion = "1.99.8-beta"; private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639215507746785684L, default(TimeSpan)); protected override Config CreateConfigSingleton(ConfigFile configFile, Logger logger) { return new Config(configFile, logger); } protected override void RegisterProcessors(IProcessorCollection processors) { processors.Add(); } private void Awake() { ServersideQoLPluginBase.Logger.LogWarning((object)string.Format("You are running a pre-release version: {0} ({1})", "1.99.8-beta", BuildTimestamp.LocalDateTime)); } } }