Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LazyBastardEngineer v2.4.3
LasyBastardEngineer.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 HarmonyLib; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using R2API; using R2API.Utils; using RoR2; using RoR2.Achievements; using RoR2.Projectile; using RoR2BepInExPack.VanillaFixes; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.Rendering; [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 = "")] [assembly: AssemblyCompany("LasyBastardEngineer")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LasyBastardEngineer")] [assembly: AssemblyTitle("LasyBastardEngineer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace LasyBastardEngineer; [RegisterAchievement("LazyBastardEngineer", "Skins.Engineer.LazyBastard", "Complete30StagesCareer", 3u, null)] public class Achievement : BaseAchievement { private int skillUseCount = 0; public override BodyIndex LookUpRequiredBodyIndex() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return BodyCatalog.FindBodyIndex("EngiBody"); } public override void OnBodyRequirementMet() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown ((BaseAchievement)this).OnBodyRequirementMet(); Run.onRunStartGlobal += ResetSkillUseCount; Run.onClientGameOverGlobal += ClearCheck; CharacterBody.OnSkillActivated += new hook_OnSkillActivated(SkillCheck); } public override void OnBodyRequirementBroken() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown Run.onRunStartGlobal += ResetSkillUseCount; Run.onClientGameOverGlobal -= ClearCheck; CharacterBody.OnSkillActivated -= new hook_OnSkillActivated(SkillCheck); ((BaseAchievement)this).OnBodyRequirementBroken(); } private void SkillCheck(orig_OnSkillActivated orig, CharacterBody self, GenericSkill skill) { //IL_0002: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 if (self.bodyIndex == ((BaseAchievement)this).LookUpRequiredBodyIndex() && (int)self.teamComponent.teamIndex == 1 && (Object)(object)skill != (Object)(object)self.skillLocator.special) { if (skillUseCount == 0) { Debug.Log((object)"DEBUG: Lazy Bastard challenge failed."); if (LazyBastardPlugin.AnnounceWhenFail.Value) { Chat.AddMessage("Lazy Bastard challenge failed!"); } } skillUseCount++; } orig.Invoke(self, skill); } private void ResetSkillUseCount(Run obj) { skillUseCount = 0; } public void ClearCheck(Run run, RunReport runReport) { bool flag = skillUseCount == 0 && ((BaseAchievement)this).meetsBodyRequirement; skillUseCount = 0; if (!((Object)(object)run == (Object)null) && runReport != null && Object.op_Implicit((Object)(object)runReport.gameEnding) && runReport.gameEnding.isWin && flag) { ((BaseAchievement)this).Grant(); } } } [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [R2APISubmoduleDependency(new string[] { "LanguageAPI", "LoadoutAPI" })] [BepInPlugin("com.Borbo.LazyBastardEngineer", "LazyBastardEngineer", "2.4.0")] internal class LazyBastardPlugin : BaseUnityPlugin { [HarmonyPatch] public class PatchAchievementDefs { public static void ILManipulator(ILContext il, MethodBase original, ILLabel retLabel) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int attr = -1; val.GotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCastclass<RegisterAchievementAttribute>(x), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref attr) }); val.Emit(OpCodes.Ldloc, attr - 1); val.Emit(OpCodes.Ldloc, attr); val.EmitDelegate<Func<Type, RegisterAchievementAttribute, RegisterAchievementAttribute>>((Func<Type, RegisterAchievementAttribute, RegisterAchievementAttribute>)((Type type, RegisterAchievementAttribute achievementAttribute) => (ForceUnlock.Value && achievementAttribute != null && achievementAttribute.unlockableRewardIdentifier == "Skins.Engineer.LazyBastard") ? null : achievementAttribute)); val.Emit(OpCodes.Stloc, attr); } public static MethodBase TargetMethod() { return AccessTools.DeclaredMethod(typeof(SaferAchievementManager).GetNestedType("<SaferCollectAchievementDefs>d__12", AccessTools.all), "MoveNext", (Type[])null, (Type[])null); } } public const string guid = "com.Borbo.LazyBastardEngineer"; public const string teamName = "Borbo"; public const string modName = "LazyBastardEngineer"; public const string version = "2.4.0"; public static LazyBastardPlugin instance; public static Harmony Harmony; public static string modPrefix = string.Format("@{0}+{1}", "LazyBastardEngineer", "lazybastardengi"); public static Sprite skinIcon = Skins.CreateSkinIcon(new Color(1f, 0.7f, 0.3f), new Color(0.7f, 0.5f, 0.3f), new Color(0.3f, 0.3f, 0.3f), new Color(0.8f, 0.8f, 0.8f)); private static AssetBundle _skinBundle; public static string meshesPath = "Assets/Models/Character/"; public static string materialsPath = "Assets/Textures/Materials/Character/"; public static string iconsPath = "Assets/Textures/Icons/Skill/"; public static UnlockableDef unlock; public static GameObject engiBodyPrefab; public static GameObject turretBodyPrefab; public static GameObject walkerBodyPrefab; public static GameObject grenadePrefab; public static GameObject grenadeGhost; public static GameObject minePrefab; public static GameObject mineGhost; public static GameObject spiderPrefab; public static GameObject spiderGhost; internal static ConfigFile CustomConfigFile { get; set; } public static ConfigEntry<bool> ForceUnlock { get; set; } public static ConfigEntry<bool> AnnounceWhenFail { get; set; } public static AssetBundle skinBundle { get { if ((Object)(object)_skinBundle == (Object)null) { _skinBundle = Assets.LoadAssetBundle("lazybastardengi"); } return _skinBundle; } set { _skinBundle = value; } } public static AssetBundle LoadAssetBundleResourcesProvider(string prefix, byte[] resourceBytes) { if (resourceBytes == null) { throw new ArgumentNullException("resourceBytes"); } if (string.IsNullOrEmpty(prefix) || !prefix.StartsWith("@")) { throw new ArgumentException("Invalid prefix format", "prefix"); } AssetBundle val = AssetBundle.LoadFromMemory(resourceBytes); if ((Object)(object)val == (Object)null) { throw new NullReferenceException(string.Format("{0} did not resolve to an assetbundle.", "resourceBytes")); } return val; } private void Awake() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown instance = this; InitializeConfig(); Log.Init(((BaseUnityPlugin)this).Logger); unlock = ScriptableObject.CreateInstance<UnlockableDef>(); unlock.cachedName = "Skins.Engineer.LazyBastard"; unlock.nameToken = "ACHIEVEMENT_LAZYBASTARDENGINEER_NAME"; unlock.achievementIcon = skinIcon; ContentAddition.AddUnlockableDef(unlock); Materials.SwapAllShaders(skinBundle); AddFactorioSkin(); LanguageAPI.Add("FACTORIO_SKIN_ENGINEER", "Power Armor MK2"); LanguageAPI.Add("ACHIEVEMENT_LAZYBASTARDENGINEER_NAME", "Engineer: Lazy Bastard"); LanguageAPI.Add("ACHIEVEMENT_LAZYBASTARDENGINEER_DESCRIPTION", "As Engineer, beat the game or obliterate without using your Primary, Secondary, or Utility skills."); Harmony = new Harmony("com.Borbo.LazyBastardEngineer"); Harmony.PatchAll(typeof(PatchAchievementDefs)); } private void InitializeConfig() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\LazyBastardEngi.cfg", true); ForceUnlock = CustomConfigFile.Bind<bool>("Achievements", "Force Unlock Lazy Bastard Skin", false, "Set this to true to bypass the unlock requirement for the Lazy Bastard Skin."); AnnounceWhenFail = CustomConfigFile.Bind<bool>("Debug", "Announce When Fail", true, "Set this to true to add an announcement to the chat when the Lazy Bastard challenge fails. "); } private void AddFactorioSkin() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) engiBodyPrefab = Resources.Load<GameObject>("prefabs/characterbodies/EngiBody"); turretBodyPrefab = Resources.Load<GameObject>("prefabs/characterbodies/EngiTurretBody"); walkerBodyPrefab = Resources.Load<GameObject>("prefabs/characterbodies/EngiWalkerTurretBody"); grenadePrefab = Resources.Load<GameObject>("prefabs/projectiles/EngiGrenadeProjectile"); grenadeGhost = Resources.Load<GameObject>("prefabs/projectileghosts/EngiGrenadeGhost"); minePrefab = Resources.Load<GameObject>("prefabs/projectiles/EngiMine"); mineGhost = Resources.Load<GameObject>("prefabs/projectileghosts/EngiMineGhost"); spiderPrefab = Resources.Load<GameObject>("prefabs/projectiles/SpiderMine"); spiderGhost = Resources.Load<GameObject>("prefabs/projectileghosts/SpiderMineGhost"); Renderer[] componentsInChildren = engiBodyPrefab.GetComponentsInChildren<Renderer>(true); ModelSkinController componentInChildren = engiBodyPrefab.GetComponentInChildren<ModelSkinController>(); GameObject gameObject = ((Component)componentInChildren).gameObject; SkinDefInfo val = default(SkinDefInfo); val.Icon = skinIcon; val.Name = "LazyBastardEngineer"; val.NameToken = "FACTORIO_SKIN_ENGINEER"; val.RootObject = gameObject; val.BaseSkins = (SkinDef[])(object)new SkinDef[1] { componentInChildren.skins[0] }; val.UnlockableDef = (ForceUnlock.Value ? null : unlock); val.GameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[0]; val.RendererInfos = (RendererInfo[])(object)new RendererInfo[1] { new RendererInfo { defaultMaterial = skinBundle.LoadAsset<Material>(materialsPath + "matLazyBastard.mat"), defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false, renderer = componentsInChildren[4] } }; val.MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[1] { new MeshReplacement { mesh = skinBundle.LoadAsset<Mesh>(meshesPath + "EngiMesh.mesh"), renderer = componentsInChildren[4] } }; val.ProjectileGhostReplacements = (ProjectileGhostReplacement[])(object)new ProjectileGhostReplacement[2] { new ProjectileGhostReplacement { projectilePrefab = minePrefab, projectileGhostReplacementPrefab = NewProjectileGhost(mineGhost, "EngiMineGhost.prefab") }, new ProjectileGhostReplacement { projectilePrefab = grenadePrefab, projectileGhostReplacementPrefab = NewProjectileGhost(grenadeGhost, "EngiGrenadeGhost.prefab") } }; val.MinionSkinReplacements = (MinionSkinReplacement[])(object)new MinionSkinReplacement[2] { new MinionSkinReplacement { minionBodyPrefab = turretBodyPrefab, minionSkin = GetSkinFromTurretBody(turretBodyPrefab, "matLazyBastard.mat", "EngiTurretMesh.mesh") }, new MinionSkinReplacement { minionBodyPrefab = walkerBodyPrefab, minionSkin = GetSkinFromTurretBody(walkerBodyPrefab, "matLazyBastard.mat", "EngiWalkerTurretMesh.mesh") } }; SkinDefInfo val2 = val; Skins.AddSkinToCharacter(engiBodyPrefab, val2); } private GameObject ModifyProjectileGhost(GameObject ghostPrefab, string material, string mesh) { Material val = skinBundle.LoadAsset<Material>(materialsPath + material); Mesh val2 = skinBundle.LoadAsset<Mesh>(meshesPath + mesh); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)ghostPrefab == (Object)null) { Debug.Log((object)("New skin for " + ((Object)ghostPrefab).name + " failed to load.")); return ghostPrefab; } GameObject val3 = PrefabAPI.InstantiateClone(ghostPrefab, "LazyBastard" + ((Object)ghostPrefab).name, true); val3.AddComponent<NetworkIdentity>(); Renderer[] componentsInChildren = val3.GetComponentsInChildren<Renderer>(true); Renderer[] array = componentsInChildren; foreach (Renderer val4 in array) { val4.sharedMaterial = val; } MeshFilter[] componentsInChildren2 = val3.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val5 in componentsInChildren2) { val5.sharedMesh = val2; } SkinnedMeshRenderer[] componentsInChildren3 = val3.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer[] array2 = componentsInChildren3; foreach (SkinnedMeshRenderer val6 in array2) { val6.sharedMesh = val2; } return val3; } private GameObject NewProjectileGhost(GameObject ghostPrefab, string prefab) { GameObject val = skinBundle.LoadAsset<GameObject>(meshesPath + prefab); if ((Object)(object)val == (Object)null) { Debug.Log((object)$"New skin for {((Object)ghostPrefab).name} failed to load. Mesh null: {(Object)(object)val == (Object)null}"); return ghostPrefab; } val.AddComponent<NetworkIdentity>(); val.AddComponent<ProjectileGhostController>(); return val; } private SkinDef GetSkinFromTurretBody(GameObject bodyPrefab, string materialName, string meshName) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) Material val = skinBundle.LoadAsset<Material>(materialsPath + materialName); Mesh val2 = skinBundle.LoadAsset<Mesh>(meshesPath + meshName); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)bodyPrefab == (Object)null) { Debug.Log((object)$"New skin for {((Object)bodyPrefab).name} failed to load. Material null: {(Object)(object)val == (Object)null}, mesh null: {(Object)(object)val2 == (Object)null}"); return bodyPrefab.GetComponentInChildren<ModelSkinController>().skins[0]; } Renderer[] componentsInChildren = bodyPrefab.GetComponentsInChildren<Renderer>(true); ModelSkinController componentInChildren = bodyPrefab.GetComponentInChildren<ModelSkinController>(); GameObject gameObject = ((Component)componentInChildren).gameObject; Debug.Log((object)"Creating turret skin..."); SkinDefInfo val3 = default(SkinDefInfo); val3.Icon = skinIcon; val3.Name = "LazyBastard" + ((Object)bodyPrefab).name; val3.NameToken = "FACTORIO_SKIN_" + ((Object)bodyPrefab).name.ToUpper(); val3.RootObject = gameObject; val3.BaseSkins = (SkinDef[])(object)new SkinDef[1] { componentInChildren.skins[0] }; val3.UnlockableDef = null; val3.GameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[0]; val3.RendererInfos = (RendererInfo[])(object)new RendererInfo[1] { new RendererInfo { defaultMaterial = val, defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false, renderer = componentsInChildren[0] } }; val3.MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[1] { new MeshReplacement { mesh = val2, renderer = componentsInChildren[0] } }; val3.ProjectileGhostReplacements = (ProjectileGhostReplacement[])(object)new ProjectileGhostReplacement[0]; val3.MinionSkinReplacements = (MinionSkinReplacement[])(object)new MinionSkinReplacement[0]; SkinDefInfo val4 = val3; SkinDef val5 = Skins.CreateNewSkinDef(val4); Skins.AddSkinToCharacter(bodyPrefab, val5); return val5; } private SkinDef GetNewSkinFromTurretBody(GameObject bodyPrefab, string material, string mesh) { //IL_0098: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) Material val = skinBundle.LoadAsset<Material>(materialsPath + material); Mesh val2 = skinBundle.LoadAsset<Mesh>(meshesPath + mesh); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)bodyPrefab == (Object)null) { Debug.Log((object)("New skin for " + ((Object)bodyPrefab).name + " failed to load.")); return bodyPrefab.GetComponentInChildren<ModelSkinController>().skins[0]; } Renderer[] componentsInChildren = bodyPrefab.GetComponentsInChildren<Renderer>(true); ModelSkinController componentInChildren = bodyPrefab.GetComponentInChildren<ModelSkinController>(); GameObject gameObject = ((Component)componentInChildren).gameObject; SkinDefInfo val3 = default(SkinDefInfo); val3.Icon = skinIcon; val3.Name = "LazyBastard" + ((Object)bodyPrefab).name; val3.NameToken = "FACTORIO_SKIN_" + ((Object)bodyPrefab).name.ToUpper(); val3.RootObject = gameObject; val3.BaseSkins = (SkinDef[])(object)new SkinDef[1] { componentInChildren.skins[0] }; val3.UnlockableDef = ScriptableObject.CreateInstance<UnlockableDef>(); val3.GameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[0]; val3.RendererInfos = (RendererInfo[])(object)new RendererInfo[1] { new RendererInfo { defaultMaterial = val, defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false, renderer = componentsInChildren[0] } }; val3.MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[1] { new MeshReplacement { mesh = val2, renderer = componentsInChildren[0] } }; val3.ProjectileGhostReplacements = (ProjectileGhostReplacement[])(object)new ProjectileGhostReplacement[0]; val3.MinionSkinReplacements = (MinionSkinReplacement[])(object)new MinionSkinReplacement[0]; SkinDefInfo val4 = val3; Skins.AddSkinToCharacter(bodyPrefab, val4); return Skins.CreateNewSkinDef(val4); } } internal static class Log { public static bool enableDebugging; internal static ManualLogSource _logSource; public static void DebugBreakpoint(string methodName, int breakpointNumber = -1) { string text = "LazyBastardEngineer: " + methodName + " IL hook failed!"; if (breakpointNumber >= 0) { text += $" (breakpoint {breakpointNumber})"; } Error(text); } internal static void Init(ManualLogSource logSource) { enableDebugging = false; _logSource = logSource; } internal static string Combine(params string[] parameters) { string text = "LazyBastardEngineer : "; foreach (string text2 in parameters) { text = text + text2 + " : "; } return text; } internal static void Debug(object data) { if (enableDebugging) { _logSource.LogDebug(data); } } internal static void Error(object data) { _logSource.LogError(data); } internal static void ErrorAssetBundle(string assetName, string bundleName) { Error("failed to load asset, " + assetName + ", because it does not exist in asset bundle, " + bundleName); } 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); } } internal static class Assets { internal static Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>(); internal static AssetBundle LoadAssetBundle(string bundleName) { if (loadedBundles.ContainsKey(bundleName)) { return loadedBundles[bundleName]; } AssetBundle val = null; val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)LazyBastardPlugin.instance).Info.Location), bundleName)); loadedBundles[bundleName] = val; return val; } } internal static class Materials { internal static void GetMaterial(GameObject model, string childObject, Color color, ref Material material, float scaleMultiplier = 1f, bool replaceAll = false) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>(); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Renderer val2 = val; if (string.Equals(((Object)val).name, childObject)) { if (color == Color.clear) { Object.Destroy((Object)(object)val); break; } if ((Object)(object)material == (Object)null) { material = new Material(val.material); material.mainTexture = val.material.mainTexture; material.shader = val.material.shader; material.color = color; } val.material = material; Transform transform = ((Component)val).transform; transform.localScale *= scaleMultiplier; if (!replaceAll) { break; } } } } internal static void DebugMaterial(GameObject model) { Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>(); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Renderer val2 = val; Debug.Log((object)("Material: " + ((Object)val2).name.ToString())); } } internal static void SwapAllShaders(AssetBundle assetBundle) { Material[] array = assetBundle.LoadAllAssets<Material>(); foreach (Material val in array) { Log.Debug("Trying to swap shader for " + ((Object)val).name); TrySwapShader(val); } } internal static void TrySwapShader(Material material) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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) { material.shader = val; } else { Log.Error("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 static Material SetColor(this Material material, Color color) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) material.SetColor("_Color", color); return material; } public static Material SetNormal(this Material material, float normalStrength = 1f) { material.SetFloat("_NormalStrength", normalStrength); return material; } public static Material SetEmission(this Material material) { return material.SetEmission(1f); } public static Material SetEmission(this Material material, float emission) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return material.SetEmission(emission, Color.white); } public static Material SetEmission(this Material material, float emission, Color emissionColor) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) material.SetFloat("_EmPower", emission); material.SetColor("_EmColor", emissionColor); return material; } public static Material SetCull(this Material material, bool cull = false) { material.SetInt("_Cull", cull ? 1 : 0); return material; } public static Material SetSpecular(this Material material, float strength) { material.SetFloat("_SpecularStrength", strength); return material; } public static Material SetSpecular(this Material material, float strength, float exponent) { material.SetFloat("_SpecularStrength", strength); material.SetFloat("SpecularExponent", exponent); return material; } }