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

@ -29,5 +29,5 @@ public class StationaryProbeLauncherVariableSync : RotatingElementsVariableSynce
launcher._degreesX = reader.Read<float>();
launcher._degreesY = reader.Read<float>();
launcher._audioSource.SetLocalVolume(reader.Read<float>());
}
}
}

View File

@ -77,26 +77,7 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject<S
this.SendMessage(new StationaryProbeLauncherMessage(_isInUse) { To = to });
}
private void UpdateUse()
{
// Stuff can be null when its sending the initial state info
if (!_isInit) return;
// If somebody is using this we disable the interaction shape
_shape.enabled = !_isInUse;
if (_isInUse)
{
_stationaryProbeLauncher._audioSource.SetLocalVolume(0f);
_stationaryProbeLauncher._audioSource.Start();
}
else
{
_stationaryProbeLauncher._audioSource.Stop();
}
}
public void OnUseStateChanged(bool isInUse, uint from)
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);
@ -105,4 +86,23 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject<S
UpdateUse();
}
private void UpdateUse()
{
// Stuff can be null when its sending the initial state info
if (!_isInit) return;
// If somebody is using this we disable the interaction shape
_shape.enabled = !_isInUse;
if (_isInUse)
{
_stationaryProbeLauncher._audioSource.SetLocalVolume(0f);
_stationaryProbeLauncher._audioSource.Play();
}
else
{
_stationaryProbeLauncher._audioSource.Stop();
}
}
}