using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Common;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
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("VariantCustomizer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+304dd3704322f5afdb700d92d726c7c4c0fd9322")]
[assembly: AssemblyProduct("VariantCustomizer")]
[assembly: AssemblyTitle("VariantCustomizer")]
[assembly: AssemblyVersion("1.0.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 VariantCustomizer
{
public class Gun
{
private readonly string name;
private readonly int weaponNumber;
private readonly GunConfiguration mainGun = new GunConfiguration();
private readonly GunConfiguration? alternateGun;
private ConfigPanel? mainGunPanel;
private ConfigPanel? alternateGunPanel;
internal bool UseCustomColors(bool visibleWithoutUnlock)
{
return visibleWithoutUnlock || MonoSingleton<GunColorController>.Instance.hasUnlockedColors[weaponNumber - 1];
}
public Gun(string name, bool hasVariant, int weaponNumber)
{
this.name = name;
this.weaponNumber = weaponNumber;
alternateGun = (hasVariant ? new GunConfiguration() : null);
}
public VariantConfiguration GetVariantConfig(int variantIndex, bool alternate)
{
return (alternate ? alternateGun : mainGun).GetVariantConfig(variantIndex);
}
public GunColorPreset GetNormalColor(bool altVersion)
{
if (1 == 0)
{
}
GunColorPreset result = (altVersion ? MonoSingleton<GunColorController>.Instance.currentAltColors[weaponNumber - 1] : MonoSingleton<GunColorController>.Instance.currentColors[weaponNumber - 1]);
if (1 == 0)
{
}
return result;
}
public void Subpanel(ConfigPanel parentPanel)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
mainGunPanel = new ConfigPanel(parentPanel, name, name);
mainGun.Subpanel(mainGunPanel);
if (alternateGun != null)
{
alternateGunPanel = new ConfigPanel(parentPanel, name + " (Alternate)", name + ".alt");
alternateGun.Subpanel(alternateGunPanel);
}
}
public void UpdateVisibility(bool visibleWithoutUnlock)
{
bool flag = UseCustomColors(visibleWithoutUnlock);
((ConfigField)mainGunPanel).hidden = !flag;
if (alternateGunPanel != null)
{
((ConfigField)alternateGunPanel).hidden = !flag;
}
}
}
public class GunConfiguration
{
private readonly VariantConfiguration blueVariant = new VariantConfiguration();
private readonly VariantConfiguration greenVariant = new VariantConfiguration();
private readonly VariantConfiguration redVariant = new VariantConfiguration();
internal VariantConfiguration GetVariantConfig(int variantIndex)
{
if (1 == 0)
{
}
VariantConfiguration result = variantIndex switch
{
0 => blueVariant,
1 => greenVariant,
2 => redVariant,
_ => throw new ArgumentOutOfRangeException(),
};
if (1 == 0)
{
}
return result;
}
public void Subpanel(ConfigPanel parentPanel)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
blueVariant.Subpanel(new ConfigPanel(parentPanel, "Blue Variant", ((ConfigField)parentPanel).guid + ".blue"));
greenVariant.Subpanel(new ConfigPanel(parentPanel, "Green Variant", ((ConfigField)parentPanel).guid + ".green"));
redVariant.Subpanel(new ConfigPanel(parentPanel, "Red Variant", ((ConfigField)parentPanel).guid + ".red"));
}
}
public class VariantConfiguration
{
private ColorField? color1;
private ColorField? color2;
private ColorField? color3;
internal GunColorPreset GetColorPreset()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
return new GunColorPreset(color1.value, color2.value, color3.value);
}
private static void MarkDirty(ColorValueChangeEvent _)
{
VariantCustomizer.Dirty = true;
}
internal void Subpanel(ConfigPanel parentPanel)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_0064: 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_0073: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Expected O, but got Unknown
color1 = new ColorField(parentPanel, "Color 1", ((ConfigField)parentPanel).guid + ".color1", Color.white);
color2 = new ColorField(parentPanel, "Color 2", ((ConfigField)parentPanel).guid + ".color2", Color.white);
color3 = new ColorField(parentPanel, "Color 3", ((ConfigField)parentPanel).guid + ".color3", Color.white);
color1.onValueChange += new ColorValueChangeEventDelegate(MarkDirty);
color2.onValueChange += new ColorValueChangeEventDelegate(MarkDirty);
color3.onValueChange += new ColorValueChangeEventDelegate(MarkDirty);
}
}
[BepInPlugin("com.einfachirgendwa1.variantCustomizer", "VariantCustomizer", "1.1.0")]
public class VariantCustomizer : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static BoolValueChangeEventDelegate <>9__9_0;
internal void <Awake>b__9_0(BoolValueChangeEvent _)
{
Dirty = true;
}
}
private static readonly int CustomColor1 = Shader.PropertyToID("_CustomColor1");
private static readonly int CustomColor2 = Shader.PropertyToID("_CustomColor2");
private static readonly int CustomColor3 = Shader.PropertyToID("_CustomColor3");
internal static bool Dirty;
private readonly PluginConfigurator config = Statics.InitPluginConfig("Variant Customizer", "com.einfachirgendwa1.variantCustomizer");
private BoolField? allowNotUnlocked;
private GameObject? currentWeaponCache;
private Gun[] guns = new Gun[0];
private BoolField? modEnabled;
private void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
modEnabled = new BoolField(config.rootPanel, "Enabled", "enabled", true);
allowNotUnlocked = new BoolField(config.rootPanel, "Circumvent having to buy custom colors", "allow_when_no_custom_colors", true);
guns = new Gun[5]
{
new Gun("Revolver", hasVariant: true, 1),
new Gun("Shotgun", hasVariant: true, 2),
new Gun("Nailgun", hasVariant: true, 3),
new Gun("Railgun", hasVariant: false, 4),
new Gun("Rocket Launcher", hasVariant: false, 5)
};
Gun[] array = guns;
foreach (Gun gun in array)
{
gun.Subpanel(config.rootPanel);
}
BoolField? obj = modEnabled;
object obj2 = <>c.<>9__9_0;
if (obj2 == null)
{
BoolValueChangeEventDelegate val = delegate
{
Dirty = true;
};
<>c.<>9__9_0 = val;
obj2 = (object)val;
}
obj.onValueChange += (BoolValueChangeEventDelegate)obj2;
allowNotUnlocked.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent data)
{
Dirty = true;
Gun[] array2 = guns;
foreach (Gun gun2 in array2)
{
gun2.UpdateVisibility(data.value);
}
};
}
private void Update()
{
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
GunControl instance = MonoSingleton<GunControl>.Instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
GameObject currentWeapon = instance.currentWeapon;
if (!((Object)(object)currentWeapon == (Object)null) && (!((Object)(object)currentWeapon == (Object)(object)currentWeaponCache) || Dirty))
{
currentWeaponCache = currentWeapon;
Dirty = false;
GunColorGetter componentInChildren = currentWeapon.GetComponentInChildren<GunColorGetter>();
bool flag = (Object)(object)componentInChildren != (Object)null && componentInChildren.altVersion;
Gun gun = guns[instance.currentSlotIndex - 1];
bool flag2 = gun.UseCustomColors(allowNotUnlocked.value) && modEnabled.value;
VariantConfiguration variantConfig = gun.GetVariantConfig(instance.currentVariationIndex, flag);
SkinnedMeshRenderer[] componentsInChildren = currentWeapon.GetComponentsInChildren<SkinnedMeshRenderer>();
SkinnedMeshRenderer[] array = componentsInChildren;
foreach (SkinnedMeshRenderer val in array)
{
GunColorPreset val2 = (flag2 ? variantConfig.GetColorPreset() : gun.GetNormalColor(flag));
MaterialPropertyBlock val3 = new MaterialPropertyBlock();
((Renderer)val).GetPropertyBlock(val3);
val3.SetColor(CustomColor1, val2.color1);
val3.SetColor(CustomColor2, val2.color2);
val3.SetColor(CustomColor3, val2.color3);
((Renderer)val).SetPropertyBlock(val3);
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "VariantCustomizer";
public const string PLUGIN_NAME = "VariantCustomizer";
public const string PLUGIN_VERSION = "1.0.0";
}
}