using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using Microsoft.CodeAnalysis;
using TrailGB;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(TrailGBMod), "TrailGB", "1.0.0", "Zooks", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TrailGB")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TrailGB")]
[assembly: AssemblyTitle("TrailGB")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace TrailGB
{
public class TrailGBMod : MelonMod
{
private class BeastTrail
{
public string rootName;
public SkinnedMeshRenderer smr;
public GameObject anchor;
public LineRenderer line;
public LineRenderer lineOuter;
public LineRenderer lineGlow;
public Renderer headGlowRend;
public GameObject headGlow;
public List<Vector3> positions = new List<Vector3>(128);
public int colorIndex;
public bool onCamera;
public float speed;
public Vector3 lastPos;
public float baseWidth = 0.5f;
}
private class Spark
{
public GameObject go;
public Renderer rend;
public Material mat;
public float spawnTime;
public Vector3 dir;
public bool active;
}
private readonly Dictionary<string, BeastTrail> _beasts = new Dictionary<string, BeastTrail>();
private readonly List<string> _cameraTracked = new List<string>();
private float _nextScan;
private float _nextCamCheck;
private float _colorTimer;
private float _effectTimer;
private string _lastScene = "";
private Camera? _mainCam;
private Plane[] _camPlanes = (Plane[])(object)new Plane[6];
private SkinnedMeshRenderer[]? _smrCache;
private float _smrCacheTime;
private readonly List<Spark> _sparks = new List<Spark>();
private float _nextSpark;
private static readonly Color[] Palette = (Color[])(object)new Color[8]
{
new Color(1f, 0.2f, 0.2f),
new Color(0.2f, 0.55f, 1f),
new Color(0.15f, 1f, 0.35f),
new Color(1f, 0.9f, 0.1f),
new Color(1f, 0.35f, 0.8f),
new Color(1f, 0.55f, 0.1f),
new Color(0.2f, 1f, 0.9f),
new Color(0.7f, 0.3f, 1f)
};
public override void OnInitializeMelon()
{
MelonLogger.Msg("TrailGB v1.0.0 loaded");
}
public override void OnUpdate()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
float time = Time.time;
float deltaTime = Time.deltaTime;
try
{
Scene activeScene = SceneManager.GetActiveScene();
string name = ((Scene)(ref activeScene)).name;
if (name != _lastScene)
{
_lastScene = name;
FullCleanup();
_nextScan = time + 2f;
return;
}
}
catch
{
}
if (time >= _nextScan)
{
_nextScan = time + 2f;
ScanForBeasts();
}
if (time >= _nextCamCheck)
{
_nextCamCheck = time + 0.3f;
UpdateCameraVisibility();
}
_colorTimer += deltaTime;
if (_colorTimer >= 2.5f)
{
_colorTimer = 0f;
CycleColors();
}
_effectTimer += deltaTime;
UpdateLines(deltaTime, time);
UpdateSparks(time, deltaTime);
}
private void FullCleanup()
{
foreach (BeastTrail value in _beasts.Values)
{
try
{
if ((Object)(object)value.anchor != (Object)null)
{
Object.Destroy((Object)(object)value.anchor);
}
}
catch
{
}
try
{
if ((Object)(object)value.headGlow != (Object)null)
{
Object.Destroy((Object)(object)value.headGlow);
}
}
catch
{
}
}
_beasts.Clear();
_cameraTracked.Clear();
_mainCam = null;
_smrCache = null;
for (int i = 0; i < _sparks.Count; i++)
{
try
{
if ((Object)(object)_sparks[i].go != (Object)null)
{
Object.Destroy((Object)(object)_sparks[i].go);
}
}
catch
{
}
}
_sparks.Clear();
}
private SkinnedMeshRenderer[] GetSMRs()
{
if (_smrCache != null && Time.time - _smrCacheTime < 2f)
{
return _smrCache;
}
try
{
_smrCache = Il2CppArrayBase<SkinnedMeshRenderer>.op_Implicit(Object.FindObjectsOfType<SkinnedMeshRenderer>());
_smrCacheTime = Time.time;
}
catch
{
_smrCache = Array.Empty<SkinnedMeshRenderer>();
}
return _smrCache;
}
private void ScanForBeasts()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
try
{
Scene activeScene = SceneManager.GetActiveScene();
string name = ((Scene)(ref activeScene)).name;
if (name == "_bootScene" || name.Contains("Menu") || name.Contains("Lobby") || name.Contains("Boot"))
{
return;
}
SkinnedMeshRenderer[] sMRs = GetSMRs();
if (sMRs == null || sMRs.Length == 0)
{
return;
}
Dictionary<string, List<SkinnedMeshRenderer>> dictionary = new Dictionary<string, List<SkinnedMeshRenderer>>();
foreach (SkinnedMeshRenderer val in sMRs)
{
if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null)
{
continue;
}
Transform root = ((Component)val).transform.root;
if ((Object)(object)root == (Object)null)
{
continue;
}
string name2 = ((Object)root).name;
if (name2.Contains("Actor") && name2.Contains("GangID"))
{
if (!dictionary.TryGetValue(name2, out var value))
{
value = (dictionary[name2] = new List<SkinnedMeshRenderer>());
}
value.Add(val);
}
}
int num = 0;
foreach (KeyValuePair<string, List<SkinnedMeshRenderer>> item in dictionary)
{
if (_beasts.ContainsKey(item.Key))
{
continue;
}
SkinnedMeshRenderer val2 = null;
float num2 = 0f;
Bounds bounds;
for (int j = 0; j < item.Value.Count; j++)
{
try
{
bounds = ((Renderer)item.Value[j]).bounds;
Vector3 size = ((Bounds)(ref bounds)).size;
float magnitude = ((Vector3)(ref size)).magnitude;
if (magnitude > num2)
{
num2 = magnitude;
val2 = item.Value[j];
}
}
catch
{
}
}
if (!((Object)(object)val2 == (Object)null))
{
BeastTrail obj2 = new BeastTrail
{
rootName = item.Key,
smr = val2,
colorIndex = num % Palette.Length
};
bounds = ((Renderer)val2).bounds;
obj2.lastPos = ((Bounds)(ref bounds)).center;
BeastTrail beastTrail = obj2;
num++;
if (SetupLine(val2, beastTrail, Palette[beastTrail.colorIndex]))
{
_beasts[item.Key] = beastTrail;
}
}
}
List<string> list2 = new List<string>();
foreach (KeyValuePair<string, BeastTrail> beast in _beasts)
{
if ((Object)(object)beast.Value.smr == (Object)null)
{
list2.Add(beast.Key);
}
}
for (int k = 0; k < list2.Count; k++)
{
string text = list2[k];
try
{
if ((Object)(object)_beasts[text].anchor != (Object)null)
{
Object.Destroy((Object)(object)_beasts[text].anchor);
}
}
catch
{
}
try
{
if ((Object)(object)_beasts[text].headGlow != (Object)null)
{
Object.Destroy((Object)(object)_beasts[text].headGlow);
}
}
catch
{
}
_beasts.Remove(text);
_cameraTracked.Remove(text);
}
}
catch
{
}
}
private void UpdateCameraVisibility()
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)_mainCam == (Object)null || !((Behaviour)_mainCam).isActiveAndEnabled)
{
_mainCam = Camera.main;
if ((Object)(object)_mainCam == (Object)null)
{
return;
}
}
GeometryUtility.CalculateFrustumPlanes(_mainCam, Il2CppStructArray<Plane>.op_Implicit(_camPlanes));
_cameraTracked.Clear();
foreach (KeyValuePair<string, BeastTrail> beast in _beasts)
{
BeastTrail value = beast.Value;
if ((Object)(object)value.smr == (Object)null || (Object)(object)value.line == (Object)null)
{
continue;
}
try
{
bool flag = (value.onCamera = GeometryUtility.TestPlanesAABB(Il2CppStructArray<Plane>.op_Implicit(_camPlanes), ((Renderer)value.smr).bounds));
((Renderer)value.line).enabled = flag;
if ((Object)(object)value.lineOuter != (Object)null)
{
((Renderer)value.lineOuter).enabled = flag;
}
if ((Object)(object)value.lineGlow != (Object)null)
{
((Renderer)value.lineGlow).enabled = flag;
}
if ((Object)(object)value.headGlow != (Object)null)
{
value.headGlow.SetActive(flag);
}
if (flag)
{
_cameraTracked.Add(beast.Key);
}
}
catch
{
}
}
}
catch
{
}
}
private bool SetupLine(SkinnedMeshRenderer smr, BeastTrail bt, Color c)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: 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_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: 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_0148: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject val = new GameObject("TrailGB_Line");
val.transform.SetParent(((Component)smr).transform, false);
val.transform.localPosition = Vector3.zero;
LineRenderer val2 = val.AddComponent<LineRenderer>();
if ((Object)(object)val2 == (Object)null)
{
Object.Destroy((Object)(object)val);
return false;
}
ConfigureLine(val2, 0.5f, 0.1f);
Material val3 = CreateMaterial(smr, c);
if ((Object)(object)val3 == (Object)null)
{
Object.Destroy((Object)(object)val);
return false;
}
((Renderer)val2).material = val3;
ApplyGradient(val2, c);
LineRenderer val4 = val.AddComponent<LineRenderer>();
if ((Object)(object)val4 != (Object)null)
{
ConfigureLine(val4, 0.8f, 0.2f);
Material val5 = CreateMaterial(smr, c);
if ((Object)(object)val5 != (Object)null)
{
Color c2 = c;
c2.a = 0.25f;
ApplyColorToMaterial(val5, c2);
val5.renderQueue = 3550;
((Renderer)val4).material = val5;
ApplyGradientAlpha(val4, 0.3f);
}
}
LineRenderer val6 = val.AddComponent<LineRenderer>();
if ((Object)(object)val6 != (Object)null)
{
ConfigureLine(val6, 0.2f, 0.02f);
Material val7 = CreateMaterial(smr, c);
if ((Object)(object)val7 != (Object)null)
{
ApplyColorToMaterial(val7, new Color(1f, 1f, 1f, 0.9f));
val7.renderQueue = 3600;
((Renderer)val6).material = val7;
ApplyGradientAlpha(val6, 0.9f);
}
}
GameObject val8 = GameObject.CreatePrimitive((PrimitiveType)0);
Renderer val9 = null;
if ((Object)(object)val8 != (Object)null)
{
((Object)val8).name = "TrailGB_Head";
val8.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f);
try
{
Collider component = val8.GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
component.enabled = false;
}
}
catch
{
}
Material val10 = CreateMaterial(smr, c);
if ((Object)(object)val10 != (Object)null)
{
ApplyColorToMaterial(val10, c);
val10.renderQueue = 3600;
val9 = val8.GetComponent<Renderer>();
if ((Object)(object)val9 != (Object)null)
{
val9.material = val10;
}
}
}
Bounds bounds = ((Renderer)smr).bounds;
Vector3 center = ((Bounds)(ref bounds)).center;
val2.positionCount = 1;
val2.SetPosition(0, center);
if ((Object)(object)val4 != (Object)null)
{
val4.positionCount = 1;
val4.SetPosition(0, center);
}
if ((Object)(object)val6 != (Object)null)
{
val6.positionCount = 1;
val6.SetPosition(0, center);
}
bt.positions.Add(center);
bt.anchor = val;
bt.line = val2;
bt.lineOuter = val4;
bt.lineGlow = val6;
bt.headGlow = val8;
bt.headGlowRend = val9;
return true;
}
catch
{
return false;
}
}
private void ConfigureLine(LineRenderer lr, float startW, float endW)
{
lr.useWorldSpace = true;
lr.startWidth = startW;
lr.endWidth = endW;
lr.numCornerVertices = 4;
lr.numCapVertices = 2;
lr.alignment = (LineAlignment)0;
((Renderer)lr).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)lr).receiveShadows = false;
((Renderer)lr).lightProbeUsage = (LightProbeUsage)0;
((Renderer)lr).reflectionProbeUsage = (ReflectionProbeUsage)0;
lr.generateLightingData = false;
}
private Material? CreateMaterial(SkinnedMeshRenderer smr, Color c)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
Material val = null;
try
{
if ((Object)(object)((Renderer)smr).sharedMaterial != (Object)null)
{
val = new Material(((Renderer)smr).sharedMaterial);
}
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
string[] array = new string[5] { "GangBeasts/Surface/VinylOrMetal", "Universal Render Pipeline/Lit", "Universal Render Pipeline/Particles/Unlit", "Standard", "Unlit/Color" };
for (int i = 0; i < array.Length; i++)
{
try
{
Shader val2 = Shader.Find(array[i]);
if ((Object)(object)val2 != (Object)null)
{
val = new Material(val2);
break;
}
}
catch
{
}
}
}
if ((Object)(object)val == (Object)null)
{
return null;
}
ApplyColorToMaterial(val, c);
val.renderQueue = 3500;
return val;
}
private void ApplyColorToMaterial(Material mat, Color c)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_004c: 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_0076: Unknown result type (might be due to invalid IL or missing references)
try
{
mat.color = c;
if (mat.HasProperty("_Color"))
{
mat.SetColor("_Color", c);
}
if (mat.HasProperty("_BaseColor"))
{
mat.SetColor("_BaseColor", c);
}
if (mat.HasProperty("_Tint"))
{
mat.SetColor("_Tint", c);
}
if (mat.HasProperty("_EmissionColor"))
{
mat.EnableKeyword("_EMISSION");
mat.SetColor("_EmissionColor", c * 3f);
}
}
catch
{
}
}
private void ApplyGradient(LineRenderer lr, Color c)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_000f: 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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_0036: 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_0057: 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_006d: 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)
Gradient val = new Gradient();
val.SetKeys(Il2CppStructArray<GradientColorKey>.op_Implicit((GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(c, 0f),
new GradientColorKey(c * 0.6f, 1f)
}), Il2CppStructArray<GradientAlphaKey>.op_Implicit((GradientAlphaKey[])(object)new GradientAlphaKey[3]
{
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0.8f, 0.3f),
new GradientAlphaKey(0f, 1f)
}));
lr.colorGradient = val;
}
private void ApplyGradientAlpha(LineRenderer lr, float maxAlpha)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_000f: 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_001e: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
Gradient val = new Gradient();
val.SetKeys(Il2CppStructArray<GradientColorKey>.op_Implicit((GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(Color.white, 0f),
new GradientColorKey(Color.white, 1f)
}), Il2CppStructArray<GradientAlphaKey>.op_Implicit((GradientAlphaKey[])(object)new GradientAlphaKey[3]
{
new GradientAlphaKey(maxAlpha, 0f),
new GradientAlphaKey(maxAlpha * 0.5f, 0.5f),
new GradientAlphaKey(0f, 1f)
}));
lr.colorGradient = val;
}
private void CycleColors()
{
//IL_0069: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: 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_00b0: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
foreach (KeyValuePair<string, BeastTrail> beast in _beasts)
{
BeastTrail value = beast.Value;
if ((Object)(object)value.line == (Object)null || (Object)(object)((Renderer)value.line).material == (Object)null)
{
continue;
}
value.colorIndex = (value.colorIndex + 1) % Palette.Length;
Color val = Palette[value.colorIndex];
try
{
ApplyColorToMaterial(((Renderer)value.line).material, val);
ApplyGradient(value.line, val);
if ((Object)(object)value.lineOuter != (Object)null && (Object)(object)((Renderer)value.lineOuter).material != (Object)null)
{
Color c = val;
c.a = 0.25f;
ApplyColorToMaterial(((Renderer)value.lineOuter).material, c);
}
if ((Object)(object)value.headGlowRend != (Object)null && (Object)(object)value.headGlowRend.material != (Object)null)
{
ApplyColorToMaterial(value.headGlowRend.material, val);
}
}
catch
{
}
}
}
private void UpdateLines(float dt, float t)
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
try
{
float num = Mathf.Sin(_effectTimer * 4f) * 0.15f + 1f;
foreach (KeyValuePair<string, BeastTrail> beast in _beasts)
{
BeastTrail value = beast.Value;
if ((Object)(object)value.smr == (Object)null || (Object)(object)value.line == (Object)null)
{
continue;
}
try
{
Bounds bounds = ((Renderer)value.smr).bounds;
Vector3 center = ((Bounds)(ref bounds)).center;
float num2 = Vector3.Distance(value.lastPos, center);
value.speed = Mathf.Lerp(value.speed, (dt > 0.0001f) ? (num2 / dt) : 0f, 0.3f);
value.lastPos = center;
if (value.positions.Count == 0 || Vector3.Distance(value.positions[value.positions.Count - 1], center) > 0.06f)
{
value.positions.Add(center);
}
while (value.positions.Count > 100)
{
value.positions.RemoveAt(0);
}
int count = value.positions.Count;
float num3 = Mathf.Clamp01(value.speed * 2f) + 0.5f;
float num4 = value.baseWidth * num3 * num;
value.line.positionCount = count;
value.line.startWidth = num4;
value.line.endWidth = num4 * 0.1f;
for (int i = 0; i < count; i++)
{
value.line.SetPosition(i, value.positions[i]);
}
if ((Object)(object)value.lineOuter != (Object)null)
{
value.lineOuter.positionCount = count;
value.lineOuter.startWidth = num4 * 1.6f;
value.lineOuter.endWidth = num4 * 0.3f;
for (int j = 0; j < count; j++)
{
value.lineOuter.SetPosition(j, value.positions[j]);
}
}
if ((Object)(object)value.lineGlow != (Object)null)
{
value.lineGlow.positionCount = count;
value.lineGlow.startWidth = num4 * 0.4f;
value.lineGlow.endWidth = num4 * 0.05f;
for (int k = 0; k < count; k++)
{
value.lineGlow.SetPosition(k, value.positions[k]);
}
}
if ((Object)(object)value.headGlow != (Object)null)
{
value.headGlow.transform.position = center + new Vector3(0f, 0.9f, 0f);
float num5 = Mathf.Sin(_effectTimer * 6f) * 0.05f + 0.25f;
value.headGlow.transform.localScale = new Vector3(num5, num5, num5);
}
}
catch
{
}
}
}
catch
{
}
}
private void UpdateSparks(float t, float dt)
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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)
if (t >= _nextSpark)
{
_nextSpark = t + 0.1f;
SpawnSparks(t);
}
for (int num = _sparks.Count - 1; num >= 0; num--)
{
Spark spark = _sparks[num];
if ((Object)(object)spark.go == (Object)null)
{
_sparks.RemoveAt(num);
}
else if (spark.active)
{
float num2 = t - spark.spawnTime;
if (num2 > 0.8f)
{
spark.go.SetActive(false);
spark.active = false;
}
else
{
float num3 = 0.08f * (1f - num2 / 0.8f);
spark.go.transform.localScale = new Vector3(num3, num3, num3);
Transform transform = spark.go.transform;
transform.position += spark.dir * dt * 1.5f;
}
}
}
}
private void SpawnSparks(float t)
{
//IL_0067: 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_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: 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_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
if (_cameraTracked.Count == 0)
{
return;
}
for (int i = 0; i < _cameraTracked.Count; i++)
{
if (!_beasts.TryGetValue(_cameraTracked[i], out BeastTrail value) || (Object)(object)value.smr == (Object)null || value.speed < 0.02f)
{
continue;
}
Spark pooledSpark = GetPooledSpark();
if (pooledSpark != null)
{
Bounds bounds = ((Renderer)value.smr).bounds;
Vector3 position = ((Bounds)(ref bounds)).center + new Vector3(Random.Range(-0.3f, 0.3f), Random.Range(0.5f, 1.2f), Random.Range(-0.3f, 0.3f));
pooledSpark.go.transform.position = position;
pooledSpark.dir = Random.onUnitSphere;
pooledSpark.go.SetActive(true);
pooledSpark.active = true;
pooledSpark.spawnTime = t;
Color val = Palette[value.colorIndex];
pooledSpark.mat.color = val;
if (pooledSpark.mat.HasProperty("_EmissionColor"))
{
pooledSpark.mat.EnableKeyword("_EMISSION");
pooledSpark.mat.SetColor("_EmissionColor", val * 5f);
}
}
}
}
private Spark? GetPooledSpark()
{
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
for (int i = 0; i < _sparks.Count; i++)
{
if (!_sparks[i].active && (Object)(object)_sparks[i].go != (Object)null)
{
return _sparks[i];
}
}
if (_sparks.Count > 150)
{
return null;
}
GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
if ((Object)(object)val == (Object)null)
{
return null;
}
((Object)val).name = "TrailGB_Spark";
try
{
Il2CppArrayBase<Component> components = val.GetComponents<Component>();
for (int j = 0; j < components.Length; j++)
{
Component obj = components[j];
Collider val2 = (Collider)(object)((obj is Collider) ? obj : null);
if (val2 != null)
{
val2.enabled = false;
break;
}
}
}
catch
{
}
Material val3 = null;
try
{
Shader val4 = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard");
if ((Object)(object)val4 != (Object)null)
{
val3 = new Material(val4);
}
}
catch
{
}
if ((Object)(object)val3 == (Object)null)
{
Object.Destroy((Object)(object)val);
return null;
}
Renderer val5 = null;
try
{
val5 = val.GetComponent<Renderer>();
}
catch
{
}
if ((Object)(object)val5 != (Object)null)
{
val5.material = val3;
}
val.SetActive(false);
Spark spark = new Spark
{
go = val,
rend = val5,
mat = val3,
active = false
};
_sparks.Add(spark);
return spark;
}
}
}