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 Dragon Cock Shenlong v1.0.0
BepInEx/plugins/DragonCockShenlong/DragonCockShenlong.dll
Decompiled 7 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; 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("DragonCockShenlong")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DragonCockShenlong")] [assembly: AssemblyTitle("DragonCockShenlong")] [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 DragonCockShenlong { [BepInPlugin("dragon.shenlong.portrait", "Dragon Cock Shenlong", "1.0.0")] [BepInDependency("evaisa.lethallib", "1.2.0")] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "dragon.shenlong.portrait"; public const string PluginName = "Dragon Cock Shenlong"; public const string Version = "1.0.0"; internal const string ItemName = "Dragon Cock Shenlong"; internal static ManualLogSource Log; internal static Item? PortraitItem; private static ConfigEntry<int> spawnWeight; private static bool registrationFailed; private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; spawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "SpawnWeight", 20, new ConfigDescription("Relative spawn weight on all moons. 0 disables natural spawning. Restart after changing; the host's setting controls spawns.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); new Harmony("dragon.shenlong.portrait").PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Dragon Cock Shenlong is ready. Portrait value: $100-$600."); } internal static bool IsPortrait(GrabbableObject prop) { if ((Object)(object)PortraitItem != (Object)null && (Object)(object)prop != (Object)null) { return (Object)(object)prop.itemProperties == (Object)(object)PortraitItem; } return false; } internal static void Register(GameNetworkManager gameNetworkManager) { //IL_01a1: 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) if (registrationFailed) { return; } try { NetworkManager component = ((Component)gameNetworkManager).GetComponent<NetworkManager>(); if ((Object)(object)PortraitItem == (Object)null) { Item val = (from entry in component.NetworkConfig.Prefabs.Prefabs select (!((Object)(object)entry.Prefab == (Object)null)) ? entry.Prefab.GetComponent<GrabbableObject>() : null into prop where (Object)(object)prop != (Object)null && (Object)(object)prop.itemProperties != (Object)null select prop.itemProperties).FirstOrDefault((Func<Item, bool>)((Item item) => string.Equals(item.itemName, "Painting", StringComparison.OrdinalIgnoreCase))); if (val == null) { val = ((IEnumerable<Item>)Resources.FindObjectsOfTypeAll<Item>()).FirstOrDefault((Func<Item, bool>)((Item item) => (Object)(object)item.spawnPrefab != (Object)null && string.Equals(item.itemName, "Painting", StringComparison.OrdinalIgnoreCase))); } if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("The vanilla Painting prefab was not found."); } Texture2D val2 = LoadPortrait(); Item val3 = Object.Instantiate<Item>(val); ((Object)val3).name = "DragonCockShenlongItem"; ((Object)val3).hideFlags = (HideFlags)61; val3.itemName = "Dragon Cock Shenlong"; val3.itemId = 0; val3.isScrap = true; val3.twoHanded = true; val3.twoHandedAnimation = true; val3.itemSpawnsOnGround = true; val3.spawnPositionTypes = new List<ItemGroup>(); val3.minValue = 250; val3.maxValue = 1501; val3.meshVariants = Array.Empty<Mesh>(); val3.materialVariants = Array.Empty<Material>(); val3.itemIcon = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f); ((Object)val3.itemIcon).name = "ShenlongPortraitIcon"; ((Object)val3.itemIcon).hideFlags = (HideFlags)61; GameObject val4 = (val3.spawnPrefab = NetworkPrefabs.CloneNetworkPrefab(val.spawnPrefab, "DragonCockShenlongPortrait")); val4.GetComponent<GrabbableObject>().itemProperties = val3; PortraitMesh.Apply(val4, val2); ScanNodeProperties[] componentsInChildren = val4.GetComponentsInChildren<ScanNodeProperties>(true); foreach (ScanNodeProperties obj in componentsInChildren) { obj.headerText = "Dragon Cock Shenlong"; obj.subText = "Value: $0"; obj.scrapValue = 0; obj.nodeType = 2; obj.creatureScanID = -1; } Items.RegisterScrap(val3, spawnWeight.Value, (LevelTypes)(-1)); PortraitItem = val3; Log.LogInfo((object)string.Format("Registered {0}: spawn weight {1}, value $100-$600, portrait {2}x{3}.", "Dragon Cock Shenlong", spawnWeight.Value, ((Texture)val2).width, ((Texture)val2).height)); } if (!component.NetworkConfig.Prefabs.Contains(PortraitItem.spawnPrefab)) { component.AddNetworkPrefab(PortraitItem.spawnPrefab); } } catch (Exception arg) { registrationFailed = true; Log.LogError((object)$"Could not register the Shenlong portrait. The item is disabled.\n{arg}"); } } private static Texture2D LoadPortrait() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0071: Expected O, but got Unknown using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DragonCockShenlong.Portrait.jpg") ?? throw new FileNotFoundException("Embedded portrait is missing."); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false)) { throw new InvalidDataException("Embedded portrait could not be decoded."); } ((Object)val).name = "DragonCockShenlongPortraitTexture"; ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; return val; } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] internal static class RegisterPortraitPatch { [HarmonyPrefix] private static void Prefix(GameNetworkManager __instance) { Plugin.Register(__instance); } } [HarmonyPatch(typeof(RoundManager), "waitForScrapToSpawnToSync")] internal static class AssignPortraitValuesPatch { [HarmonyPrefix] private static void Prefix(RoundManager __instance, NetworkObjectReference[] __0, int[] __1) { if (!((NetworkBehaviour)__instance).IsServer || (Object)(object)Plugin.PortraitItem == (Object)null) { return; } Random random = new Random(StartOfRound.Instance.randomMapSeed ^ 0x53484E4C); NetworkObject val = default(NetworkObject); for (int i = 0; i < Math.Min(__0.Length, __1.Length); i++) { if (((NetworkObjectReference)(ref __0[i])).TryGet(ref val, (NetworkManager)null)) { GrabbableObject component = ((Component)val).GetComponent<GrabbableObject>(); if (Plugin.IsPortrait(component)) { __1[i] = ValueRules.Roll(random); component.SetScrapValue(__1[i]); } } } } } [HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")] internal static class KeepPortraitValueInRangePatch { [HarmonyPrefix] private static void Prefix(GrabbableObject __instance, ref int __0) { if (Plugin.IsPortrait(__instance)) { __0 = ValueRules.Clamp(__0); } } } internal static class PortraitMesh { private sealed class Builder { private readonly Vector3 center; private readonly List<Vector3> vertices = new List<Vector3>(); private readonly List<Vector2> uv = new List<Vector2>(); private readonly List<int>[] triangles = new List<int>[3] { new List<int>(), new List<int>(), new List<int>() }; public Builder(Vector3 center) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) this.center = center; } private void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d, int material) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_002d: 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_0034: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00c4: 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) int count = vertices.Count; vertices.AddRange((IEnumerable<Vector3>)(object)new Vector3[4] { a + center, b + center, c + center, d + center }); uv.AddRange((IEnumerable<Vector2>)(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }); triangles[material].AddRange(new int[6] { count, count + 1, count + 2, count, count + 2, count + 3 }); } public void PhotoFace(float x, float width, float height, bool back) { //IL_001e: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) float num = (float)((!back) ? 1 : (-1)) * width / 2f; Quad(new Vector3(x, 0f - num, (0f - height) / 2f), new Vector3(x, num, (0f - height) / 2f), new Vector3(x, num, height / 2f), new Vector3(x, 0f - num, height / 2f), 0); } public void Box(Vector3 position, Vector3 size, int material) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_021d: 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_0249: Unknown result type (might be due to invalid IL or missing references) Vector3 s = size / 2f; Quad(P(1f, -1f, -1f), P(1f, 1f, -1f), P(1f, 1f, 1f), P(1f, -1f, 1f), material); Quad(P(-1f, 1f, -1f), P(-1f, -1f, -1f), P(-1f, -1f, 1f), P(-1f, 1f, 1f), material); Quad(P(-1f, 1f, -1f), P(-1f, 1f, 1f), P(1f, 1f, 1f), P(1f, 1f, -1f), material); Quad(P(1f, -1f, -1f), P(1f, -1f, 1f), P(-1f, -1f, 1f), P(-1f, -1f, -1f), material); Quad(P(-1f, -1f, 1f), P(1f, -1f, 1f), P(1f, 1f, 1f), P(-1f, 1f, 1f), material); Quad(P(-1f, 1f, -1f), P(1f, 1f, -1f), P(1f, -1f, -1f), P(-1f, -1f, -1f), material); Vector3 P(float x, float y, float z) { //IL_0001: 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_0032: Unknown result type (might be due to invalid IL or missing references) return position + new Vector3(x * s.x, y * s.y, z * s.z); } } public Mesh Build() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown Mesh val = new Mesh { name = "ShenlongFramedPortrait", hideFlags = (HideFlags)61 }; val.SetVertices(vertices); val.SetUVs(0, uv); val.subMeshCount = triangles.Length; for (int i = 0; i < triangles.Length; i++) { val.SetTriangles(triangles[i], i); } val.RecalculateNormals(); val.RecalculateTangents(); val.RecalculateBounds(); return val; } } internal static void Apply(GameObject prefab, Texture2D portrait) { //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_0278: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: 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) MeshFilter component = prefab.GetComponent<MeshFilter>(); MeshRenderer component2 = prefab.GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)((Renderer)component2).sharedMaterial == (Object)null) { throw new InvalidOperationException("The vanilla Painting mesh/material layout has changed."); } Bounds bounds = component.sharedMesh.bounds; float z = ((Bounds)(ref bounds)).size.z; float num = z * 0.035f; float num2 = z - 2f * num; float num3 = num2 * (float)((Texture)portrait).width / (float)((Texture)portrait).height; float num4 = num3 + 2f * num; float x = ((Bounds)(ref bounds)).size.x; Vector3 center = ((Bounds)(ref bounds)).center; Material val = MakeMaterial(((Renderer)component2).sharedMaterial, "Shenlong canvas", Color.white, portrait, 0f, 0.15f); Material val2 = MakeMaterial(((Renderer)component2).sharedMaterial, "Shenlong antique gold frame", new Color(0.48f, 0.25f, 0.065f, 1f), null, 0.65f, 0.35f); Material val3 = MakeMaterial(((Renderer)component2).sharedMaterial, "Shenlong dark backing", new Color(0.06f, 0.025f, 0.018f, 1f), null, 0f, 0.1f); Builder builder = new Builder(center); builder.PhotoFace(x * 0.32f, num3, num2, back: false); builder.PhotoFace((0f - x) * 0.32f, num3, num2, back: true); builder.Box(Vector3.zero, new Vector3(x * 0.6f, num4, z), 2); builder.Box(new Vector3(0f, (0f - (num4 - num)) / 2f, 0f), new Vector3(x, num, z), 1); builder.Box(new Vector3(0f, (num4 - num) / 2f, 0f), new Vector3(x, num, z), 1); builder.Box(new Vector3(0f, 0f, (0f - (z - num)) / 2f), new Vector3(x, num3, num), 1); builder.Box(new Vector3(0f, 0f, (z - num) / 2f), new Vector3(x, num3, num), 1); Mesh val4 = (component.sharedMesh = builder.Build()); ((Renderer)component2).sharedMaterials = (Material[])(object)new Material[3] { val, val2, val3 }; BoxCollider component3 = prefab.GetComponent<BoxCollider>(); if ((Object)(object)component3 != (Object)null) { Bounds bounds2 = val4.bounds; component3.center = ((Bounds)(ref bounds2)).center; bounds2 = val4.bounds; component3.size = ((Bounds)(ref bounds2)).size; } ScanNodeProperties[] componentsInChildren = prefab.GetComponentsInChildren<ScanNodeProperties>(true); foreach (ScanNodeProperties obj in componentsInChildren) { ((Component)obj).transform.localPosition = center; ((Component)obj).transform.localRotation = Quaternion.identity; ((Component)obj).transform.localScale = Vector3.one; BoxCollider component4 = ((Component)obj).GetComponent<BoxCollider>(); if ((Object)(object)component4 != (Object)null) { component4.center = Vector3.zero; component4.size = new Vector3(Math.Max(x, 0.3f), num4, z); } } } private static Material MakeMaterial(Material template, string name, Color color, Texture2D? texture, float metallic, float smoothness) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_00a3: 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_00c3: 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) Material val = new Material(template) { name = name, hideFlags = (HideFlags)61 }; string[] texturePropertyNames = val.GetTexturePropertyNames(); foreach (string text in texturePropertyNames) { val.SetTexture(text, (Texture)null); } texturePropertyNames = new string[4] { "_NORMALMAP", "_MASKMAP", "_EMISSIVE_COLOR_MAP", "_DETAIL_MAP" }; foreach (string text2 in texturePropertyNames) { val.DisableKeyword(text2); } if (!val.HasProperty("_BaseColorMap")) { throw new InvalidOperationException("The painting material no longer uses an HDRP base-color map."); } val.SetTexture("_BaseColorMap", (Texture)(object)texture); val.SetTextureScale("_BaseColorMap", Vector2.one); val.SetTextureOffset("_BaseColorMap", Vector2.zero); val.SetColor("_BaseColor", color); if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } if (val.HasProperty("_EmissiveColor")) { val.SetColor("_EmissiveColor", Color.black); } return val; } } internal static class ValueRules { public const int Minimum = 100; public const int Maximum = 600; public const int SeedSalt = 1397247564; public static int Roll(Random random) { return random.Next(100, 601); } public static int Clamp(int value) { return Math.Max(100, Math.Min(600, value)); } } }