using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using Microsoft.CodeAnalysis; using SULFURTogether.Api; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("NumbersGuy.SulfurTogether")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NumbersGuy.SulfurTogether")] [assembly: AssemblyTitle("NumbersGuy.SulfurTogether")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 NumbersGuy.SulfurTogether { internal sealed class CombatBridge : IDisposable { private const int SupportedApiVersion = 1; private const int TeamMarksApiVersion = 2; public readonly int ApiVersion; private CombatBridge(int apiVersion) { ApiVersion = apiVersion; } public static CombatBridge TryCreate() { int apiVersion = NetCombat.ApiVersion; if (apiVersion < 1) { return null; } CombatBridge combatBridge = new CombatBridge(apiVersion); NumbersGuyIntegration.SetRemoteHitScope((Func)combatBridge.IsResolvingRemoteHit); if (apiVersion >= 2) { NumbersGuyIntegration.SetHitBonusScope((Func)combatBridge.LocalHostHitMultiplier); } return combatBridge; } public void Dispose() { NumbersGuyIntegration.SetRemoteHitScope((Func)null); NumbersGuyIntegration.SetHitBonusScope((Func)null); } private bool IsResolvingRemoteHit() { return NetCombat.IsResolvingRemoteHit; } [MethodImpl(MethodImplOptions.NoInlining)] private float LocalHostHitMultiplier() { return NetCombat.LocalHostHitMultiplier; } } [BepInPlugin("ryuka.sulfur.numbers_guy_sulfur_together", "Numbers Guy - SULFUR Together Adapter", "0.1.0")] [BepInDependency("ryuka.sulfur.numbers_guy", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class SulfurTogetherAdapterPlugin : BaseUnityPlugin { public const string PluginGuid = "ryuka.sulfur.numbers_guy_sulfur_together"; public const string PluginName = "Numbers Guy - SULFUR Together Adapter"; private const string SulfurTogetherGuid = "com.ryuka.sulfur.together"; private const string Unfiltered = "as host, other players' hits on enemies may show as yours."; private IDisposable _bridge; private void Awake() { if (!Chainloader.PluginInfos.ContainsKey("com.ryuka.sulfur.together")) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"SULFUR Together is not installed; nothing to connect."); return; } try { _bridge = Attach(out var apiVersion); ((BaseUnityPlugin)this).Logger.LogInfo((object)((_bridge != null) ? ("Connected to SULFUR Together's combat API " + apiVersion + ".") : "The installed SULFUR Together has an unknown combat API; as host, other players' hits on enemies may show as yours.")); } catch (Exception ex) when (IsMissingApi(ex)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("The installed SULFUR Together has no combat API (it needs 1.7.0 or newer); as host, other players' hits on enemies may show as yours. (" + ex.GetType().Name + ": " + ex.Message + ")")); } } private void OnDestroy() { if (_bridge != null) { _bridge.Dispose(); _bridge = null; } } private static bool IsMissingApi(Exception e) { if (!(e is TypeLoadException) && !(e is MissingMethodException) && !(e is MissingFieldException) && !(e is TypeInitializationException)) { return e is BadImageFormatException; } return true; } [MethodImpl(MethodImplOptions.NoInlining)] private static IDisposable Attach(out int apiVersion) { CombatBridge combatBridge = CombatBridge.TryCreate(); apiVersion = combatBridge?.ApiVersion ?? 0; return combatBridge; } } }