using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BoneLib;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Pool;
using MelonLoader;
using MelonLoader.Utils;
using MortierManif;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: MelonInfo(typeof(Main), "MortierManif", "1.0.0", "MortierManif", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MortierManif;
[HarmonyPatch(typeof(Grip), "OnHandHoverBegin", new global::System.Type[]
{
typeof(Hand),
typeof(bool)
})]
internal static class GripHoverPatch
{
private static void Prefix(Grip __instance, Hand hand)
{
try
{
Main.OnGripHover(__instance, hand);
}
catch (global::System.Exception ex)
{
MelonLogger.Error("[Grip] " + (object)ex);
}
}
}
public class Main : MelonMod
{
private sealed class Cfg<T>
{
public readonly T Value;
public Cfg(T v)
{
Value = v;
}
}
private enum MPhase
{
Idle,
Fuse,
Firing,
Spent
}
private class Mortar
{
public Transform Root;
public Rigidbody Body;
public Transform Muzzle;
public Transform TubeBase;
public Transform FuseTip;
public Transform FxFuse;
public Transform FxLaunch;
public Transform FxBurst;
public MPhase Phase;
public float Timer;
public int ShotsLeft;
public Light FuseLight;
public AudioSource FuseAudio;
}
private class Shell
{
public GameObject Go;
public Transform Mortar;
public Vector3 Pos;
public Vector3 Vel;
public float Age;
public float BurstAt;
public int ColorA;
public int ColorB;
public Light Glow;
public Vector3 Spin;
public float PuffTimer;
}
private class Spark
{
public GameObject Go;
public Vector3 Vel;
public float Life;
public float Max;
public float Size;
public float Drag;
public float Gravity;
public bool Flicker;
public float Grow;
}
private class Pop
{
public float T;
public Vector3 Pos;
public int Color;
public bool Sound;
}
private class Puff
{
public GameObject Go;
public Renderer[] R;
public Vector3 Vel;
public float Age;
public float Life;
public float Size0;
public float Size1;
public bool Fire;
public Color Smoke;
}
private class Ember
{
public float T;
public Vector3 Center;
public float Radius;
}
private class Flash
{
public Light L;
public float T;
public float Dur;
public float Intensity;
}
private static class Sfx
{
private static readonly Dictionary<string, AudioClip> Clips = new Dictionary<string, AudioClip>();
public static void Load(string dir)
{
string[] array = new string[4] { "meche", "depart", "explosion", "crepitement" };
foreach (string text in array)
{
string text2 = Path.Combine(dir, text + ".wav");
try
{
if (!File.Exists(text2))
{
MelonLogger.Warning("[Son] introuvable : " + text2);
continue;
}
AudioClip val = LoadWav(text2, text);
if ((Object)(object)val != (Object)null)
{
Clips[text] = val;
}
}
catch (global::System.Exception ex)
{
MelonLogger.Warning("[Son] " + text + " : " + ex.Message);
}
}
MelonLogger.Msg($"[Son] {Clips.Count}/4 sons chargés");
}
private static AudioClip LoadWav(string path, string name)
{
byte[] array = File.ReadAllBytes(path);
int num = 1;
int num2 = 44100;
int num3 = 16;
int num4 = -1;
int num5 = 0;
int num6;
for (int i = 12; i + 8 <= array.Length; i += 8 + num6 + (num6 & 1))
{
string text = Encoding.ASCII.GetString(array, i, 4);
num6 = BitConverter.ToInt32(array, i + 4);
if (text == "fmt ")
{
num = BitConverter.ToInt16(array, i + 10);
num2 = BitConverter.ToInt32(array, i + 12);
num3 = BitConverter.ToInt16(array, i + 22);
}
else if (text == "data")
{
num4 = i + 8;
num5 = Math.Min(num6, array.Length - num4);
break;
}
}
if (num4 < 0 || num3 != 16)
{
return null;
}
int num7 = num5 / 2;
float[] array2 = new float[num7];
for (int j = 0; j < num7; j++)
{
array2[j] = (float)BitConverter.ToInt16(array, num4 + j * 2) / 32768f;
}
AudioClip obj = AudioClip.Create("MortierManif_" + name, num7 / num, num, num2, false);
obj.SetData(new Il2CppStructArray<float>(array2), 0);
((Object)obj).hideFlags = (HideFlags)32;
return obj;
}
public static AudioSource Play(string name, Vector3 pos, float vol, float maxDist, bool loop = false, Transform parent = null, float pitch = 1f, float delay = 0f)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
AudioClip val = default(AudioClip);
if (!Clips.TryGetValue(name, ref val) || (Object)(object)val == (Object)null)
{
return null;
}
GameObject val2 = new GameObject("MortierManif_Son_" + name);
if ((Object)(object)parent != (Object)null)
{
val2.transform.SetParent(parent, false);
}
else
{
val2.transform.position = pos;
}
AudioSource val3 = val2.AddComponent<AudioSource>();
val3.clip = val;
val3.volume = vol * _volume.Value;
val3.pitch = pitch;
val3.loop = loop;
val3.spatialBlend = 1f;
val3.dopplerLevel = 0f;
val3.rolloffMode = (AudioRolloffMode)1;
val3.minDistance = 2f;
val3.maxDistance = maxDist;
if (delay > 0.01f)
{
val3.PlayDelayed(delay);
}
else
{
val3.Play();
}
if (!loop)
{
Object.Destroy((Object)(object)val2, val.length / Mathf.Max(0.1f, pitch) + delay + 0.5f);
}
return val3;
}
}
public const string Tag = "MortierManif";
private static readonly Cfg<bool> _enabled = new Cfg<bool>(v: true);
private static readonly Cfg<int> _shots = new Cfg<int>(8);
private static readonly Cfg<float> _fuseTime = new Cfg<float>(4f);
private static readonly Cfg<float> _shotInterval = new Cfg<float>(2f);
private static readonly Cfg<float> _launchSpeed = new Cfg<float>(20f);
private static readonly Cfg<bool> _impactMode = new Cfg<bool>(v: true);
private static readonly Cfg<float> _blastForce = new Cfg<float>(25f);
private static readonly Cfg<float> _blastRadius = new Cfg<float>(3.5f);
private static readonly Cfg<bool> _blastPlayer = new Cfg<bool>(v: false);
private static readonly Cfg<bool> _infinite = new Cfg<bool>(v: false);
private static readonly Cfg<float> _recoil = new Cfg<float>(1.2f);
private static readonly Cfg<float> _volume = new Cfg<float>(1f);
private readonly List<Pop> _pops = new List<Pop>();
private readonly List<Puff> _puffs = new List<Puff>();
private const int MaxPuffs = 450;
private MaterialPropertyBlock _mpb;
private Material _puffMat;
private readonly List<Ember> _embers = new List<Ember>();
private readonly Dictionary<int, Mortar> _mortars = new Dictionary<int, Mortar>();
private readonly List<Shell> _shells = new List<Shell>();
private readonly List<Spark> _sparks = new List<Spark>();
private readonly List<Flash> _flashes = new List<Flash>();
private const int MaxSparks = 2000;
private static readonly Color[] Palette = (Color[])(object)new Color[8]
{
new Color(1f, 0.15f, 0.1f),
new Color(0.2f, 1f, 0.25f),
new Color(0.25f, 0.45f, 1f),
new Color(1f, 0.85f, 0.2f),
new Color(0.85f, 0.3f, 1f),
new Color(1f, 1f, 1f),
new Color(1f, 0.5f, 0.1f),
new Color(0.45f, 0.75f, 1f)
};
private readonly Material[] _mats = (Material[])(object)new Material[Palette.Length];
private bool _matsReady;
private float _gripScanTimer;
private readonly HashSet<int> _fixedGrips = new HashSet<int>();
private HandPose _cylinderPose;
private static readonly HashSet<int> _loggedHover = new HashSet<int>();
private static Main _instance;
private static int _refLayer = -1;
private static bool _refTrigger;
private static bool _refFound;
private static readonly List<Grip> _mortarGrips = new List<Grip>();
private readonly List<int> _dead = new List<int>();
private Transform _anyBurstTpl;
private readonly HashSet<int> _pushed = new HashSet<int>();
public override void OnInitializeMelon()
{
_instance = this;
Sfx.Load(Path.Combine(MelonEnvironment.UserDataDirectory, "MortierManif"));
}
public override void OnSceneWasUnloaded(int buildIndex, string sceneName)
{
_mortars.Clear();
_shells.Clear();
_sparks.Clear();
_flashes.Clear();
_pops.Clear();
_puffs.Clear();
_embers.Clear();
_fixedGrips.Clear();
_cylinderPose = null;
_mortarGrips.Clear();
}
private void ReloadAll()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Enumerator<int, Mortar> enumerator = _mortars.Values.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Mortar current = enumerator.Current;
if ((Object)(object)current.FxFuse != (Object)null)
{
((Component)current.FxFuse).gameObject.SetActive(false);
}
if ((Object)(object)current.FuseLight != (Object)null)
{
Object.Destroy((Object)(object)((Component)current.FuseLight).gameObject);
}
current.FuseLight = null;
if ((Object)(object)current.FuseAudio != (Object)null)
{
Object.Destroy((Object)(object)((Component)current.FuseAudio).gameObject);
}
current.FuseAudio = null;
current.Phase = MPhase.Idle;
}
}
finally
{
((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
}
public override void OnUpdate()
{
if (_enabled.Value)
{
float deltaTime = Time.deltaTime;
_gripScanTimer -= deltaTime;
if (_gripScanTimer <= 0f)
{
_gripScanTimer = 0.5f;
FixMortarGrips();
}
if ((Object)(object)Player.RigManager != (Object)null)
{
CheckHand(Player.LeftHand, Player.LeftController);
CheckHand(Player.RightHand, Player.RightController);
}
UpdateMortars(deltaTime);
UpdateShells(deltaTime);
UpdateSparks(deltaTime);
UpdateFlashes(deltaTime);
UpdatePops(deltaTime);
UpdatePuffs(deltaTime);
UpdateEmbers(deltaTime);
}
}
private void FixMortarGrips()
{
Il2CppReferenceArray<Object> val = Object.FindObjectsOfType(Il2CppType.Of<Grip>());
if (val == null)
{
return;
}
for (int i = 0; i < ((Il2CppArrayBase<Object>)(object)val).Length; i++)
{
Grip val2 = ((((Il2CppArrayBase<Object>)(object)val)[i] != (Object)null) ? ((Il2CppObjectBase)((Il2CppArrayBase<Object>)(object)val)[i]).TryCast<Grip>() : null);
if ((Object)(object)val2 == (Object)null)
{
continue;
}
int instanceID = ((Object)val2).GetInstanceID();
if (_fixedGrips.Contains(instanceID) || (Object)(object)FindMortarRoot(((Component)val2).transform) == (Object)null)
{
continue;
}
_fixedGrips.Add(instanceID);
if (val2.gripColliders == null || ((Il2CppArrayBase<Collider>)(object)val2.gripColliders).Length == 0)
{
Il2CppArrayBase<Collider> components = ((Component)val2).GetComponents<Collider>();
if (components != null && components.Length > 0)
{
Il2CppReferenceArray<Collider> val3 = new Il2CppReferenceArray<Collider>((long)components.Length);
for (int j = 0; j < components.Length; j++)
{
((Il2CppArrayBase<Collider>)(object)val3)[j] = components[j];
}
val2.gripColliders = val3;
}
}
_mortarGrips.Add(val2);
ApplyGripLayer(val2);
bool flag = (Object)(object)val2.handPose != (Object)null;
if (!flag)
{
HandPose cylinderPose = GetCylinderPose();
if ((Object)(object)cylinderPose != (Object)null)
{
val2.handPose = cylinderPose;
}
}
Rigidbody componentInParent = ((Component)val2).GetComponentInParent<Rigidbody>();
MelonLogger.Msg(string.Concat(new string[11]
{
"[Grip] ",
((Object)val2).name,
" : pose d'origine=",
flag ? ((Object)val2.handPose).name : "VIDE",
", pose finale=",
((Object)(object)val2.handPose != (Object)null) ? ((Object)val2.handPose).name : "VIDE",
", ",
$"colliders={((val2.gripColliders != null) ? ((Il2CppArrayBase<Collider>)(object)val2.gripColliders).Length : 0)}, ",
$"target={(Object)(object)val2.targetTransform != (Object)null}, kinematic={(Object)(object)componentInParent != (Object)null && componentInParent.isKinematic}, ",
"layer=",
LayerMask.LayerToName(((Component)val2).gameObject.layer)
}));
}
}
internal static void OnGripHover(Grip grip, Hand hand)
{
if ((Object)(object)grip == (Object)null || _instance == null)
{
return;
}
Transform obj = FindMortarRoot(((Component)grip).transform);
int instanceID = ((Object)grip).GetInstanceID();
bool flag = _loggedHover.Add(instanceID);
if ((Object)(object)obj == (Object)null)
{
Collider component = ((Component)grip).GetComponent<Collider>();
if ((Object)(object)component != (Object)null && !_refFound)
{
_refLayer = ((Component)component).gameObject.layer;
_refTrigger = component.isTrigger;
_refFound = true;
ApplyRefToMortars();
}
if (flag && _loggedHover.Count <= 15)
{
MelonLogger.Msg(string.Concat(new string[6]
{
"[Grip] autre prise : ",
Path(((Component)grip).transform),
" | layer=",
LayerMask.LayerToName(((Component)grip).gameObject.layer),
((Object)(object)component != (Object)null) ? $" | collider layer={LayerMask.LayerToName(((Component)component).gameObject.layer)} trigger={component.isTrigger}" : " | pas de collider sur l'objet",
$" | gripColliders={((grip.gripColliders != null) ? ((Il2CppArrayBase<Collider>)(object)grip.gripColliders).Length : (-1))}"
}));
}
return;
}
if ((Object)(object)grip.handPose == (Object)null)
{
HandPose cylinderPose = _instance.GetCylinderPose();
if ((Object)(object)cylinderPose != (Object)null)
{
grip.handPose = cylinderPose;
}
}
if (flag)
{
MelonLogger.Msg(string.Concat(new string[9]
{
"[Grip] MORTIER survolé : ",
Path(((Component)grip).transform),
" | main=",
((Object)(object)hand != (Object)null) ? ((Object)hand).name : "NULL",
" | pose=",
((Object)(object)grip.handPose != (Object)null) ? ((Object)grip.handPose).name : "VIDE",
" ",
$"| target={(Object)(object)grip.targetTransform != (Object)null} | colliders={((grip.gripColliders != null) ? ((Il2CppArrayBase<Collider>)(object)grip.gripColliders).Length : (-1))} ",
$"| host={(Object)(object)((Component)grip).GetComponentInParent<InteractableHost>() != (Object)null}"
}));
}
}
private static string Path(Transform t)
{
string text = ((Object)t).name;
Transform parent = t.parent;
while ((Object)(object)parent != (Object)null)
{
text = ((Object)parent).name + "/" + text;
parent = parent.parent;
}
return text;
}
private static void ApplyGripLayer(Grip grip)
{
int num = (_refFound ? _refLayer : LayerMask.NameToLayer("Interactable"));
if (num < 0)
{
return;
}
((Component)grip).gameObject.layer = num;
Il2CppArrayBase<Collider> components = ((Component)grip).GetComponents<Collider>();
for (int i = 0; i < components.Length; i++)
{
if (_refFound)
{
components[i].isTrigger = _refTrigger;
}
}
}
private static void ApplyRefToMortars()
{
for (int num = _mortarGrips.Count - 1; num >= 0; num--)
{
if ((Object)(object)_mortarGrips[num] == (Object)null)
{
_mortarGrips.RemoveAt(num);
}
else
{
ApplyGripLayer(_mortarGrips[num]);
}
}
MelonLogger.Msg($"[Grip] Calque de référence des prises du jeu : {LayerMask.LayerToName(_refLayer)} (trigger={_refTrigger})");
}
private HandPose GetCylinderPose()
{
if ((Object)(object)_cylinderPose != (Object)null)
{
return _cylinderPose;
}
Il2CppReferenceArray<Object> val = Resources.FindObjectsOfTypeAll(Il2CppType.Of<HandPose>());
HandPose val2 = null;
for (int i = 0; i < ((Il2CppArrayBase<Object>)(object)val).Length; i++)
{
HandPose val3 = ((((Il2CppArrayBase<Object>)(object)val)[i] != (Object)null) ? ((Il2CppObjectBase)((Il2CppArrayBase<Object>)(object)val)[i]).TryCast<HandPose>() : null);
if (!((Object)(object)val3 == (Object)null))
{
if (((Object)val3).name == "CylinderGripSmall")
{
_cylinderPose = val3;
break;
}
if ((Object)(object)val2 == (Object)null && ((Object)val3).name.Contains("Cylinder"))
{
val2 = val3;
}
}
}
if ((Object)(object)_cylinderPose == (Object)null)
{
_cylinderPose = val2;
}
MelonLogger.Msg("[Grip] Pose de main trouvée : " + (((Object)(object)_cylinderPose != (Object)null) ? ((Object)_cylinderPose).name : "aucune") + $" ({((Il2CppArrayBase<Object>)(object)val).Length} poses dans le jeu)");
return _cylinderPose;
}
private void CheckHand(Hand hand, BaseController ctrl)
{
if ((Object)(object)hand == (Object)null || (Object)(object)ctrl == (Object)null)
{
return;
}
GameObject currentAttachedGO = hand.m_CurrentAttachedGO;
if ((Object)(object)currentAttachedGO == (Object)null)
{
return;
}
Transform val = FindMortarRoot(currentAttachedGO.transform);
if (!((Object)(object)val == (Object)null) && ctrl.GetPrimaryInteractionButtonDown())
{
Mortar mortar = GetMortar(val);
if (mortar.Phase == MPhase.Idle)
{
Ignite(mortar);
}
}
}
private static Transform FindMortarRoot(Transform t)
{
Transform result = null;
while ((Object)(object)t != (Object)null)
{
if (((Object)t).name.Contains("MortierManif"))
{
result = t;
}
t = t.parent;
}
return result;
}
private static Transform FindDeep(Transform root, string name)
{
Il2CppArrayBase<Transform> componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
if (((Object)componentsInChildren[i]).name == name)
{
return componentsInChildren[i];
}
}
return null;
}
private Mortar GetMortar(Transform root)
{
int instanceID = ((Object)((Component)root).gameObject).GetInstanceID();
Mortar mortar = default(Mortar);
if (_mortars.TryGetValue(instanceID, ref mortar) && (Object)(object)mortar.Root != (Object)null)
{
return mortar;
}
mortar = new Mortar
{
Root = root,
Body = ((Component)root).GetComponentInChildren<Rigidbody>(),
Muzzle = FindDeep(root, "Muzzle"),
TubeBase = FindDeep(root, "TubeBase"),
FuseTip = FindDeep(root, "FuseTip"),
FxFuse = FindDeep(root, "FX_Fuse"),
FxLaunch = FindDeep(root, "FX_Launch"),
FxBurst = FindDeep(root, "FX_Burst")
};
if ((Object)(object)mortar.FxLaunch != (Object)null)
{
((Component)mortar.FxLaunch).gameObject.SetActive(false);
}
if ((Object)(object)mortar.FxBurst != (Object)null)
{
((Component)mortar.FxBurst).gameObject.SetActive(false);
}
if ((Object)(object)mortar.FxFuse != (Object)null)
{
((Component)mortar.FxFuse).gameObject.SetActive(false);
}
_mortars[instanceID] = mortar;
return mortar;
}
private void Ignite(Mortar m)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
m.Phase = MPhase.Fuse;
m.Timer = _fuseTime.Value;
m.ShotsLeft = Mathf.Max(1, _shots.Value);
if ((Object)(object)m.FxFuse != (Object)null)
{
((Component)m.FxFuse).gameObject.SetActive(true);
}
GameObject val = new GameObject("MortierManif_FuseLight");
val.transform.SetParent(FuseTransform(m), false);
m.FuseLight = val.AddComponent<Light>();
m.FuseLight.type = (LightType)2;
m.FuseLight.color = new Color(1f, 0.55f, 0.15f);
m.FuseLight.range = 1.5f;
m.FuseLight.intensity = 1.5f;
m.FuseAudio = Sfx.Play("meche", FuseTransform(m).position, 0.7f, 25f, loop: true, FuseTransform(m));
}
private static Transform FuseTransform(Mortar m)
{
if (!((Object)(object)m.FuseTip != (Object)null))
{
return m.Root;
}
return m.FuseTip;
}
private static Vector3 MuzzlePos(Mortar m)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)m.Muzzle != (Object)null))
{
return m.Root.TransformPoint(new Vector3(0f, 0.78f, 0f));
}
return m.Muzzle.position;
}
private static Vector3 MuzzleDir(Mortar m)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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)
if ((Object)(object)m.Muzzle != (Object)null && (Object)(object)m.TubeBase != (Object)null)
{
Vector3 val = m.Muzzle.position - m.TubeBase.position;
if (((Vector3)(ref val)).sqrMagnitude > 1E-06f)
{
return ((Vector3)(ref val)).normalized;
}
}
if (!((Object)(object)m.Muzzle != (Object)null))
{
return m.Root.up;
}
return m.Muzzle.up;
}
private void UpdateMortars(float dt)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
_dead.Clear();
Enumerator<int, Mortar> enumerator = _mortars.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
KeyValuePair<int, Mortar> current = enumerator.Current;
Mortar value = current.Value;
if ((Object)(object)value.Root == (Object)null || !((Component)value.Root).gameObject.activeInHierarchy)
{
_dead.Add(current.Key);
continue;
}
switch (value.Phase)
{
case MPhase.Fuse:
value.Timer -= dt;
FuseEffects(value, dt);
if (value.Timer <= 0f)
{
value.Phase = MPhase.Firing;
value.Timer = 0f;
}
break;
case MPhase.Firing:
FuseEffects(value, dt);
value.Timer -= dt;
if (value.Timer <= 0f)
{
FireShot(value);
value.ShotsLeft--;
value.Timer = _shotInterval.Value;
if (value.ShotsLeft <= 0)
{
EndFiring(value);
}
}
break;
case MPhase.Spent:
value.Timer -= dt;
if (value.Timer <= 0f)
{
value.Phase = MPhase.Idle;
DespawnMortar(value);
}
break;
}
}
}
finally
{
((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
Enumerator<int> enumerator2 = _dead.GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
int current2 = enumerator2.Current;
_mortars.Remove(current2);
}
}
finally
{
((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
}
}
private void FuseEffects(Mortar m, float dt)
{
//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_004f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_006e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)m.FuseLight != (Object)null)
{
m.FuseLight.intensity = Random.Range(0.8f, 2.2f);
}
if ((Object)(object)m.FxFuse == (Object)null && Random.value < 0.6f)
{
Vector3 position = FuseTransform(m).position;
SpawnSpark(position, Random.insideUnitSphere * 1.5f + Vector3.up * 0.5f, (Random.value < 0.7f) ? 3 : 6, 0.012f, Random.Range(0.2f, 0.45f), 2f, 2f, flicker: true, 0.12f);
}
}
private void EndFiring(Mortar m)
{
if ((Object)(object)m.FxFuse != (Object)null)
{
((Component)m.FxFuse).gameObject.SetActive(false);
}
if ((Object)(object)m.FuseLight != (Object)null)
{
Object.Destroy((Object)(object)((Component)m.FuseLight).gameObject);
}
m.FuseLight = null;
if ((Object)(object)m.FuseAudio != (Object)null)
{
Object.Destroy((Object)(object)((Component)m.FuseAudio).gameObject);
}
m.FuseAudio = null;
m.Phase = ((!_infinite.Value) ? MPhase.Spent : MPhase.Idle);
m.Timer = 10f;
}
private void DespawnMortar(Mortar m)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_0072: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = m.Root.position;
for (int i = 0; i < 3; i++)
{
SpawnPuff(position + Random.insideUnitSphere * 0.15f + Vector3.up * 0.3f, Vector3.up * 0.3f, 0.1f, Random.Range(0.3f, 0.45f), 1.5f, fire: false, new Color(0.6f, 0.6f, 0.62f));
}
try
{
Poolee componentInParent = ((Component)m.Root).GetComponentInParent<Poolee>();
if ((Object)(object)componentInParent != (Object)null)
{
componentInParent.Despawn();
return;
}
}
catch (global::System.Exception ex)
{
MelonLogger.Warning("Despawn : " + ex.Message);
}
((Component)m.Root).gameObject.SetActive(false);
}
private void FireShot(Mortar m)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_0084: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: 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_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_00d9: 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_00e8: 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_0135: 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)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = MuzzlePos(m);
Vector3 val2 = MuzzleDir(m);
if ((Object)(object)m.Body != (Object)null && !m.Body.isKinematic)
{
m.Body.AddForce(-val2 * _recoil.Value * 0.6f, (ForceMode)1);
Rigidbody body = m.Body;
body.angularVelocity *= 0.3f;
}
if ((Object)(object)m.FxLaunch != (Object)null)
{
SpawnTemplate(m.FxLaunch, val, Quaternion.LookRotation(val2), 3f);
}
else
{
AddFlash(val, new Color(1f, 0.75f, 0.35f), 8f, 0.18f, 8f);
for (int i = 0; i < 28; i++)
{
SpawnSpark(val, val2 * Random.Range(4f, 9f) + Random.insideUnitSphere * 2.5f, (Random.value < 0.6f) ? 6 : 3, 0.018f, Random.Range(0.2f, 0.5f), 3f, 3f, flicker: false, 0.15f);
}
SpawnFireball(val + val2 * 0.05f, 0.25f, 0.12f, 6);
}
Sfx.Play("depart", val, 1f, 120f);
Shell shell = new Shell
{
Mortar = m.Root,
Pos = val + val2 * 0.02f,
Vel = val2 * _launchSpeed.Value,
BurstAt = Random.Range(1.2f, 1.7f) * (_launchSpeed.Value / 26f),
ColorA = 2,
ColorB = 7,
Spin = Random.onUnitSphere * Random.Range(360f, 900f)
};
shell.Go = CreateShellObject(m, shell);
_shells.Add(shell);
}
private GameObject CreateShellObject(Mortar m, Shell s)
{
//IL_000d: 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_006f: 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)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
val.transform.localScale = Vector3.one * 0.03f;
Material mat = GetMat(5);
Renderer component = val.GetComponent<Renderer>();
component.shadowCastingMode = (ShadowCastingMode)0;
if ((Object)(object)mat != (Object)null)
{
component.sharedMaterial = mat;
}
else
{
component.enabled = false;
}
((Object)val).name = "MortierManif_ObusVol";
val.transform.SetParent((Transform)null, true);
val.transform.position = s.Pos;
val.transform.rotation = Random.rotation;
Il2CppArrayBase<Collider> componentsInChildren = val.GetComponentsInChildren<Collider>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
Object.Destroy((Object)(object)componentsInChildren[i]);
}
Il2CppArrayBase<Rigidbody> componentsInChildren2 = val.GetComponentsInChildren<Rigidbody>(true);
for (int j = 0; j < componentsInChildren2.Length; j++)
{
Object.Destroy((Object)(object)componentsInChildren2[j]);
}
GameObject val2 = new GameObject("Glow");
val2.transform.SetParent(val.transform, false);
s.Glow = val2.AddComponent<Light>();
s.Glow.type = (LightType)2;
s.Glow.color = new Color(1f, 0.6f, 0.25f);
s.Glow.range = 6f;
s.Glow.intensity = 5f;
if ((Object)(object)mat != (Object)null)
{
TrailRenderer obj = val.AddComponent<TrailRenderer>();
obj.time = 0.12f;
obj.startWidth = 0.045f;
obj.endWidth = 0f;
obj.minVertexDistance = 0.05f;
((Renderer)obj).sharedMaterial = GetMat(3);
((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)obj).receiveShadows = false;
}
return val;
}
private void UpdateShells(float dt)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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_0083: 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_008f: 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)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: 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_00fa: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: 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_02c5: Unknown result type (might be due to invalid IL or missing references)
for (int num = _shells.Count - 1; num >= 0; num--)
{
Shell shell = _shells[num];
if ((Object)(object)shell.Go == (Object)null)
{
_shells.RemoveAt(num);
}
else
{
shell.Age += dt;
Vector3 pos = shell.Pos;
shell.Vel += Physics.gravity * dt;
shell.Vel *= 1f - 0.12f * dt;
shell.Pos += shell.Vel * dt;
shell.PuffTimer -= dt;
if (shell.PuffTimer <= 0f)
{
shell.PuffTimer = 0.07f;
SpawnPuff(shell.Pos - ((Vector3)(ref shell.Vel)).normalized * 0.05f, -shell.Vel * 0.03f + Random.insideUnitSphere * 0.15f, 0.06f, Random.Range(0.35f, 0.5f), Random.Range(1.6f, 2.2f), fire: true, new Color(0.55f, 0.55f, 0.58f));
}
if (Random.value < 0.6f)
{
SpawnSpark(shell.Pos - shell.Vel * dt * Random.value, -shell.Vel * 0.05f + Random.insideUnitSphere * 0.8f, (Random.value < 0.5f) ? 6 : 3, 0.012f, Random.Range(0.2f, 0.4f), 1f, 1.5f, flicker: true);
}
if (Sweep(pos, shell.Pos, shell.Mortar, shell.Age, out var point))
{
Burst(point, shell.ColorA, shell.ColorB, ground: true);
Kill(shell, num);
}
else if ((!_impactMode.Value && (shell.Age >= shell.BurstAt || (shell.Age > 0.4f && shell.Vel.y < 0f))) || shell.Age > 8f)
{
Burst(shell.Pos, shell.ColorA, shell.ColorB, ground: false);
Kill(shell, num);
}
else
{
shell.Go.transform.position = shell.Pos;
shell.Go.transform.Rotate(shell.Spin * dt, (Space)0);
}
}
}
}
private static bool Sweep(Vector3 a, Vector3 b, Transform mortar, float age, out Vector3 point)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_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_000a: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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_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_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)
point = b;
Vector3 val = b - a;
float magnitude = ((Vector3)(ref val)).magnitude;
if (magnitude < 1E-05f)
{
return false;
}
Il2CppStructArray<RaycastHit> val2 = Physics.RaycastAll(a, val / magnitude, magnitude, -1, (QueryTriggerInteraction)1);
float num = 3.4028235E+38f;
bool result = false;
Transform val3 = (((Object)(object)Player.PhysicsRig != (Object)null) ? ((Component)Player.PhysicsRig).transform.root : null);
for (int i = 0; i < ((Il2CppArrayBase<RaycastHit>)(object)val2).Length; i++)
{
RaycastHit val4 = ((Il2CppArrayBase<RaycastHit>)(object)val2)[i];
if (!((Object)(object)((RaycastHit)(ref val4)).collider == (Object)null))
{
Transform transform = ((Component)((RaycastHit)(ref val4)).collider).transform;
if ((!((Object)(object)mortar != (Object)null) || !transform.IsChildOf(mortar)) && (!(age < 0.15f) || !((Object)(object)val3 != (Object)null) || !((Object)(object)transform.root == (Object)(object)val3)) && ((RaycastHit)(ref val4)).distance < num)
{
num = ((RaycastHit)(ref val4)).distance;
point = ((RaycastHit)(ref val4)).point;
result = true;
}
}
}
return result;
}
private void Kill(Shell s, int index)
{
if ((Object)(object)s.Go != (Object)null)
{
Object.Destroy((Object)(object)s.Go);
}
_shells.RemoveAt(index);
}
private void Burst(Vector3 pos, int colA, int colB, bool ground)
{
//IL_000d: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_0352: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: 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_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_040e: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Unknown result type (might be due to invalid IL or missing references)
//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
Transform val = null;
Enumerator<int, Mortar> enumerator = _mortars.Values.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Mortar current = enumerator.Current;
if ((Object)(object)current.FxBurst != (Object)null)
{
val = current.FxBurst;
break;
}
}
}
finally
{
((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
if ((Object)(object)val != (Object)null)
{
_anyBurstTpl = val;
}
else
{
val = _anyBurstTpl;
}
if ((Object)(object)val != (Object)null)
{
SpawnTemplate(val, pos, Quaternion.identity, 6f);
}
float delay = 0f;
if ((Object)(object)Player.Head != (Object)null)
{
delay = Vector3.Distance(Player.Head.position, pos) / 343f;
}
Sfx.Play("explosion", pos, 1f, 400f, loop: false, null, Random.Range(0.85f, 1.1f), delay);
SpawnFireball(pos, ground ? 1f : 1.6f, 0.15f, 5);
AddFlash(pos, Color.white, ground ? 25f : 45f, 0.2f, ground ? 25f : 60f);
AddFlash(pos, new Color(0.3f, 0.45f, 1f), ground ? 18f : 30f, 1.8f, ground ? 35f : 80f);
int num = (ground ? 150 : 190);
for (int i = 0; i < num; i++)
{
Vector3 val2 = FibDir(i, num);
if (ground)
{
Vector3 val3 = val2 + Vector3.up * 0.35f;
val2 = ((Vector3)(ref val3)).normalized;
}
float num2 = Random.Range(26f, 42f);
Star(pos, val2 * num2, (Random.value < 0.6f) ? 7 : 2, 0.055f, Random.Range(1.6f, 2.4f), 2.4f, 3.5f, flicker: false, Random.Range(0.3f, 0.45f), ground);
}
for (int j = 0; j < 40; j++)
{
Star(pos, Random.onUnitSphere * Random.Range(8f, 16f), 7, 0.04f, Random.Range(1.2f, 1.8f), 1.8f, 3f, flicker: false, 0.25f, ground);
}
Color smoke = default(Color);
((Color)(ref smoke))..ctor(0.32f, 0.36f, 0.62f);
int num3 = (ground ? 5 : 6);
for (int k = 0; k < num3; k++)
{
Vector3 val4 = Random.insideUnitSphere * (ground ? 1.2f : 1.6f);
if (ground && val4.y < 0f)
{
val4.y = 0f - val4.y;
}
SpawnPuff(pos + val4, val4 * 0.35f + Vector3.up * 0.25f, 0.3f, Random.Range(1.4f, 2.2f), Random.Range(3.5f, 5f), fire: false, smoke);
}
_embers.Add(new Ember
{
T = 0.6f,
Center = pos,
Radius = (ground ? 6f : 9f)
});
if (Random.value < 0.5f)
{
int num4 = Random.Range(12, 22);
for (int l = 0; l < num4; l++)
{
_pops.Add(new Pop
{
T = Random.Range(0.8f, 1.7f),
Pos = pos + Random.insideUnitSphere * 8f + Vector3.down * Random.Range(0f, 2f),
Color = 7,
Sound = (l == 0)
});
}
}
Blast(pos, ground ? 1f : 0.6f);
}
private void UpdateEmbers(float dt)
{
//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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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)
for (int num = _embers.Count - 1; num >= 0; num--)
{
Ember ember = _embers[num];
ember.T -= dt;
if (!(ember.T > 0f))
{
for (int i = 0; i < 70; i++)
{
Vector3 pos = ember.Center + Random.insideUnitSphere * ember.Radius;
pos.y = ember.Center.y + Random.Range(-1f, ember.Radius * 0.6f);
SpawnSpark(pos, new Vector3(Random.Range(-0.3f, 0.3f), Random.Range(-1.5f, -0.5f), Random.Range(-0.3f, 0.3f)), (i % 3 == 0) ? 2 : 7, 0.02f, Random.Range(2f, 3.2f), 0.8f, 1.2f, Random.value < 0.3f, 0.12f);
}
_embers.RemoveAt(num);
}
}
}
private void SpawnPuff(Vector3 pos, Vector3 vel, float size0, float size1, float life, bool fire, Color smoke)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: 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_00ca: 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)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
if (_puffs.Count >= 450)
{
return;
}
if ((Object)(object)_puffMat == (Object)null)
{
if ((Object)(object)GetMat(0) == (Object)null)
{
return;
}
_puffMat = new Material(_mats[0].shader);
((Object)_puffMat).hideFlags = (HideFlags)32;
}
if (_mpb == null)
{
_mpb = new MaterialPropertyBlock();
}
GameObject val = new GameObject("MortierManif_Puff");
val.transform.position = pos;
val.transform.rotation = Random.rotation;
Renderer[] array = (Renderer[])(object)new Renderer[3];
for (int i = 0; i < 3; i++)
{
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
Object.Destroy((Object)(object)obj.GetComponent<Collider>());
obj.transform.SetParent(val.transform, false);
obj.transform.localPosition = ((i == 0) ? Vector3.zero : (Random.insideUnitSphere * 0.45f));
obj.transform.localScale = Vector3.one * ((i == 0) ? 1f : Random.Range(0.55f, 0.8f));
Renderer component = obj.GetComponent<Renderer>();
component.sharedMaterial = _puffMat;
component.shadowCastingMode = (ShadowCastingMode)0;
component.receiveShadows = false;
array[i] = component;
}
val.transform.localScale = Vector3.one * size0;
Puff puff = new Puff
{
Go = val,
R = array,
Vel = vel,
Life = life,
Size0 = size0,
Size1 = size1,
Fire = fire,
Smoke = smoke
};
_puffs.Add(puff);
ApplyPuffColor(puff, 0f);
}
private void ApplyPuffColor(Puff p, float t)
{
//IL_00d9: 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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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_0101: 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_0070: 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_007d: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: 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_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
Color val4;
if (p.Fire)
{
Color val = new Color(1f, 0.95f, 0.8f) * 4f;
Color val2 = new Color(1f, 0.45f, 0.1f) * 2.5f;
Color val3 = default(Color);
((Color)(ref val3))..ctor(0.6f, 0.3f, 0.15f);
float age = p.Age;
val4 = ((age < 0.08f) ? val : ((age < 0.25f) ? Color.Lerp(val, val2, (age - 0.08f) / 0.17f) : ((!(age < 0.55f)) ? Color.Lerp(val3, p.Smoke, Mathf.Clamp01((age - 0.55f) / 0.5f)) : Color.Lerp(val2, val3, (age - 0.25f) / 0.3f))));
}
else
{
val4 = p.Smoke;
}
val4.a = 1f;
_mpb.Clear();
_mpb.SetColor("_BaseColor", val4);
_mpb.SetColor("_Color", val4);
for (int i = 0; i < p.R.Length; i++)
{
if ((Object)(object)p.R[i] != (Object)null)
{
p.R[i].SetPropertyBlock(_mpb);
}
}
}
private void UpdatePuffs(float dt)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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_00b1: 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_00c1: 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_00cb: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: 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_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
for (int num = _puffs.Count - 1; num >= 0; num--)
{
Puff puff = _puffs[num];
puff.Age += dt;
if ((Object)(object)puff.Go == (Object)null || puff.Age >= puff.Life)
{
if ((Object)(object)puff.Go != (Object)null)
{
Object.Destroy((Object)(object)puff.Go);
}
_puffs.RemoveAt(num);
}
else
{
float num2 = puff.Age / puff.Life;
puff.Vel *= Mathf.Max(0f, 1f - 1.5f * dt);
puff.Vel += Vector3.up * 0.08f * dt;
Transform transform = puff.Go.transform;
transform.position += puff.Vel * dt;
float num3 = 1f - (1f - num2) * (1f - num2) * (1f - num2);
float num4 = Mathf.Lerp(puff.Size0, puff.Size1, num3);
if (num2 > 0.8f)
{
num4 *= 1f - (num2 - 0.8f) / 0.2f;
}
puff.Go.transform.localScale = Vector3.one * num4;
if (puff.Fire && puff.Age < 1.2f)
{
ApplyPuffColor(puff, num2);
}
}
}
}
private static Vector3 FibDir(int i, int n)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
float num = 1f - ((float)i + 0.5f) / (float)n * 2f;
float num2 = Mathf.Sqrt(Mathf.Max(0f, 1f - num * num));
float num3 = (float)i * 2.3999631f;
return new Vector3(Mathf.Cos(num3) * num2, num, Mathf.Sin(num3) * num2);
}
private void Star(Vector3 pos, Vector3 v, int col, float size, float life, float drag, float gravity, bool flicker, float trail, bool ground)
{
//IL_0026: 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_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (ground && v.y < 0f)
{
v.y = (0f - v.y) * 0.5f;
}
SpawnSpark(pos, v, col, size, life, drag, gravity, flicker, trail);
}
private void UpdatePops(float dt)
{
//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_005d: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
for (int num = _pops.Count - 1; num >= 0; num--)
{
Pop pop = _pops[num];
pop.T -= dt;
if (!(pop.T > 0f))
{
for (int i = 0; i < 7; i++)
{
SpawnSpark(pop.Pos, Random.onUnitSphere * Random.Range(1.5f, 3f), pop.Color, 0.03f, Random.Range(0.12f, 0.3f), 3f, 1f, flicker: true);
}
if (Random.value < 0.25f)
{
AddFlash(pop.Pos, Color.white, 4f, 0.08f, 6f);
}
if (pop.Sound)
{
float delay = (((Object)(object)Player.Head != (Object)null) ? (Vector3.Distance(Player.Head.position, pop.Pos) / 343f) : 0f);
Sfx.Play("crepitement", pop.Pos, 0.9f, 300f, loop: false, null, Random.Range(0.9f, 1.1f), delay);
}
_pops.RemoveAt(num);
}
}
}
private void SpawnFireball(Vector3 pos, float maxSize, float life, int col)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
SpawnSpark(pos, Vector3.zero, col, maxSize, life, 0f, 0f, flicker: false);
if (_sparks.Count > 0)
{
_sparks[_sparks.Count - 1].Grow = maxSize;
}
}
private void Blast(Vector3 pos, float mult)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
float num = _blastForce.Value * mult;
float value = _blastRadius.Value;
if (num <= 0f)
{
return;
}
Transform val = (((Object)(object)Player.PhysicsRig != (Object)null) ? ((Component)Player.PhysicsRig).transform.root : null);
_pushed.Clear();
Il2CppReferenceArray<Collider> val2 = Physics.OverlapSphere(pos, value, -1, (QueryTriggerInteraction)1);
for (int i = 0; i < ((Il2CppArrayBase<Collider>)(object)val2).Length; i++)
{
Rigidbody val3 = (((Object)(object)((Il2CppArrayBase<Collider>)(object)val2)[i] != (Object)null) ? ((Il2CppArrayBase<Collider>)(object)val2)[i].attachedRigidbody : null);
if (!((Object)(object)val3 == (Object)null) && !val3.isKinematic && _pushed.Add(((Object)val3).GetInstanceID()))
{
bool flag = (Object)(object)val != (Object)null && (Object)(object)((Component)val3).transform.root == (Object)(object)val;
if (!flag || _blastPlayer.Value)
{
val3.AddExplosionForce(flag ? (num * 0.3f) : num, pos, value, 0.4f, (ForceMode)1);
}
}
}
}
private static void SpawnTemplate(Transform tpl, Vector3 pos, Quaternion rot, float life)
{
//IL_0006: 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)
GameObject obj = Object.Instantiate<GameObject>(((Component)tpl).gameObject, pos, rot);
obj.transform.SetParent((Transform)null, true);
obj.SetActive(true);
Object.Destroy((Object)(object)obj, life);
}
private void AddFlash(Vector3 pos, Color c, float intensity, float dur, float range)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("MortierManif_Flash");
val.transform.position = pos;
Light val2 = val.AddComponent<Light>();
val2.type = (LightType)2;
val2.color = c;
val2.range = range;
val2.intensity = intensity;
_flashes.Add(new Flash
{
L = val2,
T = 0f,
Dur = dur,
Intensity = intensity
});
}
private void UpdateFlashes(float dt)
{
for (int num = _flashes.Count - 1; num >= 0; num--)
{
Flash flash = _flashes[num];
if ((Object)(object)flash.L == (Object)null)
{
_flashes.RemoveAt(num);
}
else
{
flash.T += dt;
float num2 = 1f - flash.T / flash.Dur;
if (num2 <= 0f)
{
Object.Destroy((Object)(object)((Component)flash.L).gameObject);
_flashes.RemoveAt(num);
}
else
{
flash.L.intensity = flash.Intensity * num2 * num2;
}
}
}
}
private void SpawnSpark(Vector3 pos, Vector3 vel, int colorIndex, float size, float life, float drag, float gravity, bool flicker, float trail = 0f)
{
//IL_0048: 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_005b: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
if (_sparks.Count >= 2000)
{
return;
}
Material mat = GetMat(colorIndex);
if (!((Object)(object)mat == (Object)null))
{
GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
Object.Destroy((Object)(object)val.GetComponent<Collider>());
((Object)val).name = "MortierManif_Spark";
val.transform.position = pos;
val.transform.localScale = Vector3.one * size;
Renderer component = val.GetComponent<Renderer>();
component.sharedMaterial = mat;
component.shadowCastingMode = (ShadowCastingMode)0;
component.receiveShadows = false;
if (trail > 0f)
{
TrailRenderer obj = val.AddComponent<TrailRenderer>();
obj.time = trail;
obj.startWidth = size * 0.8f;
obj.endWidth = 0f;
obj.minVertexDistance = 0.08f;
((Renderer)obj).sharedMaterial = mat;
((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)obj).receiveShadows = false;
}
_sparks.Add(new Spark
{
Go = val,
Vel = vel,
Life = life,
Max = life,
Size = size,
Drag = drag,
Gravity = gravity,
Flicker = flicker
});
}
}
private void UpdateSparks(float dt)
{
//IL_0075: 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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_009c: 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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
for (int num = _sparks.Count - 1; num >= 0; num--)
{
Spark spark = _sparks[num];
spark.Life -= dt;
if ((Object)(object)spark.Go == (Object)null || spark.Life <= 0f)
{
if ((Object)(object)spark.Go != (Object)null)
{
Object.Destroy((Object)(object)spark.Go);
}
_sparks.RemoveAt(num);
}
else
{
spark.Vel += Vector3.down * spark.Gravity * dt;
spark.Vel *= Mathf.Max(0f, 1f - spark.Drag * dt);
Transform transform = spark.Go.transform;
transform.position += spark.Vel * dt;
float num2 = spark.Life / spark.Max;
float num3 = ((spark.Grow > 0f) ? (spark.Grow * Mathf.Sin(Mathf.Clamp01(1f - num2) * (float)Math.PI)) : (spark.Size * Mathf.Sqrt(num2)));
if (spark.Flicker && Random.value < 0.35f)
{
num3 = 0f;
}
transform.localScale = Vector3.one * num3;
}
}
}
private Material GetMat(int index)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
if (!_matsReady)
{
_matsReady = true;
string[] obj = new string[4] { "Universal Render Pipeline/Unlit", "Universal Render Pipeline/Particles/Unlit", "Unlit/Color", "Sprites/Default" };
Shader val = null;
string[] array = obj;
for (int i = 0; i < array.Length; i++)
{
val = Shader.Find(array[i]);
if ((Object)(object)val != (Object)null)
{
break;
}
}
if ((Object)(object)val == (Object)null)
{
MelonLogger.Warning("Aucun shader unlit trouvé : étincelles code désactivées (ajoute FX_Burst dans Unity).");
return null;
}
for (int j = 0; j < Palette.Length; j++)
{
Material val2 = new Material(val);
Color val3 = Palette[j] * 4f;
val3.a = 1f;
if (val2.HasProperty("_BaseColor"))
{
val2.SetColor("_BaseColor", val3);
}
if (val2.HasProperty("_Color"))
{
val2.SetColor("_Color", val3);
}
((Object)val2).hideFlags = (HideFlags)32;
_mats[j] = val2;
}
}
return _mats[Mathf.Clamp(index, 0, _mats.Length - 1)];
}
}