mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-21 00:39:53 +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);
|
||||
}
|
||||
|
@ -29,5 +29,5 @@ public class StationaryProbeLauncherVariableSync : RotatingElementsVariableSynce
|
||||
launcher._degreesX = reader.Read<float>();
|
||||
launcher._degreesY = reader.Read<float>();
|
||||
launcher._audioSource.SetLocalVolume(reader.Read<float>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user