Decompiled source of SandevistanAfterimage v1.1.8
Mods/SandevistanAfterimage.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BoneLib; using BoneLib.BoneMenu; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using SandevistanAfterimage; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Main), "Sandevistan Afterimage", "1.0.42-experimental", "OpenAI", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("SandevistanAfterimage")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SandevistanAfterimage")] [assembly: AssemblyTitle("SandevistanAfterimage")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SandevistanAfterimage { public enum PaletteMode { David, Cyberpsycho, Blackwall } public class Main : MelonMod { private class TintOverlay { public Camera camera; public GameObject quad; public Material material; public GameObject edgeQuad; public Material edgeMaterial; public GameObject spineQuad; public Material spineMaterial; public int spineFrame = -1; } private class GhostSnapshot { public readonly float created; public readonly float lifetime; public readonly Vector3 origin; public readonly List<BodyMat> bodyMaterials = new List<BodyMat>(); public readonly Dictionary<int, Material> bodyByKey = new Dictionary<int, Material>(); public readonly Material shellMaterial; public readonly Color cyberpsychoColor; public readonly PaletteMode palette; public readonly List<GhostPart> parts = new List<GhostPart>(); public bool mini; public float glitchNext; public float flicker = 1f; public float nextEvent; public int dissolveState = -1; public GhostSnapshot(float createdTime, float life, Vector3 originPosition, Material shell, Color cyberColor, PaletteMode paletteMode) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) created = createdTime; lifetime = life; origin = originPosition; shellMaterial = shell; cyberpsychoColor = cyberColor; palette = paletteMode; } } private class BodyMat { public readonly Material material; public readonly bool alphaCapable; public readonly List<string> colorProps = new List<string>(); public readonly List<Color> baseColors = new List<Color>(); public bool hasEmission; public Color baseEmission = Color.black; public bool cutout; public readonly List<string> texProps = new List<string>(); public readonly List<Texture> origTextures = new List<Texture>(); public BodyMat(Material mat, bool alpha) { //IL_0017: 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) material = mat; alphaCapable = alpha; } } private class GhostPart { public readonly GameObject bodyObject; public readonly GameObject shellObject; public readonly Mesh mesh; public readonly Mesh shellMesh; public readonly GameObject overlayObject; public readonly Mesh overlayMesh; public Vector3 baseBodyPos; public Vector3 baseBodyScale; public Vector3 baseShellPos; public Vector3 baseShellScale; public GhostPart(GameObject body, GameObject shell, Mesh meshValue, Mesh shellMeshValue, GameObject overlay, Mesh overlayMeshValue) { overlayObject = overlay; overlayMesh = overlayMeshValue; bodyObject = body; shellObject = shell; mesh = meshValue; shellMesh = shellMeshValue; } } private static readonly Color BodyNear = new Color(0.05f, 0.95f, 0.9f, 1f); private static readonly Color BodyFar = new Color(0.02f, 0.5f, 0.4f, 1f); private static readonly Color RimNear = new Color(0.55f, 1f, 0.95f, 1f); private static readonly Color RimFar = new Color(0.05f, 0.85f, 0.65f, 1f); private static readonly Color BodyGreenCyanNear = new Color(0.04f, 0.94f, 0.78f, 1f); private static readonly Color BodyGreenCyanFar = new Color(0.02f, 0.58f, 0.36f, 1f); private static readonly Color RimGreenCyanNear = new Color(0.42f, 1f, 0.82f, 1f); private static readonly Color RimGreenCyanFar = new Color(0.04f, 0.88f, 0.54f, 1f); private static readonly Color BlackwallRed = new Color(1f, 0.015f, 0.01f, 1f); private static readonly Color TintColor = new Color(0.04f, 0.68f, 0.18f, 1f); private static readonly Color[] CyberpsychoColors = (Color[])(object)new Color[14] { new Color(1f, 0.03f, 0.02f, 1f), new Color(1f, 0.2f, 0f, 1f), new Color(1f, 0.43f, 0f, 1f), new Color(1f, 0.68f, 0f, 1f), new Color(1f, 0.94f, 0f, 1f), new Color(0.68f, 1f, 0f, 1f), new Color(0.12f, 1f, 0.02f, 1f), new Color(0f, 1f, 0.35f, 1f), new Color(0f, 1f, 0.78f, 1f), new Color(0f, 0.82f, 1f, 1f), new Color(0f, 0.48f, 1f, 1f), new Color(0.04f, 0.2f, 1f, 1f), new Color(0.16f, 0.08f, 0.82f, 1f), new Color(0.34f, 0.1f, 0.72f, 1f) }; private MelonPreferences_Category prefs; private MelonPreferences_Entry<bool> enabledPref; private MelonPreferences_Entry<bool> slowMoPref; private MelonPreferences_Entry<float> thresholdPref; private MelonPreferences_Entry<int> ghostCountPref; private MelonPreferences_Entry<int> palettePref; private MelonPreferences_Entry<float> spawnIntervalPref; private MelonPreferences_Entry<float> fadeDurationPref; private MelonPreferences_Entry<float> alphaPref; private MelonPreferences_Entry<float> textureTintPref; private MelonPreferences_Entry<float> glowPref; private MelonPreferences_Entry<float> shadowLiftPref; private MelonPreferences_Entry<float> opacityPref; private MelonPreferences_Entry<bool> spineFlashPref; private MelonPreferences_Entry<string> songFilePref; private MelonPreferences_Entry<float> musicVolumePref; private MelonPreferences_Entry<bool> movementOnlyPref; private MelonPreferences_Entry<float> spawnDistancePref; private MelonPreferences_Entry<bool> rimPref; private MelonPreferences_Entry<float> rimWidthPref; private MelonPreferences_Entry<bool> additivePref; private MelonPreferences_Entry<bool> worldTintPref; private MelonPreferences_Entry<float> worldTintStrengthPref; private MelonPreferences_Entry<bool> debugPref; private MelonPreferences_Entry<bool> hotkeyPref; private readonly List<GhostSnapshot> snapshots = new List<GhostSnapshot>(); private int nextRainbowColorIndex; private SkinnedMeshRenderer[] avatarRenderers = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[0]; private GameObject avatarObject; private Vector3 lastSpawnPosition; private Vector3 lastMovementDirection = Vector3.forward; private float spawnTimer; private float scanTimer; private bool wasSlow; private bool lastEnabled; private bool announcedAvatar; private Material ghostMaterialTemplate; private bool blendControllable; private bool loggedNoTexture; private float edgeFade; private Vector3 lastSpeedPos; private float smoothSpeed; private Texture2D vignetteTexture; private readonly Dictionary<int, Texture> liftedTextureCache = new Dictionary<int, Texture>(); private readonly List<Texture2D> ownedTextures = new List<Texture2D>(); private static readonly string[] TextureProps = new string[8] { "_BaseMap", "_MainTex", "_BaseColorMap", "_Albedo", "_AlbedoMap", "_Diffuse", "_DiffuseMap", "_ColorMap" }; private static readonly string[] ColorProps = new string[5] { "_BaseColor", "_Color", "_Tint", "_TintColor", "_MainColor" }; private readonly List<TintOverlay> tintOverlays = new List<TintOverlay>(); private Material tintMaterialTemplate; private bool tintActive; private float tintFade; private const float TintFadeDuration = 0.12f; private bool fogSaved; private bool savedFog; private Color savedFogColor; private float savedFogDensity; private FogMode savedFogMode; private Color savedAmbient; private float savedAmbientIntensity; private static MethodInfo heldGetObject; private static PropertyInfo heldLeftProp; private static PropertyInfo heldRightProp; private static bool heldResolved; private readonly HashSet<string> heldLogged = new HashSet<string>(); private static Type marrowEntityType; private static bool marrowEntitySearched; private readonly Dictionary<int, GameObject> heldRootCache = new Dictionary<int, GameObject>(); private Vector3 lastLeftLocal; private Vector3 lastRightLocal; private bool haveLastHands; private float poseCooldown; private List<Material> warmList; private int warmIndex; private static Mesh unitQuadMesh; private const int SpineW = 320; private const int SpineH = 200; private const int SpineFrameCount = 0; private const int SpineGlitchFrames = 0; private const int SpineTotalFrames = 0; private const float SpineDuration = 1.55f; private const int GifW = 498; private const int GifH = 281; private const int GifFrameCount = 32; private const int CanvasW = 1000; private const int CanvasH = 562; private const float GifCanvasFraction = 0.47f; private const float GifFps = 25f; private readonly List<Texture2D> gifFrames = new List<Texture2D>(); private byte[] gifRaw; private bool gifFailed; private const float SpineCooldown = 4f; private readonly List<Texture2D> spineFrames = new List<Texture2D>(); private bool spineBuildFailed; private bool spinePlaying; private bool spineShown; private float spineStart; private float spineLastTrigger = -100f; private string musicDir; private readonly Dictionary<int, string> musicPaths = new Dictionary<int, string>(); private GameObject musicObject; private AudioSource musicSource; private AudioClip musicClip; private int musicClipTrack = -1; private int musicFailedTrack = -1; private int randomNext; private float musicFade; private bool musicWasSlow; private bool musicEmptyLogged; private MethodInfo aiLoadMethod; private bool aiSearched; private const float GifDistance = 0.8f; private bool frameMissing; public override void OnInitializeMelon() { //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_0683: Unknown result type (might be due to invalid IL or missing references) //IL_071c: Unknown result type (might be due to invalid IL or missing references) prefs = MelonPreferences.CreateCategory("SandevistanAfterimage", "Sandevistan Afterimage"); enabledPref = prefs.CreateEntry<bool>("Enabled", true, "Enabled", "Master switch.", false, false, (ValueValidator)null, (string)null); slowMoPref = prefs.CreateEntry<bool>("TriggerOnSlowMotion", true, "Trigger on slow motion", "Activate when Time.timeScale is below threshold (Quicksilver compatible).", false, false, (ValueValidator)null, (string)null); thresholdPref = prefs.CreateEntry<float>("SlowMotionThreshold", 0.92f, "Slow-motion threshold", "Below this timeScale the effect runs.", false, false, (ValueValidator)null, (string)null); ghostCountPref = prefs.CreateEntry<int>("GhostCountV3", 48, "Ghost count", "Maximum simultaneous afterimages; lower this if performance drops.", false, false, (ValueValidator)null, (string)null); palettePref = prefs.CreateEntry<int>("ColorPaletteV2", 1, "Color palette", "0 = David cyan-to-green-cyan, 1 = Cyberpsycho spectrum, 2 = Blackwall black-to-red.", false, false, (ValueValidator)null, (string)null); spawnIntervalPref = prefs.CreateEntry<float>("SpawnIntervalV2", 0.008f, "Min spawn interval", "Minimum unscaled seconds between snapshots.", false, false, (ValueValidator)null, (string)null); fadeDurationPref = prefs.CreateEntry<float>("FadeDurationV3", 2f, "Fade Time", "Total unscaled seconds each afterimage takes to fade from full intensity to invisible (0.5–5 seconds).", false, false, (ValueValidator)null, (string)null); alphaPref = prefs.CreateEntry<float>("Alpha", 0.62f, "Alpha", "Starting intensity of the afterimage outline.", false, false, (ValueValidator)null, (string)null); textureTintPref = prefs.CreateEntry<float>("ColorStrengthV3", 0.8f, "Color strength", "How strongly the palette color tints the avatar copies (0 = original avatar colors, 1 = fully palette-colored).", false, false, (ValueValidator)null, (string)null); glowPref = prefs.CreateEntry<float>("GhostGlowV3", 0.8f, "Ghost glow", "Brightness boost of the tinted ghosts so they stay vivid on dark armor (0 = none, 1.5 = strong).", false, false, (ValueValidator)null, (string)null); shadowLiftPref = prefs.CreateEntry<float>("ShadowLiftV1", 0.35f, "Shadow lift", "Raises the black/grey parts of the avatar so they become a darker shade of the palette color instead of staying black (0 = off, 0.6 = very light).", false, false, (ValueValidator)null, (string)null); opacityPref = prefs.CreateEntry<float>("GhostOpacityV1", 0.5f, "Afterimage opacity", "How see-through the afterimages are at spawn (0.1 = very faint, 1 = solid). They fade out smoothly from this value.", false, false, (ValueValidator)null, (string)null); spineFlashPref = prefs.CreateEntry<bool>("SpineFlashV1", true, "Spine flash", "Plays a neon ribcage/spine X-ray flash across your view when slow motion starts.", false, false, (ValueValidator)null, (string)null); songFilePref = prefs.CreateEntry<string>("MusicFileV3", "*random*", "Music file", "Empty = off, *random* = random, otherwise the mp3 file name. Plays during slow motion; mp3 files go in UserData/SandevistanAfterimage/Music.", false, false, (ValueValidator)null, (string)null); musicVolumePref = prefs.CreateEntry<float>("MusicVolumeV1", 0.5f, "Music volume", "Volume of the slow-motion music (0-1).", false, false, (ValueValidator)null, (string)null); movementOnlyPref = prefs.CreateEntry<bool>("MovementOnly", true, "Movement only", "Only spawn after moving SpawnDistance.", false, false, (ValueValidator)null, (string)null); spawnDistancePref = prefs.CreateEntry<float>("SpawnDistanceV6", 0.65f, "Image spacing", "Meters between afterimages (0.30–1.00); larger values create more space.", false, false, (ValueValidator)null, (string)null); rimPref = prefs.CreateEntry<bool>("RimGlowV2", false, "Rim glow", "Bright inverted-hull outline.", false, false, (ValueValidator)null, (string)null); rimWidthPref = prefs.CreateEntry<float>("RimWidth", 0.022f, "Rim width", "Outline thickness in meters.", false, false, (ValueValidator)null, (string)null); additivePref = prefs.CreateEntry<bool>("Additive", true, "Additive glow", "Additive blending for brighter overlaps.", false, false, (ValueValidator)null, (string)null); worldTintPref = prefs.CreateEntry<bool>("WorldTint", true, "World green tint", "Full-screen green overlay + ambient while slow-mo is active.", false, false, (ValueValidator)null, (string)null); worldTintStrengthPref = prefs.CreateEntry<float>("WorldTintStrengthV4", 0.8f, "World tint strength", "0 = off, 1 = heavy green. Affects only your view.", false, false, (ValueValidator)null, (string)null); debugPref = prefs.CreateEntry<bool>("DebugLogging", true, "Debug logging", "Console diagnostics.", false, false, (ValueValidator)null, (string)null); hotkeyPref = prefs.CreateEntry<bool>("F8Toggle", true, "F8 toggle", "Press F8 to toggle.", false, false, (ValueValidator)null, (string)null); prefs.SaveToFile(false); lastEnabled = enabledPref.Value; try { musicDir = Path.Combine(MelonEnvironment.UserDataDirectory, "SandevistanAfterimage", "Music"); Directory.CreateDirectory(musicDir); RefreshMusicFiles(); MelonLogger.Msg("Music folder: " + musicDir + " (" + musicPaths.Count + " tracks found) - copy your mp3 files into this folder"); } catch (Exception ex) { MelonLogger.Warning("Music folder setup failed: " + ex.Message); } try { Color val = default(Color); ((Color)(ref val))..ctor(0.05f, 0.85f, 0.78f, 1f); Page obj = Page.Root.CreatePage("Sandevistan Afterimage", val, 0, true); obj.CreateBool("Mod Enabled", Color.white, enabledPref.Value, (Action<bool>)delegate(bool value) { enabledPref.Value = value; prefs.SaveToFile(false); if (!value) { ClearSnapshots(); SetTintActive(active: false); SetEdgeBlur(active: false); } MelonLogger.Msg("Sandevistan Afterimage: " + (value ? "ON" : "OFF")); }); Page target = obj.CreatePage("Trail", val, 0, true); AddFloat(target, "Fade Time (seconds)", fadeDurationPref, 0.5f, 0.5f, 5f, null); AddFloat(target, "Image Spacing (meters)", spawnDistancePref, 0.05f, 0.3f, 1f, null); Page val2 = obj.CreatePage("Look", val, 0, true); PaletteMode paletteMode = ((palettePref.Value != 0) ? ((palettePref.Value != 2) ? PaletteMode.Cyberpsycho : PaletteMode.Blackwall) : PaletteMode.David); val2.CreateEnum("Color Palette", Color.white, (Enum)paletteMode, (Action<Enum>)delegate(Enum value) { palettePref.Value = Convert.ToInt32(value); prefs.SaveToFile(false); MelonLogger.Msg("Sandevistan Afterimage palette: " + value); }); AddFloat(val2, "Afterimage Opacity", opacityPref, 0.05f, 0.1f, 1f, null); AddFloat(val2, "Color Strength", textureTintPref, 0.05f, 0f, 1f, null); AddFloat(val2, "Shadow Lift", shadowLiftPref, 0.05f, 0f, 0.6f, delegate { ClearSnapshots(); ClearLookCaches(); }); Page val3 = obj.CreatePage("Effects", val, 0, true); AddFloat(val3, "Green Tint Strength", worldTintStrengthPref, 0.05f, 0f, 1f, null); val3.CreateBool("Spine Flash", Color.white, spineFlashPref.Value, (Action<bool>)delegate(bool value) { spineFlashPref.Value = value; prefs.SaveToFile(false); if (!value) { spinePlaying = false; } MelonLogger.Msg("Sandevistan Afterimage spine flash: " + (value ? "ON" : "OFF")); }); Page val4 = obj.CreatePage("Music", val, 0, true); Page val5 = val4.CreatePage("Songs", val, 0, true); val5.CreateFunction("Off", Color.white, (Action)delegate { SelectSong("", "Off"); }); val5.CreateFunction("Random", Color.white, (Action)delegate { SelectSong("*random*", "Random"); }); for (int num = 1; num <= musicPaths.Count; num++) { string path = musicPaths[num]; string fileName = Path.GetFileName(path); string text = Regex.Replace(Path.GetFileNameWithoutExtension(path), "^\\d+[\\s_.\\-]+", "").Replace('_', ' ').Replace(" - ", " - ") .Trim(); if (text.Length == 0) { text = fileName; } string capturedName = fileName; string capturedLabel = text; val5.CreateFunction(text, Color.white, (Action)delegate { SelectSong(capturedName, capturedLabel); }); } AddFloat(val4, "Volume", musicVolumePref, 0.05f, 0f, 1f, null); MelonLogger.Msg("BoneMenu controls registered."); } catch (Exception ex2) { MelonLogger.Error("Failed to register BoneMenu controls: " + ex2); } MelonLogger.Msg("Sandevistan Afterimage 1.0.42-experimental loaded."); MelonLogger.Msg("Afterimages + full-screen green tint are client-side only (Fusion-safe)."); MelonLogger.Msg("Settings: UserData/MelonPreferences.cfg [SandevistanAfterimage]"); } private static void ResolveHeldApi() { heldResolved = true; try { Type? typeFromHandle = typeof(Player); heldGetObject = typeFromHandle.GetMethod("GetObjectInHand", BindingFlags.Static | BindingFlags.Public); heldLeftProp = typeFromHandle.GetProperty("LeftHand", BindingFlags.Static | BindingFlags.Public); heldRightProp = typeFromHandle.GetProperty("RightHand", BindingFlags.Static | BindingFlags.Public); MelonLogger.Msg("Held-item afterimages: GetObjectInHand=" + (heldGetObject != null) + " LeftHand=" + (heldLeftProp != null) + " RightHand=" + (heldRightProp != null)); } catch (Exception ex) { MelonLogger.Warning("Held-item lookup failed: " + ex.Message); } } private static object ReadMember(object o, string name) { if (o == null) { return null; } try { Type type = o.GetType(); PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.GetIndexParameters().Length == 0) { return property.GetValue(o); } FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return field.GetValue(o); } } catch (Exception) { } return null; } private GameObject GetHeldObject(PropertyInfo handProp) { if (handProp == null) { return null; } object value = handProp.GetValue(null); if (value == null) { return null; } GameObject val = null; if (heldGetObject != null) { try { object? obj = heldGetObject.Invoke(null, new object[1] { value }); val = (GameObject)((obj is GameObject) ? obj : null); } catch (Exception) { val = null; } } if ((Object)(object)val != (Object)null) { return val; } try { object obj2 = ReadMember(value, "AttachedReceiver"); Component val2 = (Component)((obj2 is Component) ? obj2 : null); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.gameObject != (Object)null) { val = val2.gameObject; } if ((Object)(object)val == (Object)null) { object obj3 = ReadMember(value, "m_CurrentAttachedGO"); val = (GameObject)((obj3 is GameObject) ? obj3 : null); } if ((Object)(object)val != (Object)null) { string item = "fallback:" + ((Object)val).name; if (heldLogged.Add(item)) { MelonLogger.Msg("Hand grips '" + ((Object)val).name + "' (found through the hand, BoneLib reported nothing)."); } } } catch (Exception) { val = null; } return val; } private Transform FindEntityRoot(Transform grip) { try { if (!marrowEntitySearched) { marrowEntitySearched = true; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = null; try { type = assembly.GetType("Il2CppSLZ.Marrow.Entities.MarrowEntity", throwOnError: false); } catch (Exception) { } if (type != null) { marrowEntityType = type; break; } } MelonLogger.Msg("Held-item root: MarrowEntity type " + ((marrowEntityType != null) ? "found" : "not found (using parent walk)")); } if (marrowEntityType == null) { return null; } Component componentInParent = ((Component)grip).GetComponentInParent(Il2CppType.From(marrowEntityType)); if ((Object)(object)componentInParent != (Object)null) { return componentInParent.transform; } } catch (Exception ex2) { marrowEntityType = null; MelonLogger.Warning("MarrowEntity lookup failed: " + ex2.Message); } return null; } private GameObject ResolveHeldRoot(GameObject grip) { //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) int instanceID = ((Object)grip).GetInstanceID(); if (heldRootCache.TryGetValue(instanceID, out var value)) { if (!((Object)(object)value != (Object)null)) { return null; } return value; } if (heldRootCache.Count > 64) { heldRootCache.Clear(); } GameObject val = null; try { Transform val2 = grip.transform; Transform val3 = val2; int i = 0; Transform val4 = FindEntityRoot(grip.transform); if ((Object)(object)val4 != (Object)null && (!((Object)(object)avatarObject != (Object)null) || !avatarObject.transform.IsChildOf(val4))) { int num = ((Component)val4).GetComponentsInChildren<MeshRenderer>(false).Length + ((Component)val4).GetComponentsInChildren<SkinnedMeshRenderer>(false).Length; if (num > 0 && num <= 250) { val2 = val4; val3 = val4; i = 99; } } for (; i < 8; i++) { if (!((Object)(object)val3.parent != (Object)null)) { break; } Transform parent = val3.parent; if (((Object)(object)avatarObject != (Object)null && avatarObject.transform.IsChildOf(parent)) || ((Component)parent).GetComponentsInChildren<MeshRenderer>(false).Length + ((Component)parent).GetComponentsInChildren<SkinnedMeshRenderer>(false).Length > 90) { break; } val3 = parent; val2 = parent; } Il2CppArrayBase<Renderer> componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(false); bool flag = false; bool flag2 = false; Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(val2.position, Vector3.zero); for (int j = 0; j < componentsInChildren.Length; j++) { Renderer val5 = componentsInChildren[j]; if ((Object)(object)val5 == (Object)null) { continue; } bool num2 = (Object)(object)((Il2CppObjectBase)val5).TryCast<MeshRenderer>() != (Object)null; bool flag3 = (Object)(object)((Il2CppObjectBase)val5).TryCast<SkinnedMeshRenderer>() != (Object)null; if (!num2 && !flag3) { continue; } if (flag3) { flag = true; continue; } if (HeldMeshSize(val5) > 3f) { flag = true; flag2 = true; continue; } if (!flag || ((Bounds)(ref bounds)).size == Vector3.zero) { bounds = val5.bounds; } else { ((Bounds)(ref bounds)).Encapsulate(val5.bounds); } flag = true; } if (!flag) { goto IL_02bc; } Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).magnitude <= 6f || componentsInChildren.Length <= 40 || flag2)) { goto IL_02bc; } val = ((Component)val2).gameObject; LogHeldBreakdown(val2); string[] obj = new string[9] { "Holding '", ((Object)grip).name, "' -> item '", ((Object)val).name, "' (", componentsInChildren.Length.ToString(), " renderers, size ", null, null }; size = ((Bounds)(ref bounds)).size; obj[7] = ((Vector3)(ref size)).magnitude.ToString("0.0"); obj[8] = " m) - copying it into the afterimages."; MelonLogger.Msg(string.Concat(obj)); goto end_IL_0040; IL_02bc: string[] obj2 = new string[5] { "Holding '", ((Object)grip).name, "' but skipped: ", null, null }; object obj3; if (!flag) { obj3 = "no visible renderers"; } else { size = ((Bounds)(ref bounds)).size; obj3 = "too large (" + ((Vector3)(ref size)).magnitude.ToString("0.0") + " m, probably level geometry)"; } obj2[3] = (string)obj3; obj2[4] = "."; MelonLogger.Msg(string.Concat(obj2)); end_IL_0040:; } catch (Exception ex) { MelonLogger.Warning("Held item root lookup failed: " + ex.Message); } heldRootCache[instanceID] = val; return val; } private static float HeldMeshSize(Renderer r) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) try { Mesh val = null; MeshRenderer val2 = ((Il2CppObjectBase)r).TryCast<MeshRenderer>(); if ((Object)(object)val2 != (Object)null) { MeshFilter component = ((Component)val2).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { val = component.sharedMesh; } } if ((Object)(object)val == (Object)null) { return 0f; } Vector3 lossyScale = ((Component)r).transform.lossyScale; Bounds bounds = val.bounds; Vector3 size = ((Bounds)(ref bounds)).size; Vector3 val3 = new Vector3(size.x * Mathf.Abs(lossyScale.x), size.y * Mathf.Abs(lossyScale.y), size.z * Mathf.Abs(lossyScale.z)); return ((Vector3)(ref val3)).magnitude; } catch (Exception) { return 0f; } } private void LogHeldBreakdown(Transform root) { try { Il2CppArrayBase<Renderer> componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true); int num = 0; int num2 = 0; int num3 = 0; for (int i = 0; i < componentsInChildren.Length; i++) { Renderer val = componentsInChildren[i]; if ((Object)(object)val == (Object)null) { continue; } string text = null; MeshRenderer val2 = ((Il2CppObjectBase)val).TryCast<MeshRenderer>(); SkinnedMeshRenderer val3 = ((Il2CppObjectBase)val).TryCast<SkinnedMeshRenderer>(); if ((Object)(object)val2 == (Object)null && (Object)(object)val3 == (Object)null) { text = "not a mesh (" + ((object)val).GetType().Name + ")"; } else if (!((Component)val).gameObject.activeInHierarchy) { text = "inactive"; } else if (!val.enabled) { text = "renderer disabled"; } else if ((Object)(object)val2 != (Object)null) { MeshFilter component = ((Component)val2).GetComponent<MeshFilter>(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { text = "no mesh"; } else if (component.sharedMesh.vertexCount < 12) { text = "only " + component.sharedMesh.vertexCount + " vertices"; } } else if ((Object)(object)val3.sharedMesh == (Object)null) { text = "no mesh (skinned)"; } else if (val3.sharedMesh.vertexCount < 12) { text = "only " + val3.sharedMesh.vertexCount + " vertices (skinned)"; } if (text == null) { num2++; continue; } num3++; if (num++ < 25) { MelonLogger.Msg(" [held] skip '" + ((Object)((Component)val).gameObject).name + "': " + text); } } MelonLogger.Msg("[held] '" + ((Object)root).name + "': " + num2 + " renderers will be copied, " + num3 + " skipped"); } catch (Exception ex) { MelonLogger.Warning("Held breakdown failed: " + ex.Message); } } private void CollectHeldRenderers(List<SkinnedMeshRenderer> skinned, List<MeshRenderer> meshes) { if (!heldResolved) { ResolveHeldApi(); } try { PropertyInfo[] array = new PropertyInfo[2] { heldLeftProp, heldRightProp }; HashSet<int> hashSet = new HashSet<int>(); for (int i = 0; i < array.Length; i++) { GameObject heldObject = GetHeldObject(array[i]); if ((Object)(object)heldObject == (Object)null || ((Object)(object)avatarObject != (Object)null && heldObject.transform.IsChildOf(avatarObject.transform))) { continue; } heldObject = ResolveHeldRoot(heldObject); if ((Object)(object)heldObject == (Object)null) { continue; } Il2CppArrayBase<MeshRenderer> componentsInChildren = heldObject.GetComponentsInChildren<MeshRenderer>(false); for (int j = 0; j < componentsInChildren.Length; j++) { if (meshes.Count >= 96) { break; } MeshRenderer val = componentsInChildren[j]; if (!((Object)(object)val == (Object)null) && ((Renderer)val).enabled && !((Object)((Component)val).gameObject).name.StartsWith("SandevistanAfterimage") && hashSet.Add(((Object)val).GetInstanceID())) { meshes.Add(val); } } Il2CppArrayBase<SkinnedMeshRenderer> componentsInChildren2 = heldObject.GetComponentsInChildren<SkinnedMeshRenderer>(false); for (int k = 0; k < componentsInChildren2.Length; k++) { if (skinned.Count >= 64) { break; } SkinnedMeshRenderer val2 = componentsInChildren2[k]; if (!((Object)(object)val2 == (Object)null) && ((Renderer)val2).enabled && hashSet.Add(((Object)val2).GetInstanceID())) { skinned.Add(val2); } } } } catch (Exception ex) { if (debugPref.Value) { MelonLogger.Warning("Held-item scan failed: " + ex.Message); } } } private bool TryGetHandsLocal(out Vector3 left, out Vector3 right) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) left = (right = Vector3.zero); try { if (!heldResolved) { ResolveHeldApi(); } if ((Object)(object)avatarObject == (Object)null || heldLeftProp == null || heldRightProp == null) { return false; } object? value = heldLeftProp.GetValue(null); Component val = (Component)((value is Component) ? value : null); object? value2 = heldRightProp.GetValue(null); Component val2 = (Component)((value2 is Component) ? value2 : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return false; } Transform transform = avatarObject.transform; left = transform.InverseTransformPoint(val.transform.position); right = transform.InverseTransformPoint(val2.transform.position); return true; } catch (Exception) { return false; } } private void RememberPose() { haveLastHands = TryGetHandsLocal(out lastLeftLocal, out lastRightLocal); } private bool PoseMoved(float threshold) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (!TryGetHandsLocal(out var left, out var right)) { return false; } if (!haveLastHands) { lastLeftLocal = left; lastRightLocal = right; haveLastHands = true; return false; } float num = threshold * threshold; Vector3 val = left - lastLeftLocal; if (!(((Vector3)(ref val)).sqrMagnitude >= num)) { val = right - lastRightLocal; return ((Vector3)(ref val)).sqrMagnitude >= num; } return true; } private void SelectSong(string fileOrCode, string label) { songFilePref.Value = fileOrCode; prefs.SaveToFile(false); musicFailedTrack = -1; randomNext = 0; MelonLogger.Msg("Sandevistan Afterimage song: " + label); } private void AddFloat(Page target, string label, MelonPreferences_Entry<float> pref, float step, float min, float max, Action onChanged) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) target.CreateFloat(label, Color.white, Mathf.Clamp(pref.Value, min, max), step, min, max, (Action<float>)delegate(float value) { pref.Value = Mathf.Clamp(value, min, max); prefs.SaveToFile(false); if (onChanged != null) { onChanged(); } MelonLogger.Msg("Sandevistan Afterimage " + label + ": " + pref.Value.ToString("0.00")); }); } public override void OnUpdate() { //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: 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_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) if (hotkeyPref.Value && Input.GetKeyDown((KeyCode)289)) { enabledPref.Value = !enabledPref.Value; prefs.SaveToFile(false); if (!enabledPref.Value) { ClearSnapshots(); SetTintActive(active: false); SetEdgeBlur(active: false); } MelonLogger.Msg("Sandevistan Afterimage: " + (enabledPref.Value ? "ON" : "OFF")); } if (lastEnabled != enabledPref.Value) { lastEnabled = enabledPref.Value; if (!lastEnabled) { ClearSnapshots(); SetTintActive(active: false); SetEdgeBlur(active: false); } } UpdateSnapshots(); if (spineFlashPref.Value && !spineBuildFailed && (Object)(object)avatarObject != (Object)null && spineFrames.Count < 0) { BuildSpineFrame(spineFrames.Count); } else if (spineFlashPref.Value && !gifFailed && (Object)(object)avatarObject != (Object)null && gifFrames.Count < 32) { BuildGifFrames(1); } UpdateSpineFlash(); UpdateMusic(); if (!enabledPref.Value) { SetTintActive(active: false); SetEdgeBlur(active: false); return; } scanTimer -= Time.unscaledDeltaTime; if (scanTimer <= 0f) { scanTimer = 0.4f; RefreshAvatar(); RefreshTintCameras(); } if ((Object)(object)avatarObject == (Object)null || avatarRenderers.Length == 0) { SetTintActive(active: false); SetEdgeBlur(active: false); return; } Vector3 position = avatarObject.transform.position; float unscaledDeltaTime = Time.unscaledDeltaTime; if (unscaledDeltaTime > 0.0001f) { Vector3 val = new Vector3(position.x - lastSpeedPos.x, 0f, position.z - lastSpeedPos.z); float num = ((Vector3)(ref val)).magnitude / unscaledDeltaTime; smoothSpeed = Mathf.Lerp(smoothSpeed, Mathf.Min(num, 30f), 0.12f); } lastSpeedPos = position; if (!wasSlow) { WarmGhostCaches(); } bool flag = slowMoPref.Value && Time.timeScale < Mathf.Clamp(thresholdPref.Value, 0.01f, 1f); if (flag && !wasSlow) { lastSpawnPosition = avatarObject.transform.position; TriggerSpineFlash(); if (debugPref.Value) { MelonLogger.Msg("Slow motion ON timeScale=" + Time.timeScale.ToString("0.000")); } } if (!flag && wasSlow && debugPref.Value) { MelonLogger.Msg("Slow motion OFF"); } wasSlow = flag; SetTintActive(flag && worldTintPref.Value); SetEdgeBlur(flag); if (!flag) { return; } spawnTimer -= Time.unscaledDeltaTime; if (spawnTimer > 0f) { return; } Vector3 position2 = avatarObject.transform.position; Vector3 val2 = position2 - lastSpawnPosition; float num2 = Mathf.Clamp(spawnDistancePref.Value, 0.3f, 1f); bool flag2 = ((Vector3)(ref val2)).sqrMagnitude >= num2 * num2; poseCooldown -= Time.unscaledDeltaTime; bool flag3 = !flag2 && poseCooldown <= 0f && PoseMoved(0.2f); if (!movementOnlyPref.Value || flag2 || flag3) { Vector3 zero = Vector3.zero; if (flag2) { lastMovementDirection = ((Vector3)(ref val2)).normalized; zero = lastMovementDirection; } spawnTimer = Mathf.Max(0.008f, spawnIntervalPref.Value); lastSpawnPosition = position2; RememberPose(); if (!flag2) { poseCooldown = 0.12f; } CreateSnapshot(zero, mini: false, !flag2); } } private void RefreshAvatar() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.RigManager == (Object)null) { if (debugPref.Value && !announcedAvatar) { MelonLogger.Msg("Waiting for BoneLib player..."); } return; } GameObject val = null; try { if ((Object)(object)Player.Avatar != (Object)null) { val = ((Component)Player.Avatar).gameObject; } } catch (Exception ex) { if (debugPref.Value) { MelonLogger.Warning("Player.Avatar read failed: " + ex.Message); } return; } if (!((Object)(object)val == (Object)null) && (Object)(object)avatarObject != (Object)(object)val) { avatarObject = val; avatarRenderers = Il2CppArrayBase<SkinnedMeshRenderer>.op_Implicit(avatarObject.GetComponentsInChildren<SkinnedMeshRenderer>(true)); lastSpawnPosition = avatarObject.transform.position; ClearSnapshots(); TrimLookCaches(); warmList = null; nextRainbowColorIndex = 0; announcedAvatar = true; string[] obj = new string[6] { "Avatar: ", ((Object)avatarObject).name, " renderers=", avatarRenderers.Length.ToString(), " rootLossyScale=", null }; Vector3 lossyScale = avatarObject.transform.lossyScale; obj[5] = ((Vector3)(ref lossyScale)).ToString("F3"); MelonLogger.Msg(string.Concat(obj)); } } private void CreateSnapshot(Vector3 movementDirection, bool mini = false, bool quick = false) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) EnsureGhostTemplate(); if ((Object)(object)ghostMaterialTemplate == (Object)null) { if (debugPref.Value) { MelonLogger.Warning("No usable shader for ghost material."); } return; } Material val = ((rimPref.Value && (Object)(object)ghostMaterialTemplate != (Object)null && ghostMaterialTemplate.HasProperty("_Cull")) ? CreateGhostMaterial(shell: true) : null); float width = Mathf.Clamp(rimWidthPref.Value, 0.001f, 0.08f); int ghostIndex = nextRainbowColorIndex++; Color cyberColor = GetCyberpsychoColor(ghostIndex); PaletteMode paletteMode = ((palettePref.Value != 0) ? ((palettePref.Value != 2) ? PaletteMode.Cyberpsycho : PaletteMode.Blackwall) : PaletteMode.David); if (paletteMode == PaletteMode.Blackwall) { cyberColor = GetBlackwallColor(ghostIndex); } float num = Mathf.Clamp(fadeDurationPref.Value, 0.5f, 5f); float scaleK = 1f; float num2 = 0f; Vector3 worldOffset = -movementDirection * 0.25f; Vector3 position = avatarObject.transform.position; float life = num; if (quick) { life = Mathf.Max(0.25f, num * 0.35f); } if (mini) { scaleK = Random.Range(0.18f, 0.32f); num2 = Random.Range(0f, 360f); float num3 = Random.Range(0f, (float)Math.PI * 2f); float num4 = Random.Range(1.5f, 6f); ((Vector3)(ref worldOffset))..ctor(Mathf.Cos(num3) * num4, 0f, Mathf.Sin(num3) * num4); life = Random.Range(0.9f, 1.7f); } Quaternion yawRot = Quaternion.AngleAxis(num2, Vector3.up); GhostSnapshot ghostSnapshot = new GhostSnapshot(Time.realtimeSinceStartup, life, avatarObject.transform.position, val, cyberColor, paletteMode); ghostSnapshot.mini = mini; ghostSnapshot.nextEvent = Time.realtimeSinceStartup + Random.Range(0.2f, 0.9f); ghostSnapshot.glitchNext = Time.realtimeSinceStartup + Random.Range(0.02f, 0.1f); List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>(avatarRenderers); List<MeshRenderer> list2 = new List<MeshRenderer>(); CollectHeldRenderers(list, list2); int num5 = 0; for (int i = 0; i < list.Count; i++) { SkinnedMeshRenderer val2 = list[i]; if ((Object)(object)val2 == (Object)null || !((Renderer)val2).enabled || (Object)(object)val2.sharedMesh == (Object)null || val2.sharedMesh.vertexCount < 12) { continue; } GameObject val3 = null; GameObject val4 = null; GameObject val5 = null; Mesh val6 = null; Mesh val7 = null; Mesh val8 = null; try { val6 = new Mesh(); ((Object)val6).name = "SandevistanAfterimageMesh"; val2.BakeMesh(val6, true); int num6 = Mathf.Max(1, val6.subMeshCount); Material[] materials = BuildBodyMaterials(ghostSnapshot, val2, num6); val3 = SpawnGhostPart("SandevistanAfterimagePart", ((Component)val2).transform, val6, materials, worldOffset, position, yawRot, scaleK); if ((Object)(object)val != (Object)null) { val7 = BuildShellMesh(val6, width); if ((Object)(object)val7 != (Object)null) { Material[] array = (Material[])(object)new Material[num6]; for (int j = 0; j < num6; j++) { array[j] = val; } val4 = SpawnGhostPart("SandevistanAfterimageRim", ((Component)val2).transform, val7, array, worldOffset, position, yawRot, scaleK); } } GhostPart ghostPart = new GhostPart(val3, val4, val6, val7, val5, val8); ghostPart.baseBodyPos = val3.transform.position; ghostPart.baseBodyScale = val3.transform.localScale; if ((Object)(object)val4 != (Object)null) { ghostPart.baseShellPos = val4.transform.position; ghostPart.baseShellScale = val4.transform.localScale; } ghostSnapshot.parts.Add(ghostPart); num5++; } catch (Exception ex) { if ((Object)(object)val3 != (Object)null) { Object.Destroy((Object)(object)val3); } if ((Object)(object)val4 != (Object)null) { Object.Destroy((Object)(object)val4); } if ((Object)(object)val5 != (Object)null) { Object.Destroy((Object)(object)val5); } if ((Object)(object)val8 != (Object)null) { Object.Destroy((Object)(object)val8); } if ((Object)(object)val6 != (Object)null) { Object.Destroy((Object)(object)val6); } if ((Object)(object)val7 != (Object)null) { Object.Destroy((Object)(object)val7); } if (debugPref.Value || heldLogged.Add("bakefail:" + ((Object)val2).name)) { MelonLogger.Warning("Bake failed on " + ((Object)val2).name + ": " + ex.Message); } } } for (int k = 0; k < list2.Count; k++) { MeshRenderer val9 = list2[k]; GameObject val10 = null; Mesh val11 = null; try { MeshFilter component = ((Component)val9).GetComponent<MeshFilter>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null) && component.sharedMesh.vertexCount >= 12) { val11 = Object.Instantiate<Mesh>(component.sharedMesh); int subCount = Mathf.Max(1, val11.subMeshCount); Material[] materials2 = BuildBodyMaterials(ghostSnapshot, ((Renderer)val9).sharedMaterials, subCount); val10 = SpawnGhostPart("SandevistanAfterimagePart", ((Component)val9).transform, val11, materials2, worldOffset, position, yawRot, scaleK); GhostPart ghostPart2 = new GhostPart(val10, null, val11, null, null, null); ghostPart2.baseBodyPos = val10.transform.position; ghostPart2.baseBodyScale = val10.transform.localScale; ghostSnapshot.parts.Add(ghostPart2); num5++; } } catch (Exception ex2) { if ((Object)(object)val10 != (Object)null) { Object.Destroy((Object)(object)val10); } if ((Object)(object)val11 != (Object)null) { Object.Destroy((Object)(object)val11); } MelonLogger.Warning("Held item copy failed on " + ((Object)val9).name + ": " + ex2.Message); } } if (num5 == 0) { DestroySnapshot(ghostSnapshot); if (debugPref.Value) { MelonLogger.Warning("Snapshot produced 0 mesh parts."); } return; } ApplySnapshotColors(ghostSnapshot, 0f); snapshots.Add(ghostSnapshot); TrimSnapshots(); if (debugPref.Value) { MelonLogger.Msg("Snapshot: " + num5 + " parts" + (((Object)(object)val != (Object)null) ? " +rim" : "")); } } private static GameObject SpawnGhostPart(string name, Transform source, Mesh mesh, Material[] materials, Vector3 worldOffset, Vector3 pivot, Quaternion yawRot, float scaleK) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0061: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.position = pivot + yawRot * ((source.position - pivot) * scaleK) + worldOffset; val.transform.rotation = yawRot * source.rotation; val.transform.localScale = source.lossyScale * scaleK; MeshFilter val2 = val.AddComponent<MeshFilter>(); MeshRenderer val3 = val.AddComponent<MeshRenderer>(); val2.sharedMesh = mesh; Il2CppReferenceArray<Material> val4 = new Il2CppReferenceArray<Material>((long)materials.Length); for (int i = 0; i < materials.Length; i++) { ((Il2CppArrayBase<Material>)(object)val4)[i] = materials[i]; } ((Renderer)val3).sharedMaterials = val4; ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val3).receiveShadows = false; return val; } private static Mesh BuildShellMesh(Mesh baked, float width) { //IL_0046: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) Mesh val = Object.Instantiate<Mesh>(baked); ((Object)val).name = "SandevistanAfterimageRimMesh"; Vector3[] array = Il2CppArrayBase<Vector3>.op_Implicit((Il2CppArrayBase<Vector3>)(object)val.vertices); Vector3[] array2 = Il2CppArrayBase<Vector3>.op_Implicit((Il2CppArrayBase<Vector3>)(object)val.normals); if (array == null || array2 == null || array2.Length != array.Length) { Object.Destroy((Object)(object)val); return null; } for (int i = 0; i < array.Length; i++) { Vector3 val2 = array2[i]; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude > 1E-05f) { array[i] += val2 * (width / magnitude); } } val.vertices = Il2CppStructArray<Vector3>.op_Implicit(array); val.RecalculateBounds(); return val; } private void EnsureGhostTemplate() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown if ((Object)(object)ghostMaterialTemplate != (Object)null) { return; } 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("Sprites/Default"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Standard"); } if (!((Object)(object)val == (Object)null)) { ghostMaterialTemplate = new Material(val); ((Object)ghostMaterialTemplate).name = "SandevistanAfterimageMatTemplate"; blendControllable = ghostMaterialTemplate.HasProperty("_SrcBlend") && ghostMaterialTemplate.HasProperty("_DstBlend"); if (debugPref.Value) { MelonLogger.Msg("Ghost shader: " + ((Object)val).name + " blend=" + blendControllable + " _Cull=" + ghostMaterialTemplate.HasProperty("_Cull")); } } } private Material[] BuildBodyMaterials(GhostSnapshot snapshot, SkinnedMeshRenderer source, int subCount) { Il2CppReferenceArray<Material> srcMats = null; try { srcMats = ((Renderer)source).sharedMaterials; } catch { } return BuildBodyMaterials(snapshot, srcMats, subCount); } private Material[] BuildBodyMaterials(GhostSnapshot snapshot, Il2CppReferenceArray<Material> srcMats, int subCount) { Material[] array = (Material[])(object)new Material[subCount]; for (int i = 0; i < subCount; i++) { Material val = null; if (srcMats != null && ((Il2CppArrayBase<Material>)(object)srcMats).Length > 0) { val = ((Il2CppArrayBase<Material>)(object)srcMats)[Mathf.Min(i, ((Il2CppArrayBase<Material>)(object)srcMats).Length - 1)]; } int key = (((Object)(object)val != (Object)null) ? ((Object)val).GetInstanceID() : 0); if (!snapshot.bodyByKey.TryGetValue(key, out var value)) { BodyMat bodyMat = CloneOriginalMaterial(val); value = bodyMat.material; snapshot.bodyByKey[key] = value; snapshot.bodyMaterials.Add(bodyMat); } array[i] = value; } return array; } private BodyMat CloneOriginalMaterial(Material src) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) Material val = ((!((Object)(object)src != (Object)null)) ? new Material(ghostMaterialTemplate) : new Material(src)); ((Object)val).name = "SandevistanGhost"; bool flag = false; try { if (val.HasProperty("_Surface") && val.HasProperty("_SrcBlend") && val.HasProperty("_DstBlend")) { val.SetFloat("_Surface", 1f); if (val.HasProperty("_Blend")) { val.SetFloat("_Blend", 0f); } val.SetFloat("_SrcBlend", 5f); val.SetFloat("_DstBlend", 10f); val.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); val.SetOverrideTag("RenderType", "Transparent"); if (val.HasProperty("_ZWrite")) { val.SetFloat("_ZWrite", 0f); } val.renderQueue = 3000; flag = true; } } catch { } if (!flag) { Material val2 = BuildTransparentFallback(val); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val); val = val2; flag = true; } } float num = Mathf.Clamp(shadowLiftPref.Value, 0f, 0.6f); bool flag2 = false; try { flag2 = (val.HasProperty("_AlphaClip") && val.GetFloat("_AlphaClip") > 0.5f) || val.IsKeywordEnabled("_ALPHATEST_ON"); } catch { } BodyMat bodyMat = new BodyMat(val, flag); bodyMat.cutout = flag2; for (int i = 0; i < TextureProps.Length; i++) { try { if (!val.HasProperty(TextureProps[i])) { continue; } Texture texture = val.GetTexture(TextureProps[i]); if ((Object)(object)texture == (Object)null) { continue; } bodyMat.texProps.Add(TextureProps[i]); bodyMat.origTextures.Add(texture); if (num > 0.01f) { Texture liftedTexture = GetLiftedTexture(texture, num, flag2, 512); if ((Object)(object)liftedTexture != (Object)null) { val.SetTexture(TextureProps[i], liftedTexture); } } } catch { } } for (int j = 0; j < ColorProps.Length; j++) { try { if (val.HasProperty(ColorProps[j])) { bodyMat.colorProps.Add(ColorProps[j]); bodyMat.baseColors.Add(val.GetColor(ColorProps[j])); } } catch { } } try { if (val.HasProperty("_EmissionColor")) { bodyMat.hasEmission = true; bodyMat.baseEmission = val.GetColor("_EmissionColor"); val.EnableKeyword("_EMISSION"); } } catch { } if (debugPref.Value) { MelonLogger.Msg("Ghost clone of '" + (((Object)(object)src != (Object)null) ? ((Object)src).name : "null") + "' shader=" + (((Object)(object)val.shader != (Object)null) ? ((Object)val.shader).name : "?") + " tintProps=" + bodyMat.colorProps.Count + " emission=" + bodyMat.hasEmission + " fade=" + (flag ? "alpha" : "none")); } if (bodyMat.colorProps.Count == 0 && !bodyMat.hasEmission && !loggedNoTexture) { loggedNoTexture = true; MelonLogger.Warning("An avatar material has no color or emission property, so it can't be tinted. Send Latest.log."); } return bodyMat; } private Texture GetLiftedTexture(Texture source, float lift, bool keepAlpha, int maxSize) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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) int key = ((Object)source).GetInstanceID() * 8 + (keepAlpha ? 1 : 0) + ((maxSize < 256) ? 2 : 0); if (liftedTextureCache.TryGetValue(key, out var value)) { return value; } Texture val = null; RenderTexture val2 = null; RenderTexture active = RenderTexture.active; try { int num = Mathf.Clamp(source.width, 4, maxSize); int num2 = Mathf.Clamp(source.height, 4, maxSize); val2 = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0); Graphics.Blit(source, val2); RenderTexture.active = val2; Texture2D val3 = new Texture2D(num, num2, (TextureFormat)4, false); ((Object)val3).name = "SandevistanAfterimageTex"; val3.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0); Il2CppStructArray<Color32> pixels = val3.GetPixels32(); int num3 = Mathf.Clamp(Mathf.RoundToInt(lift * 255f), 0, 255); int num4 = 255 - num3; for (int i = 0; i < ((Il2CppArrayBase<Color32>)(object)pixels).Length; i++) { Color32 val4 = ((Il2CppArrayBase<Color32>)(object)pixels)[i]; val4.r = (byte)(num3 + val4.r * num4 / 255); val4.g = (byte)(num3 + val4.g * num4 / 255); val4.b = (byte)(num3 + val4.b * num4 / 255); if (!keepAlpha) { val4.a = byte.MaxValue; } ((Il2CppArrayBase<Color32>)(object)pixels)[i] = val4; } val3.SetPixels32(pixels); val3.Apply(false, true); ownedTextures.Add(val3); val = (Texture)(object)val3; } catch (Exception ex) { if (debugPref.Value) { MelonLogger.Warning("Shadow lift failed for texture " + ((Object)source).name + ": " + ex.Message); } } finally { RenderTexture.active = active; if ((Object)(object)val2 != (Object)null) { RenderTexture.ReleaseTemporary(val2); } } liftedTextureCache[key] = val; return val; } private Material BuildTransparentFallback(Material original) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00d4: Unknown result type (might be due to invalid IL or missing references) try { Material val = new Material(ghostMaterialTemplate); ((Object)val).name = "SandevistanGhostFlat"; Texture val2 = null; for (int i = 0; i < TextureProps.Length; i++) { if (original.HasProperty(TextureProps[i])) { Texture texture = original.GetTexture(TextureProps[i]); if ((Object)(object)texture != (Object)null) { val2 = texture; break; } } } if ((Object)(object)val2 != (Object)null) { if (val.HasProperty("_BaseMap")) { val.SetTexture("_BaseMap", val2); } if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", val2); } } Color white = Color.white; for (int j = 0; j < ColorProps.Length; j++) { if (original.HasProperty(ColorProps[j])) { Color color = original.GetColor(ColorProps[j]); ((Color)(ref white))..ctor(color.r, color.g, color.b, 1f); break; } } SetMaterialColor(val, white); if (val.HasProperty("_Surface")) { val.SetFloat("_Surface", 1f); val.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); val.SetOverrideTag("RenderType", "Transparent"); } if (val.HasProperty("_Blend")) { val.SetFloat("_Blend", 0f); } if (val.HasProperty("_SrcBlend")) { val.SetFloat("_SrcBlend", 5f); } if (val.HasProperty("_DstBlend")) { val.SetFloat("_DstBlend", 10f); } if (val.HasProperty("_ZWrite")) { val.SetFloat("_ZWrite", 0f); } float num = 2f; if (original.HasProperty("_Cull")) { num = original.GetFloat("_Cull"); } if (val.HasProperty("_Cull")) { val.SetFloat("_Cull", num); } val.renderQueue = 3000; if (((original.HasProperty("_AlphaClip") && original.GetFloat("_AlphaClip") > 0.5f) || original.IsKeywordEnabled("_ALPHATEST_ON")) && val.HasProperty("_Cutoff")) { float num2 = (original.HasProperty("_Cutoff") ? original.GetFloat("_Cutoff") : 0.5f); if (val.HasProperty("_AlphaClip")) { val.SetFloat("_AlphaClip", 1f); } val.SetFloat("_Cutoff", num2); val.EnableKeyword("_ALPHATEST_ON"); } return val; } catch (Exception ex) { if (debugPref.Value) { MelonLogger.Warning("Transparent fallback failed: " + ex.Message); } return null; } } private Material CreateGhostMaterial(bool shell) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) EnsureGhostTemplate(); if ((Object)(object)ghostMaterialTemplate == (Object)null) { return null; } Material val = new Material(ghostMaterialTemplate); bool flag = shell && additivePref.Value && blendControllable; if (val.HasProperty("_Surface")) { val.SetFloat("_Surface", 1f); val.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); val.SetOverrideTag("RenderType", "Transparent"); } if (val.HasProperty("_Blend")) { val.SetFloat("_Blend", flag ? 2f : 0f); } if (val.HasProperty("_SrcBlend")) { val.SetFloat("_SrcBlend", flag ? 1f : 5f); } if (val.HasProperty("_DstBlend")) { val.SetFloat("_DstBlend", flag ? 1f : 10f); } if (val.HasProperty("_ZWrite")) { val.SetFloat("_ZWrite", 0f); } if (val.HasProperty("_Cull")) { val.SetFloat("_Cull", shell ? 1f : 0f); } val.renderQueue = (shell ? 3001 : 3000); SetMaterialColor(val, Compose(shell ? RimNear : BodyNear, shell ? Mathf.Clamp01(alphaPref.Value) : 1f)); return val; } private Color Compose(Color rgb, float intensity) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0047: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (additivePref.Value && blendControllable) { return new Color(rgb.r * intensity, rgb.g * intensity, rgb.b * intensity, intensity); } return new Color(rgb.r, rgb.g, rgb.b, intensity); } private static void SetMaterialColor(Material material, Color color) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)material == (Object)null)) { if (material.HasProperty("_Color")) { material.SetColor("_Color", color); } if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", color); } } } private Color GetCyberpsychoColor(int ghostIndex) { //IL_005d: 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_0070: 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) int num = CyberpsychoColors.Length - 1; int num2 = num * 2; int num3 = ghostIndex / 24 % num2; int num4 = ghostIndex % 24; bool num5 = num3 < num; int num6 = (num5 ? num3 : (num2 - num3)); int num7 = (num5 ? (num6 + 1) : (num6 - 1)); if (num4 < 8) { return CyberpsychoColors[num6]; } float num8 = (float)(num4 - 8 + 1) / 16f; return Color.Lerp(CyberpsychoColors[num6], CyberpsychoColors[num7], num8); } private Color GetBlackwallColor(int ghostIndex) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) float num = 0.5f - 0.5f * Mathf.Cos((float)Mathf.Max(0, ghostIndex) * 0.055f); num = num * num * (3f - 2f * num); return Color.Lerp(Color.black, BlackwallRed, num); } private void ApplySnapshotColors(GhostSnapshot snapshot, float t) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_00d7: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0213: 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_0227: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: 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) float num = Mathf.Clamp01(t); float num2 = Mathf.Clamp01(alphaPref.Value) * (1f - num) * snapshot.flicker; float num3 = (1f - num) * snapshot.flicker; Color val3; Color rgb; if (snapshot.palette == PaletteMode.David) { float num4 = 0f; if ((Object)(object)avatarObject != (Object)null) { num4 = Mathf.Clamp01(Vector3.Distance(avatarObject.transform.position, snapshot.origin) / 8f); } Color val = Color.Lerp(BodyNear, BodyGreenCyanNear, num4); Color.Lerp(BodyFar, BodyGreenCyanFar, num4); Color val2 = Color.Lerp(RimNear, RimGreenCyanNear, num4); Color.Lerp(RimFar, RimGreenCyanFar, num4); val3 = val; rgb = val2; } else if (snapshot.palette == PaletteMode.Blackwall) { Color cyberpsychoColor = snapshot.cyberpsychoColor; val3 = cyberpsychoColor; rgb = Color.Lerp(Color.black, cyberpsychoColor, 0.88f); } else { Color cyberpsychoColor2 = snapshot.cyberpsychoColor; val3 = cyberpsychoColor2; rgb = Color.Lerp(Color.white, cyberpsychoColor2, 0.78f); } float num5 = Mathf.Clamp01(textureTintPref.Value); float num6 = Mathf.Clamp(glowPref.Value, 0f, 1.5f); Color val4 = Color.Lerp(Color.white, val3, num5); float num7 = 1f + num6 * 0.8f; for (int i = 0; i < snapshot.bodyMaterials.Count; i++) { BodyMat bodyMat = snapshot.bodyMaterials[i]; if ((Object)(object)bodyMat.material == (Object)null) { continue; } for (int j = 0; j < bodyMat.colorProps.Count; j++) { Color val5 = bodyMat.baseColors[j]; float num8 = val4.r * num7; float num9 = val4.g * num7; float num10 = val4.b * num7; float num11 = val5.a; if (bodyMat.alphaCapable) { num11 = val5.a * num3 * Mathf.Clamp(opacityPref.Value, 0.1f, 1f); } bodyMat.material.SetColor(bodyMat.colorProps[j], new Color(val5.r * num8, val5.g * num9, val5.b * num10, num11)); } if (bodyMat.hasEmission) { float num12 = num6 * 0.5f * (bodyMat.alphaCapable ? num3 : 1f); bodyMat.material.SetColor("_EmissionColor", new Color(bodyMat.baseEmission.r + val3.r * num12, bodyMat.baseEmission.g + val3.g * num12, bodyMat.baseEmission.b + val3.b * num12, 1f)); } } if ((Object)(object)snapshot.shellMaterial != (Object)null) { SetMaterialColor(snapshot.shellMaterial, Compose(rgb, Mathf.Clamp01(num2 * 1.7f))); } } private void UpdateSnapshots() { float realtimeSinceStartup = Time.realtimeSinceStartup; for (int num = snapshots.Count - 1; num >= 0; num--) { GhostSnapshot ghostSnapshot = snapshots[num]; if (ghostSnapshot == null) { snapshots.RemoveAt(num); } else { float num2 = Mathf.Clamp01((realtimeSinceStartup - ghostSnapshot.created) / ghostSnapshot.lifetime); ApplySnapshotColors(ghostSnapshot, num2); if (num2 >= 1f) { DestroySnapshot(ghostSnapshot); snapshots.RemoveAt(num); } } } } private void TrimSnapshots() { int num = Mathf.Clamp(ghostCountPref.Value, 1, 2048); while (snapshots.Count > num) { DestroySnapshot(snapshots[0]); snapshots.RemoveAt(0); } } private void DestroySnapshot(GhostSnapshot snapshot) { for (int i = 0; i < snapshot.parts.Count; i++) { GhostPart ghostPart = snapshot.parts[i]; if (ghostPart != null) { if ((Object)(object)ghostPart.mesh != (Object)null) { Object.Destroy((Object)(object)ghostPart.mesh); } if ((Object)(object)ghostPart.shellMesh != (Object)null) { Object.Destroy((Object)(object)ghostPart.shellMesh); } if ((Object)(object)ghostPart.bodyObject != (Object)null) { Object.Destroy((Object)(object)ghostPart.bodyObject); } if ((Object)(object)ghostPart.shellObject != (Object)null) { Object.Destroy((Object)(object)ghostPart.shellObject); } if ((Object)(object)ghostPart.overlayObject != (Object)null) { Object.Destroy((Object)(object)ghostPart.overlayObject); } if ((Object)(object)ghostPart.overlayMesh != (Object)null) { Object.Destroy((Object)(object)ghostPart.overlayMesh); } } } snapshot.parts.Clear(); for (int j = 0; j < snapshot.bodyMaterials.Count; j++) { if ((Object)(object)snapshot.bodyMaterials[j].material != (Object)null) { Object.Destroy((Object)(object)snapshot.bodyMaterials[j].material); } } snapshot.bodyMaterials.Clear(); snapshot.bodyByKey.Clear(); if ((Object)(object)snapshot.shellMaterial != (Object)null) { Object.Destroy((Object)(object)snapshot.shellMaterial); } } private void TrimLookCaches() { if (liftedTextureCache.Count > 48) { ClearLookCaches(); } } private void WarmGhostCaches() { if (avatarRenderers == null || shadowLiftPref.Value <= 0.01f) { return; } try { if (warmList == null) { EnsureGhostTemplate(); if ((Object)(object)ghostMaterialTemplate == (Object)null) { return; } warmList = new List<Material>(); warmIndex = 0; HashSet<int> hashSet = new HashSet<int>(); for (int i = 0; i < avatarRenderers.Length; i++) { if ((Object)(object)avatarRenderers[i] == (Object)null) { continue; } Il2CppReferenceArray<Material> sharedMaterials = ((Renderer)avatarRenderers[i]).sharedMaterials; for (int j = 0; j < ((Il2CppArrayBase<Material>)(object)sharedMaterials).Length; j++) { if ((Object)(object)((Il2CppArrayBase<Material>)(object)sharedMaterials)[j] != (Object)null && hashSet.Add(((Object)((Il2CppArrayBase<Material>)(object)sharedMaterials)[j]).GetInstanceID())) { warmList.Add(((Il2CppArrayBase<Material>)(object)sharedMaterials)[j]); } } } } if (warmIndex >= warmList.Count) { return; } Material val = warmList[warmIndex++]; if ((Object)(object)val != (Object)null) { BodyMat bodyMat = CloneOriginalMaterial(val); if (bodyMat != null && (Object)(object)bodyMat.material != (Object)null) { Object.Destroy((Object)(object)bodyMat.material); } } if (warmIndex >= warmList.Count) { MelonLogger.Msg("Ghost textures pre-built (" + warmList.Count + " materials) - no hitch when slow motion starts."); } } catch (Exception ex) { warmIndex = ((warmList != null) ? warmList.Count : 0); MelonLogger.Warning("Ghost texture pre-build failed: " + ex.Message); } } private void ClearLookCaches() { warmList = null; loggedNoTexture = false; liftedTextureCache.Clear(); for (int i = 0; i < ownedTextures.Count; i++) { if ((Object)(object)ownedTextures[i] != (Object)null) { Object.Destroy((Object)(object)ownedTextures[i]); } } ownedTextures.Clear(); } private void ClearSnapshots() { for (int i = 0; i < snapshots.Count; i++) { DestroySnapshot(snapshots[i]); } snapshots.Clear(); wasSlow = false; } private void RefreshTintCameras() { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Expected O, but got Unknown //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) for (int num = tintOverlays.Count - 1; num >= 0; num--) { if ((Object)(object)tintOverlays[num].camera == (Object)null || (Object)(object)tintOverlays[num].quad == (Object)null) { if ((Object)(object)tintOverlays[num].quad != (Object)null) { Object.Destroy((Object)(object)tintOverlays[num].quad); } tintOverlays.RemoveAt(num); } } Camera[] array = Il2CppArrayBase<Camera>.op_Implicit((Il2CppArrayBase<Camera>)(object)Camera.allCameras); foreach (Camera val in array) { if ((Object)(object)val == (Object)null || !((Behaviour)val).enabled || !((Component)val).gameObject.activeInHierarchy || (val.orthographic && val.depth < 0f)) { continue; } bool flag = false; for (int j = 0; j < tintOverlays.Count; j++) { if ((Object)(object)tintOverlays[j].camera == (Object)(object)val) { flag = true; break; } } if (flag) { continue; } GameObject val2 = new GameObject("SandevistanTintOverlay"); val2.transform.SetParent(((Component)val).transform, false); float num2 = Mathf.Max(0.01f, val.nearClipPlane + 0.02f); val2.transform.localPosition = new Vector3(0f, 0f, num2); val2.transform.localRotation = Quaternion.identity; float num3 = val.fieldOfView * 0.5f * ((float)Math.PI / 180f); float num4 = 2f * num2 * Mathf.Tan(num3); float num5 = num4 * val.aspect; val2.transform.localScale = new Vector3(num5 * 1.25f, num4 * 1.25f, 1f); val2.AddComponent<MeshFilter>().sharedMesh = BuildUnitQuad(); MeshRenderer obj = val2.AddComponent<MeshRenderer>(); Material material = (((Renderer)obj).sharedMaterial = CreateTintMaterial()); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; ((Renderer)obj).sortingOrder = 32767; val2.SetActive(false); GameObject val4 = new GameObject("SandevistanEdgeBlur"); val4.transform.SetParent(((Component)val).transform, false); val4.transform.localPosition = new Vector3(0f, 0f, num2); val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = new Vector3(num5 * 1.02f, num4 * 1.02f, 1f); val4.AddComponent<MeshFilter>().sharedMesh = BuildUnitQuad(); MeshRenderer obj2 = val4.AddComponent<MeshRenderer>(); Material val5 = CreateTintMaterial(); Texture2D val6 = GetVignetteTexture(); if ((Object)(object)val6 != (Object)null) { if (val5.HasProperty("_BaseMap")) { val5.SetTexture("_BaseMap", (Texture)(object)val6); } if (val5.HasProperty("_MainTex")) { val5.SetTexture("_MainTex", (Texture)(object)val6); } } val5.renderQueue = 5000; ((Renderer)obj2).sharedMaterial = val5; ((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj2).receiveShadows = false; ((Renderer)obj2).sortingOrder = 32767; val4.SetActive(false); GameObject val7 = new GameObject("SandevistanSpineFlash"); val7.transform.SetParent(((Component)val).transform, false); val7.transform.localPosition = new Vector3(0f, 0f, num2); val7.transform.localRotation = Quaternion.identity; val7.transform.localScale = new Vector3(num5 * 1.02f, num4 * 1.02f, 1f); val7.AddComponent<MeshFilter>().sharedMesh = BuildUnitQuad(); MeshRenderer obj3 = val7.AddComponent<MeshRenderer>(); Material val8 = CreateTintMaterial(); val8.renderQueue = 5000; ((Renderer)obj3).sharedMaterial = val8; ((Renderer)obj3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj3).receiveShadows = false; ((Renderer)obj3).sortingOrder = 32767; val7.SetActive(false); tintOverlays.Add(new TintOverlay { camera = val, quad = val2, material = material, edgeQuad = val4, edgeMaterial = val5, spineQuad = val7, spineMaterial = val8 }); if (debugPref.Value) { MelonLogger.Msg("Tint overlay attached to camera: " + ((Object)val).name); } } } private static Mesh BuildUnitQuad() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_009e: 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) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)unitQuadMesh != (Object)null) { return unitQuadMesh; } unitQuadMesh = new Mesh(); ((Object)unitQuadMesh).name = "SandevistanTintQuad"; unitQuadMesh.vertices = Il2CppStructArray<Vector3>.op_Implicit((Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, -0.5f, 0f), new Vector3(0.5f, -0.5f, 0f), new Vector3(-0.5f, 0.5f, 0f), new Vector3(0.5f, 0.5f, 0f) }); unitQuadMesh.uv = Il2CppStructArray<Vector2>.op_Implicit((Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f) }); unitQuadMesh.triangles = Il2CppStructArray<int>.op_Implicit(new int[6] { 0, 2, 1, 2, 3, 1 }); unitQuadMesh.RecalculateNormals(); unitQuadMesh.RecalculateBounds(); return unitQuadMesh; } private Material CreateTintMaterial() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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 //IL_016c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tintMaterialTemplate == (Object)null) { 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("Sprites/Default"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("UI/Default"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Standard"); } tintMaterialTemplate = new Material(val); ((Object)tintMaterialTemplate).name = "SandevistanTintMatTemplate"; } Material val2 = new Material(tintMaterialTemplate); if (val2.HasProperty("_Surface")) { val2.SetFloat("_Surface", 1f); val2.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); val2.SetOverrideTag("RenderType", "Transparent"); } if (val2.HasProperty("_SrcBlend")) { val2.SetFloat("_SrcBlend", 5f); } if (val2.HasProperty("_DstBlend")) { val2.SetFloat("_DstBlend", 10f); } if (val2.HasProperty("_ZWrite")) { val2.SetFloat("_ZWrite", 0f); } if (val2.HasProperty("_Cull")) { val2.SetFloat("_Cull", 0f); } val2.renderQueue = 5000; SetMaterialColor(val2, new Color(TintColor.r, TintColor.g, TintColor.b, 0f)); return val2; } private void SetTintActive(bool active) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: 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) float num = Mathf.Clamp01(worldTintStrengthPref.Value); bool flag = active && num > 0.01f; if (flag && !fogSaved) { savedFog = RenderSettings.fog; savedFogColor = RenderSettings.fogColor; savedFogDensity = RenderSettings.fogDensity; savedFogMode = RenderSettings.fogMode; savedAmbient = RenderSettings.ambientLight; savedAmbientIntensity = RenderSettings.ambientIntensity; fogSaved = true; } float num2 = Time.unscaledDeltaTime / Mathf.Max(0.01f, 0.12f); tintFade = Mathf.MoveTowards(tintFade, flag ? 1f : 0f, num2); if (tintFade > 0.001f && fogSaved) { float num3 = num * tintFade; Color color = default(Color); ((Color)(ref color))..ctor(TintColor.r, TintColor.g, TintColor.b, num3 * 0.55f); for (int i = 0; i < tintOverlays.Count; i++) { TintOverlay tintOverlay = tintOverlays[i]; if (!((Object)(object)tintOverlay.quad == (Object)null) && !spinePlaying) { tintOverlay.quad.SetActive(true); if ((Object)(object)tintOverlay.camera != (Object)null) { float num4 = Mathf.Max(0.01f, tintOverlay.camera.nearClipPlane + 0.02f); tintOverlay.quad.transform.localPosition = new Vector3(0f, 0f, num4); float num5 = tintOverlay.camera.fieldOfView * 0.5f * ((float)Math.PI / 180f); float num6 = 2f * num4 * Mathf.Tan(num5); float num7 = num6 * tintOverlay.camera.aspect; tintOverlay.quad.transform.localScale = new Vector3(num7 * 1.25f, num6 * 1.25f, 1f); } if ((Object)(object)tintOverlay.material != (Object)null) { SetMaterialColor(tintOverlay.material, color); } } } if (!tintActive && debugPref.Value) { MelonLogger.Msg("World tint ON (smooth fade) strength=" + num.ToString("0.00") + " overlays=" + tintOverlays.Count); } tintActive = true; } else { if (flag || !(tintFade <= 0.001f)) { return; } for (int j = 0; j < tintOverlays.Count; j++) { if ((Object)(object)tintOverlays[j].quad != (Object)null && !spinePlaying) { tintOverlays[j].quad.SetActive(false); } } if (fogSaved) { RenderSettings.fog = savedFog; RenderSettings.fogColor = savedFogColor; RenderSettings.fogDensity = savedFogDensity; RenderSettings.fogMode = savedFogMode; RenderSettings.ambientLight = savedAmbient; RenderSettings.ambientIntensity = savedAmbientIntensity; fogSaved = false; } if (tintActive && debugPref.Value) { MelonLogger.Msg("World tint OFF"); } tintActive = false; } } private Texture2D GetVignetteTexture() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to