mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-20 15:41:01 +00:00
dont set IsRising in the transform sync. instead, do it in resync.
This commit is contained in:
parent
20083188c1
commit
c621761c25
@ -7,7 +7,6 @@ namespace QSB.JellyfishSync.Messages
|
||||
{
|
||||
public JellyfishRisingMessage(bool isRising) => Value = isRising;
|
||||
|
||||
public override void OnReceiveRemote() => WorldObject.IsRising = Value;
|
||||
|
||||
public override void OnReceiveRemote() => WorldObject.SetIsRising(Value);
|
||||
}
|
||||
}
|
||||
|
@ -20,17 +20,16 @@ namespace QSB.JellyfishSync.Patches
|
||||
return true;
|
||||
}
|
||||
|
||||
var qsbJellyfish = __instance.GetWorldObject<QSBJellyfish>();
|
||||
|
||||
var sqrMagnitude = (__instance._jellyfishBody.GetPosition() - __instance._planetBody.GetPosition()).sqrMagnitude;
|
||||
if (qsbJellyfish.IsRising)
|
||||
if (__instance._isRising)
|
||||
{
|
||||
__instance._jellyfishBody.AddAcceleration(__instance.transform.up * __instance._upwardsAcceleration);
|
||||
if (sqrMagnitude > __instance._upperLimit * __instance._upperLimit)
|
||||
{
|
||||
qsbJellyfish.IsRising = false;
|
||||
|
||||
qsbJellyfish.SendMessage(new JellyfishRisingMessage(qsbJellyfish.IsRising));
|
||||
__instance._isRising = false;
|
||||
__instance._attractiveFluidVolume.SetVolumeActivation(true);
|
||||
__instance.GetWorldObject<QSBJellyfish>().SendMessage(new JellyfishRisingMessage(false));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -38,8 +37,9 @@ namespace QSB.JellyfishSync.Patches
|
||||
__instance._jellyfishBody.AddAcceleration(-__instance.transform.up * __instance._downwardsAcceleration);
|
||||
if (sqrMagnitude < __instance._lowerLimit * __instance._lowerLimit)
|
||||
{
|
||||
qsbJellyfish.IsRising = true;
|
||||
qsbJellyfish.SendMessage(new JellyfishRisingMessage(qsbJellyfish.IsRising));
|
||||
__instance._isRising = true;
|
||||
__instance._attractiveFluidVolume.SetVolumeActivation(false);
|
||||
__instance.GetWorldObject<QSBJellyfish>().SendMessage(new JellyfishRisingMessage(true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Mirror;
|
||||
using QSB.AuthoritySync;
|
||||
using QSB.AuthoritySync;
|
||||
using QSB.JellyfishSync.WorldObjects;
|
||||
using QSB.Syncs.Unsectored.Rigidbodies;
|
||||
using QSB.Utility;
|
||||
@ -65,36 +64,9 @@ namespace QSB.JellyfishSync.TransformSync
|
||||
private void OnUnsuspend(OWRigidbody suspendedBody) => netIdentity.SendAuthQueueMessage(AuthQueueAction.Add);
|
||||
private void OnSuspend(OWRigidbody suspendedBody) => netIdentity.SendAuthQueueMessage(AuthQueueAction.Remove);
|
||||
|
||||
private bool _isRising;
|
||||
|
||||
protected override void Serialize(NetworkWriter writer, bool initialState)
|
||||
{
|
||||
base.Serialize(writer, initialState);
|
||||
|
||||
writer.Write(_isRising);
|
||||
}
|
||||
|
||||
protected override void Deserialize(NetworkReader reader, bool initialState)
|
||||
{
|
||||
base.Deserialize(reader, initialState);
|
||||
|
||||
_isRising = reader.ReadBool();
|
||||
}
|
||||
|
||||
protected override void GetFromAttached()
|
||||
{
|
||||
base.GetFromAttached();
|
||||
|
||||
_qsbJellyfish.Align = true;
|
||||
_isRising = _qsbJellyfish.IsRising;
|
||||
}
|
||||
|
||||
/// replacement using SetPosition/Rotation instead of Move
|
||||
protected override void ApplyToAttached()
|
||||
{
|
||||
_qsbJellyfish.Align = false;
|
||||
_qsbJellyfish.IsRising = _isRising;
|
||||
|
||||
var pos = ReferenceTransform.FromRelPos(transform.position);
|
||||
AttachedRigidbody.SetPosition(pos);
|
||||
AttachedRigidbody.SetRotation(ReferenceTransform.FromRelRot(transform.rotation));
|
||||
|
@ -32,24 +32,15 @@ namespace QSB.JellyfishSync.WorldObjects
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRising
|
||||
public void SetIsRising(bool value)
|
||||
{
|
||||
get => AttachedObject._isRising;
|
||||
set
|
||||
if (AttachedObject._isRising == value)
|
||||
{
|
||||
if (AttachedObject._isRising == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AttachedObject._isRising = value;
|
||||
AttachedObject._attractiveFluidVolume.SetVolumeActivation(!value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Align
|
||||
{
|
||||
set => _alignWithTargetBody.enabled = value;
|
||||
AttachedObject._isRising = value;
|
||||
AttachedObject._attractiveFluidVolume.SetVolumeActivation(!value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
using OWML.Common;
|
||||
using QSB.Anglerfish.Messages;
|
||||
using QSB.Anglerfish.WorldObjects;
|
||||
using QSB.CampfireSync.Messages;
|
||||
using QSB.CampfireSync.WorldObjects;
|
||||
using QSB.ClientServerStateSync;
|
||||
using QSB.ClientServerStateSync.Messages;
|
||||
using QSB.ConversationSync.Messages;
|
||||
using QSB.JellyfishSync.Messages;
|
||||
using QSB.JellyfishSync.WorldObjects;
|
||||
using QSB.LogSync.Messages;
|
||||
using QSB.Messaging;
|
||||
using QSB.MeteorSync.Messages;
|
||||
@ -148,6 +152,26 @@ namespace QSB.Player.Messages
|
||||
qsbOrb.SendMessage(new OrbDragMessage(qsbOrb.AttachedObject._isBeingDragged) { To = From });
|
||||
qsbOrb.SendMessage(new OrbSlotMessage(qsbOrb.AttachedObject._slots.IndexOf(qsbOrb.AttachedObject._occupiedSlot)) { To = From });
|
||||
}
|
||||
|
||||
foreach (var qsbJellyfish in QSBWorldSync.GetWorldObjects<QSBJellyfish>())
|
||||
{
|
||||
if (!qsbJellyfish.TransformSync.hasAuthority)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
qsbJellyfish.SendMessage(new JellyfishRisingMessage(qsbJellyfish.AttachedObject._isRising));
|
||||
}
|
||||
|
||||
foreach (var qsbAngler in QSBWorldSync.GetWorldObjects<QSBAngler>())
|
||||
{
|
||||
if (!qsbAngler.TransformSync.hasAuthority)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user