Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///RECON STATION CODE
- using System;
- using System.Collections.Generic;
- using System.Text;
- using TombsMadnessMod.ItemScript;
- using UnityEngine;
- namespace TombsMadnessMod.Unlockables
- {
- public class ReconStation : MonoBehaviour
- {
- public static readonly List<RangedMicrophone> rangedMicrophones = new List<RangedMicrophone>();
- public int tuneIndex;
- private bool enabled;
- public void PowerButtonPress()
- {
- enabled = !enabled;
- if (!enabled)
- {
- foreach (var rangedMics in rangedMicrophones) { rangedMics.StopRecording(); }
- }
- else
- {
- if (rangedMicrophones.Count > 0) { rangedMicrophones[tuneIndex].StartRecording(); }
- }
- TombsMadnessModBase.mls.LogWarning("the Recon Station have been turned on!");
- }
- public void SwitchChannelForwordButton()
- {
- if(enabled)
- {
- if (rangedMicrophones.Count > 1 && tuneIndex < rangedMicrophones.Count - 1)
- {
- rangedMicrophones[tuneIndex].StopRecording();
- tuneIndex++;
- rangedMicrophones[tuneIndex].StartRecording();
- TombsMadnessModBase.mls.LogWarning("Shifting to the next mic in the list with an index of " + tuneIndex);
- }
- TombsMadnessModBase.mls.LogWarning("looks like the forword button was pressed");
- }
- }
- public void SwitchChannelBackButton()
- {
- if (enabled)
- {
- if (rangedMicrophones.Count > 1 && tuneIndex > 0)
- {
- rangedMicrophones[tuneIndex].StopRecording();
- tuneIndex--;
- rangedMicrophones[tuneIndex].StartRecording();
- TombsMadnessModBase.mls.LogWarning("Shifting to the last mic in the list with an index of " + tuneIndex);
- }
- TombsMadnessModBase.mls.LogWarning("looks like the back button was pressed");
- }
- }
- }
- }
- ///RANGED MIC CODE
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using TombsMadnessMod.Unlockables;
- using UnityEngine;
- using UnityEngine.InputSystem;
- namespace TombsMadnessMod.ItemScript
- {
- public class RangedMicrophone : GrabbableObject
- {
- private ModdedUI m_UI;
- public bool isPowerd;
- public bool tunedInto;
- public float micRange;
- private AudioSource audioSource;
- private AudioListener playerAudioListener;
- private AudioListener micAudioListener;
- public AudioClip[] stopTransmissionSFX;
- public AudioClip[] startTransmissionSFX;
- public AudioClip clickON;
- public void Awake()
- {
- TombsMadnessModBase.mls.LogInfo("RangedMicrophone Awake");
- m_UI = TombsMadnessModBase.ModdedUI.GetComponent<ModdedUI>();
- ReconStation.rangedMicrophones.Add(this);
- }
- public override void Start()
- {
- base.Start();
- playerAudioListener = StartOfRound.Instance.localPlayerController.activeAudioListener;
- audioSource = GetComponent<AudioSource>();
- micAudioListener = this.GetComponent<AudioListener>();
- }
- public override void OnDestroy()
- {
- base.OnDestroy();
- ReconStation.rangedMicrophones.Remove(this);
- }
- public override void ItemActivate(bool used, bool buttonDown = true)
- {
- base.ItemActivate(used, buttonDown);
- SwitchOn(used);
- audioSource.pitch = UnityEngine.Random.Range(0.7f, 1.3f);
- audioSource.PlayOneShot(clickON);
- }
- public void SwitchOn(bool enabled)
- {
- isBeingUsed = enabled;
- }
- public void StartRecording()
- {
- TombsMadnessModBase.mls.LogWarning(this.name + " has started recording!");
- playerAudioListener.enabled = false;
- micAudioListener.enabled = true;
- }
- public void StopRecording()
- {
- TombsMadnessModBase.mls.LogWarning(this.name + " has Stopped recording!");
- playerAudioListener.enabled = true;
- micAudioListener.enabled = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement