Fixed rope startup errors

This commit is contained in:
BOTAlex 2024-05-26 03:29:03 +02:00
parent 9017315bfe
commit 007e762a47
1 changed files with 20 additions and 15 deletions

View File

@ -108,12 +108,16 @@ public class RopeSimulator : NetworkBehaviour
private void OnEnable() private void OnEnable()
{ {
GameManager.OnPlayersReady += PlayersReady; GameManager.OnPlayersReady += PlayersReady;
if (NetworkManager.Singleton != null)
NetworkManager.Singleton.NetworkTickSystem.Tick += NetworkTick; NetworkManager.Singleton.NetworkTickSystem.Tick += NetworkTick;
} }
private void OnDisable() private void OnDisable()
{ {
GameManager.OnPlayersReady -= PlayersReady; GameManager.OnPlayersReady -= PlayersReady;
if (NetworkManager.Singleton != null)
NetworkManager.Singleton.NetworkTickSystem.Tick -= NetworkTick; NetworkManager.Singleton.NetworkTickSystem.Tick -= NetworkTick;
} }
@ -384,7 +388,8 @@ public class RopeSimulator : NetworkBehaviour
private GameState ProcessGame() private GameState ProcessGame()
{ {
GameState localState = new() { GameState localState = new()
{
tick = currentTick, tick = currentTick,
nrope = Rope.ToNetworkRope(this.rope), nrope = Rope.ToNetworkRope(this.rope),
enemyPositions = GameObject.FindObjectsByType<EnemyPathFinding>(FindObjectsSortMode.None).Select(e => new Vector3(e.transform.position.x, e.transform.position.y, e.GetComponent<NetworkObject>().NetworkObjectId)).ToArray(), enemyPositions = GameObject.FindObjectsByType<EnemyPathFinding>(FindObjectsSortMode.None).Select(e => new Vector3(e.transform.position.x, e.transform.position.y, e.GetComponent<NetworkObject>().NetworkObjectId)).ToArray(),