Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of RiskOfRamen v1.0.4
RiskOfRamen.dll
Decompiled 3 days agousing System; using System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HG.Reflection; using LoadingScreenFix; using R2API; using RoR2; using RoR2.ContentManagement; using RoR2.ExpansionManagement; using RoR2.Items; using UnityEngine; using UnityEngine.AddressableAssets; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("RiskOfRamen")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RiskOfRamen")] [assembly: AssemblyTitle("RiskOfRamen")] [assembly: OptIn] [assembly: AssemblyVersion("1.0.0.0")] namespace RiskOfRamen; public class RiskOfRamenContent : IContentPackProvider { public static ItemDef _WaxIdol; public static ItemDef _ObsidianCard; public static ItemDef _DenkuRope; public static ItemDef _StainedBelt; public static GameObject _WaxWispBody; public static GameObject _WaxWispMaster; public static CharacterSpawnCard _cscWaxWisp; public static ItemDisplayRuleDict _idrsObsidianCard; public static AssetBundle _assetBundle; public string identifier => "com.Ramen.RiskOfRamen"; public static ReadOnlyContentPack readOnlyContentPack => new ReadOnlyContentPack(RiskOfRamenContentPack); internal static ContentPack RiskOfRamenContentPack { get; } = new ContentPack(); [Obsolete] public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { AssetBundleCreateRequest asyncOperation = AssetBundle.LoadFromFileAsync(RiskOfRamenMain.assetBundleDir); while (!((AsyncOperation)asyncOperation).isDone) { args.ReportProgress(((AsyncOperation)asyncOperation).progress); yield return null; } _assetBundle = asyncOperation.assetBundle; _WaxIdol = _assetBundle.LoadAsset<ItemDef>("WaxIdol"); _ObsidianCard = _assetBundle.LoadAsset<ItemDef>("ObsidianCard"); _DenkuRope = _assetBundle.LoadAsset<ItemDef>("DenkuRope"); _StainedBelt = _assetBundle.LoadAsset<ItemDef>("StainedBelt"); _WaxWispBody = _assetBundle.LoadAsset<GameObject>("WaxWispBody"); _WaxWispMaster = _assetBundle.LoadAsset<GameObject>("WaxWispMaster"); _cscWaxWisp = _assetBundle.LoadAsset<CharacterSpawnCard>("cscWaxWisp"); ExpansionDef val = _assetBundle.LoadAsset<ExpansionDef>("RiskOfRamenExpansion"); RiskOfRamenContentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { _WaxIdol }); RiskOfRamenContentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { _ObsidianCard }); RiskOfRamenContentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { _DenkuRope }); RiskOfRamenContentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { _StainedBelt }); RiskOfRamenContentPack.bodyPrefabs.Add((GameObject[])(object)new GameObject[1] { _WaxWispBody }); RiskOfRamenContentPack.masterPrefabs.Add((GameObject[])(object)new GameObject[1] { _WaxWispMaster }); RiskOfRamenContentPack.expansionDefs.Add((ExpansionDef[])(object)new ExpansionDef[1] { val }); SwapAllShaders(); } private static void SwapAllShaders() { Material[] array = _assetBundle.LoadAllAssets<Material>(); for (int i = 0; i < array.Length; i++) { TrySwapShader(array[i]); } } internal static void TrySwapShader(Material material) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) string name = ((Object)material.shader).name; if (name.Contains("Stubbed")) { name = name.Replace("Stubbed", string.Empty) + ".shader"; Shader val = Addressables.LoadAssetAsync<Shader>((object)name).WaitForCompletion(); if ((Object)(object)val != (Object)null) { RiskOfRamenMain.LogInfo("Swapped shader " + ((Object)material.shader).name + " with " + name); material.shader = val; } else { RiskOfRamenMain.LogError("Failed to load shader " + name); } } else if (name == "Standard") { Texture texture = material.GetTexture("_BumpMap"); float @float = material.GetFloat("_BumpScale"); Texture texture2 = material.GetTexture("_EmissionMap"); material.shader = Resources.Load<Shader>("Shaders/Deferred/HGStandard"); material.SetTexture("_NormalMap", texture); material.SetFloat("_NormalStrength", @float); material.SetTexture("_EmTex", texture2); material.SetColor("_EmColor", new Color(0.2f, 0.2f, 0.2f)); material.SetFloat("_EmPower", 0.15f); } } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(RiskOfRamenContentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } private void AddSelf(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)this); } internal RiskOfRamenContent() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(AddSelf); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.Ramen.RiskOfRamen", "Risk Of Ramen", "1.0.4")] public class RiskOfRamenMain : BaseUnityPlugin { public const string GUID = "com.Ramen.RiskOfRamen"; public const string MODNAME = "Risk Of Ramen"; public const string VERSION = "1.0.4"; public static PluginInfo pluginInfo { get; private set; } public static RiskOfRamenMain instance { get; private set; } internal static AssetBundle assetBundle { get; private set; } internal static string assetBundleDir => Path.Combine(Path.GetDirectoryName(pluginInfo.Location), "riskoframenassets"); internal static string loadingScreenBundleDir => Path.Combine(Path.GetDirectoryName(pluginInfo.Location), "riskoframenssa"); [Obsolete] private void Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown instance = this; pluginInfo = ((BaseUnityPlugin)this).Info; new RiskOfRamenContent(); RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients); LoadingScreenFix.AddSpriteAnimations(GetLoadingScreenBundle()); } internal static void LogFatal(object data) { ((BaseUnityPlugin)instance).Logger.LogFatal(data); } internal static void LogError(object data) { ((BaseUnityPlugin)instance).Logger.LogError(data); } internal static void LogWarning(object data) { ((BaseUnityPlugin)instance).Logger.LogWarning(data); } internal static void LogMessage(object data) { ((BaseUnityPlugin)instance).Logger.LogMessage(data); } internal static void LogInfo(object data) { ((BaseUnityPlugin)instance).Logger.LogInfo(data); } internal static void LogDebug(object data) { ((BaseUnityPlugin)instance).Logger.LogDebug(data); } private static void RecalculateStatsAPI_GetStatCoefficients(CharacterBody self, StatHookEventArgs args) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) BuffDef val = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/Common/bdOnFire.asset").WaitForCompletion(); BuffDef val2 = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/Common/bdStrongerBurn.asset").WaitForCompletion(); if (Object.op_Implicit((Object)(object)self.inventory)) { int itemCountEffective = self.inventory.GetItemCountEffective(RiskOfRamenContent._DenkuRope); int itemCountEffective2 = self.inventory.GetItemCountEffective(RiskOfRamenContent._ObsidianCard); int itemCountEffective3 = self.inventory.GetItemCountEffective(RiskOfRamenContent._WaxIdol); int itemCountEffective4 = self.inventory.GetItemCountEffective(RiskOfRamenContent._StainedBelt); if (itemCountEffective >= 1) { args.critDamageMultAdd += 0.1f * (float)itemCountEffective; } if (itemCountEffective2 >= 1) { args.barrierDecayMult -= 0.25f + 0.1f * (float)itemCountEffective2; } if (itemCountEffective3 >= 1 && (self.HasBuff(val) || self.HasBuff(val2))) { args.armorAdd += (float)(40 + 10 * itemCountEffective3); } if (itemCountEffective4 >= 1) { args.critAdd += GetBarrierPercentage(self) * (0.25f * (float)itemCountEffective4); } } } internal static AssetBundle GetLoadingScreenBundle() { return AssetBundle.LoadFromFile(loadingScreenBundleDir); } public static float GetBarrierPercentage(CharacterBody self) { return self.healthComponent.barrier / self.healthComponent.fullBarrier; } } public class WaxIdolBodyBehavior : BaseItemBodyBehavior { private static readonly float timeBetweenWispResummons = 30f; private static readonly float timeBetweenWispRetryResummons = 1f; private float wispResummonCooldown; [ItemDefAssociation(useOnServer = true, useOnClient = false)] private static ItemDef GetItemDef() { return RiskOfRamenContent._WaxIdol; } private void Start() { wispResummonCooldown = timeBetweenWispRetryResummons; } private void FixedUpdate() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown int stack = base.stack; CharacterMaster bodyMaster = ((BaseItemBodyBehavior)this).body.master; if (!Object.op_Implicit((Object)(object)bodyMaster)) { return; } int deployableCount = bodyMaster.GetDeployableCount((DeployableSlot)1); if (deployableCount >= stack) { return; } wispResummonCooldown -= Time.fixedDeltaTime; if (wispResummonCooldown <= 0f) { DirectorSpawnRequest val = new DirectorSpawnRequest((SpawnCard)(object)RiskOfRamenContent._cscWaxWisp, new DirectorPlacementRule { placementMode = (PlacementMode)1, minDistance = 3f, maxDistance = 40f, spawnOnTarget = ((Component)this).transform }, RoR2Application.rng); val.summonerBodyObject = ((Component)this).gameObject; val.onSpawnedServer = OnWispSpawned; DirectorCore.instance.TrySpawnObject(val); if (deployableCount < stack) { wispResummonCooldown = timeBetweenWispRetryResummons; } else { wispResummonCooldown = timeBetweenWispResummons; } } void OnWispSpawned(SpawnResult spawnResult) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GameObject spawnedInstance = spawnResult.spawnedInstance; if (Object.op_Implicit((Object)(object)spawnedInstance)) { CharacterMaster component = spawnedInstance.GetComponent<CharacterMaster>(); if (Object.op_Implicit((Object)(object)component)) { component.inventory.GiveItemPermanent(Items.BoostDamage, 30); component.inventory.GiveItemPermanent(Items.BoostHp, 10); Deployable component2 = ((Component)component).GetComponent<Deployable>(); if (Object.op_Implicit((Object)(object)component2)) { bodyMaster.AddDeployable(component2, (DeployableSlot)1); } } } } } }