LethalCompany/Lethal Company/ExportedProject/Assets/Scripts/Assembly-CSharp/NoisemakerProp.cs

70 lines
1.7 KiB
C#
Raw Normal View History

2023-12-22 22:51:17 +00:00
using System;
using UnityEngine;
public class NoisemakerProp : GrabbableObject
{
public AudioSource noiseAudio;
public AudioSource noiseAudioFar;
[Space(3f)]
public AudioClip[] noiseSFX;
public AudioClip[] noiseSFXFar;
[Space(3f)]
public float noiseRange;
public float maxLoudness;
public float minLoudness;
public float minPitch;
public float maxPitch;
private System.Random noisemakerRandom;
public Animator triggerAnimator;
public override void Start()
{
base.Start();
noisemakerRandom = new System.Random(StartOfRound.Instance.randomMapSeed + 85);
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
base.ItemActivate(used, buttonDown);
if (!(GameNetworkManager.Instance.localPlayerController == null))
{
int num = noisemakerRandom.Next(0, noiseSFX.Length);
float num2 = (float)noisemakerRandom.Next((int)(minLoudness * 100f), (int)(maxLoudness * 100f)) / 100f;
float pitch = (float)noisemakerRandom.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
noiseAudio.pitch = pitch;
noiseAudio.PlayOneShot(noiseSFX[num], num2);
if (noiseAudioFar != null)
{
noiseAudioFar.pitch = pitch;
noiseAudioFar.PlayOneShot(noiseSFXFar[num], num2);
}
if (triggerAnimator != null)
{
triggerAnimator.SetTrigger("playAnim");
}
WalkieTalkie.TransmitOneShotAudio(noiseAudio, noiseSFX[num], num2);
RoundManager.Instance.PlayAudibleNoise(base.transform.position, noiseRange, num2, 0, isInElevator && StartOfRound.Instance.hangarDoorsClosed);
}
}
protected override void __initializeVariables()
{
base.__initializeVariables();
}
protected internal override string __getTypeName()
{
return "NoisemakerProp";
}
}