using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CicekMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CicekMod")]
[assembly: AssemblyTitle("CicekMod")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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;
}
}
[CompilerGenerated]
[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 CicekMod
{
[BepInPlugin("senin_adin.cicekmod", "CicekMod", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string PluginGUID = "senin_adin.cicekmod";
public const string PluginName = "CicekMod";
public const string PluginVersion = "1.0.0";
internal static ManualLogSource Log = null;
public static Texture2D? FlowerTexture;
public static readonly string TargetItemName = "Stone";
private void Awake()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string path = Path.Combine(directoryName, "flower.png");
if (File.Exists(path))
{
byte[] array = File.ReadAllBytes(path);
FlowerTexture = new Texture2D(2, 2);
ImageConversion.LoadImage(FlowerTexture, array);
Log.LogInfo((object)"flower.png yuklendi.");
}
else
{
Log.LogError((object)("flower.png bulunamadi! Su klasore koy: " + directoryName));
}
new Harmony("senin_adin.cicekmod").PatchAll();
Log.LogInfo((object)"CicekMod yuklendi!");
}
}
[HarmonyPatch(typeof(Item), "Start")]
public class ItemTexturePatch
{
private static void Postfix(Item __instance)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
if (((Object)__instance).name.Contains(Plugin.TargetItemName) && !((Object)(object)((Component)__instance).transform.Find("CicekModel") != (Object)null))
{
MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Renderer)componentsInChildren[i]).enabled = false;
}
GameObject val = new GameObject("CicekModel");
val.transform.SetParent(((Component)__instance).transform, false);
val.transform.localPosition = Vector3.zero;
val.transform.localScale = Vector3.one * 0.15f;
if ((Object)(object)Plugin.FlowerTexture != (Object)null)
{
float size = 4.48f;
Vector3 zero = Vector3.zero;
CreateFlowerQuad(val.transform, zero, 0f, size, Plugin.FlowerTexture);
CreateFlowerQuad(val.transform, zero, 90f, size, Plugin.FlowerTexture);
}
Plugin.Log.LogInfo((object)(((Object)__instance).name + " icin 3D cicek modeli olusturuldu."));
}
}
private static void CreateFlowerQuad(Transform parent, Vector3 localPos, float yRotation, float size, Texture2D texture)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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)
for (int i = 0; i < 2; i++)
{
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5);
((Object)obj).name = "CicekYuzey";
obj.transform.SetParent(parent, false);
obj.transform.localPosition = localPos;
obj.transform.localRotation = Quaternion.Euler(0f, yRotation + (float)i * 180f, 0f);
obj.transform.localScale = new Vector3(size, size, size);
Object.Destroy((Object)(object)obj.GetComponent<Collider>());
MeshRenderer component = obj.GetComponent<MeshRenderer>();
Material material = CreateTransparentMaterial(texture);
((Renderer)component).material = material;
}
}
private static Material CreateTransparentMaterial(Texture2D texture)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
Shader val = Shader.Find("Universal Render Pipeline/Unlit");
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Unlit/Transparent");
}
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Universal Render Pipeline/Lit");
}
Material val2 = new Material(val);
if (val2.HasProperty("_BaseMap"))
{
val2.SetTexture("_BaseMap", (Texture)(object)texture);
}
if (val2.HasProperty("_MainTex"))
{
val2.SetTexture("_MainTex", (Texture)(object)texture);
}
val2.mainTexture = (Texture)(object)texture;
if (val2.HasProperty("_BaseColor"))
{
val2.SetColor("_BaseColor", Color.white);
}
if (val2.HasProperty("_Color"))
{
val2.SetColor("_Color", Color.white);
}
if (val2.HasProperty("_Surface"))
{
val2.SetFloat("_Surface", 1f);
}
if (val2.HasProperty("_Blend"))
{
val2.SetFloat("_Blend", 0f);
}
if (val2.HasProperty("_ZWrite"))
{
val2.SetFloat("_ZWrite", 0f);
}
if (val2.HasProperty("_AlphaClip"))
{
val2.SetFloat("_AlphaClip", 1f);
}
if (val2.HasProperty("_Cutoff"))
{
val2.SetFloat("_Cutoff", 0.3f);
}
val2.EnableKeyword("_ALPHATEST_ON");
val2.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
val2.renderQueue = 3000;
return val2;
}
private static void SetColor(GameObject obj, Color color, Texture2D? texture = null)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
MeshRenderer component = obj.GetComponent<MeshRenderer>();
if ((Object)(object)component == (Object)null)
{
return;
}
Shader val = Shader.Find("Universal Render Pipeline/Lit");
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Standard");
}
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Unlit/Color");
}
Material val2 = new Material(val);
if ((Object)(object)texture != (Object)null)
{
if (val2.HasProperty("_BaseMap"))
{
val2.SetTexture("_BaseMap", (Texture)(object)texture);
}
if (val2.HasProperty("_MainTex"))
{
val2.SetTexture("_MainTex", (Texture)(object)texture);
}
val2.mainTexture = (Texture)(object)texture;
if (val2.HasProperty("_BaseColor"))
{
val2.SetColor("_BaseColor", Color.white);
}
if (val2.HasProperty("_Color"))
{
val2.SetColor("_Color", Color.white);
}
}
else
{
if (val2.HasProperty("_BaseColor"))
{
val2.SetColor("_BaseColor", color);
}
if (val2.HasProperty("_Color"))
{
val2.SetColor("_Color", color);
}
}
((Renderer)component).material = val2;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "CicekMod";
public const string PLUGIN_NAME = "CicekMod";
public const string PLUGIN_VERSION = "1.0.0";
}
}