mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-30 03:32:47 +00:00
format
This commit is contained in:
parent
a2d34c22bc
commit
236254f8ea
@ -5,29 +5,30 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace QSB.StationaryProbeLauncherSync.VariableSync;
|
namespace QSB.StationaryProbeLauncherSync.VariableSync;
|
||||||
|
|
||||||
|
// TODO: use base variable sync instead of doing transform, uses less network bandwidth lol
|
||||||
public class StationaryProbeLauncherVariableSync : RotatingElementsVariableSyncer<QSBStationaryProbeLauncher>
|
public class StationaryProbeLauncherVariableSync : RotatingElementsVariableSyncer<QSBStationaryProbeLauncher>
|
||||||
{
|
{
|
||||||
protected override Transform[] RotatingElements => new Transform[] { WorldObject.AttachedObject.transform };
|
protected override Transform[] RotatingElements => new[] { WorldObject.AttachedObject.transform };
|
||||||
|
|
||||||
protected override void Serialize(NetworkWriter writer)
|
protected override void Serialize(NetworkWriter writer)
|
||||||
{
|
{
|
||||||
base.Serialize(writer);
|
base.Serialize(writer);
|
||||||
|
|
||||||
var launcher = WorldObject.AttachedObject as StationaryProbeLauncher;
|
var launcher = (StationaryProbeLauncher)WorldObject.AttachedObject;
|
||||||
|
|
||||||
writer.Write(launcher._degreesX);
|
writer.Write(launcher._degreesX);
|
||||||
writer.Write(launcher._degreesY);
|
writer.Write(launcher._degreesY);
|
||||||
writer.Write(launcher._audioSource.GetLocalVolume());
|
writer.Write(launcher._audioSource.GetLocalVolume());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Deserialize(NetworkReader reader)
|
protected override void Deserialize(NetworkReader reader)
|
||||||
{
|
{
|
||||||
base.Deserialize(reader);
|
base.Deserialize(reader);
|
||||||
|
|
||||||
var launcher = WorldObject.AttachedObject as StationaryProbeLauncher;
|
var launcher = (StationaryProbeLauncher)WorldObject.AttachedObject;
|
||||||
|
|
||||||
launcher._degreesX = reader.Read<float>();
|
launcher._degreesX = reader.Read<float>();
|
||||||
launcher._degreesY = reader.Read<float>();
|
launcher._degreesY = reader.Read<float>();
|
||||||
launcher._audioSource.SetLocalVolume(reader.Read<float>());
|
launcher._audioSource.SetLocalVolume(reader.Read<float>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,10 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject<S
|
|||||||
{
|
{
|
||||||
// Whoever is using it needs authority to be able to rotate it
|
// Whoever is using it needs authority to be able to rotate it
|
||||||
// If this is a client they'll get authority from the host when the message is received otherwise give now
|
// If this is a client they'll get authority from the host when the message is received otherwise give now
|
||||||
if (QSBCore.IsHost) NetworkBehaviour.netIdentity.SetAuthority(QSBPlayerManager.LocalPlayerId);
|
if (QSBCore.IsHost)
|
||||||
|
{
|
||||||
|
NetworkBehaviour.netIdentity.SetAuthority(QSBPlayerManager.LocalPlayerId);
|
||||||
|
}
|
||||||
|
|
||||||
_isInUse = true;
|
_isInUse = true;
|
||||||
this.SendMessage(new StationaryProbeLauncherMessage(_isInUse));
|
this.SendMessage(new StationaryProbeLauncherMessage(_isInUse));
|
||||||
@ -77,7 +80,10 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject<S
|
|||||||
public void OnRemoteUseStateChanged(bool isInUse, uint from)
|
public void OnRemoteUseStateChanged(bool isInUse, uint from)
|
||||||
{
|
{
|
||||||
// Whoever is using it needs authority to be able to rotate it
|
// Whoever is using it needs authority to be able to rotate it
|
||||||
if (QSBCore.IsHost) NetworkBehaviour.netIdentity.SetAuthority(from);
|
if (QSBCore.IsHost)
|
||||||
|
{
|
||||||
|
NetworkBehaviour.netIdentity.SetAuthority(from);
|
||||||
|
}
|
||||||
|
|
||||||
_isInUse = isInUse;
|
_isInUse = isInUse;
|
||||||
|
|
||||||
@ -88,7 +94,10 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject<S
|
|||||||
{
|
{
|
||||||
// Stuff can be null when its sending the initial state info
|
// Stuff can be null when its sending the initial state info
|
||||||
// BUG: uhhh how? this shouldnt be possible since initial state happens AFTER AllObjectsReady
|
// BUG: uhhh how? this shouldnt be possible since initial state happens AFTER AllObjectsReady
|
||||||
if (!_isInit) return;
|
if (!_isInit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If somebody is using this we disable the interaction shape
|
// If somebody is using this we disable the interaction shape
|
||||||
_stationaryProbeLauncher._interactVolume.SetInteractionEnabled(!_isInUse);
|
_stationaryProbeLauncher._interactVolume.SetInteractionEnabled(!_isInUse);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user