Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RepoDarkSoulsPopUpMod v0.2.2
DarkSoulsPopUp.dll
Decompiled 5 months agousing System.CodeDom.Compiler; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] public class DarkSoulsPopUp : MonoBehaviour { private Image _backgroundImageBar; private TMP_Text _tmpText; private AudioSource _audioSource; [Header("Text")] [SerializeField] private Color _textColor = new Color(19f / 51f, 0.12156863f, 0.11372549f, 1f); [SerializeField] private string _titleText = "Dark Souls Pop Up"; [Header("Animation Background Fade")] [SerializeField] [Range(0f, 2f)] private float _backgroundFadeInTime; [SerializeField] [Range(0f, 2f)] private float _backgroundFadeOutTime; [SerializeField] [Range(0.1f, 5f)] private float _backgroundStayTime; [Header("Animation Text Fade")] [SerializeField] [Range(0f, 2f)] private float _textFadeInTime; [SerializeField] [Range(0f, 2f)] private float _textFadeOutTime; [SerializeField] [Range(0f, 2f)] private float _textFadeDelayTime; [SerializeField] [Range(0.1f, 5f)] private float _textStayTime; [Header("Animation Text Size")] [SerializeField] [Range(0f, 5f)] private float _textSizeInTime; [SerializeField] private float _startTextSize; [SerializeField] private float _stopTextSize; [Header("Animation Other")] [SerializeField] [Range(0f, 2f)] private float _timeScaler; [Header("Audio")] [SerializeField] private AudioClip _popUpAudio; private float _startAlphaBackground; private float _stopAlphaBackground = 1f; private float _startAlphaTitle; private float _stopAlphaTitle = 1f; private float _textSizeScaler = 1f; private bool _isPlaying; private float _currentPlayTime; private float _totalPlayTime; private bool _playedAudio; private void Start() { _totalPlayTime = _backgroundFadeInTime + _backgroundStayTime + _backgroundFadeOutTime + _textFadeDelayTime + 0.1f; _backgroundImageBar = ((Component)this).GetComponentInChildren<Image>(); _tmpText = ((Component)this).GetComponentInChildren<TMP_Text>(); _audioSource = ((Component)this).GetComponent<AudioSource>(); _SetBackgroundAlpha(_startAlphaBackground); _SetTextAlpha(_startAlphaTitle); _SetTitleText(_titleText); } private void FixedUpdate() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) if (!_isPlaying) { return; } _currentPlayTime += Time.fixedDeltaTime * _timeScaler; if (_currentPlayTime > 0f && !_playedAudio) { if ((Object)(object)_audioSource != (Object)null) { _audioSource.PlayOneShot(_popUpAudio); } _playedAudio = true; } Vector2 val = _CalculatePopUpAlpha(_currentPlayTime); float size = _CalculateTextSize(_currentPlayTime); _SetBackgroundAlpha(val.x); _SetTextAlpha(val.y); _SetTitleSize(size); if (_currentPlayTime > _totalPlayTime) { _currentPlayTime = 0f; _SetBackgroundAlpha(_startAlphaBackground); _SetTextAlpha(_startAlphaTitle); _isPlaying = false; } } public bool StartPopUp(string titleText, Color textColor, float delay = 0f) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (_isPlaying) { return false; } _currentPlayTime = 0f - delay; _playedAudio = false; _SetTitleText(titleText); textColor.a = _startAlphaTitle; _SetTitleColor(textColor); _SetBackgroundAlpha(_startAlphaBackground); _SetTextAlpha(_startAlphaTitle); _isPlaying = true; return true; } public void StopPopUp() { if (_isPlaying) { _SetBackgroundAlpha(_startAlphaBackground); _SetTextAlpha(_startAlphaTitle); _isPlaying = false; _currentPlayTime = 0f; } } public bool IsDone() { return _currentPlayTime > _totalPlayTime; } public bool IsPlaying() { return _isPlaying; } internal Vector2 _CalculatePopUpAlpha(float t) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) Vector2 result = default(Vector2); ((Vector2)(ref result))..ctor(0f, 0f); result.x = _rampFloat(t, _startAlphaBackground, _stopAlphaBackground, _backgroundFadeInTime, _backgroundFadeOutTime, _backgroundStayTime); result.y = _rampFloat(t - _textFadeDelayTime, _startAlphaTitle, _stopAlphaTitle, _textFadeInTime, _textFadeOutTime, _textStayTime); return result; } internal float _CalculateTextSize(float t) { return _rampFloat(t - _textFadeDelayTime, _startTextSize * _textSizeScaler, _stopTextSize * _textSizeScaler, _textSizeInTime, 0f, 1f); } internal float _rampFloat(float t, float start, float peak, float rampUpTime, float rampDownTime, float stayTime) { float num = rampUpTime + stayTime + rampDownTime; if (t < 0f) { return start; } if (t < rampUpTime) { return start + (peak - start) * (t / rampUpTime); } if (t < rampUpTime + stayTime) { return peak; } if (t < num) { float num2 = t - (rampUpTime + stayTime); return peak - (peak - start) * (num2 / rampDownTime); } return start; } internal void _SetBackgroundAlpha(float alpha) { //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_0029: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_backgroundImageBar == (Object)null)) { Color color = ((Graphic)_backgroundImageBar).color; color.a = alpha; ((Graphic)_backgroundImageBar).color = color; } } internal void _SetTextAlpha(float alpha) { //IL_0010: 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_0024: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_tmpText == (Object)null)) { Color textColor = _textColor; textColor.a = alpha; ((Graphic)_tmpText).color = textColor; } } internal void _SetTitleText(string newText) { if (!((Object)(object)_tmpText == (Object)null)) { _titleText = newText; _tmpText.text = newText; } } internal void _SetTitleColor(Color color) { //IL_0010: 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_001c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_tmpText == (Object)null)) { _textColor = color; ((Graphic)_tmpText).color = color; } } internal void _SetTitleSize(float size) { if (!((Object)(object)_tmpText == (Object)null)) { _tmpText.fontSize = size; } } } public class DarkSoulsPopUpManager : MonoBehaviour { public static DarkSoulsPopUpManager Instance; private DarkSoulsPopUp darkSoulsPopUpScript; private void Awake() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)this); } Instance = this; } private void Start() { darkSoulsPopUpScript = ((Component)this).GetComponentInChildren<DarkSoulsPopUp>(); } public void CreatePopUp(string titleText, Color titleColor, float delay = 0f) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)darkSoulsPopUpScript == (Object)null)) { darkSoulsPopUpScript.StartPopUp(titleText, titleColor, delay); } } public void DestroyPopUp() { if (!((Object)(object)darkSoulsPopUpScript == (Object)null)) { darkSoulsPopUpScript.StopPopUp(); } } } [BepInPlugin("local.MrBraadworst", "DarkSoulsPopUp", "0.1.0")] public class Plugin : BaseUnityPlugin { public static class DarkSoulsPopUpHelper { public static string getCleanValuableName(string name) { name = name.Replace("Valuable", ""); name = name.Replace("(Clone)", ""); name = name.TrimStart(); name = name.TrimEnd(); return name; } public static bool isPopUpItem(string name) { if (name == "Manor Vase Big") { return true; } return false; } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "DestroyObjectRPC")] internal static class DarkSoulsPopUpDestoryObjectRPCPatch { [HarmonyPrefix] private static void DestroyObjectRPCPatch(PhysGrabObjectImpactDetector __instance) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) string cleanValuableName = DarkSoulsPopUpHelper.getCleanValuableName(((Object)__instance).name); bool flag = DarkSoulsPopUpHelper.isPopUpItem(cleanValuableName); if (flag) { if ((Object)(object)DarkSoulsPopUpManager.Instance == (Object)null) { Logger.LogError((object)"Failed to find ManagerPrefab"); return; } DarkSoulsPopUpManager.Instance.CreatePopUp("Vase Broken", new Color(19f / 51f, 0.12156863f, 0.11372549f)); } Logger.LogInfo((object)("[" + cleanValuableName + "] broke and is " + (flag ? "a PopUpItem" : "not a PopUpItem"))); } } [HarmonyPatch(typeof(PlayerAvatar), "PlayerDeath")] internal static class DarkSoulsPopUpPlayerDeathPatch { [HarmonyPrefix] private static void PlayerDeathPatch() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)DarkSoulsPopUpManager.Instance == (Object)null) { Logger.LogError((object)"Failed to find ManagerPrefab"); } else { DarkSoulsPopUpManager.Instance.CreatePopUp("YOU DIED", new Color(19f / 51f, 0.12156863f, 0.11372549f)); } } } [HarmonyPatch(typeof(HealthUI), "Start")] internal static class DarkSoulsPopUpHealthUIStartPatch { [HarmonyPostfix] private static void StartPatch() { if ((Object)(object)HealthUI.instance == (Object)null && (Object)(object)((Component)HealthUI.instance).transform.parent == (Object)null) { Logger.LogError((object)"HealthUI Instance is not created correcly? No place to hook DarkSoulsPopUp onto"); } else if ((Object)(object)Object.Instantiate<GameObject>(ManagerPrefab, ((Component)HealthUI.instance).transform.parent) == (Object)null) { Logger.LogError((object)"Failed to Instantiate DarkSoulsPopUpManager"); } else { Logger.LogInfo((object)"Loaded the ManagerPrefab onto the Game HUD"); } } } internal static ManualLogSource Logger; internal static string assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); internal static AssetBundle DarkSoulsPopUpAssets; internal static GameObject ManagerPrefab; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Loaded Plugin DarkSoulsPopUp"); DarkSoulsPopUpAssets = AssetBundle.LoadFromFile(Path.Combine(assemblyLocation, "darksoulspopupbundle")); if ((Object)(object)DarkSoulsPopUpAssets == (Object)null) { Logger.LogError((object)"Failed to load DarkSoulsPopUp AssetBundle"); return; } Logger.LogInfo((object)"Loaded DarkSoulsPopUp AssetBundle"); ManagerPrefab = DarkSoulsPopUpAssets.LoadAsset<GameObject>("Assets/DarkSoulsPopUp/Prefabs/DarkSoulsPopUpManager.prefab"); if ((Object)(object)ManagerPrefab == (Object)null) { Logger.LogError((object)"Failed to load ManagerPrefab from DarkSoulsPopUp AssetBundle"); } else { Patch(); } } internal void Patch() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("DarkSoulsPopUp").PatchAll(); } } [CompilerGenerated] [EditorBrowsable(EditorBrowsableState.Never)] [GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)] internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1 { private struct MonoScriptData { public byte[] FilePathsData; public byte[] TypesData; public int TotalTypes; public int TotalFiles; public bool IsEditorOnly; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static MonoScriptData Get() { MonoScriptData result = default(MonoScriptData); result.FilePathsData = new byte[167] { 0, 0, 0, 1, 0, 0, 0, 48, 92, 65, 115, 115, 101, 116, 115, 92, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 92, 83, 99, 114, 105, 112, 116, 115, 92, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 55, 92, 65, 115, 115, 101, 116, 115, 92, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 92, 83, 99, 114, 105, 112, 116, 115, 92, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 77, 97, 110, 97, 103, 101, 114, 46, 99, 115, 0, 0, 0, 5, 0, 0, 0, 40, 92, 65, 115, 115, 101, 116, 115, 92, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 92, 83, 99, 114, 105, 112, 116, 115, 92, 80, 108, 117, 103, 105, 110, 46, 99, 115 }; result.TypesData = new byte[224] { 0, 0, 0, 0, 15, 124, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 0, 0, 0, 0, 22, 124, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 77, 97, 110, 97, 103, 101, 114, 0, 0, 0, 0, 7, 124, 80, 108, 117, 103, 105, 110, 0, 0, 0, 0, 27, 80, 108, 117, 103, 105, 110, 124, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 72, 101, 108, 112, 101, 114, 0, 0, 0, 0, 42, 80, 108, 117, 103, 105, 110, 124, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 68, 101, 115, 116, 111, 114, 121, 79, 98, 106, 101, 99, 116, 82, 80, 67, 80, 97, 116, 99, 104, 0, 0, 0, 0, 37, 80, 108, 117, 103, 105, 110, 124, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 80, 108, 97, 121, 101, 114, 68, 101, 97, 116, 104, 80, 97, 116, 99, 104, 0, 0, 0, 0, 39, 80, 108, 117, 103, 105, 110, 124, 68, 97, 114, 107, 83, 111, 117, 108, 115, 80, 111, 112, 85, 112, 72, 101, 97, 108, 116, 104, 85, 73, 83, 116, 97, 114, 116, 80, 97, 116, 99, 104 }; result.TotalFiles = 3; result.TotalTypes = 7; result.IsEditorOnly = false; return result; } }