Skip to content

Commit

Permalink
I think this works
Browse files Browse the repository at this point in the history
  • Loading branch information
xen-42 committed May 12, 2023
1 parent dce4395 commit dce6dd8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
23 changes: 12 additions & 11 deletions CosmicHorrorFishingBuddies/BaseSync/TransformSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ internal abstract class TransformSync : NetworkBehaviour

private Transform _syncedTransform;

private void Start()
private NetworkTransform _networkTransform;

public void Awake()
{
_networkTransform = gameObject.GetComponent<NetworkTransform>();
_networkTransform.target = transform;
}

public void Start()
{
CFBCore.LogInfo($"Start TransformSync: {netId}");

_syncedTransform = isOwned ? InitLocalTransform() : InitRemoteTransform();

var networkTransform = gameObject.GetComponent<NetworkTransform>();
networkTransform.target = transform;
}
_networkTransform.transform.position = Vector3.zero;
_networkTransform.transform.rotation = Quaternion.identity;

private void Update()
{
if (isOwned)
{
transform.position = GameManager.Instance.Player.transform.position;
transform.rotation = GameManager.Instance.Player.transform.rotation;
}
_networkTransform.target = _syncedTransform;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ namespace CosmicHorrorFishingBuddies.Debugging.Patches
[HarmonyPatch(typeof(Debug))]
internal static class DebugLogPatches
{
/*
[HarmonyPostfix]
[HarmonyPatch(nameof(Debug.Log), new Type[] { typeof(object) })]
public static void Debug_Log(object message) => CFBCore.LogInfo($"[UnityEngine.Debug.Log] {message}");

[HarmonyPostfix]
[HarmonyPatch(nameof(Debug.LogWarning), new Type[] { typeof(object) })]
public static void Debug_LogWarning(object message) => CFBCore.LogWarning($"[UnityEngine.Debug.Log] {message}");
*/

[HarmonyPostfix]
[HarmonyPatch(nameof(Debug.LogError), new Type[] { typeof(object) })]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public NetworkHarvestPOI GetNetworkObject(HarvestPOI harvestPOI)
}
else
{
CFBCore.LogError($"Untracked HarvestPOI {harvestPOI.name} on {NetworkPlayer.LocalPlayer.netId}");
CFBCore.LogError($"Untracked HarvestPOI {harvestPOI?.name} on {NetworkPlayer.LocalPlayer?.netId}");
return null;
}
}
Expand Down
15 changes: 12 additions & 3 deletions CosmicHorrorFishingBuddies/PlayerSync/PlayerTransformSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected override Transform InitLocalTransform()

GameManager.Instance.Player.gameObject.AddComponent<DebugCommands>();

return GameManager.Instance.Player.transform;
return transform;
}

protected override Transform InitRemoteTransform()
Expand All @@ -97,7 +97,7 @@ protected override Transform InitRemoteTransform()
remotePlayer.transform.localRotation = Quaternion.identity;

var networkPlayer = GetComponent<NetworkPlayer>();

networkPlayer.remotePlayerBoatGraphics.boatSubModelTogglers = remotePlayer.GetComponentsInChildren<BoatSubModelToggler>();
networkPlayer.remotePlayerBoatGraphics.boatModelProxies = remotePlayer.GetComponentsInChildren<BoatModelProxy>();
networkPlayer.remotePlayerBoatGraphics.wake = remotePlayer.Find("BoatTrailParticles").gameObject;
Expand All @@ -116,7 +116,16 @@ protected override Transform InitRemoteTransform()
networkPlayer.remoteAtrophyAbility.loopAudio.minDistance = 5;
networkPlayer.remoteAtrophyAbility.loopAudio.clip = atrophy.loopAudioSource.clip;

return remotePlayer;
return transform;
}

private void Update()
{
if (isOwned)
{
transform.position = GameManager.Instance.Player.transform.position;
transform.rotation = GameManager.Instance.Player.transform.rotation;
}
}
}
}

0 comments on commit dce6dd8

Please sign in to comment.