using System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Steamworks; 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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace CatCosmetics; [BepInPlugin("eberk30.catcosmetics", "Cat Cosmetics", "1.2.0")] public class CatCosmeticsPlugin : BaseUnityPlugin { public const string PLUGIN_GUID = "eberk30.catcosmetics"; public const string PLUGIN_NAME = "Cat Cosmetics"; public const string PLUGIN_VERSION = "1.2.0"; internal static ManualLogSource Log; private static readonly string[] GiftUsernames = new string[2] { "catnamednorris", "[GEMs]catnamednorris" }; private static readonly string[] GiftCosmeticNames = new string[2] { "Fleur", "Loaf of Fleur" }; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ((MonoBehaviour)this).StartCoroutine(GiftCosmeticRoutine()); } private IEnumerator GiftCosmeticRoutine() { float waited = 0f; while ((Object)(object)MetaManager.instance == (Object)null || MetaManager.instance.cosmeticAssets.Count == 0) { yield return null; waited += Time.deltaTime; if (waited > 30f) { Log.LogWarning((object)"[CatCosmetics] No assests found"); yield break; } } if (!SteamClient.IsValid) { yield break; } bool matched = false; string[] giftUsernames = GiftUsernames; for (int i = 0; i < giftUsernames.Length; i++) { if (string.Equals(b: giftUsernames[i], a: SteamClient.Name, comparisonType: StringComparison.OrdinalIgnoreCase)) { matched = true; break; } } if (!matched) { yield break; } string[] giftCosmeticNames = GiftCosmeticNames; foreach (string cosmeticName in giftCosmeticNames) { CosmeticAsset target = null; waited = 0f; while ((Object)(object)target == (Object)null) { foreach (CosmeticAsset asset in MetaManager.instance.cosmeticAssets) { if ((Object)(object)asset != (Object)null && asset.assetName == cosmeticName) { target = asset; break; } } if ((Object)(object)target != (Object)null) { break; } yield return null; waited += Time.deltaTime; if (waited > 30f) { Log.LogWarning((object)("[CatCosmetics] timed out waiting for cosmetic asset '" + cosmeticName + "' to be registered")); break; } } if ((Object)(object)target != (Object)null && MetaManager.instance.CosmeticUnlock(target)) { Log.LogInfo((object)("[CatCosmetics] gifted '" + target.assetName + "' to " + SteamClient.Name)); } } } }