private void ReceiveServerSwitches(Message message) { using (DarkRiftReader reader = message.GetReader()) { Main.Log($"[CLIENT] < SWITCH_SYNC"); while (reader.Position < reader.Length) { Switch[] switchesServer = reader.ReadSerializables <Switch>(); foreach (Switch switchInfo in switchesServer) { if (switchInfo.Id >= junctions.Length) { Main.Log($"Unidentified junction received. Skipping (ID: {switchInfo.Id})"); continue; } Junction junction = junctions[switchInfo.Id]; if (switchInfo.SwitchToLeft && junction.selectedBranch == 0 || !switchInfo.SwitchToLeft && junction.selectedBranch == 1) { Main.Log($"Junction with ID {switchInfo.Id} already set to correct branch."); continue; } IsChangeByNetwork = true; junction.Switch(Junction.SwitchMode.NO_SOUND); IsChangeByNetwork = false; } } } IsSynced = true; buffer.RunBuffer(); }
private void ReceiveTurntableSync(Message message) { using (DarkRiftReader reader = message.GetReader()) { Main.Log($"[CLIENT] < TURNTABLE_SYNC"); while (reader.Position < reader.Length) { Turntable[] turntableInfos = reader.ReadSerializables <Turntable>(); foreach (Turntable turntable in turntableInfos) { TurntableController turntableController = turntables.FirstOrDefault(j => j.transform.position == turntable.Position + WorldMover.currentMove); if (turntableController) { turntableController.GetComponent <NetworkTurntableSync>().playerAuthId = turntable.playerAuthId; SingletonBehaviour <CoroutineManager> .Instance.Run(RotateTurntableTowardsByNetwork(turntableController, turntable.Rotation)); } } } } IsSynced = true; buffer.RunBuffer(); }