Advertisement
Guest User

Untitled

a guest
Dec 4th, 2015
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. using spaar;
  8. using System.IO;
  9. using spaar.ModLoader;
  10.  
  11.  
  12. public class CopyPasteSettingsLoader : spaar.ModLoader.Mod{
  13. public CopyPasteSettingsLoader(){
  14. Debug.Log("Started the CopyPasteSettings mod!");
  15. }
  16.  
  17. public override string Name {
  18. get { return "CopyPasteSettings"; }
  19. }
  20.  
  21. public override string Author {
  22. get { return "ITR"; }
  23. }
  24.  
  25. public override string DisplayName {
  26. get { return "CopyPasteSettings"; }
  27. }
  28.  
  29. AGMwo agmWO;
  30. public override void OnLoad() {
  31. Game.DontDestroyOnLoad(agmWO = AGMwo.Instance);
  32. }
  33.  
  34. public override void OnUnload() {
  35.  
  36. }
  37.  
  38. public override Version Version {
  39. get { return new Version(3,0,0); }
  40. }
  41. }
  42.  
  43. class AGMwo : SingleInstance<AGMwo>{
  44. CopyPasteSettingsCoreMod agm = new CopyPasteSettingsCoreMod();
  45. public void Update() {
  46. agm.Update();
  47. }
  48.  
  49. Rect windowRect = new Rect(0,75,200,45);
  50. Rect smallRect = new Rect(0,20,200,20);
  51.  
  52. void OnGUI() {
  53. windowRect = GUI.Window(0,windowRect,DoMyWindow,"CopyPasteSettings");
  54. }
  55. void DoMyWindow(int windowID) {
  56. agm.G(smallRect);
  57. GUI.DragWindow();
  58. }
  59.  
  60.  
  61. public override string Name {
  62. get { return "CopyPasteSettings"; }
  63. }
  64. }
  65.  
  66. public class CopyPasteSettingsCoreMod{
  67. GameObject gm;
  68. BlockInfoController blockInfoController;
  69.  
  70. bool pasteBuild = false;
  71. int n = 0;
  72. int n2 = 0;
  73.  
  74. bool shownError = false;
  75.  
  76. MyBlockInfo myBlockInfo;
  77.  
  78. public void pasteInfo() {
  79. for(int x = n;x<=n;x++) {
  80. GameObject gm = GameObject.Find("bsg"+x.ToString());
  81. if(gm!=null) {
  82. if(x==n)
  83. n++;
  84. if(!pasteBuild||myBlockInfo==null)
  85. continue;
  86. MyBlockInfo tempBlockInfo = gm.GetComponent<MyBlockInfo>();
  87. if(tempBlockInfo.blockName==myBlockInfo.blockName) {
  88. tempBlockInfo.toggleModeEnabled = myBlockInfo.toggleModeEnabled;
  89. tempBlockInfo.sliderValue = myBlockInfo.sliderValue;
  90. tempBlockInfo.key1 = myBlockInfo.key1;
  91. tempBlockInfo.key2 = myBlockInfo.key2;
  92. }
  93. }
  94. }
  95. for(int x = n2;x<=n2;x++) {
  96. GameObject gm = GameObject.Find("bgeL"+x.ToString());
  97. if(gm!=null) {
  98. if(x==n2)
  99. n2++;
  100. if(!pasteBuild||myBlockInfo==null)
  101. continue;
  102. MyBlockInfo tempBlockInfo = gm.GetComponent<MyBlockInfo>();
  103. if(tempBlockInfo.blockName==myBlockInfo.blockName) {
  104. tempBlockInfo.toggleModeEnabled = myBlockInfo.toggleModeEnabled;
  105. tempBlockInfo.sliderValue = myBlockInfo.sliderValue;
  106. tempBlockInfo.key1 = myBlockInfo.key1;
  107. tempBlockInfo.key2 = myBlockInfo.key2;
  108. }
  109. }
  110. }
  111. }
  112.  
  113. public void G(Rect rect){
  114. if(AddPiece.isSimulating)
  115. return;
  116. GUILayout.BeginArea(rect);
  117. GUILayout.BeginHorizontal();
  118. GUILayout.FlexibleSpace();
  119. try {
  120. pasteBuild = GUILayout.Toggle(pasteBuild,"auto paste settings");
  121. shownError = false;
  122. }
  123. catch (Exception e) {
  124. if(!shownError)
  125. Debug.Log("CopyPaste error: "+e.ToString());
  126. shownError = true;
  127. }
  128. GUILayout.FlexibleSpace();
  129. GUILayout.EndHorizontal();
  130. GUILayout.EndArea();
  131. // GUILayout.BeginArea(new Rect(0,78,40,300));
  132. // GUILayout.Label("n: "+n.ToString()+" n2:"+n2.ToString());
  133. // if(myBlockInfo!=null)
  134. // GUILayout.Label(myBlockInfo.blockName);
  135. // GUILayout.EndArea();
  136. }
  137.  
  138. public void Update(){
  139. if(AddPiece.isSimulating)
  140. return;
  141. if(gm==null){
  142. gm = GameObject.Find("BLOCK INFO CONTROLLER");
  143. if(gm!=null)
  144. Debug.Log("found \"BLOCK INFO CONTROLLER\"");
  145. }
  146. else{
  147. if(blockInfoController==null) {
  148. blockInfoController = gm.GetComponent<BlockInfoController>();
  149. if(blockInfoController!=null)
  150. Debug.Log("found \"JoinOnTriggerBlock\"");
  151. }
  152. else {
  153. if(blockInfoController.menuHolder.gameObject.activeSelf) {
  154. myBlockInfo = blockInfoController.activeBlockInfoCode;
  155. }
  156. }
  157. }
  158. pasteInfo();
  159. }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement