mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-11 19:13:32 +00:00
make sure detachable isnt recursive
This commit is contained in:
parent
8f797a22ab
commit
db69f220eb
@ -29,7 +29,6 @@ public class PlayerJoinMessage : QSBMessage
|
||||
|
||||
FirstIncompatibleMod = "";
|
||||
|
||||
#if RELEASE
|
||||
foreach (var mod in allEnabledMods)
|
||||
{
|
||||
if (QSBCore.IncompatibleMods.Contains(mod.ModHelper.Manifest.UniqueName))
|
||||
@ -37,7 +36,6 @@ public class PlayerJoinMessage : QSBMessage
|
||||
FirstIncompatibleMod = mod.ModHelper.Manifest.UniqueName;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
AddonHashes = QSBCore.Addons.Keys
|
||||
.Select(x => x.GetStableHashCode())
|
||||
|
11
QSB/ShipSync/Messages/LegDetachMessage.cs
Normal file
11
QSB/ShipSync/Messages/LegDetachMessage.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.ShipSync.WorldObjects;
|
||||
|
||||
namespace QSB.ShipSync.Messages;
|
||||
|
||||
internal class LegDetachMessage : QSBWorldObjectMessage<QSBShipDetachableLeg>
|
||||
{
|
||||
public override void OnReceiveRemote() =>
|
||||
QSBPatch.RemoteCall(WorldObject.AttachedObject.Detach);
|
||||
}
|
@ -1,17 +1,11 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.ShipSync.WorldObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QSB.ShipSync.Messages;
|
||||
|
||||
internal class ModuleDetachMessage : QSBWorldObjectMessage<QSBShipDetachableModule>
|
||||
{
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
WorldObject.AttachedObject.Detach();
|
||||
}
|
||||
public override void OnReceiveRemote() =>
|
||||
QSBPatch.RemoteCall(WorldObject.AttachedObject.Detach);
|
||||
}
|
||||
|
@ -3,9 +3,7 @@ using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.ShipSync.Messages;
|
||||
using QSB.ShipSync.WorldObjects;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.ShipSync.Patches;
|
||||
|
||||
@ -14,10 +12,47 @@ internal class ShipDetachableModulePatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(ShipDetachableModule.Detach))]
|
||||
public static void Detach(ShipDetachableModule __instance)
|
||||
{
|
||||
if (Remote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.isDetached)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
__instance.GetWorldObject<QSBShipDetachableModule>().SendMessage(new ModuleDetachMessage());
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(ShipDetachableLeg.Detach))]
|
||||
public static void Detach(ShipDetachableLeg __instance)
|
||||
{
|
||||
if (Remote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.isDetached)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
__instance.GetWorldObject<QSBShipDetachableLeg>().SendMessage(new LegDetachMessage());
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,12 @@ internal class ShipLegTransformSync : SectoredRigidbodySync, ILinkedNetworkBehav
|
||||
/// </summary>
|
||||
protected override bool CheckValid()
|
||||
=> AttachedTransform
|
||||
&& base.CheckValid();
|
||||
&& base.CheckValid();
|
||||
|
||||
protected override bool CheckReady()
|
||||
=> _qsbModule != null
|
||||
&& _qsbModule.AttachedObject.isDetached
|
||||
&& base.CheckReady();
|
||||
&& _qsbModule.AttachedObject.isDetached
|
||||
&& base.CheckReady();
|
||||
|
||||
protected override bool UseInterpolation => true;
|
||||
protected override float DistanceChangeThreshold => 1f;
|
||||
@ -32,14 +32,4 @@ internal class ShipLegTransformSync : SectoredRigidbodySync, ILinkedNetworkBehav
|
||||
SectorDetector.Init(owRigidbody.transform.Find("DetectorVolume").GetComponent<SectorDetector>());
|
||||
return owRigidbody;
|
||||
}
|
||||
|
||||
protected override void ApplyToAttached()
|
||||
{
|
||||
if (!_qsbModule.AttachedObject.isDetached)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.ApplyToAttached();
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,12 @@ internal class ShipModuleTransformSync : SectoredRigidbodySync, ILinkedNetworkBe
|
||||
/// </summary>
|
||||
protected override bool CheckValid()
|
||||
=> AttachedTransform
|
||||
&& base.CheckValid();
|
||||
&& base.CheckValid();
|
||||
|
||||
protected override bool CheckReady()
|
||||
=> _qsbModule != null
|
||||
&& _qsbModule.AttachedObject.isDetached
|
||||
&& base.CheckReady();
|
||||
&& _qsbModule.AttachedObject.isDetached
|
||||
&& base.CheckReady();
|
||||
|
||||
protected override bool UseInterpolation => true;
|
||||
protected override float DistanceChangeThreshold => 1f;
|
||||
@ -32,14 +32,4 @@ internal class ShipModuleTransformSync : SectoredRigidbodySync, ILinkedNetworkBe
|
||||
SectorDetector.Init(owRigidbody.transform.Find("DetectorVolume").GetComponent<SectorDetector>());
|
||||
return owRigidbody;
|
||||
}
|
||||
|
||||
protected override void ApplyToAttached()
|
||||
{
|
||||
if (!_qsbModule.AttachedObject.isDetached)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.ApplyToAttached();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user