mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-22 03:40:54 +00:00
Reorganize + use right method to play audio
This commit is contained in:
parent
a328a99a0c
commit
593388b110
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user