using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Atlas;
using BepInEx.Bootstrap;
using FistVR;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Valve.VR;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("Modmas2025Scripts")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Modmas2025Scripts")]
[assembly: AssemblyTitle("Modmas2025Scripts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 Modmas2025
{
public class AtlasPortal : MonoBehaviour
{
private bool teleporting;
public string sceneFileName;
private CustomSceneInfo? sceneInfo;
private void OnTriggerEnter(Collider other)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
if (teleporting)
{
return;
}
Debug.Log((object)((Object)((Component)other).gameObject).name);
if ((Object)(object)((Component)other).GetComponent<HeadTriggerDetect>() != (Object)null)
{
sceneInfo = AtlasPlugin.GetCustomScene(sceneFileName);
if (sceneInfo != null)
{
teleporting = true;
SteamVR_Fade.Start(Color.black, 0.5f, false);
((MonoBehaviour)this).Invoke("DelayedSceneLoad", 0.5f);
}
}
}
public void DelayedSceneLoad()
{
AtlasPlugin.LoadCustomScene(sceneInfo);
}
}
public class CrankHandle : FVRInteractiveObject
{
public MagicMirror mirror;
[NonSerialized]
public float lastrot;
[NonSerialized]
public float currot;
[NonSerialized]
public float m_rotTilShot = 180f;
[NonSerialized]
public int date = 1;
[Header("Dials Related")]
public GameObject crankobjroot;
public AudioEvent ding;
public float[] rot1;
public float[] rot2;
public GameObject wheel1;
public GameObject wheel2;
[HideInInspector]
public bool isDateAvailable;
public GameObject lightOff;
public GameObject lightOn;
public override void Awake()
{
((FVRInteractiveObject)this).Awake();
}
public override void OnDestroy()
{
((FVRInteractiveObject)this).OnDestroy();
}
private void FixedUpdate()
{
//IL_003f: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
if (((FVRInteractiveObject)this).IsHeld)
{
AxisLookAt(((Component)this).gameObject.transform, ((Component)base.m_hand).gameObject.transform.position, Vector3.forward);
}
currot = ((Component)this).gameObject.transform.localEulerAngles.y;
float num = Mathf.DeltaAngle(lastrot, currot);
lastrot = currot;
m_rotTilShot -= num;
if (m_rotTilShot < 0f)
{
SM.PlayCoreSound((FVRPooledAudioType)0, ding, ((Component)this).transform.position);
if ((Object)(object)base.m_hand != (Object)null)
{
base.m_hand.Buzz(base.m_hand.Buzzer.Buzz_BeginInteraction);
}
if (date < 24)
{
date++;
}
else if (date >= 24)
{
date = 1;
}
m_rotTilShot = 360f;
}
if (m_rotTilShot > 360f)
{
SM.PlayCoreSound((FVRPooledAudioType)41, ding, ((Component)this).gameObject.transform.position);
if ((Object)(object)base.m_hand != (Object)null)
{
base.m_hand.Buzz(base.m_hand.Buzzer.Buzz_BeginInteraction);
}
if (date > 1)
{
date--;
}
else if (date <= 1)
{
date = 24;
}
m_rotTilShot = 0f;
}
wheel1.transform.localEulerAngles = new Vector3(Mathf.Lerp(wheel1.transform.localEulerAngles.x, rot1[date - 1], 1f), 0f, 0f);
wheel2.transform.localEulerAngles = new Vector3(Mathf.Lerp(wheel2.transform.localEulerAngles.x, rot2[date - 1], 1f), 0f, 0f);
isDateAvailable = date <= mirror.GetDateCount();
if (isDateAvailable && !mirror.isBroken)
{
lightOn.SetActive(true);
lightOff.SetActive(false);
}
else
{
lightOn.SetActive(false);
lightOff.SetActive(true);
}
}
private void AxisLookAt(Transform tr_self, Vector3 lookPos, Vector3 directionAxis)
{
//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_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_0031: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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_0061: Unknown result type (might be due to invalid IL or missing references)
Quaternion rotation = tr_self.rotation;
Vector3 val = lookPos - tr_self.position;
Vector3 val2 = tr_self.rotation * directionAxis;
Vector3 val3 = Vector3.Cross(val2, val);
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float num = Vector3.Angle(val2, val);
tr_self.rotation = Quaternion.AngleAxis(num, normalized) * rotation;
tr_self.localEulerAngles = new Vector3(0f, tr_self.localEulerAngles.y, 0f);
}
}
public static class JsonHelper
{
[Serializable]
private class Wrapper<T>
{
public T[] items;
}
public static T[] FromJson<T>(string json)
{
return JsonUtility.FromJson<Wrapper<T>>(json).items;
}
public static string ToJson<T>(T[] array)
{
return JsonUtility.ToJson((object)new Wrapper<T>
{
items = array
});
}
public static string ToJson<T>(T[] array, bool prettyPrint)
{
return JsonUtility.ToJson((object)new Wrapper<T>
{
items = array
}, prettyPrint);
}
}
public class MagicMirror : MonoBehaviour, IFVRDamageable
{
[Serializable]
public struct MirrorParticles
{
public ParticleSystem particles_Shatter;
public ParticleSystem particles_ColdAir;
public ParticleSystem particles_Repairing;
public ParticleSystem particles_FinishRepair;
}
[Serializable]
public struct MirrorAudio
{
public AudioSource loop_PortalHum;
public AudioEvent sound_Shatter;
public AudioEvent sound_SpawnItem;
public AudioEvent sound_ActivateShard;
public AudioEvent sound_AttachShard;
public AudioEvent sound_RepairMirror;
}
[Serializable]
internal class Date
{
public bool isMapTransition;
public MirrorItemSpawnData[] itemsToSpawn;
public int mapProbeAnchorIndex = -1;
public string mapName = "";
}
[Serializable]
internal class MirrorItemSpawnData
{
public string itemName;
public uint itemCount = 1u;
[Tooltip("Time until the item after this one spawns.")]
public float spawnDelay = 0.5f;
}
[CompilerGenerated]
private sealed class <AddItemsToQueue>d__78 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public MagicMirror <>4__this;
public int _adjustedDate;
private float <prevSpawnDelay>5__2;
private int <i>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <AddItemsToQueue>d__78(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
MagicMirror magicMirror = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
if (magicMirror.dates[_adjustedDate].isMapTransition)
{
return false;
}
magicMirror.isLoadingAssets = true;
if (magicMirror.dates[_adjustedDate] == null || magicMirror.dates[_adjustedDate].itemsToSpawn.Count() == 0)
{
Debug.LogError((object)"Current date is missing or has no items to spawn!");
}
<prevSpawnDelay>5__2 = 0f;
<i>5__3 = 0;
break;
case 1:
{
<>1__state = -1;
for (int i = 0; i < magicMirror.dates[_adjustedDate].itemsToSpawn[<i>5__3].itemCount; i++)
{
magicMirror.itemSpawnQueue.Enqueue(new KeyValuePair<GameObject, float>(magicMirror.itemLoader.Result, <prevSpawnDelay>5__2));
<prevSpawnDelay>5__2 = magicMirror.dates[_adjustedDate].itemsToSpawn[<i>5__3].spawnDelay;
}
<i>5__3++;
break;
}
}
if (<i>5__3 < magicMirror.dates[_adjustedDate].itemsToSpawn.Length)
{
magicMirror.itemLoader = ((AnvilAsset)IM.OD[magicMirror.dates[_adjustedDate].itemsToSpawn[<i>5__3].itemName]).GetGameObjectAsync();
<>2__current = magicMirror.itemLoader;
<>1__state = 1;
return true;
}
magicMirror.isLoadingAssets = false;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <MirrorRepairBuildup>d__80 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public MagicMirror <>4__this;
private float <repairTimer>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MirrorRepairBuildup>d__80(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0033: 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_004e: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
MagicMirror magicMirror = <>4__this;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
if (!(<repairTimer>5__2 < magicMirror.mirrorRepairDelay))
{
magicMirror.RepairMirror();
return false;
}
}
else
{
<>1__state = -1;
SM.PlayCoreSound((FVRPooledAudioType)0, magicMirror.mirrorAudio.sound_RepairMirror, ((Component)magicMirror).transform.position);
EmissionModule emission = magicMirror.mirrorParticles.particles_ColdAir.emission;
((EmissionModule)(ref emission)).enabled = false;
<repairTimer>5__2 = 0f;
}
<repairTimer>5__2 += Time.deltaTime;
magicMirror.mirrorLight.intensity = Mathf.Lerp(magicMirror.lightIntensity_broken, magicMirror.lightIntensity_repairing, <repairTimer>5__2 / magicMirror.mirrorRepairDelay);
<>2__current = null;
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <PrewarmItems>d__69 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public MagicMirror <>4__this;
private List<string>.Enumerator <>7__wrap1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PrewarmItems>d__69(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 2)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>7__wrap1 = default(List<string>.Enumerator);
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
try
{
int num = <>1__state;
MagicMirror magicMirror = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
magicMirror.isPrewarming = true;
List<string> list = new List<string>();
for (int i = 0; i < magicMirror.dates.Length; i++)
{
for (int j = 0; j < magicMirror.dates[i].itemsToSpawn.Length; j++)
{
if (!list.Contains(magicMirror.dates[i].itemsToSpawn[j].itemName))
{
list.Add(magicMirror.dates[i].itemsToSpawn[j].itemName.Trim());
}
}
}
<>7__wrap1 = list.GetEnumerator();
<>1__state = -3;
break;
}
case 2:
<>1__state = -3;
break;
}
if (<>7__wrap1.MoveNext())
{
string current = <>7__wrap1.Current;
if (IM.OD.TryGetValue(current, out var _))
{
magicMirror.itemLoader = ((AnvilAsset)IM.OD[current]).GetGameObjectAsync();
Object.Destroy((Object)(object)Object.Instantiate<GameObject>(magicMirror.itemLoader.Result, new Vector3(0f, -100f, 0f), Quaternion.identity));
}
else
{
Debug.LogError((object)("Key " + current + " does not correspond to a value!"));
}
<>2__current = magicMirror.itemLoader;
<>1__state = 2;
return true;
}
<>m__Finally1();
<>7__wrap1 = default(List<string>.Enumerator);
magicMirror.isPrewarming = false;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
((IDisposable)<>7__wrap1).Dispose();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public CrankHandle crank;
private int curDate;
public GameObject mirrorCollider;
public GameObject playerOnlyCollider;
[Header("Shard Params")]
public GameObject IntactMirror;
[SerializeField]
private MirrorShardSet[] mirrorShardSets;
public Material glassMaterial;
private int currentShardSet;
private int shardsSnappedToMirror;
public float timeUntilAntiOrbit = 3f;
public float timeUntilMassIncrease = 10f;
public float timeUntilNoColShards = 20f;
public float timeUntilForceReset = 30f;
[Header("Physics Params")]
[Tooltip("The backwards force applied to every shard on shattering")]
public float baseShardPushForceMult = 1f;
[Tooltip("Adds variety to the base push force applied to each shard")]
public float baseShardPushForceVariance = 0.2f;
[Tooltip("Moves impact point inwards a set amount for a better looking shatter effect")]
public float impactPointInwardShift = 0.5f;
[Tooltip("The radius of the explosion force added to the mirror on shatter")]
public float impactExplosionForceRadius = 2f;
[Tooltip("How long the mirror waits after the last gift before the mirror shards activate")]
public float shardActivationDelay = 3f;
[Tooltip("Special case: how long the mirror waits for the player to enter the map")]
public float shardActivationDelay_Map = 30f;
[Tooltip("Adds variance for when the shards activate")]
public float shardActivationDelayVariance = 0.3f;
[Tooltip("The force applied to the shards per physics tick when activated")]
public float shardConstantPushForce = 50f;
[Tooltip("The force that pushes the shards up when they're activated")]
public float shardActivationAscentForce = 1f;
[Tooltip("Adds a slight delay to the push force after ascending for visual flair")]
public float shardDelayAfterAscent = 0.5f;
[Tooltip("How aggressively the shard will redirect towards its origin point")]
public float shardVectorDampeningMult = 2f;
[Tooltip("How quickly the shard rotates towards its starting angle")]
public float shardRotationMult = 1f;
[Tooltip("If shard is closer than this to its origin, snap to it")]
public float shardSnapDistanceThreshold = 0.15f;
[Header("Damage Params")]
public float debugDamage = 1000f;
public Transform debugImpactPoint;
public float mirrorDamageThreshold = 2f;
public float maxMirrorDamage = 10f;
public float minDamagePushForce = 100f;
public float maxDamagePushForce = 500f;
[Header("Gift Params")]
public Transform objectSpawnPoint;
[Tooltip("The time between the mirror being broken and the first item being dispensed")]
public float timeBeforeGiftsStartSpawning = 2f;
public Vector3 giftEjectionSpeed;
public float giftSpinSpeed = 20f;
[SerializeField]
private Date[] dates;
private AnvilCallback<GameObject> itemLoader;
private Queue<KeyValuePair<GameObject, float>> itemSpawnQueue = new Queue<KeyValuePair<GameObject, float>>();
private bool isPrewarming;
private bool isLoadingAssets;
private bool isSpawningItems;
[Header("Map Transition Params")]
[Tooltip("The reflection probe that the mirror anchors to")]
public ReflectionProbe anchorProbe;
[Tooltip("The cubemap that the anchor probe uses by default")]
public Cubemap defaultCubemap;
[Tooltip("0 on a date's mapProbeAnchorIndex is the zeroth object in this array")]
public Cubemap[] cubemaps;
public AtlasPortal mapTeleporter;
public MeshRenderer reflectionRenderer;
public MeshRenderer portalRenderer;
public Material portalMaterial;
public Material portalMaterial_half;
[Header("FX Params")]
public MirrorParticles mirrorParticles;
[Tooltip("The time between all shards reaching the mirror and the mirror repairing itself.")]
public float mirrorRepairDelay = 1f;
public Light mirrorLight;
public float lightIntensity_broken = 1f;
public float lightIntensity_repairing = 4f;
public MirrorAudio mirrorAudio;
[Header("BepInEx Params")]
public string jsonFileName = "modmas2025items.json";
public string pluginDictionaryString = "Modmas2025.Modmas_2025";
public bool debugDoLoadFromJson;
public bool debugDoSaveToJson;
public bool isBroken { get; private set; }
private void Awake()
{
if (debugDoSaveToJson)
{
SaveToJson();
}
LoadFromJson();
if (!Application.isEditor)
{
((MonoBehaviour)this).StartCoroutine(PrewarmItems());
}
for (int i = 0; i < mirrorShardSets.Length; i++)
{
mirrorShardSets[i].InitShardSet(this);
mirrorShardSets[i].setParent.SetActive(false);
}
}
private void LoadFromJson()
{
if (Application.isEditor)
{
if (debugDoLoadFromJson)
{
string json = File.ReadAllText(Application.dataPath + jsonFileName);
dates = JsonHelper.FromJson<Date>(json);
}
return;
}
Chainloader.PluginInfos.TryGetValue(pluginDictionaryString, out var value);
string directoryName = Path.GetDirectoryName(value.Location);
Debug.Log((object)("Current file path is " + directoryName + jsonFileName));
if (File.Exists(directoryName + jsonFileName))
{
string json2 = File.ReadAllText(directoryName + jsonFileName);
dates = JsonHelper.FromJson<Date>(json2);
}
else
{
Debug.LogError((object)"Modmas item .json missing, please reinstall!");
dates = new Date[0];
}
}
private void SaveToJson()
{
if (Application.isEditor)
{
string contents = JsonHelper.ToJson(dates, prettyPrint: true);
File.WriteAllText(Application.dataPath + "/modmas2025items.json", contents);
}
}
private IEnumerator PrewarmItems()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PrewarmItems>d__69(0)
{
<>4__this = this
};
}
private void Update()
{
if (isPrewarming)
{
return;
}
if (Application.isEditor && Input.GetKeyDown((KeyCode)98))
{
if (isBroken)
{
RepairMirror();
}
else
{
DestroyMirrorDebug(debugDamage, 1);
}
}
if (isBroken && itemSpawnQueue.Count > 0 && !isLoadingAssets && !isSpawningItems)
{
((MonoBehaviour)this).Invoke("SpawnGift", timeBeforeGiftsStartSpawning);
isSpawningItems = true;
}
}
private void SpawnGift()
{
//IL_002f: 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_00b9: 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_009c: Unknown result type (might be due to invalid IL or missing references)
if (itemSpawnQueue.Count > 0)
{
Rigidbody component = Object.Instantiate<GameObject>(itemSpawnQueue.Dequeue().Key, ((Component)objectSpawnPoint).transform.position, ((Component)objectSpawnPoint).transform.rotation).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.AddForce(giftEjectionSpeed, (ForceMode)2);
component.AddTorque(new Vector3(Random.Range(0f - giftSpinSpeed, giftSpinSpeed), Random.Range(0f - giftSpinSpeed, giftSpinSpeed), Random.Range(0f - giftSpinSpeed, giftSpinSpeed)), (ForceMode)2);
}
SM.PlayCoreSound((FVRPooledAudioType)0, mirrorAudio.sound_SpawnItem, ((Component)this).transform.position);
if (itemSpawnQueue.Count > 0)
{
((MonoBehaviour)this).Invoke("SpawnGift", itemSpawnQueue.Peek().Value);
return;
}
}
StartCountdown();
}
public void Damage(Damage _dam)
{
if (crank.isDateAvailable && _dam.Dam_TotalKinetic + _dam.Dam_TotalEnergetic >= mirrorDamageThreshold)
{
DestroyMirror(_dam, crank.date);
}
}
private void DestroyMirrorDebug(float _debugDamage, int _date)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_0014: 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)
Damage val = new Damage();
val.Dam_TotalKinetic = _debugDamage;
val.point = debugImpactPoint.position;
DestroyMirror(val, _date);
}
public void DestroyMirror(Damage _dam, int _date)
{
//IL_008b: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
if (isBroken)
{
return;
}
isBroken = true;
IntactMirror.SetActive(false);
curDate = _date;
currentShardSet = Random.Range(0, mirrorShardSets.Length);
mirrorShardSets[currentShardSet].setParent.SetActive(true);
mirrorShardSets[currentShardSet].EnableShards();
foreach (MirrorShard mirrorShard in mirrorShardSets[currentShardSet].mirrorShards)
{
mirrorShard.AddPushForce(_dam.Dam_TotalKinetic, _dam.point);
}
mirrorParticles.particles_Shatter.Play();
EmissionModule emission = mirrorParticles.particles_ColdAir.emission;
((EmissionModule)(ref emission)).enabled = true;
mirrorParticles.particles_ColdAir.Play();
SM.PlayCoreSound((FVRPooledAudioType)5, mirrorAudio.sound_Shatter, ((Component)this).transform.position);
mirrorAudio.loop_PortalHum.Play();
((Component)mirrorLight).gameObject.SetActive(true);
mirrorLight.intensity = lightIntensity_broken;
int num = _date - 1;
if (dates[num].isMapTransition)
{
if (dates[num].mapProbeAnchorIndex > -1)
{
((Component)reflectionRenderer).gameObject.SetActive(true);
if (cubemaps.Length != 0 && dates[num].mapProbeAnchorIndex > -1)
{
anchorProbe.bakedTexture = (Texture)(object)cubemaps[dates[num].mapProbeAnchorIndex];
anchorProbe.customBakedTexture = (Texture)(object)cubemaps[dates[num].mapProbeAnchorIndex];
}
((Renderer)portalRenderer).material = portalMaterial_half;
((Component)mapTeleporter).GetComponent<Collider>().enabled = true;
mapTeleporter.sceneFileName = dates[num].mapName;
}
StartCountdown();
}
else if (dates[num].itemsToSpawn.Count() == 0 || Application.isEditor)
{
StartCountdown();
}
else
{
AnvilManager.Run(AddItemsToQueue(num));
}
}
private void StartCountdown()
{
isSpawningItems = false;
foreach (MirrorShard mirrorShard in mirrorShardSets[currentShardSet].mirrorShards)
{
mirrorShard.SetShardState(MirrorShard.ShardState.Countdown);
}
}
public int GetDateCount()
{
return dates.Length;
}
public bool isCurDateAMap()
{
return dates[(curDate > 0) ? (curDate - 1) : (crank.date - 1)].isMapTransition;
}
private IEnumerator AddItemsToQueue(int _adjustedDate)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <AddItemsToQueue>d__78(0)
{
<>4__this = this,
_adjustedDate = _adjustedDate
};
}
public void CheckMirrorIntegrity()
{
//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)
shardsSnappedToMirror++;
EmissionModule emission = mirrorParticles.particles_ColdAir.emission;
((EmissionModule)(ref emission)).enabled = false;
if (shardsSnappedToMirror >= mirrorShardSets[currentShardSet].mirrorShards.Count)
{
if (!Application.isEditor)
{
AnvilManager.Run(MirrorRepairBuildup());
}
else
{
((MonoBehaviour)this).StartCoroutine(MirrorRepairBuildup());
}
}
}
private IEnumerator MirrorRepairBuildup()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MirrorRepairBuildup>d__80(0)
{
<>4__this = this
};
}
private void RepairMirror()
{
if (isBroken)
{
isBroken = false;
mirrorShardSets[currentShardSet].DebugResetShards();
mirrorShardSets[currentShardSet].setParent.SetActive(false);
IntactMirror.SetActive(true);
shardsSnappedToMirror = 0;
mirrorAudio.loop_PortalHum.Pause();
((Component)mirrorLight).gameObject.SetActive(false);
if ((Object)(object)defaultCubemap != (Object)null)
{
anchorProbe.bakedTexture = (Texture)(object)defaultCubemap;
anchorProbe.customBakedTexture = (Texture)(object)defaultCubemap;
}
else
{
anchorProbe.bakedTexture = null;
anchorProbe.customBakedTexture = null;
}
((Component)reflectionRenderer).gameObject.SetActive(false);
mapTeleporter.sceneFileName = "";
((Component)mapTeleporter).GetComponent<Collider>().enabled = false;
((Renderer)portalRenderer).material = portalMaterial;
curDate = 0;
}
}
private void OnTriggerEnter(Collider other)
{
if ((Object)(object)((Component)other).GetComponent<MirrorShard>() != (Object)null)
{
MirrorShard component = ((Component)other).GetComponent<MirrorShard>();
if (component.curShardState == MirrorShard.ShardState.Activated)
{
component.SetShardState(MirrorShard.ShardState.Reset);
CheckMirrorIntegrity();
}
}
}
}
public class MirrorShard : MonoBehaviour
{
private struct ShardOriginalPosRot
{
public Vector3 origPos;
public Quaternion origRot;
}
public enum ShardState
{
Reset,
Enabled,
Countdown,
Activated
}
private enum FallbackMode
{
None,
AntiOrbit,
MassIncrease,
Noclip,
ForceReset
}
private MagicMirror mirror;
private float timeUntilActivation;
private float timeSpentActivated;
private ShardOriginalPosRot shardOriginalTransform;
private FallbackMode fallbackMode;
private float orbitStrength = 1f;
public Rigidbody rigidbody { get; private set; }
public ShardState curShardState { get; private set; }
public void InitShard(MagicMirror _mirror, Vector3 _position, Quaternion _rotation)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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)
mirror = _mirror;
shardOriginalTransform.origPos = _position;
shardOriginalTransform.origRot = _rotation;
rigidbody = ((Component)this).GetComponent<Rigidbody>();
if (Application.isEditor)
{
((Behaviour)((Component)this).GetComponent<AudioImpactController>()).enabled = false;
}
}
private void Update()
{
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
switch (curShardState)
{
case ShardState.Countdown:
timeUntilActivation -= Time.deltaTime;
if (timeUntilActivation <= 0f)
{
SetShardState(ShardState.Activated);
}
break;
case ShardState.Activated:
timeSpentActivated += Time.deltaTime;
switch (fallbackMode)
{
case FallbackMode.None:
if (timeSpentActivated >= mirror.timeUntilAntiOrbit)
{
orbitStrength = 3f;
fallbackMode = FallbackMode.AntiOrbit;
}
break;
case FallbackMode.AntiOrbit:
if (timeSpentActivated >= mirror.timeUntilMassIncrease)
{
rigidbody.mass = 100f;
fallbackMode = FallbackMode.MassIncrease;
}
break;
case FallbackMode.MassIncrease:
if (timeSpentActivated >= mirror.timeUntilNoColShards)
{
((Component)this).GetComponent<Collider>().enabled = false;
fallbackMode = FallbackMode.Noclip;
}
break;
case FallbackMode.Noclip:
if (timeSpentActivated >= mirror.timeUntilForceReset)
{
fallbackMode = FallbackMode.ForceReset;
}
break;
case FallbackMode.ForceReset:
((Component)this).transform.localPosition = shardOriginalTransform.origPos;
timeSpentActivated = 0f;
orbitStrength = 1f;
rigidbody.mass = 1f;
((Component)this).GetComponent<Collider>().enabled = true;
fallbackMode = FallbackMode.None;
break;
}
break;
}
}
private void FixedUpdate()
{
//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_0038: 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_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_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_006f: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: 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_00c7: 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_00e3: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
if (curShardState == ShardState.Activated && timeSpentActivated >= 1f)
{
Vector3 val = ((Component)mirror).transform.TransformPoint(shardOriginalTransform.origPos);
Vector3 val2 = val - ((Component)this).transform.position;
Vector3 normalized = ((Vector3)(ref val2)).normalized;
rigidbody.AddForce(normalized * mirror.shardConstantPushForce * Time.deltaTime, (ForceMode)5);
rigidbody.velocity = Vector3.RotateTowards(rigidbody.velocity, normalized, mirror.shardVectorDampeningMult * Time.deltaTime * orbitStrength, 0f);
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(val.x, val.y, ((Component)this).transform.position.z);
rigidbody.AddForce((val3 - ((Component)this).transform.position) * mirror.shardConstantPushForce * Time.deltaTime * 2f, (ForceMode)5);
Quaternion val4 = Quaternion.Slerp(Quaternion.identity, ((Component)this).transform.rotation, Time.deltaTime * mirror.shardRotationMult);
rigidbody.AddTorque(((Quaternion)(ref val4)).eulerAngles, (ForceMode)5);
if (Vector3.Distance(((Component)this).transform.position, val) <= mirror.shardSnapDistanceThreshold && curShardState == ShardState.Activated)
{
SM.PlayCoreSound((FVRPooledAudioType)0, mirror.mirrorAudio.sound_AttachShard, ((Component)this).transform.position);
SetShardState(ShardState.Reset);
mirror.CheckMirrorIntegrity();
}
}
}
public void SetShardState(ShardState _state)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
switch (_state)
{
case ShardState.Reset:
curShardState = ShardState.Reset;
((Component)this).transform.localPosition = shardOriginalTransform.origPos;
((Component)this).transform.localRotation = shardOriginalTransform.origRot;
rigidbody.isKinematic = true;
((Collider)((Component)this).GetComponent<MeshCollider>()).enabled = false;
break;
case ShardState.Enabled:
curShardState = ShardState.Enabled;
rigidbody.isKinematic = false;
rigidbody.useGravity = true;
if (mirror.isCurDateAMap())
{
mirror.mirrorCollider.SetActive(false);
mirror.playerOnlyCollider.SetActive(false);
}
else
{
mirror.mirrorCollider.SetActive(false);
}
((Collider)((Component)this).GetComponent<MeshCollider>()).enabled = true;
break;
case ShardState.Countdown:
curShardState = ShardState.Countdown;
timeUntilActivation = (mirror.isCurDateAMap() ? mirror.shardActivationDelay_Map : mirror.shardActivationDelay) + Random.Range(0f - mirror.shardActivationDelayVariance, mirror.shardActivationDelayVariance);
break;
case ShardState.Activated:
curShardState = ShardState.Activated;
rigidbody.AddForce(Vector3.up * mirror.shardActivationAscentForce, (ForceMode)2);
rigidbody.AddRelativeTorque(Vector3.left, (ForceMode)2);
timeSpentActivated = 0f;
rigidbody.useGravity = false;
mirror.mirrorCollider.SetActive(true);
mirror.playerOnlyCollider.SetActive(true);
SM.PlayCoreSound((FVRPooledAudioType)0, mirror.mirrorAudio.sound_ActivateShard, ((Component)this).transform.position);
mirror.mirrorParticles.particles_Repairing.Play();
break;
}
}
public void AddPushForce(float _damage, Vector3 impactPoint)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
rigidbody.AddForce(((Component)mirror).transform.forward * (mirror.baseShardPushForceMult + Random.Range(mirror.baseShardPushForceVariance, 0f - mirror.baseShardPushForceVariance)), (ForceMode)1);
float num = Mathf.Lerp(mirror.minDamagePushForce, mirror.maxDamagePushForce, Mathf.InverseLerp(mirror.mirrorDamageThreshold, mirror.maxMirrorDamage, Mathf.Min(_damage, mirror.maxMirrorDamage)));
rigidbody.AddExplosionForce(num, impactPoint - ((Component)this).transform.forward * mirror.impactPointInwardShift, mirror.impactExplosionForceRadius);
}
}
[Serializable]
public class MirrorShardSet
{
[Tooltip("The parent object of all the shards. This is to make setup less tedious.")]
public GameObject setParent;
private MagicMirror mirror;
public List<MirrorShard> mirrorShards { get; private set; }
public void InitShardSet(MagicMirror _mirror)
{
//IL_00db: 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)
mirror = _mirror;
mirrorShards = new List<MirrorShard>();
for (int i = 0; i < setParent.transform.childCount; i++)
{
GameObject gameObject = ((Component)setParent.transform.GetChild(i)).gameObject;
if ((Object)(object)gameObject.GetComponent<MeshCollider>() == (Object)null)
{
gameObject.AddComponent<MeshCollider>();
}
gameObject.GetComponent<MeshCollider>().convex = true;
if ((Object)(object)gameObject.GetComponent<MeshRenderer>() != (Object)null)
{
((Renderer)gameObject.GetComponent<MeshRenderer>()).material = mirror.glassMaterial;
}
Rigidbody val = null;
val = ((!((Object)(object)gameObject.GetComponent<Rigidbody>() == (Object)null)) ? gameObject.GetComponent<Rigidbody>() : gameObject.AddComponent<Rigidbody>());
val.angularDrag = 0f;
val.isKinematic = true;
val.useGravity = false;
MirrorShard mirrorShard = null;
mirrorShard = ((!((Object)(object)gameObject.GetComponent<MirrorShard>() == (Object)null)) ? gameObject.GetComponent<MirrorShard>() : gameObject.AddComponent<MirrorShard>());
mirrorShard.InitShard(mirror, gameObject.transform.localPosition, gameObject.transform.localRotation);
mirrorShards.Add(mirrorShard);
}
}
public void EnableShards()
{
for (int i = 0; i < mirrorShards.Count; i++)
{
mirrorShards[i].SetShardState(MirrorShard.ShardState.Enabled);
}
}
public void DebugResetShards()
{
for (int i = 0; i < mirrorShards.Count; i++)
{
mirrorShards[i].SetShardState(MirrorShard.ShardState.Reset);
}
}
}
internal static class PluginInfo
{
internal const string NAME = "Modmas2025 Scripts";
internal const string GUID = "modmas2025.modmas2025scripts";
internal const string VERSION = "1.0.1";
}
}