Advertisement
EmmyDev

Terminal Execution

Dec 29th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.91 KB | Source Code | 0 0
  1. private IEnumerator COMMAND(string command, string param, TextMeshProUGUI output)
  2.     {
  3.         //override
  4.         if(command == "OVERRIDE")
  5.         {
  6.             int percentage = 0;
  7.             if(GameObject.Find(param) != null && GameObject.Find(param).GetComponent<SecDoor>() != null && GameObject.Find(param).GetComponent<SecDoor>().scanning == true)
  8.             {
  9.                 while(percentage < 100)
  10.                 {
  11.                     output.text = "Overriding " + param + "... [" + percentage + "%]";
  12.                     yield return new WaitForSeconds(0.2f);
  13.                     percentage++;
  14.                 }
  15.                 output.text = "Override success!";
  16.                 GameObject.Find(param).GetComponent<SecDoor>().open = true;
  17.                
  18.             }
  19.             else
  20.             {
  21.                 output.text = "ERROR: " + param + " does not meet the requirements";
  22.                
  23.             }
  24.         }
  25.         else if(command == "QUERY")
  26.         {
  27.             try
  28.             {
  29.                 if(GameObject.FindGameObjectsWithTag(param) != null)
  30.                 {
  31.                
  32.                     output.text = "FOUND:\n";
  33.                     GameObject[] searchedObjects = GameObject.FindGameObjectsWithTag(param);
  34.                     if(searchedObjects[0] == null)
  35.                     {
  36.                         output.text = "Cannot find any objects of type: " + param;
  37.                     }
  38.  
  39.                     foreach (GameObject objs in searchedObjects)
  40.                     {
  41.                         if(objs != searchedObjects[searchedObjects.Length - 1])
  42.                         {
  43.                             output.text += objs.GetComponent<SecDoor>().defName;
  44.  
  45.                             //find mac adress if secDoor
  46.                             if(objs.GetComponent<SecDoor>() != null)
  47.                             {
  48.                                 if(objs.GetComponent<SecDoor>().scanning == false)
  49.                                 {
  50.                                     output.text += " address access denied";
  51.                                 }
  52.                                 else
  53.                                 {
  54.                                     output.text += " address is " + objs.GetComponent<SecDoor>().macAdress;
  55.                                 }
  56.                                
  57.                             }
  58.                             output.text += "\n";
  59.                            
  60.                            
  61.                         }
  62.                         else
  63.                         {
  64.                             output.text += objs.GetComponent<SecDoor>().defName;
  65.                             //find mac adress if secDoor
  66.                             if(objs.GetComponent<SecDoor>() != null)
  67.                             {
  68.                                 if(objs.GetComponent<SecDoor>().scanning == false)
  69.                                 {
  70.                                     output.text += " address access denied";
  71.                                    
  72.                                 }
  73.                                 else
  74.                                 {
  75.                                     output.text += " address is " + objs.GetComponent<SecDoor>().macAdress;
  76.                                    
  77.                                 }
  78.                             }
  79.                            
  80.                         }
  81.                         console.transform.position -= new Vector3(0, 7f, 0);
  82.                     }
  83.                 }
  84.                 console.transform.position -= new Vector3(0, 7f, 0);
  85.             }
  86.             catch
  87.             {
  88.                
  89.                 output.text = "Cannot find any objects of type: " + param;
  90.                 console.transform.position -= new Vector3(0, 7f, 0);
  91.            
  92.             }
  93.            
  94.            
  95.            
  96.         }
  97.        
  98.         yield return null;
  99.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement