Decompiled source of CommunityBadges v0.1.0

CommunityBadges.dll

Decompiled a week ago
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreBadges;
using Photon.Realtime;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CommunityBadges")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("CommunityBadges")]
[assembly: AssemblyTitle("CommunityBadges")]
[assembly: AssemblyVersion("0.1.0.0")]
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;
		}
	}
}
namespace CommunityBadges
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.snosz.communitybadges", "CommunityBadges", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static class BadgeNames
		{
			public const string SharingIsCaringBadge = "Badge_CommunityBadges_SharingIsCaring";

			public const string PeakScoutBadge = "Badge_CommunityBadges_PeakScout";

			public const string NapTimeBadge = "Badge_CommunityBadges_NapTime";

			public const string YouMonsterBadge = "Badge_CommunityBadges_YouMonster";
		}

		[HarmonyPatch(typeof(Action_RaycastDart), "RPC_DartImpact")]
		public static class RPC_DartImpactPatch
		{
			private static void Postfix(Action_RaycastDart __instance, Player hitPlayer)
			{
				if (hitPlayer != null && hitPlayer.IsLocal && ((Component)__instance).GetComponent<Item>().itemID == 70)
				{
					MoreBadgesPlugin.AddProgress("Badge_CommunityBadges_NapTime", 1);
				}
			}
		}

		[HarmonyPatch(typeof(Item), "FinishCastSecondary")]
		public static class FinishCastSecondaryPatch
		{
			private static void Prefix(Item __instance)
			{
				if (__instance.canUseOnFriend && Interaction.instance.hasValidTargetCharacter && (Object)(object)__instance.holderCharacter != (Object)null && __instance.itemID == 95)
				{
					MoreBadgesPlugin.AddProgress("Badge_CommunityBadges_SharingIsCaring", 1);
				}
			}
		}

		[HarmonyPatch(typeof(ItemCooking), "FinishCooking")]
		public static class FinishCookingRPCPatch
		{
			private static void Postfix(ItemCooking __instance)
			{
				IntItemData data = ((ItemComponent)__instance).GetData<IntItemData>((DataEntryKey)1);
				if (data.Value == 1)
				{
					Item component = ((Component)__instance).GetComponent<Item>();
					if ((Object)(object)component != (Object)null && component.itemID == 13)
					{
						MoreBadgesPlugin.AddProgress("Badge_CommunityBadges_YouMonster", 1);
					}
				}
			}
		}

		[HarmonyPatch(typeof(EndScreen), "EndSequenceRoutine")]
		public static class EndSequenceRoutinePatch
		{
			private static void Prefix(EndScreen __instance)
			{
				if (Ascents.currentAscent == 7)
				{
					MoreBadgesPlugin.AddProgress("Badge_CommunityBadges_PeakScout", 1);
				}
			}
		}

		public static Plugin Instance;

		private static Harmony _harmony;

		private AssetBundle badgesBundle;

		private static readonly FieldRef<Interaction, CharacterInteractible> bestCharacterRef = AccessTools.FieldRefAccess<Interaction, CharacterInteractible>("bestCharacter");

		private void Awake()
		{
			Instance = this;
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.snosz.communitybadges");
			byte[] communitybadges = Resource1.communitybadges;
			badgesBundle = AssetBundle.LoadFromMemory(communitybadges);
			MoreBadgesPlugin.RegisterBadgeAssetBundle(badgesBundle);
		}
	}
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resource1
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("CommunityBadges.Resource1", typeof(Resource1).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] communitybadges
		{
			get
			{
				object @object = ResourceManager.GetObject("communitybadges", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resource1()
		{
		}
	}
}