using System;
using System.Collections;
using System.Collections.Generic;
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.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;
[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("RoflItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RoflItems")]
[assembly: AssemblyTitle("RoflItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 ExamplePlugin
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("idolfan.RoflItems", "RoflItems", "1.0.2")]
public class RoflItems : BaseUnityPlugin
{
public const string PluginGUID = "idolfan.RoflItems";
public const string PluginAuthor = "idolfan";
public const string PluginName = "RoflItems";
public const string PluginVersion = "1.0.2";
private static readonly int[] PrimeNumbers = new int[8] { 2, 3, 5, 7, 11, 13, 17, 19 };
private readonly Dictionary<CharacterBody, int> playerPrimes = new Dictionary<CharacterBody, int>();
public static int testRadius = 1;
public ItemDef sledgehammerDef;
public ItemDef armorplateDef;
public EquipmentDef leckererLachs;
public static BuffDef firstHitBuff;
public static GameObject RingEffectPrefab;
public static ConfigEntry<float> armorPerStack { get; set; }
public static ConfigEntry<float> bonusDamageForFirstStack { get; set; }
public static ConfigEntry<float> bonusDamageForMoreStacks { get; set; }
public static ConfigEntry<bool> debugEnabled { get; set; }
public static ConfigEntry<float> aggroChance { get; set; }
public static ConfigEntry<float> aggroInnerRadius { get; set; }
public static ConfigEntry<float> aggroOuterRadius { get; set; }
public static ConfigEntry<float> aggroCooldown { get; set; }
public static ConfigEntry<float> aggroDuration { get; set; }
public static ConfigEntry<bool> enableSalmon { get; set; }
public void Awake()
{
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected O, but got Unknown
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Expected O, but got Unknown
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Expected O, but got Unknown
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Expected O, but got Unknown
armorPerStack = ((BaseUnityPlugin)this).Config.Bind<float>("Armorplate", "Armor per Stack", 4f, "The armor the item gives per Stack.");
bonusDamageForFirstStack = ((BaseUnityPlugin)this).Config.Bind<float>("Sledgehammer", "First stack bonus", 0.8f, "The damage bonus given on one stack of the item.");
bonusDamageForMoreStacks = ((BaseUnityPlugin)this).Config.Bind<float>("Sledgehammer", "Further stacks bonus", 0.5f, "The damage bonus given for each further stack of the item.");
debugEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Logs debug messages", false, "");
aggroChance = ((BaseUnityPlugin)this).Config.Bind<float>("Salmon", "Chance", 0.7f, "The chance for far away enemies to also take aggro");
aggroInnerRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Salmon", "Inner Radius", 25f, "The radius within which enemies are affected 100% of the time");
aggroOuterRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Salmon", "Outer Radius", 50f, "The radius within which enemies might be affected, dependent on aggroChance");
aggroCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Salmon", "Cooldown", 60f, "The cooldown of the Equipment");
aggroDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Salmon", "Duration", 7f, "The duration of the taunt in seconds.");
enableSalmon = ((BaseUnityPlugin)this).Config.Bind<bool>("Salmon", "Enable", true, "Whether the Salmon will appear in your runs.");
createItems();
CharacterBody.RecalculateStats += new hook_RecalculateStats(grantStats);
CharacterMaster.OnBodyStart += new hook_OnBodyStart(CharacterMaster_OnStart);
firstHitBuff = ScriptableObject.CreateInstance<BuffDef>();
((Object)firstHitBuff).name = "FirstHitMarker";
firstHitBuff.iconSprite = null;
firstHitBuff.canStack = true;
firstHitBuff.isDebuff = true;
ContentAddition.AddBuffDef(firstHitBuff);
HealthComponent.TakeDamage += new hook_TakeDamage(extraDamageOnFirstHit);
if (enableSalmon.Value)
{
EquipmentSlot.PerformEquipmentAction += new hook_PerformEquipmentAction(EquipmentSlot_PerformEquipmentAction);
}
Stage.onStageStartGlobal += onStageStart;
}
private bool EquipmentSlot_PerformEquipmentAction(orig_PerformEquipmentAction orig, EquipmentSlot equipmentSlot, EquipmentDef equipmentDef)
{
if (debugEnabled.Value)
{
Console.WriteLine("MEGAROFL EQDEFAC " + ((Object)equipmentDef).name);
}
if ((Object)(object)equipmentDef == (Object)(object)leckererLachs)
{
OnEquipmentActivated(equipmentSlot);
return true;
}
return orig.Invoke(equipmentSlot, equipmentDef);
}
private void onStageStart(Stage stage)
{
playerPrimes.Clear();
if (debugEnabled.Value)
{
Console.WriteLine("MEGAROFL playerPrimes wurde gecleared");
}
}
private void createItems()
{
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Expected O, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Expected O, but got Unknown
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Expected O, but got Unknown
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Expected O, but got Unknown
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_035b: Expected O, but got Unknown
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Expected O, but got Unknown
AssetBundle val = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("RoflItems.dll", "rofl_items_assets"));
((MonoBehaviour)this).StartCoroutine(UpgradeStubbedShadersAsync(val));
armorplateDef = ScriptableObject.CreateInstance<ItemDef>();
((Object)armorplateDef).name = "Armorplate";
armorplateDef.nameToken = "Armorplate";
armorplateDef.pickupToken = "You become the tank.";
armorplateDef.descriptionToken = $"Grants {armorPerStack.Value}(+{armorPerStack.Value} per Stack) Armor.";
armorplateDef.loreToken = "Es war einmal ein Panzer.\nSchaden hat er keinen bekommen.";
armorplateDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
armorplateDef.pickupIconSprite = val.LoadAsset<Sprite>("armorplate.png");
armorplateDef.pickupModelPrefab = val.LoadAsset<GameObject>("armorplate.prefab");
armorplateDef.canRemove = true;
armorplateDef.hidden = false;
ItemDisplayRuleDict val2 = new ItemDisplayRuleDict((ItemDisplayRule[])null);
ItemAPI.Add(new CustomItem(armorplateDef, val2));
sledgehammerDef = ScriptableObject.CreateInstance<ItemDef>();
((Object)sledgehammerDef).name = "Sledgehammer";
sledgehammerDef.nameToken = "Sledgehammer";
sledgehammerDef.pickupToken = "You make the suggestion.";
sledgehammerDef.descriptionToken = $"Your first hit against an enemy deals {bonusDamageForFirstStack.Value * 100f}% (+{bonusDamageForMoreStacks.Value * 100f}% per Stack) more damage";
sledgehammerDef.loreToken = "Ich geh mal den Garten durchsuchen (-> Stärke 9 :)).";
sledgehammerDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
sledgehammerDef.pickupIconSprite = val.LoadAsset<Sprite>("sledgehammer.png");
sledgehammerDef.pickupModelPrefab = val.LoadAsset<GameObject>("sledgehammer.prefab");
sledgehammerDef.canRemove = true;
sledgehammerDef.hidden = false;
ItemDisplayRuleDict val3 = new ItemDisplayRuleDict((ItemDisplayRule[])null);
ItemAPI.Add(new CustomItem(sledgehammerDef, val3));
if (enableSalmon.Value)
{
leckererLachs = ScriptableObject.CreateInstance<EquipmentDef>();
((Object)leckererLachs).name = "Salmon";
leckererLachs.nameToken = "Salmon";
leckererLachs.pickupToken = "Salmon in shark's clothing.";
leckererLachs.descriptionToken = $"Attracts all enemies within {aggroInnerRadius.Value} meters.\nAttracts {aggroChance.Value * 100f}% of enemies within {aggroOuterRadius.Value} meters.\nLasts {aggroDuration.Value} seconds.";
leckererLachs.loreToken = "Nimm den Lachs von meinen Sandalen runter!";
leckererLachs.pickupIconSprite = val.LoadAsset<Sprite>("salmon.png");
leckererLachs.pickupModelPrefab = val.LoadAsset<GameObject>("lachs.prefab");
leckererLachs.cooldown = aggroCooldown.Value;
leckererLachs.canDrop = true;
leckererLachs.enigmaCompatible = true;
ItemDisplayRuleDict val4 = new ItemDisplayRuleDict((ItemDisplayRule[])null);
bool flag = ItemAPI.Add(new CustomEquipment(leckererLachs, val4));
if (debugEnabled.Value)
{
Console.WriteLine("MEGAROFL Lachs " + flag);
}
}
}
private void CharacterMaster_OnStart(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
{
if (debugEnabled.Value)
{
Console.WriteLine("MEGAROFLL " + ((Object)self).name);
}
orig.Invoke(self, body);
if ((Object)(object)self.playerCharacterMasterController != (Object)null)
{
AssignPrimeToPlayer(body);
}
}
private void AssignPrimeToPlayer(CharacterBody body)
{
if (debugEnabled.Value)
{
Console.WriteLine("MEGAROFL body " + (object)body);
}
if (!((Object)(object)body != (Object)null) || playerPrimes.ContainsKey(body))
{
return;
}
if (playerPrimes.Count < PrimeNumbers.Length)
{
playerPrimes[body] = PrimeNumbers[playerPrimes.Count];
if (debugEnabled.Value)
{
Console.WriteLine($"MEGAROFL Primzahl {PrimeNumbers[playerPrimes.Count - 1]} zugewiesen an Spieler {((Object)body).name}");
}
}
else if (debugEnabled.Value)
{
Console.WriteLine("MEGAROFL Nicht genug Primzahlen für alle Spieler!");
}
}
private void extraDamageOnFirstHit(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
{
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
CharacterBody body = self.body;
if (!Object.op_Implicit((Object)(object)damageInfo.attacker) || !Object.op_Implicit((Object)(object)body))
{
orig.Invoke(self, damageInfo);
return;
}
CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
if ((Object)(object)component == (Object)null || (Object)(object)body == (Object)null)
{
orig.Invoke(self, damageInfo);
return;
}
int valueOrDefault = playerPrimes.GetValueOrDefault(component);
if (valueOrDefault == 0)
{
orig.Invoke(self, damageInfo);
return;
}
Inventory inventory = component.inventory;
int itemCount = inventory.GetItemCount(sledgehammerDef);
if ((Object)(object)inventory == (Object)null || itemCount <= 0)
{
orig.Invoke(self, damageInfo);
return;
}
if (!body.HasBuff(firstHitBuff))
{
body.AddBuff(firstHitBuff);
body.SetBuffCount(firstHitBuff.buffIndex, valueOrDefault);
damageInfo.damage *= calculateFirstHitMult(itemCount);
}
else
{
int buffCount = body.GetBuffCount(firstHitBuff);
if (buffCount % valueOrDefault != 0)
{
body.SetBuffCount(firstHitBuff.buffIndex, buffCount * valueOrDefault);
damageInfo.damage *= calculateFirstHitMult(itemCount);
}
}
orig.Invoke(self, damageInfo);
}
private float calculateFirstHitMult(int itemCount)
{
return 1f + bonusDamageForFirstStack.Value + (float)(itemCount - 1) * bonusDamageForMoreStacks.Value;
}
private void grantStats(orig_RecalculateStats orig, CharacterBody self)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (Object.op_Implicit((Object)(object)self.inventory))
{
int itemCount = self.inventory.GetItemCount(armorplateDef.itemIndex);
if (itemCount > 0)
{
self.armor += armorPerStack.Value * (float)itemCount;
}
}
}
public static void OnEquipmentActivated(EquipmentSlot equipmentSlot)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)equipmentSlot == (Object)null) && !((Object)(object)equipmentSlot.characterBody == (Object)null))
{
GameObject gameObject = ((Component)equipmentSlot.characterBody).gameObject;
AggroEnemiesInRadius(gameObject.transform.position, aggroInnerRadius.Value, aggroOuterRadius.Value, gameObject);
}
}
private static void AggroEnemiesInRadius(Vector3 position, float innerRadius, float outerRadius, GameObject player)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Expected O, but got Unknown
BullseyeSearch val = new BullseyeSearch
{
searchOrigin = position,
searchDirection = Vector3.up,
maxDistanceFilter = outerRadius,
teamMaskFilter = TeamMask.GetEnemyTeams((TeamIndex)1),
sortMode = (SortMode)1
};
val.RefreshCandidates();
Random random = new Random();
foreach (HurtBox result in val.GetResults())
{
if (!(random.NextDouble() < (double)aggroChance.Value))
{
continue;
}
AISkillDriver component = ((Component)result.healthComponent.body.master).GetComponent<AISkillDriver>();
BaseAI component2 = ((Component)result.healthComponent.body.master).GetComponent<BaseAI>();
if (!((Object)(object)component2 == (Object)null))
{
component2.currentEnemy.gameObject = player;
component2.targetRefreshTimer = aggroDuration.Value;
if (debugEnabled.Value)
{
Console.WriteLine($"MEGAROFL aggro {((Object)result).name} {player.GetComponent<HurtBox>()}");
}
}
}
BullseyeSearch val2 = new BullseyeSearch
{
searchOrigin = position,
searchDirection = Vector3.up,
maxDistanceFilter = innerRadius,
teamMaskFilter = TeamMask.GetEnemyTeams((TeamIndex)1),
sortMode = (SortMode)1
};
val2.RefreshCandidates();
foreach (HurtBox result2 in val2.GetResults())
{
AISkillDriver component3 = ((Component)result2.healthComponent.body.master).GetComponent<AISkillDriver>();
BaseAI component4 = ((Component)result2.healthComponent.body.master).GetComponent<BaseAI>();
if (!((Object)(object)component4 == (Object)null))
{
component4.currentEnemy.gameObject = player;
component4.targetRefreshTimer = aggroDuration.Value;
if (debugEnabled.Value)
{
Console.WriteLine($"MEGAROFL aggro {((Object)result2).name} {player.GetComponent<HurtBox>()}");
}
}
}
if (debugEnabled.Value)
{
Console.WriteLine($"MEGAROFL Alle Gegner innerhalb von {aggroInnerRadius} Metern fokussieren nun {((Object)player).name}");
}
}
private static void RegisterRingEffect()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
RingEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/NearbyDamageBonus/DiamondDamageBonusEffect.prefab").WaitForCompletion();
GameObject val = PrefabAPI.InstantiateClone(RingEffectPrefab, "CustomRingEffect", true);
val.transform.localScale = Vector3.one * 10f;
RingEffectPrefab = val;
ContentAddition.AddEffect(RingEffectPrefab);
}
private void Update()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
if (debugEnabled.Value && Input.GetKeyDown((KeyCode)283))
{
Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;
PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(armorplateDef.itemIndex), transform.position, transform.forward * 20f);
PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(sledgehammerDef.itemIndex), transform.position, transform.forward * 15f);
EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(((Object)leckererLachs).name);
PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(val), transform.position, transform.forward * 15f);
}
}
public IEnumerator UpgradeStubbedShadersAsync(AssetBundle assetBundle)
{
Object[] _ = Array.Empty<Object>();
if ((Object)(object)assetBundle == (Object)null)
{
throw new ArgumentNullException("assetBundle");
}
AssetBundleRequest loadMaterials = assetBundle.LoadAllAssetsAsync<Material>();
while (!((AsyncOperation)loadMaterials).isDone)
{
yield return null;
}
Object[] allMaterials = loadMaterials.allAssets;
int materialCount = allMaterials.Length;
if (materialCount <= 0)
{
yield break;
}
List<AsyncOperationHandle> loadResourceLocationsOperations = new List<AsyncOperationHandle>(materialCount);
for (int k = materialCount - 1; k >= 0; k--)
{
string cachedShaderName = ((Object)((Material)allMaterials[k]).shader).name;
if (cachedShaderName.StartsWith("Stubbed"))
{
loadResourceLocationsOperations.Add(AsyncOperationHandle<IList<IResourceLocation>>.op_Implicit(Addressables.LoadResourceLocationsAsync((object)(cachedShaderName.Substring(7) + ".shader"), typeof(Shader))));
}
else
{
materialCount--;
for (int l = k; l < materialCount; l++)
{
allMaterials[l] = allMaterials[l + 1];
}
}
}
if (materialCount <= 0)
{
yield break;
}
AsyncOperationHandle<IList<AsyncOperationHandle>> loadResourceLocationsGroup = Addressables.ResourceManager.CreateGenericGroupOperation(loadResourceLocationsOperations, false);
while (!loadResourceLocationsGroup.IsDone)
{
yield return null;
}
List<IResourceLocation> resourceLocations = new List<IResourceLocation>(materialCount);
for (int j = materialCount - 1; j >= 0; j--)
{
AsyncOperationHandle val = loadResourceLocationsGroup.Result[j];
IList<IResourceLocation> result = (IList<IResourceLocation>)((AsyncOperationHandle)(ref val)).Result;
if (result.Count > 0)
{
resourceLocations.Add(result[0]);
}
else
{
materialCount--;
for (int m = materialCount - j; m < materialCount; m++)
{
allMaterials[m] = allMaterials[m + 1];
}
}
}
if (materialCount > 0)
{
AsyncOperationHandle<IList<Shader>> loadShaders = Addressables.LoadAssetsAsync<Shader>((IList<IResourceLocation>)resourceLocations, (Action<Shader>)null, false);
while (!loadShaders.IsDone)
{
yield return null;
}
int startIndex = _.Length;
Array.Resize(ref _, startIndex + materialCount);
for (int i = 0; i < materialCount; i++)
{
SwapShader((Material)allMaterials[i], loadShaders.Result[i]);
_[startIndex + i] = allMaterials[i];
}
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void SwapShader(Material material, Shader shader)
{
int renderQueue = material.renderQueue;
material.shader = shader;
material.renderQueue = renderQueue;
}
}
}
namespace EntityStates.Abathur.test
{
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
}