using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BetterCommand.Source.NetworkMessages;
using BetterCommand.Source.Utils;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.CharacterAI;
using UnityEngine;
using UnityEngine.Networking;
[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("BetterCommand")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Made you immune and untargetable when you open artifact of command menu")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+10dc977b29aceccd8be6f20fce98aef4db37c9f1")]
[assembly: AssemblyProduct("BetterCommand")]
[assembly: AssemblyTitle("BetterCommand")]
[assembly: AssemblyVersion("1.0.1.0")]
[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.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]
[Microsoft.CodeAnalysis.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]
[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 BetterCommand.Source
{
[BepInPlugin("AnnasVirtual.BetterCommand", "BetterCommand", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BetterCommand : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static hook_OnDisplayBegin <>9__4_0;
public static hook_OnDisplayEnd <>9__4_1;
internal void <Awake>b__4_0(orig_OnDisplayBegin orig, PickupPickerController self, NetworkUIPromptController networkUIPromptController, LocalUser localUser, CameraRigController cameraRigController)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (NetworkServer.active)
{
Helper.ApplyBetterCommandOnServer(((Component)networkUIPromptController.currentParticipantMaster).gameObject, PickupPickerMessageType.Add);
orig.Invoke(self, networkUIPromptController, localUser, cameraRigController);
}
else
{
NetMessageExtensions.Send((INetMessage)(object)new PickupPickerMessage(((NetworkBehaviour)networkUIPromptController.currentParticipantMaster).netId, PickupPickerMessageType.Add), (NetworkDestination)2);
orig.Invoke(self, networkUIPromptController, localUser, cameraRigController);
}
}
internal void <Awake>b__4_1(orig_OnDisplayEnd orig, PickupPickerController self, NetworkUIPromptController networkUIPromptController, LocalUser localUser, CameraRigController cameraRigController)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (NetworkServer.active)
{
Helper.ApplyBetterCommandOnServer(((Component)networkUIPromptController.currentParticipantMaster).gameObject, PickupPickerMessageType.Remove);
orig.Invoke(self, networkUIPromptController, localUser, cameraRigController);
}
else
{
NetMessageExtensions.Send((INetMessage)(object)new PickupPickerMessage(((NetworkBehaviour)networkUIPromptController.currentParticipantMaster).netId, PickupPickerMessageType.Remove), (NetworkDestination)2);
orig.Invoke(self, networkUIPromptController, localUser, cameraRigController);
}
}
}
public const string PluginGUID = "AnnasVirtual.BetterCommand";
public const string PluginAuthor = "AnnasVirtual";
public const string PluginName = "BetterCommand";
public const string PluginVersion = "1.0.1";
public void Awake()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
NetworkingAPI.RegisterMessageType<PickupPickerMessage>();
object obj = <>c.<>9__4_0;
if (obj == null)
{
hook_OnDisplayBegin val = delegate(orig_OnDisplayBegin orig, PickupPickerController self, NetworkUIPromptController networkUIPromptController, LocalUser localUser, CameraRigController cameraRigController)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (NetworkServer.active)
{
Helper.ApplyBetterCommandOnServer(((Component)networkUIPromptController.currentParticipantMaster).gameObject, PickupPickerMessageType.Add);
orig.Invoke(self, networkUIPromptController, localUser, cameraRigController);
}
else
{
NetMessageExtensions.Send((INetMessage)(object)new PickupPickerMessage(((NetworkBehaviour)networkUIPromptController.currentParticipantMaster).netId, PickupPickerMessageType.Add), (NetworkDestination)2);
orig.Invoke(self, networkUIPromptController, localUser, cameraRigController);
}
};
<>c.<>9__4_0 = val;
obj = (object)val;
}
PickupPickerController.OnDisplayBegin += (hook_OnDisplayBegin)obj;
object obj2 = <>c.<>9__4_1;
if (obj2 == null)
{
hook_OnDisplayEnd val2 = delegate(orig_OnDisplayEnd orig, PickupPickerController self, NetworkUIPromptController networkUIPromptController, LocalUser localUser, CameraRigController cameraRigController)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (NetworkServer.active)
{
Helper.ApplyBetterCommandOnServer(((Component)networkUIPromptController.currentParticipantMaster).gameObject, PickupPickerMessageType.Remove);
orig.Invoke(self, networkUIPromptController, localUser, cameraRigController);
}
else
{
NetMessageExtensions.Send((INetMessage)(object)new PickupPickerMessage(((NetworkBehaviour)networkUIPromptController.currentParticipantMaster).netId, PickupPickerMessageType.Remove), (NetworkDestination)2);
orig.Invoke(self, networkUIPromptController, localUser, cameraRigController);
}
};
<>c.<>9__4_1 = val2;
obj2 = (object)val2;
}
PickupPickerController.OnDisplayEnd += (hook_OnDisplayEnd)obj2;
Log.Info("Better Command is loaded");
}
}
}
namespace BetterCommand.Source.Utils
{
public static class Helper
{
public static List<MinionOwnership> GetMinionOfPlayer(CharacterMaster playerMaster)
{
List<MinionOwnership> list = new List<MinionOwnership>();
MinionOwnership[] array = Object.FindObjectsOfType<MinionOwnership>();
MinionOwnership[] array2 = array;
foreach (MinionOwnership val in array2)
{
if ((Object)(object)val.ownerMaster == (Object)(object)playerMaster)
{
list.Add(val);
}
}
return list;
}
public static void ApplyBetterCommandOnServer(GameObject gameObject, PickupPickerMessageType pickupPickerMessageType)
{
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
CharacterMaster val = default(CharacterMaster);
if (!NetworkServer.active)
{
Log.Error("Cannot apply the modifiers because this function is not run on the server");
}
else if (gameObject.TryGetComponent<CharacterMaster>(ref val))
{
CharacterBody body = val.GetBody();
List<MinionOwnership> minionOfPlayer = GetMinionOfPlayer(val);
switch (pickupPickerMessageType)
{
case PickupPickerMessageType.Add:
foreach (MinionOwnership item in minionOfPlayer)
{
if (item == null)
{
continue;
}
CharacterMaster component2 = ((Component)item).gameObject.GetComponent<CharacterMaster>();
if (component2 == null || component2.GetBody() == null)
{
continue;
}
component2.GetBody().AddBuff(Buffs.HealingDisabled);
component2.GetBody().AddBuff(Buffs.Untargetable);
component2.GetBody().AddBuff(Buffs.Immune);
component2.GetBody().AddBuff(Buffs.Entangle);
BaseAI[] aiComponents2 = component2.AiComponents;
foreach (BaseAI val4 in aiComponents2)
{
AISkillDriver[] skillDrivers2 = val4.skillDrivers;
foreach (AISkillDriver val5 in skillDrivers2)
{
val5.aimType = (AimType)0;
}
}
}
body.AddBuff(Buffs.HealingDisabled);
body.AddBuff(Buffs.Untargetable);
body.AddBuff(Buffs.Immune);
body.AddBuff(Buffs.Entangle);
break;
case PickupPickerMessageType.Remove:
foreach (MinionOwnership item2 in minionOfPlayer)
{
if (item2 == null)
{
continue;
}
CharacterMaster component = ((Component)item2).gameObject.GetComponent<CharacterMaster>();
if (component == null || component.GetBody() == null)
{
continue;
}
component.GetBody().RemoveBuff(Buffs.HealingDisabled);
component.GetBody().RemoveBuff(Buffs.Untargetable);
component.GetBody().RemoveBuff(Buffs.Immune);
component.GetBody().RemoveBuff(Buffs.Entangle);
BaseAI[] aiComponents = component.AiComponents;
foreach (BaseAI val2 in aiComponents)
{
AISkillDriver[] skillDrivers = val2.skillDrivers;
foreach (AISkillDriver val3 in skillDrivers)
{
val3.aimType = (AimType)2;
}
}
}
body.RemoveBuff(Buffs.HealingDisabled);
body.RemoveBuff(Buffs.Untargetable);
body.RemoveBuff(Buffs.Immune);
body.RemoveBuff(Buffs.Entangle);
break;
}
}
else
{
Log.Error("Cannot apply the modifiers because this gameObject doesn't have CharacterMaster component");
}
}
}
internal static class Log
{
private static ManualLogSource? _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
ManualLogSource? logSource = _logSource;
if (logSource != null)
{
logSource.LogDebug(data);
}
}
internal static void Error(object data)
{
ManualLogSource? logSource = _logSource;
if (logSource != null)
{
logSource.LogError(data);
}
}
internal static void Fatal(object data)
{
ManualLogSource? logSource = _logSource;
if (logSource != null)
{
logSource.LogFatal(data);
}
}
internal static void Info(object data)
{
ManualLogSource? logSource = _logSource;
if (logSource != null)
{
logSource.LogInfo(data);
}
}
internal static void Message(object data)
{
ManualLogSource? logSource = _logSource;
if (logSource != null)
{
logSource.LogMessage(data);
}
}
internal static void Warning(object data)
{
ManualLogSource? logSource = _logSource;
if (logSource != null)
{
logSource.LogWarning(data);
}
}
}
}
namespace BetterCommand.Source.NetworkMessages
{
public enum PickupPickerMessageType
{
Add,
Remove
}
public class PickupPickerMessage : INetMessage, ISerializableObject
{
private NetworkInstanceId characterMasterNetId;
private PickupPickerMessageType pickupPickerMessageType;
public PickupPickerMessage()
{
}
public PickupPickerMessage(NetworkInstanceId characterMasterNetId, PickupPickerMessageType pickupPickerMessageType)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
this.characterMasterNetId = characterMasterNetId;
this.pickupPickerMessageType = pickupPickerMessageType;
}
public void Deserialize(NetworkReader reader)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
characterMasterNetId = reader.ReadNetworkId();
pickupPickerMessageType = (PickupPickerMessageType)reader.ReadInt32();
}
public void OnReceived()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkServer.active)
{
Log.Error("Cannot apply the modifier because this function is not run on the server");
return;
}
GameObject val = Util.FindNetworkObject(characterMasterNetId);
if (!Object.op_Implicit((Object)(object)val))
{
Log.Error("Cannot find player network game object");
}
else
{
Helper.ApplyBetterCommandOnServer(val, pickupPickerMessageType);
}
}
public void Serialize(NetworkWriter writer)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
writer.Write(characterMasterNetId);
writer.Write((int)pickupPickerMessageType);
}
}
}