Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.Linq;
- using System.IO;
- using System.Text.RegularExpressions;
- using UnityEngine;
- using MelonLoader;
- using SG.Claymore.Interaction;//Where the Name and Description hide
- using SG.Claymore.Entities;//Health hides here
- namespace SimpleRewards
- {
- public class MyMod : MelonMod
- {
- static void Blank(string file)
- {
- if (File.ReadAllText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\" + file) != null)
- {
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\" + file, null);
- }
- }
- static void WriteReward(string position)
- {
- string pattern = "(<script(\\s|\\S)*?<\\/script>)|(<style(\\s|\\S)*?<\\/style>)|(<!--(\\s|\\S)*?-->)|(<\\/?(\\s|\\S)*?>)";
- GameObject gameObject = GameObject.Find("RewardSpawner/SpawnPoints/" + position);
- if (gameObject != null)
- {
- RewardInteractable rewardInteractable = gameObject.GetComponentInChildren<RewardInteractable>();
- if (rewardInteractable != null)
- {
- if (rewardInteractable.DisplayName.ToString() != File.ReadAllText(MelonUtils.UserDataDirectory + "\\DisplayName" + position + ".txt"))
- {
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\DisplayName" + position + ".txt", rewardInteractable.DisplayName.ToString());
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\DisplayDescription" + position + ".txt", Regex.Replace(rewardInteractable.DisplayDescription.ToString(), pattern, ""));
- }
- }
- }
- }
- public override void OnLateUpdate()
- {
- GameObject playerInteractor = GameObject.Find("Player/PlayerInteractor");
- if (playerInteractor != null)
- {
- PlayerHealth playerHealth = playerInteractor.GetComponent<PlayerHealth>();
- if (playerHealth != null)
- {
- string healthPip = "<img src=\"HealthPip.png\">";
- string healthPipCracked = "<img src=\"HealthPipCracked.png\">";
- int currentHealth = (int)Math.Ceiling(playerHealth.CurrentHealth);
- int maxHealth = (int)Math.Ceiling(playerHealth.MaxHealth);
- int emptyHealth = maxHealth - currentHealth;
- if (playerHealth.MaxHealth.ToString() != File.ReadAllText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\MaxHealth.txt"))
- {
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\MaxHealth.txt", playerHealth.MaxHealth.ToString());
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\Health.html", "<center>" + String.Concat(Enumerable.Repeat(healthPip, currentHealth)) + String.Concat(Enumerable.Repeat(healthPipCracked, emptyHealth)) + "</center><script>function timedRefresh(timeoutPeriod) {setTimeout(\"location.reload(true); \",timeoutPeriod);} window.onload = timedRefresh(2000);</script>");
- }
- if (playerHealth.CurrentHealth.ToString() != File.ReadAllText(MelonUtils.UserDataDirectory + "\\CurrentHealth.txt"))
- {
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\CurrentHealth.txt", playerHealth.CurrentHealth.ToString());
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\Health.html", "<center>" + String.Concat(Enumerable.Repeat(healthPip, currentHealth)) + String.Concat(Enumerable.Repeat(healthPipCracked, emptyHealth)) + "</center><script>function timedRefresh(timeoutPeriod) {setTimeout(\"location.reload(true); \",timeoutPeriod);} window.onload = timedRefresh(2000);</script>");
- }
- //File.WriteAllText(MelonUtils.UserDataDirectory + "\\Health.html", "<center>" + String.Concat(Enumerable.Repeat(healthPip, currentHealth)) + String.Concat(Enumerable.Repeat(healthPipCracked, emptyHealth)) + "</center><script>function timedRefresh(timeoutPeriod) {setTimeout(\"location.reload(true); \",timeoutPeriod);} window.onload = timedRefresh(2000);</script>");
- }
- }
- WriteReward("Left");
- WriteReward("Center");
- WriteReward("Right");
- }
- public override void OnSceneWasLoaded(int buildIndex, string sceneName)
- {
- Blank("DisplayNameLeft.txt");
- Blank("DisplayNameCenter.txt");
- Blank("DisplayNameRight.txt");
- Blank("DisplayDescriptionLeft.txt");
- Blank("DisplayDescriptionCenter.txt");
- Blank("DisplayDescriptionRight.txt");
- }
- public override void OnApplicationStart()
- {
- Directory.CreateDirectory(MelonUtils.UserDataDirectory + "\\SimpleInfo\\");
- if (File.Exists(MelonUtils.UserDataDirectory + "\\MaxHealth.txt") == false)
- {
- File.CreateText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\MaxHealth.txt");
- File.CreateText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\CurrentHealth.txt");
- File.CreateText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\DisplayNameLeft.txt");
- File.CreateText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\DisplayDescriptionLeft.txt");
- File.CreateText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\DisplayNameCenter.txt");
- File.CreateText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\DisplayDescriptionCenter.txt");
- File.CreateText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\DisplayNameRight.txt");
- File.CreateText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\DisplayDescriptionRight.txt");
- }
- if (File.Exists(MelonUtils.UserDataDirectory + "\\SimpleInfo\\HealthPip.png") == false)
- {
- Bitmap img = Properties.Resources.HealthPip;
- img.Save(MelonUtils.UserDataDirectory + "\\SimpleInfo\\HealthPip.png", ImageFormat.Png);
- //File.Create(MelonUtils.UserDataDirectory + "\\HealthPip.png");
- //Properties.Resources.HealthPip.Save(MelonUtils.UserDataDirectory + "\\HealthPip.png");
- }
- if (File.Exists(MelonUtils.UserDataDirectory + "\\SimpleInfo\\HealthPipCracked.png") == false)
- {
- Bitmap img = Properties.Resources.HealthPipCracked;
- img.Save(MelonUtils.UserDataDirectory + "\\SimpleInfo\\HealthPipCracked.png", ImageFormat.Png);
- //File.Create(MelonUtils.UserDataDirectory + "\\HealthPipCracked.png");
- //Properties.Resources.HealthPipCracked.Save(MelonUtils.UserDataDirectory + "\\HealthPipCracked.png");
- }
- }
- public override void OnApplicationQuit()
- {
- Blank("DisplayNameLeft.txt");
- Blank("DisplayNameCenter.txt");
- Blank("DisplayNameRight.txt");
- Blank("DisplayDescriptionLeft.txt");
- Blank("DisplayDescriptionCenter.txt");
- Blank("DisplayDescriptionRight.txt");
- Blank("MaxHealth.txt");
- Blank("CurrentHealth.txt");
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\SimpleInfo\\Health.html", "<script>function timedRefresh(timeoutPeriod) {setTimeout(\"location.reload(true); \",timeoutPeriod);} window.onload = timedRefresh(2000);</script>");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement