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 IvoryModel v0.1.0
BepInEx/plugins/IvoryModel.dll
Decompiled an hour 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 GameNetcodeStuff; using Microsoft.CodeAnalysis; using ModelReplacement; 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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("IvoryModel")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("IvoryModel")] [assembly: AssemblyTitle("IvoryModel")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 IvoryModel { public class MRIVORY : BodyReplacementBase { private IvoryRosto rosto; protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset<GameObject>("Ivory"); } protected override void AddModelScripts() { ((BodyReplacementBase)this).AddModelScripts(); rosto = base.replacementModel.AddComponent<IvoryRosto>(); rosto.owner = this; } protected override void OnEmoteStart(int emoteId) { ((BodyReplacementBase)this).OnEmoteStart(emoteId); if (Object.op_Implicit((Object)(object)rosto)) { rosto.emoting = true; } } protected override void OnEmoteEnd() { ((BodyReplacementBase)this).OnEmoteEnd(); if (Object.op_Implicit((Object)(object)rosto)) { rosto.emoting = false; } } protected override void OnDamageTaken(bool dead) { ((BodyReplacementBase)this).OnDamageTaken(dead); if (Object.op_Implicit((Object)(object)rosto) && !dead) { rosto.Startle(); } } } public class IvoryRosto : MonoBehaviour { public MRIVORY owner; public bool emoting; private float startleUntil; private float nextBlink; private float blinkT = -1f; private float falando; private float surpresa; private float sorriso; private float fechados; private float orelhas; private readonly List<(SkinnedMeshRenderer r, int pl, int pr, int fa, int su, int so, int fe)> rends = new List<(SkinnedMeshRenderer, int, int, int, int, int, int)>(); private readonly List<Material> potionMats = new List<Material>(); private readonly List<Material> gemMats = new List<Material>(); private float lastPotion = -1f; private float lastGem = -1f; private readonly List<(Transform t, Quaternion rest, Vector3 axis)> ears = new List<(Transform, Quaternion, Vector3)>(); private const float EarDroop = 35f; private static FieldInfo fVoice; private static PropertyInfo pAmplitude; private static PropertyInfo pSpeaking; private static bool voiceBroken; private void Start() { //IL_01a1: 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_01ad: 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_01b7: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { Mesh sharedMesh = val.sharedMesh; if ((Object)(object)sharedMesh == (Object)null) { continue; } if (sharedMesh.blendShapeCount > 0) { rends.Add((val, sharedMesh.GetBlendShapeIndex("exp_Piscar.L"), sharedMesh.GetBlendShapeIndex("exp_Piscar.R"), sharedMesh.GetBlendShapeIndex("exp_Falando"), sharedMesh.GetBlendShapeIndex("exp_Surpresa"), sharedMesh.GetBlendShapeIndex("exp_Sorriso"), sharedMesh.GetBlendShapeIndex("exp_Fechados"))); } Material[] materials = ((Renderer)val).materials; foreach (Material val2 in materials) { if (!((Object)(object)val2 == (Object)null)) { if (((Object)val2).name.StartsWith("ICG_Acess")) { potionMats.Add(val2); } if (((Object)val2).name.StartsWith("ICG_Vidro")) { gemMats.Add(val2); } } } } Transform[] all = ((Component)this).GetComponentsInChildren<Transform>(true); string[] array = new string[2] { "L", "R" }; foreach (string text in array) { Transform val3 = Find("Ear." + text + "1"); Transform val4 = Find("Ear." + text + "2"); if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val4 == (Object)null) && !((Object)(object)val3.parent == (Object)null)) { Transform parent = val3.parent; Vector3 val5 = parent.InverseTransformDirection(val4.position - val3.position); Vector3 normalized = ((Vector3)(ref val5)).normalized; val5 = parent.InverseTransformDirection(-((Component)this).transform.up); Vector3 normalized2 = ((Vector3)(ref val5)).normalized; Vector3 val6 = Vector3.Cross(normalized, normalized2); if (!(((Vector3)(ref val6)).sqrMagnitude < 1E-06f)) { ears.Add((val3, val3.localRotation, ((Vector3)(ref val6)).normalized)); } } } nextBlink = Time.time + Random.Range(2f, 5f); Transform Find(string n) { return Array.Find(all, (Transform x) => ((Object)x).name == n); } } public void Startle() { startleUntil = Time.time + 2f; } private static void Set(SkinnedMeshRenderer r, int i, float w) { if (i >= 0) { r.SetBlendShapeWeight(i, w); } } private static float VoiceLevel(PlayerControllerB pc) { if (voiceBroken || (Object)(object)pc == (Object)null) { return 0f; } try { if (fVoice == null) { fVoice = typeof(PlayerControllerB).GetField("voicePlayerState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (fVoice == null) { voiceBroken = true; return 0f; } object obj = fVoice.GetValue(pc); if (obj == null && (Object)(object)pc == (Object)(object)GameNetworkManager.Instance?.localPlayerController) { obj = LocalVoice(); } if (obj == null) { return 0f; } if (pAmplitude == null) { pAmplitude = obj.GetType().GetProperty("Amplitude"); pSpeaking = obj.GetType().GetProperty("IsSpeaking"); if (pAmplitude == null) { voiceBroken = true; return 0f; } } if (pSpeaking != null && !(bool)pSpeaking.GetValue(obj)) { return 0f; } return Convert.ToSingle(pAmplitude.GetValue(obj)); } catch (Exception) { voiceBroken = true; return 0f; } } private static object LocalVoice() { StartOfRound instance = StartOfRound.Instance; object obj = ((!((Object)(object)instance != (Object)null)) ? null : typeof(StartOfRound).GetField("voiceChatModule", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance)); if (obj == null) { return null; } Type type = obj.GetType(); string text = type.GetProperty("LocalPlayerName")?.GetValue(obj) as string; MethodInfo method = type.GetMethod("FindPlayer", new Type[1] { typeof(string) }); if (text == null || !(method != null)) { return null; } return method.Invoke(obj, new object[1] { text }); } private void LateUpdate() { //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = (((Object)(object)owner != (Object)null) ? ((BodyReplacementBase)owner).controller : null); float deltaTime = Time.deltaTime; float num = 0f; if (Plugin.blink.Value) { if (blinkT < 0f && Time.time >= nextBlink) { blinkT = 0f; } if (blinkT >= 0f) { blinkT += deltaTime; num = ((blinkT < 0.07f) ? (blinkT / 0.07f) : ((blinkT < 0.12f) ? 1f : (1f - (blinkT - 0.12f) / 0.1f))); if (blinkT > 0.22f) { blinkT = -1f; num = 0f; nextBlink = Time.time + Random.Range(3f, 6f); if (Random.value < 0.15f) { nextBlink = Time.time + 0.25f; } } } } bool flag = (Object)(object)val != (Object)null && val.isPlayerDead; float num2 = ((Plugin.talkWithVoice.Value && !flag) ? Mathf.Clamp01(VoiceLevel(val) * Plugin.voiceSensitivity.Value) : 0f); falando = Mathf.MoveTowards(falando, num2, deltaTime * 12f); float num3 = ((Plugin.surpriseOnDamage.Value && !flag && Time.time < startleUntil) ? 1f : 0f); surpresa = Mathf.MoveTowards(surpresa, num3, deltaTime * 6f); float num4 = ((Plugin.smileOnEmote.Value && emoting && !flag) ? 1f : 0f); sorriso = Mathf.MoveTowards(sorriso, num4, deltaTime * 5f); fechados = Mathf.MoveTowards(fechados, flag ? 1f : 0f, deltaTime * 4f); if (surpresa > 0.5f || fechados > 0.5f) { num = 0f; } float num5 = Mathf.Max(0f, falando - surpresa); foreach (var (val2, i, i2, i3, i4, i5, i6) in rends) { if (!((Object)(object)val2 == (Object)null)) { Set(val2, i, num * 100f); Set(val2, i2, num * 100f); Set(val2, i3, num5 * 100f); Set(val2, i4, surpresa * 100f); Set(val2, i5, sorriso * 100f); Set(val2, i6, fechados * 100f); } } bool flag2 = (Object)(object)val != (Object)null && Plugin.earsDroop.Value && (flag || val.health <= Plugin.earsDroopHealth.Value); orelhas = Mathf.MoveTowards(orelhas, flag2 ? 1f : 0f, deltaTime * 2f); if (orelhas > 0.001f) { foreach (var (val3, val4, val5) in ears) { if ((Object)(object)val3 != (Object)null) { val3.localRotation = Quaternion.AngleAxis(35f * orelhas, val5) * val4; } } } float num6 = (((Object)(object)val != (Object)null && val.isInsideFactory) ? Plugin.potionGlowInside.Value : Plugin.potionGlowOutside.Value); if (flag) { num6 = 0f; } if (!Mathf.Approximately(num6, lastPotion)) { foreach (Material potionMat in potionMats) { if ((Object)(object)potionMat != (Object)null) { potionMat.SetColor("_EmissiveColor", Color.white * num6); } } lastPotion = num6; } float value = Plugin.gemGlow.Value; if (Mathf.Approximately(value, lastGem)) { return; } foreach (Material gemMat in gemMats) { if ((Object)(object)gemMat != (Object)null) { gemMat.SetColor("_EmissiveColor", Color.white * value); } } lastGem = value; } } [BepInPlugin("com.tavin.ivorymodel", "IvoryModel", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "com.tavin.ivorymodel"; public static ConfigFile config; public static ConfigEntry<bool> enableModelForAllSuits { get; private set; } public static ConfigEntry<bool> enableModelAsDefault { get; private set; } public static ConfigEntry<string> suitNamesToEnableModel { get; private set; } public static ConfigEntry<bool> blink { get; private set; } public static ConfigEntry<bool> smileOnEmote { get; private set; } public static ConfigEntry<bool> surpriseOnDamage { get; private set; } public static ConfigEntry<bool> talkWithVoice { get; private set; } public static ConfigEntry<float> voiceSensitivity { get; private set; } public static ConfigEntry<bool> earsDroop { get; private set; } public static ConfigEntry<int> earsDroopHealth { get; private set; } public static ConfigEntry<float> potionGlowInside { get; private set; } public static ConfigEntry<float> potionGlowOutside { get; private set; } public static ConfigEntry<float> gemGlow { get; private set; } private static void InitConfig() { enableModelForAllSuits = config.Bind<bool>("Suits to Replace Settings", "Enable Model for all Suits", false, "Enable to model replace every suit. Set to false to specify suits"); enableModelAsDefault = config.Bind<bool>("Suits to Replace Settings", "Enable Model as default", false, "Enable to model replace every suit that hasn't been otherwise registered."); suitNamesToEnableModel = config.Bind<string>("Suits to Replace Settings", "Suits to enable Model for", "Ivory", "Enter a comma separated list of suit names.(Additionally, [Default,Orange suit,Green suit,Pajama suit,Hazard suit])"); blink = config.Bind<bool>("Face", "Blink", true, "Ivory blinks every few seconds."); smileOnEmote = config.Bind<bool>("Face", "Smile on emote", true, "She smiles while emoting."); surpriseOnDamage = config.Bind<bool>("Face", "Surprised when hurt", true, "Surprised face for a moment after taking damage."); talkWithVoice = config.Bind<bool>("Face", "Talk with voice chat", true, "Her mouth moves while the player speaks on voice chat (turns itself off if the voice data is not available)."); voiceSensitivity = config.Bind<float>("Face", "Voice sensitivity", 8f, "How much the mouth opens for a given voice volume."); earsDroop = config.Bind<bool>("Ears", "Droop when low health", true, "Her ears droop while health is low."); earsDroopHealth = config.Bind<int>("Ears", "Low health threshold", 30, "Health at or below which the ears droop."); potionGlowInside = config.Bind<float>("Glow", "Potion glow inside the facility", 1f, "Glow strength of the red potion inside the facility (0 = off)."); potionGlowOutside = config.Bind<float>("Glow", "Potion glow outside", 0f, "Glow strength of the red potion on the ship and outside."); gemGlow = config.Bind<float>("Glow", "Brooch gem glow", 0.35f, "Constant faint glow of the emerald brooch (0 = off)."); } private void Awake() { config = ((BaseUnityPlugin)this).Config; InitConfig(); Assets.PopulateAssets(); if (enableModelForAllSuits.Value) { ModelReplacementAPI.RegisterModelReplacementOverride(typeof(MRIVORY)); } if (enableModelAsDefault.Value) { ModelReplacementAPI.RegisterModelReplacementDefault(typeof(MRIVORY)); } string[] array = suitNamesToEnableModel.Value.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { ModelReplacementAPI.RegisterSuitModelReplacement(text, typeof(MRIVORY)); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Plugin {0} is loaded! bundle={1}", "com.tavin.ivorymodel", (Object)(object)Assets.MainAssetBundle != (Object)null)); } } public static class Assets { public static string mainAssetBundleName = "ivorybundle"; public static AssetBundle MainAssetBundle = null; private static string GetAssemblyName() { return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_"); } public static void PopulateAssets() { if ((Object)(object)MainAssetBundle != (Object)null) { return; } using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName); if (stream == null) { Console.WriteLine("IvoryModel: embedded asset bundle not found"); } else { MainAssetBundle = AssetBundle.LoadFromStream(stream); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }