Advertisement
glados123123123123

Untitled

Jan 7th, 2024
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.47 KB | None | 0 0
  1. ///RECON STATION CODE
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using TombsMadnessMod.ItemScript;
  6. using UnityEngine;
  7.  
  8. namespace TombsMadnessMod.Unlockables
  9. {
  10.     public class ReconStation : MonoBehaviour
  11.     {
  12.         public static readonly List<RangedMicrophone> rangedMicrophones = new List<RangedMicrophone>();
  13.         public int tuneIndex;
  14.         private bool enabled;
  15.  
  16.         public void PowerButtonPress()
  17.         {
  18.             enabled = !enabled;
  19.             if (!enabled)
  20.             {
  21.                 foreach (var rangedMics in rangedMicrophones) { rangedMics.StopRecording(); }
  22.             }
  23.             else
  24.             {
  25.                 if (rangedMicrophones.Count > 0) { rangedMicrophones[tuneIndex].StartRecording(); }
  26.                
  27.             }
  28.  
  29.             TombsMadnessModBase.mls.LogWarning("the Recon Station have been turned on!");
  30.         }
  31.  
  32.         public void SwitchChannelForwordButton()
  33.         {
  34.             if(enabled)
  35.             {
  36.                 if (rangedMicrophones.Count > 1 && tuneIndex < rangedMicrophones.Count - 1)
  37.                 {
  38.                     rangedMicrophones[tuneIndex].StopRecording();
  39.                     tuneIndex++;
  40.                     rangedMicrophones[tuneIndex].StartRecording();
  41.                     TombsMadnessModBase.mls.LogWarning("Shifting to the next mic in the list with an index of " + tuneIndex);
  42.                 }
  43.                 TombsMadnessModBase.mls.LogWarning("looks like the forword button was pressed");
  44.             }
  45.         }
  46.         public void SwitchChannelBackButton()
  47.         {
  48.             if (enabled)
  49.             {
  50.                 if (rangedMicrophones.Count > 1 && tuneIndex > 0)
  51.                 {
  52.                     rangedMicrophones[tuneIndex].StopRecording();
  53.                     tuneIndex--;
  54.                     rangedMicrophones[tuneIndex].StartRecording();
  55.                     TombsMadnessModBase.mls.LogWarning("Shifting to the last mic in the list with an index of " + tuneIndex);
  56.                 }
  57.                 TombsMadnessModBase.mls.LogWarning("looks like the back button was pressed");
  58.             }
  59.         }
  60.  
  61.     }
  62. }
  63.  
  64. ///RANGED MIC CODE
  65.  
  66. using System;
  67. using System.Collections.Generic;
  68. using System.Linq;
  69. using System.Text;
  70. using TombsMadnessMod.Unlockables;
  71. using UnityEngine;
  72. using UnityEngine.InputSystem;
  73.  
  74. namespace TombsMadnessMod.ItemScript
  75. {
  76.     public class RangedMicrophone : GrabbableObject
  77.     {
  78.         private ModdedUI m_UI;
  79.         public bool isPowerd;
  80.         public bool tunedInto;
  81.         public float micRange;
  82.  
  83.         private AudioSource audioSource;
  84.  
  85.         private AudioListener playerAudioListener;
  86.         private AudioListener micAudioListener;
  87.  
  88.         public AudioClip[] stopTransmissionSFX;
  89.          
  90.         public AudioClip[] startTransmissionSFX;
  91.          
  92.         public AudioClip clickON;
  93.  
  94.  
  95.         public void Awake()
  96.         {
  97.             TombsMadnessModBase.mls.LogInfo("RangedMicrophone Awake");
  98.             m_UI = TombsMadnessModBase.ModdedUI.GetComponent<ModdedUI>();
  99.             ReconStation.rangedMicrophones.Add(this);
  100.         }
  101.         public override void Start()
  102.         {
  103.             base.Start();
  104.             playerAudioListener = StartOfRound.Instance.localPlayerController.activeAudioListener;
  105.             audioSource = GetComponent<AudioSource>();
  106.             micAudioListener = this.GetComponent<AudioListener>();
  107.         }
  108.  
  109.  
  110.         public override void OnDestroy()
  111.         {
  112.             base.OnDestroy();
  113.             ReconStation.rangedMicrophones.Remove(this);
  114.         }
  115.  
  116.         public override void ItemActivate(bool used, bool buttonDown = true)
  117.         {
  118.             base.ItemActivate(used, buttonDown);
  119.             SwitchOn(used);
  120.             audioSource.pitch = UnityEngine.Random.Range(0.7f, 1.3f);
  121.             audioSource.PlayOneShot(clickON);
  122.         }
  123.  
  124.         public void SwitchOn(bool enabled)
  125.         {
  126.             isBeingUsed = enabled;
  127.         }
  128.  
  129.         public void StartRecording()
  130.         {
  131.             TombsMadnessModBase.mls.LogWarning(this.name + " has started recording!");
  132.             playerAudioListener.enabled = false;
  133.             micAudioListener.enabled = true;
  134.         }
  135.  
  136.         public void StopRecording()
  137.         {
  138.             TombsMadnessModBase.mls.LogWarning(this.name + " has Stopped recording!");
  139.             playerAudioListener.enabled = true;
  140.             micAudioListener.enabled = false;
  141.         }
  142.  
  143.     }
  144. }
  145.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement