using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ColoredCrystalGlass")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ColoredCrystalGlass")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace ColoredCrystalGlass;
[BepInPlugin("org.bepinex.plugins.bid.coloredcrystalglass", "ColoredCrystalGlass", "0.2.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class ColoredCrystalGlass : BaseUnityPlugin
{
public const string PluginGUID = "org.bepinex.plugins.bid.coloredcrystalglass";
public const string PluginName = "ColoredCrystalGlass";
public const string PluginVersion = "0.2.2";
private Dictionary<string, Material> glassMats = new Dictionary<string, Material>();
public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();
private void Awake()
{
Logger.LogInfo((object)"ColoredCrystalGlass has landed");
PrefabManager.OnVanillaPrefabsAvailable += AddClonedItems;
}
private void AddGlass(AssetBundle glassAssetBundle, string color, float scale, string item1, string item2 = null)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Expected O, but got Unknown
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Expected O, but got Unknown
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Expected O, but got Unknown
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Expected O, but got Unknown
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Expected O, but got Unknown
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Expected O, but got Unknown
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Expected O, but got Unknown
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Expected O, but got Unknown
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Expected O, but got Unknown
GameObject val = PrefabManager.Instance.CreateClonedPrefab("item_glass_" + color + "_" + scale, "crystal_wall_1x1");
Vector3 localScale = val.transform.localScale;
localScale.x *= scale;
localScale.y *= scale;
val.transform.localScale = localScale;
MeshRenderer component = ((Component)((Component)val.transform.GetChild(4)).transform.GetChild(0)).GetComponent<MeshRenderer>();
MeshRenderer component2 = ((Component)((Component)val.transform.GetChild(4)).transform.GetChild(1)).GetComponent<MeshRenderer>();
if (!Utility.IsNullOrWhiteSpace(color))
{
Material val2 = null;
string key = "glass_" + color;
if (glassMats.ContainsKey(key))
{
val2 = glassMats[key];
}
else
{
val2 = glassAssetBundle.LoadAsset<Material>("glass_" + color);
val2.SetTexture("_BumpMap", ((Renderer)val.GetComponentInChildren<MeshRenderer>()).material.GetTexture("_BumpMap"));
}
((Renderer)component).sharedMaterial = val2;
((Renderer)component2).sharedMaterial = val2;
}
string text = Localization.TryTranslate("$item_glass") + " ";
if (!Utility.IsNullOrWhiteSpace(color))
{
text = text + Localization.TryTranslate("$color_" + color) + " ";
}
text = text + scale + "x" + scale;
val.GetComponent<Piece>().m_name = text;
string text2 = "icon_glass_" + color + "_" + scale;
text2 = text2.Replace(",", "").Replace(".", "");
Sprite icon = glassAssetBundle.LoadAsset<Sprite>(text2);
val.GetComponent<Piece>().m_icon = icon;
int num = 4;
int amount = num;
if ((double)scale <= 0.5)
{
num = 1;
amount = 1;
}
else if (scale <= 1f)
{
num = 2;
amount = 2;
}
PieceConfig val3;
if (item2 == null)
{
PieceManager instance = PieceManager.Instance;
val3 = new PieceConfig();
val3.PieceTable = "Hammer";
val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
{
new RequirementConfig
{
Item = "Crystal",
Recover = true,
Amount = num
},
new RequirementConfig
{
Item = item1,
Recover = true,
Amount = amount
}
};
val3.CraftingStation = "piece_workbench";
val3.Category = Localization.TryTranslate("$category_glass");
instance.AddPiece(new CustomPiece(val, true, val3));
return;
}
amount = 2;
if (scale <= 1f)
{
amount = 1;
}
PieceManager instance2 = PieceManager.Instance;
val3 = new PieceConfig();
val3.PieceTable = "Hammer";
val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
{
new RequirementConfig
{
Item = "Crystal",
Recover = true,
Amount = num
},
new RequirementConfig
{
Item = item1,
Recover = true,
Amount = amount
},
new RequirementConfig
{
Item = item2,
Recover = true,
Amount = amount
}
};
val3.CraftingStation = "piece_workbench";
val3.Category = Localization.TryTranslate("$category_glass");
instance2.AddPiece(new CustomPiece(val, true, val3));
}
private void AddClonedItems()
{
AssetBundle val = AssetUtils.LoadAssetBundleFromResources("glass");
if ((Object)(object)val == (Object)null)
{
MonoBehaviour.print((object)"Error loading assetbundle glass");
return;
}
try
{
AddGlass(val, "", 2f, null);
AddGlass(val, "red", 2f, "Raspberry");
AddGlass(val, "blue", 2f, "Blueberries");
AddGlass(val, "cyan", 2f, "GreydwarfEye");
AddGlass(val, "green", 2f, "Guck");
AddGlass(val, "orange", 2f, "Carrot");
AddGlass(val, "purple", 2f, "Blueberries", "Raspberry");
AddGlass(val, "yellow", 2f, "Dandelion");
AddGlass(val, "", 1f, null);
AddGlass(val, "red", 1f, "Raspberry");
AddGlass(val, "blue", 1f, "Blueberries");
AddGlass(val, "cyan", 1f, "GreydwarfEye");
AddGlass(val, "green", 1f, "Guck");
AddGlass(val, "orange", 1f, "Carrot");
AddGlass(val, "purple", 1f, "Blueberries", "Raspberry");
AddGlass(val, "yellow", 1f, "Dandelion");
AddGlass(val, "", 0.5f, null);
AddGlass(val, "red", 0.5f, "Raspberry");
AddGlass(val, "blue", 0.5f, "Blueberries");
AddGlass(val, "cyan", 0.5f, "GreydwarfEye");
AddGlass(val, "green", 0.5f, "Guck");
AddGlass(val, "orange", 0.5f, "Carrot");
AddGlass(val, "purple", 0.5f, "Blueberries", "Raspberry");
AddGlass(val, "yellow", 0.5f, "Dandelion");
AddGlass(val, "", 0.25f, null);
AddGlass(val, "red", 0.25f, "Raspberry");
AddGlass(val, "blue", 0.25f, "Blueberries");
AddGlass(val, "cyan", 0.25f, "GreydwarfEye");
AddGlass(val, "green", 0.25f, "Guck");
AddGlass(val, "orange", 0.25f, "Carrot");
AddGlass(val, "purple", 0.25f, "Blueberries", "Raspberry");
AddGlass(val, "yellow", 0.25f, "Dandelion");
}
finally
{
val.Unload(false);
}
PrefabManager.OnVanillaPrefabsAvailable -= AddClonedItems;
}
}