This commit is contained in:
Mister_Nebula 2022-08-24 08:15:51 +01:00
commit ca42319262
5 changed files with 18 additions and 46 deletions

View File

@ -111,6 +111,11 @@ internal class LightSensorPatches : QSBPatch
_illuminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList);
}
__instance.UpdateIllumination();
if (__instance._illuminatingDreamLanternList != null &&
!__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList))
{
qsbLightSensor.SendMessage(new IlluminatingLanternsMessage(__instance._illuminatingDreamLanternList));
}
if (!illuminated && __instance._illuminated)
{
__instance.OnDetectLight.Invoke();
@ -121,11 +126,6 @@ internal class LightSensorPatches : QSBPatch
__instance.OnDetectDarkness.Invoke();
qsbLightSensor.SendMessage(new SetIlluminatedMessage(false));
}
if (__instance._illuminatingDreamLanternList != null &&
!__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList))
{
qsbLightSensor.SendMessage(new IlluminatingLanternsMessage(__instance._illuminatingDreamLanternList));
}
}
var locallyIlluminated = qsbLightSensor._locallyIlluminated;
@ -165,6 +165,11 @@ internal class LightSensorPatches : QSBPatch
_illuminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList);
}
__instance.UpdateIllumination();
if (__instance._illuminatingDreamLanternList != null &&
!__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList))
{
new PlayerIlluminatingLanternsMessage(QSBPlayerManager.LocalPlayerId, __instance._illuminatingDreamLanternList).Send();
}
if (!illuminated && __instance._illuminated)
{
__instance.OnDetectLight.Invoke();
@ -175,11 +180,6 @@ internal class LightSensorPatches : QSBPatch
__instance.OnDetectDarkness.Invoke();
new PlayerSetIlluminatedMessage(QSBPlayerManager.LocalPlayerId, false).Send();
}
if (__instance._illuminatingDreamLanternList != null &&
!__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList))
{
new PlayerIlluminatingLanternsMessage(QSBPlayerManager.LocalPlayerId, __instance._illuminatingDreamLanternList).Send();
}
return false;
}

View File

@ -10,7 +10,7 @@ namespace QSB.EchoesOfTheEye.RaftSync.TransformSync;
public class RaftTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehaviour
{
protected override bool UseInterpolation => Locator.GetPlayerController().GetGroundBody() != AttachedRigidbody; /*TODO: test that this doesnt NRE*/
protected override bool UseInterpolation => Locator.GetPlayerController().GetGroundBody() != AttachedRigidbody;
private float _lastSetPositionTime;
private const float ForcePositionAfterTime = 1;
@ -74,8 +74,8 @@ public class RaftTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehaviou
/// </summary>
protected override void ApplyToAttached()
{
var targetPos = ReferenceTransform.FromRelPos(transform.position);
var targetRot = ReferenceTransform.FromRelRot(transform.rotation);
var targetPos = ReferenceTransform.FromRelPos(UseInterpolation ? SmoothPosition : transform.position);
var targetRot = ReferenceTransform.FromRelRot(UseInterpolation ? SmoothRotation : transform.rotation);
var onRaft = Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody;
if (onRaft)

View File

@ -131,6 +131,7 @@ public static class QSBPlayerManager
public static IEnumerator ValidatePlayers()
{
// BUG: this does not work. try using a ping (heartbeat) message to detect whether the player actually exists. if they dont, kick the player.
while (true)
{
if (QSBCore.IsInMultiplayer && QSBCore.IsHost)

View File

@ -29,25 +29,8 @@ public class PlayerTransformSync : SectoredTransformSync
private Transform _visibleStickTip;
private Transform _networkStickTip => _networkStickPivot.GetChild(0);
private bool _hasRanOnStartClient;
public override void OnStartClient()
{
if (_hasRanOnStartClient)
{
DebugLog.ToConsole($"ERROR - OnStartClient is being called AGAIN for {Player.PlayerId}'s PlayerTransformSync!", MessageType.Error);
return;
}
_hasRanOnStartClient = true;
if (QSBPlayerManager.PlayerList.Any(x => x.TransformSync == this))
{
// this really shouldnt happen...
DebugLog.ToConsole($"Error - A PlayerInfo already exists with TransformSync {name}", MessageType.Error);
Destroy(gameObject); // probably bad
return;
}
var player = new PlayerInfo(this);
QSBPlayerManager.PlayerList.SafeAdd(player);
base.OnStartClient();
@ -57,19 +40,7 @@ public class PlayerTransformSync : SectoredTransformSync
JoinLeaveSingularity.Create(Player, true);
}
public override void OnStartLocalPlayer()
{
if (LocalInstance != null)
{
DebugLog.ToConsole($"ERROR - LocalInstance is already non-null in OnStartLocalPlayer!", MessageType.Error);
Destroy(gameObject); // probably bad
return;
}
LocalInstance = this;
}
public override void OnStopLocalPlayer() => LocalInstance = null;
public override void OnStartLocalPlayer() => LocalInstance = this;
public override void OnStopClient()
{

View File

@ -56,8 +56,8 @@ public class ShipTransformSync : SectoredRigidbodySync
return;
}
var targetPos = ReferenceTransform.FromRelPos(transform.position);
var targetRot = ReferenceTransform.FromRelRot(transform.rotation);
var targetPos = ReferenceTransform.FromRelPos(UseInterpolation ? SmoothPosition : transform.position);
var targetRot = ReferenceTransform.FromRelRot(UseInterpolation ? SmoothRotation : transform.rotation);
if (PlayerState.IsInsideShip())
{
@ -98,5 +98,5 @@ public class ShipTransformSync : SectoredRigidbodySync
rigidbody._currentVelocity = newVelocity;
}
protected override bool UseInterpolation => !PlayerState.IsInsideShip(); /*TODO: test that this doesnt NRE*/
protected override bool UseInterpolation => !PlayerState.IsInsideShip();
}