Reorganize + use right method to play audio

This commit is contained in:
Nick 2022-08-26 18:52:20 -04:00
parent a328a99a0c
commit 593388b110
3 changed files with 22 additions and 22 deletions

View File

@ -7,5 +7,5 @@ public class StationaryProbeLauncherMessage : QSBWorldObjectMessage<QSBStationar
{
public StationaryProbeLauncherMessage(bool inUse) : base(inUse) { }
public override void OnReceiveRemote() => WorldObject.OnUseStateChanged(Data, From);
public override void OnReceiveRemote() => WorldObject.OnRemoteUseStateChanged(Data, From);
}

View File

@ -77,6 +77,16 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject<S
this.SendMessage(new StationaryProbeLauncherMessage(_isInUse) { To = to });
}
public void OnRemoteUseStateChanged(bool isInUse, uint from)
{
// Whoever is using it needs authority to be able to rotate it
if (QSBCore.IsHost) NetworkBehaviour.netIdentity.SetAuthority(from);
_isInUse = isInUse;
UpdateUse();
}
private void UpdateUse()
{
// Stuff can be null when its sending the initial state info
@ -88,21 +98,11 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject<S
if (_isInUse)
{
_stationaryProbeLauncher._audioSource.SetLocalVolume(0f);
_stationaryProbeLauncher._audioSource.Start();
_stationaryProbeLauncher._audioSource.Play();
}
else
{
_stationaryProbeLauncher._audioSource.Stop();
}
}
public void OnUseStateChanged(bool isInUse, uint from)
{
// Whoever is using it needs authority to be able to rotate it
if (QSBCore.IsHost) NetworkBehaviour.netIdentity.SetAuthority(from);
_isInUse = isInUse;
UpdateUse();
}
}