Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using UnityEngine.UI;
- using Wolfpack;
- // Token: 0x020004EE RID: 1262
- public class Recordplayer : W_NetworkBehaviour
- {
- // Token: 0x06001E01 RID: 7681 RVA: 0x0000E473 File Offset: 0x0000C673
- public Recordplayer()
- {
- }
- // Token: 0x06001E02 RID: 7682 RVA: 0x00116FDC File Offset: 0x001151DC
- private void Start()
- {
- string text = Application.dataPath + "/Mods/Pedram/Music/";
- if (Directory.Exists(text) && File.Exists(text + "list.txt"))
- {
- this.audioNames = File.ReadAllLines(text + "list.txt");
- GameObject gameObject = GameObject.Find("Canvas");
- Transform transform = gameObject.transform.GetChild(4);
- if (transform.name != "MusicPanel")
- {
- Transform[] componentsInChildren = gameObject.GetComponentsInChildren<Transform>();
- for (int i = 0; i < componentsInChildren.Length; i++)
- {
- if (componentsInChildren[i].name == "MusicPanel")
- {
- transform = componentsInChildren[i];
- }
- }
- }
- this.musicContainer = transform.GetChild(0).GetChild(0).GetChild(0).GetChild(0).gameObject;
- if (this.musicContainer.GetComponent<ContentSizeFitter>() == null)
- {
- this.musicContainer.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
- for (int j = 0; j < this.records.Length; j++)
- {
- this.musicContainer.transform.GetChild(j).gameObject.AddComponent<LayoutElement>().preferredHeight = 20f;
- }
- }
- this.musicButton = this.musicContainer.transform.GetChild(0).gameObject;
- this.newlist = new AudioClip[this.audioNames.Length];
- for (int k = 0; k < this.newlist.Length; k++)
- {
- base.StartCoroutine(this.GetAudioClip(text + this.audioNames[k], k));
- }
- }
- this.thisSub = base.GetComponent<W_Uboat>();
- if (W_NetworkManager.instance.isServer)
- {
- this.OnFirstUpdate();
- }
- }
- // Token: 0x06001E03 RID: 7683 RVA: 0x0001441B File Offset: 0x0001261B
- private LocalRecordplayer getLocal()
- {
- if (this.local == null)
- {
- this.local = UnityEngine.Object.FindObjectOfType<LocalRecordplayer>();
- }
- return this.local;
- }
- // Token: 0x06001E04 RID: 7684 RVA: 0x00117194 File Offset: 0x00115394
- public override void instantiateSyncvars(List<SyncBase> list)
- {
- this.b_radioRoom = new SyncedBool(list);
- this.b_radioRoom.editable = true;
- this.b_radioRoom.callback = new Callback(this.radioroomSpeakerOnOff);
- this.b_controlRoom = new SyncedBool(list);
- this.b_controlRoom.editable = true;
- this.b_controlRoom.callback = new Callback(this.controlroomSpeakerOnOff);
- this.b_conningTower = new SyncedBool(list);
- this.b_conningTower.editable = true;
- this.b_conningTower.callback = new Callback(this.conningtowerSpeakerOnOff);
- this.b_outside = new SyncedBool(list);
- this.b_outside.editable = true;
- this.b_outside.callback = new Callback(this.outsideSpeakerOnOff);
- this.playing = new SyncedBool(list);
- this.playing.editable = true;
- this.index = new SyncedInt(list);
- this.index.editable = true;
- this.position = new SyncedFloat(list);
- this.position.editable = true;
- this.insideVolume = new SyncedFloat(list);
- this.insideVolume.editable = true;
- this.insideVolume.callback = new FloatCallback(this.setInsideVolume);
- this.outsideVolume = new SyncedFloat(list);
- this.outsideVolume.editable = true;
- this.outsideVolume.callback = new FloatCallback(this.setOutsideVolume);
- if (W_NetworkManager.instance.isServer)
- {
- this.b_radioRoom.set(true);
- this.b_controlRoom.set(true);
- this.b_conningTower.set(true);
- this.insideVolume.set(1f);
- }
- }
- // Token: 0x06001E05 RID: 7685 RVA: 0x00002AE9 File Offset: 0x00000CE9
- public override void instantiateCommands(List<W_ClientCommand> list)
- {
- }
- // Token: 0x06001E06 RID: 7686 RVA: 0x00002AE9 File Offset: 0x00000CE9
- public override void instantiateRPCS(List<W_RPC> list)
- {
- }
- // Token: 0x06001E07 RID: 7687 RVA: 0x0001443C File Offset: 0x0001263C
- private void setInsideVolume(float old)
- {
- if (this.getLocal() != null)
- {
- this.getLocal().setInsideVolume();
- }
- }
- // Token: 0x06001E08 RID: 7688 RVA: 0x00117344 File Offset: 0x00115544
- private void setOutsideVolume(float old)
- {
- if (this.getLocal() != null)
- {
- this.getLocal().setOutsideVolume();
- this.s_outside.volume = ((!this.b_outside.get()) ? 0f : this.outsideVolume.get());
- }
- }
- // Token: 0x06001E09 RID: 7689 RVA: 0x00014457 File Offset: 0x00012657
- private void radioroomSpeakerOnOff()
- {
- if (this.getLocal() != null)
- {
- this.getLocal().speakerRadioRoomCallback(this.b_radioRoom.get());
- }
- }
- // Token: 0x06001E0A RID: 7690 RVA: 0x0001447D File Offset: 0x0001267D
- private void controlroomSpeakerOnOff()
- {
- if (this.getLocal() != null)
- {
- this.getLocal().speakerControlroomCallback(this.b_controlRoom.get());
- }
- }
- // Token: 0x06001E0B RID: 7691 RVA: 0x000144A3 File Offset: 0x000126A3
- private void conningtowerSpeakerOnOff()
- {
- if (this.getLocal() != null)
- {
- this.getLocal().speakerConningtowerCallback(this.b_conningTower.get());
- }
- }
- // Token: 0x06001E0C RID: 7692 RVA: 0x00117394 File Offset: 0x00115594
- private void outsideSpeakerOnOff()
- {
- if (this.getLocal() != null)
- {
- this.getLocal().speakerBridgeCallback(this.b_outside.get());
- this.s_outside.volume = ((!this.b_outside.get()) ? 0f : this.outsideVolume.get());
- }
- }
- // Token: 0x06001E0D RID: 7693 RVA: 0x001173F0 File Offset: 0x001155F0
- private void Update()
- {
- if (W_Uboat.mySub != null && this.m_playing != this.playing.get())
- {
- this.m_playing = this.playing.get();
- if (this.m_playing)
- {
- this.play(this.position.get());
- }
- else
- {
- this.stop();
- }
- }
- if (this.playing.get() && W_NetworkManager.instance.isServer)
- {
- this.position.set(this.position.get() + Time.deltaTime);
- if (!this.s_outside.isPlaying)
- {
- this.playing.set(false);
- }
- }
- }
- // Token: 0x06001E0E RID: 7694 RVA: 0x001174A0 File Offset: 0x001156A0
- private void play(float startPosition)
- {
- this.s_outside.clip = this.records[this.index.get()];
- this.s_outside.time = startPosition;
- this.s_outside.Play();
- this.outsideSpeakerOnOff();
- if (this.thisSub == W_Uboat.mySub)
- {
- this.getLocal().playCallback(startPosition, this.records[this.index.get()]);
- this.radioroomSpeakerOnOff();
- this.controlroomSpeakerOnOff();
- this.conningtowerSpeakerOnOff();
- }
- }
- // Token: 0x06001E0F RID: 7695 RVA: 0x000144C9 File Offset: 0x000126C9
- public override void OnFirstUpdate()
- {
- this.radioroomSpeakerOnOff();
- this.controlroomSpeakerOnOff();
- this.conningtowerSpeakerOnOff();
- this.outsideSpeakerOnOff();
- this.setInsideVolume(0f);
- this.setOutsideVolume(0f);
- }
- // Token: 0x06001E10 RID: 7696 RVA: 0x000144F9 File Offset: 0x000126F9
- private void stop()
- {
- this.s_outside.Stop();
- if (this.thisSub == W_Uboat.mySub)
- {
- this.getLocal().stopCallback();
- }
- }
- // Token: 0x06001E11 RID: 7697 RVA: 0x00014523 File Offset: 0x00012723
- public void playRecord(int index)
- {
- if (index >= 0 && index < this.records.Length)
- {
- this.index.set(index);
- this.position.set(0f);
- this.playing.set(true);
- }
- }
- // Token: 0x06001E12 RID: 7698 RVA: 0x0001455C File Offset: 0x0001275C
- public void stopRecord()
- {
- this.playing.set(false);
- }
- // Token: 0x06001E13 RID: 7699 RVA: 0x0001456A File Offset: 0x0001276A
- private IEnumerator GetAudioClip(string path, int myIndex)
- {
- WWW www = new WWW("file://" + path);
- yield return www;
- AudioClip audioClip = www.GetAudioClip(false);
- if (audioClip != null)
- {
- this.newlist[myIndex] = audioClip;
- if (myIndex == this.newlist.Length - 1)
- {
- this.SetRecordList();
- }
- }
- yield break;
- }
- // Token: 0x06001E14 RID: 7700 RVA: 0x0011752C File Offset: 0x0011572C
- private void SetRecordList()
- {
- AudioClip[] array = new AudioClip[this.newlist.Length + this.records.Length];
- int num = this.records.Length;
- for (int i = 0; i < this.records.Length; i++)
- {
- array[i] = this.records[i];
- }
- for (int j = 0; j < this.newlist.Length; j++)
- {
- array[j + this.records.Length] = this.newlist[j];
- }
- this.records = array;
- if (this.musicContainer.transform.childCount == num)
- {
- for (int k = num; k < this.records.Length; k++)
- {
- if (this.records[k] != null)
- {
- GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.musicButton, this.musicContainer.transform);
- gameObject.AddComponent<LayoutElement>().preferredHeight = 20f;
- gameObject.GetComponentInChildren<Text>().text = this.audioNames[k - num].Substring(0, this.audioNames[k - num].Length - 4);
- gameObject.GetComponent<RecordPlayButton>().index = k;
- gameObject.GetComponent<Button>().onClick.AddListener(delegate()
- {
- gameObject.GetComponent<RecordPlayButton>().play();
- });
- }
- }
- }
- }
- // Token: 0x040027E3 RID: 10211
- public AudioClip[] records;
- // Token: 0x040027E4 RID: 10212
- public AudioSource s_outside;
- // Token: 0x040027E5 RID: 10213
- public SyncedBool b_radioRoom;
- // Token: 0x040027E6 RID: 10214
- public SyncedBool b_controlRoom;
- // Token: 0x040027E7 RID: 10215
- public SyncedBool b_conningTower;
- // Token: 0x040027E8 RID: 10216
- public SyncedBool b_outside;
- // Token: 0x040027E9 RID: 10217
- public SyncedBool playing;
- // Token: 0x040027EA RID: 10218
- public SyncedFloat position;
- // Token: 0x040027EB RID: 10219
- public SyncedInt index;
- // Token: 0x040027EC RID: 10220
- public SyncedFloat insideVolume;
- // Token: 0x040027ED RID: 10221
- public SyncedFloat outsideVolume;
- // Token: 0x040027EE RID: 10222
- private LocalRecordplayer local;
- // Token: 0x040027EF RID: 10223
- private W_Uboat thisSub;
- // Token: 0x040027F0 RID: 10224
- private bool m_playing;
- // Token: 0x040027F1 RID: 10225
- private AudioClip[] newlist;
- // Token: 0x040027F2 RID: 10226
- private string[] audioNames;
- // Token: 0x040027F3 RID: 10227
- private GameObject musicContainer;
- // Token: 0x040027F4 RID: 10228
- private GameObject musicButton;
- }
Add Comment
Please, Sign In to add comment