Advertisement
joerkig

Does something

Apr 12th, 2021
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.92 KB | None | 0 0
  1. using System.IO;
  2. using UnityEngine;
  3. using MelonLoader;
  4. using SG.Claymore.Interaction;//Where the Name and Description hide
  5.  
  6. namespace SimpleRewards
  7. {
  8.     public class MyMod : MelonMod
  9.     {
  10.         public override void OnLateUpdate()
  11.         {
  12.             GameObject left = GameObject.Find("RewardSpawner/SpawnPoints/Left");//finding the switch
  13.             if (left != null)//prevents the code from crashing the game while referencing a null object
  14.             {
  15.                 RewardInteractable rewardInteractable = left.GetComponentInChildren<RewardInteractable>();//still finding the switch
  16.                 if (rewardInteractable != null)
  17.                 {
  18.                     if (rewardInteractable.DisplayName.ToString() != File.ReadAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameLeft.txt"))
  19.                     {
  20.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameLeft.txt", rewardInteractable.DisplayName.ToString());
  21.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayDescriptionLeft.txt", rewardInteractable.DisplayDescription.ToString());
  22.                         //MelonLogger.Log(rewardInteractable.DisplayName.ToString());
  23.                         //MelonLogger.Log(rewardInteractable.DisplayDescription.ToString());
  24.                     }
  25.                 }
  26.                 else
  27.                 {
  28.                     if (File.ReadAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameLeft.txt") != null)
  29.                     {
  30.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameLeft.txt", null);
  31.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayDescriptionLeft.txt", null);
  32.                     }
  33.                 }
  34.             }
  35.             GameObject center = GameObject.Find("RewardSpawner/SpawnPoints/Center");//finding the switch
  36.             if (center != null)//prevents the code from crashing the game while referencing a null object
  37.             {
  38.                 RewardInteractable rewardInteractable = center.GetComponentInChildren<RewardInteractable>();//still finding the switch
  39.                 if (rewardInteractable != null)
  40.                 {
  41.                     if (rewardInteractable.DisplayName.ToString() != File.ReadAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameCenter.txt"))
  42.                     {
  43.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameCenter.txt", rewardInteractable.DisplayName.ToString());
  44.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayDescriptionCenter.txt", rewardInteractable.DisplayDescription.ToString());
  45.                         //MelonLogger.Log(rewardInteractable.DisplayName.ToString());
  46.                         //MelonLogger.Log(rewardInteractable.DisplayDescription.ToString());
  47.                     }
  48.                 }
  49.                 else
  50.                 {
  51.                     if (File.ReadAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameCenter.txt") != null)
  52.                     {
  53.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameCenter.txt", null);
  54.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayDescriptionCenter.txt", null);
  55.                     }
  56.                 }
  57.             }
  58.             GameObject right = GameObject.Find("RewardSpawner/SpawnPoints/Right");//finding the switch
  59.             if (right != null)//prevents the code from crashing the game while referencing a null object
  60.             {
  61.                 RewardInteractable rewardInteractable = right.GetComponentInChildren<RewardInteractable>();//still finding the switch
  62.                 if (rewardInteractable != null)
  63.                 {
  64.                     if (rewardInteractable.DisplayName.ToString() != File.ReadAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameRight.txt"))
  65.                     {
  66.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameRight.txt", rewardInteractable.DisplayName.ToString());
  67.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayDescriptionRight.txt", rewardInteractable.DisplayDescription.ToString());
  68.                         //MelonLogger.Log(rewardInteractable.DisplayName.ToString());
  69.                         //MelonLogger.Log(rewardInteractable.DisplayDescription.ToString());
  70.                     }
  71.                 }
  72.                 else
  73.                 {
  74.                     if (File.ReadAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameRight.txt") != null)
  75.                     {
  76.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameRight.txt", null);
  77.                         File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayDescriptionRight.txt", null);
  78.                     }
  79.                 }
  80.             }
  81.         }
  82.         public override void OnApplicationQuit()
  83.         {
  84.             if (File.ReadAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameLeft.txt") != null)
  85.             {
  86.                 File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameLeft.txt", null);
  87.                 File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayDescriptionLeft.txt", null);
  88.             }
  89.             if (File.ReadAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameCenter.txt") != null)
  90.             {
  91.                 File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameCenter.txt", null);
  92.                 File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayDescriptionCenter.txt", null);
  93.             }
  94.             if (File.ReadAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameRight.txt") != null)
  95.             {
  96.                 File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayNameRight.txt", null);
  97.                 File.WriteAllText(MelonLoaderBase.UserDataPath + "\\DisplayDescriptionRight.txt", null);
  98.             }
  99.         }
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement