using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using CG; using CG.Game; using CG.Game.Player; using CG.Network; using CG.Objects; using CG.Ship.Hull; using CG.Ship.Modules; using CG.Space; using Gameplay.Carryables; using Gameplay.CompositeWeapons; using Gameplay.Tags; using Gameplay.Utilities; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using VoidManager; using VoidManager.MPModChecks; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("BalancedDuoSentry")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+a406bf73525647deba127b15d201544406be94a4")] [assembly: AssemblyProduct("BalancedDuoSentry")] [assembly: AssemblyTitle("Adds a two-player version of the Lone Sentry Destroyer.")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 BalancedDuoSentry { internal class BlessedHomunculusPatcher { private static GUIDUnion destroyerShipGUID = new GUIDUnion("4bc2ff9e1d156c94a9c94286a7aaa79b"); private static DuoPlayerCondition duoPlayerCondition = new DuoPlayerCondition(); public static void ApplyPatch(CarryableMod homunculus) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (((AbstractCloneStarObject)ClientGame.Current.PlayerShip).assetGuid != destroyerShipGUID) { return; } StatMod val = null; StatMod val2 = null; foreach (StatMod modifier in homunculus.Modifiers) { if (modifier.DynamicCondition is DuoPlayerCondition) { return; } if (modifier.DynamicCondition is SinglePlayerModRule) { if (modifier.Type == ((Enumeration)StatType.Damage).Id) { val = modifier; } else if (modifier.Type == ((Enumeration)StatType.PowerWanted).Id) { val2 = modifier; } } } if (val2 != null) { BepinPlugin.Log.LogInfo((object)"Applying Duo Power Wanted Mod to Blessed Homunculus"); StatMod val3 = (StatMod)(object)new DuoPowerWantedStatMod(val2.TagConfiguration); val3.Mod.Source = (IModifierSource)(object)homunculus; val3.Mod.InformationSource = (IModifierSource)(object)homunculus; val3.DynamicCondition = (ModDynamicCondition)(object)duoPlayerCondition; homunculus.Modifiers.Add(val3); } if (val != null) { BepinPlugin.Log.LogInfo((object)"Applying Duo Damage Mod to Blessed Homunculus"); StatMod val4 = (StatMod)(object)new DuoDamageStatMod(val.TagConfiguration); val4.Mod.Source = (IModifierSource)(object)homunculus; val4.Mod.InformationSource = (IModifierSource)(object)homunculus; val4.DynamicCondition = (ModDynamicCondition)(object)duoPlayerCondition; homunculus.Modifiers.Add(val4); } } } internal class DuoDamageStatMod : StatMod, IDescriptiveModifierSource, IModifierSource { public DuoDamageStatMod(ModTagConfiguration tagConfig) : base((PrimitiveModifier)new FloatModifier(0.75f, (ModifierType)0, (IModifierSource)null), ((Enumeration)StatType.Damage).Id, tagConfig) { }//IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown public string GetDescription() { return "+75%"; } public string GetHeader() { return "Blessed Homunculus"; } } [Serializable] public class DuoPlayerCondition : ModDynamicCondition { public override void OnInitialize() { ClientGame.Current.ModelEventBus.OnPlayerAdded.Subscribe((Action)OnPlayerAdded, (AutoUnsubscribeCollection)null); ClientGame.Current.ModelEventBus.OnPlayerRemoved.Subscribe((Action)OnPlayerRemoved, (AutoUnsubscribeCollection)null); } public override void OnDestroy() { ClientGame.Current.ModelEventBus.OnPlayerAdded.Unsubscribe((Action)OnPlayerAdded); ClientGame.Current.ModelEventBus.OnPlayerRemoved.Unsubscribe((Action)OnPlayerRemoved); } private void OnPlayerRemoved(Player obj) { ((ModDynamicCondition)this).CheckIfActive(); } private void OnPlayerAdded(Player obj) { ((ModDynamicCondition)this).CheckIfActive(); } public override bool ShouldApply() { return ClientGame.Current.Players.Count == 2; } public override string Description() { return "When playing Duo"; } } internal class DuoPowerWantedStatMod : StatMod, IDescriptiveModifierSource, IModifierSource { public DuoPowerWantedStatMod(ModTagConfiguration tagConfig) : base((PrimitiveModifier)new IntModifier(-1, (ModifierType)2), ((Enumeration)StatType.PowerWanted).Id, tagConfig) { }//IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown public string GetDescription() { return "-1"; } public string GetHeader() { return "Blessed Homunculus"; } } public class MyPluginInfo { public const string PLUGIN_GUID = "rcannood.BalancedDuoSentry"; public const string PLUGIN_NAME = "BalancedDuoSentry"; public const string USERS_PLUGIN_NAME = "Balanced Duo Sentry"; public const string PLUGIN_VERSION = "0.1.0"; public const string PLUGIN_DESCRIPTION = "Adds a two-player version of the Lone Sentry Destroyer."; public const string PLUGIN_ORIGINAL_AUTHOR = "rcannood"; public const string PLUGIN_AUTHORS = "rcannood, Grifs"; public const string PLUGIN_THUNDERSTORE_ID = "BrosBeforeFoes/BalancedDuoSentry"; } [HarmonyPatch(typeof(HomunculusAndBiomassSocket), "DispenseHomunculusNow")] internal class HomunculusAndBiomassSocket_DispenseHomunculusNow_Patch { private static void Postfix(HomunculusAndBiomassSocket __instance) { if (!((Object)(object)((CarryablesSocket)__instance).Payload == (Object)null)) { CarryableObject payload = ((CarryablesSocket)__instance).Payload; CarryableMod val = (CarryableMod)(object)((payload is CarryableMod) ? payload : null); if (val != null) { BlessedHomunculusPatcher.ApplyPatch(val); } } } } [HarmonyPatch(typeof(ModSocket), "Start")] internal class ModSocket_Start_Patch { private static void Postfix(ModSocket __instance) { ClientGame current = ClientGame.Current; object obj; if (current == null) { obj = null; } else { PlayerControlledShip playerShip = current.PlayerShip; obj = ((playerShip != null) ? playerShip.GetModule() : null); } CentralShipComputerModule val = (CentralShipComputerModule)obj; if (!((Object)(object)val == (Object)null) && !((Object)(object)__instance != (Object)(object)val.HomunculusSocket)) { ((CarryablesSocket)__instance).OnAcquireCarryable += OnCarriableAcquired; } } private static void OnCarriableAcquired(ICarrier carrier, CarryableObject carryable, ICarrier previousCarrier) { CarryableMod val = (CarryableMod)(object)((carryable is CarryableMod) ? carryable : null); if (val != null) { BlessedHomunculusPatcher.ApplyPatch(val); } } } [BepInPlugin("rcannood.BalancedDuoSentry", "Balanced Duo Sentry", "0.1.0")] [BepInProcess("Void Crew.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BepinPlugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static readonly GUIDUnion SENTRY_FRIGATE_AUTO_BRAIN_WEAPON_GUID = new GUIDUnion("bc2dcf53afe3a90478b5d9fcffb1f523"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin rcannood.BalancedDuoSentry is loaded!"); } } public class VoidManagerPlugin : VoidPlugin { public override MultiplayerType MPType => (MultiplayerType)14; public override string Author => "rcannood, Grifs"; public override string Description => "Adds a two-player version of the Lone Sentry Destroyer."; public override string ThunderstoreID => "BrosBeforeFoes/BalancedDuoSentry"; public override SessionChangedReturn OnSessionChange(SessionChangedInput input) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) SessionChangedReturn result = default(SessionChangedReturn); result.SetMod_Session = true; return result; } } }