/// <summary> /// Handle full world sync message. /// </summary> /// <param name="msg">The message to handle.</param> public void HandleFullWorldSync(Messages.FullWorldSyncMessage msg) { // Doors. foreach (Messages.DoorsInitMessage door in msg.doors) { Vector3 position = Utils.NetVec3ToGame(door.position); Game.Objects.GameDoor doors = Game.GameDoorsManager.Instance.FindGameDoors(position); Client.Assert(doors != null, $"Unable to find doors at: {position}."); if (doors.IsOpen != door.open) { doors.Open(door.open); } } // Vehicles. foreach (Messages.VehicleInitMessage vehicleMsg in msg.vehicles) { Vector3 pos = Utils.NetVec3ToGame(vehicleMsg.transform.position); Quaternion rot = Utils.NetQuatToGame(vehicleMsg.transform.rotation); NetVehicle vehicle = GetVehicle(vehicleMsg.id); Client.Assert(vehicle != null, $"Received info about non existing vehicle {vehicleMsg.id} in full world sync. (pos: {pos}, rot: {rot})"); vehicle.Teleport(pos, rot); } // Pickupables foreach (Messages.PickupableSpawnMessage pickupableMsg in msg.pickupables) { SpawnPickupable(pickupableMsg); } }
/// <summary> /// Leave vehicle player is currently sitting in. /// </summary> public virtual void LeaveVehicle() { Client.Assert(currentVehicle != null && state != State.OnFoot, "Player is leaving vehicle but he is not in vehicle."); // Detach character game object from vehicle. if (characterGameObject != null) { characterGameObject.transform.SetParent(null); // TODO: Teleport interpolator to use current position so ped will not be interpolated from previous on foot location here. } // Notify vehicle that the player left. currentVehicle.ClearPlayer(state == State.Passenger); currentVehicle = null; // Set state of the player. SwitchState(State.OnFoot); // Play seated animation PlayAnimation(AnimationId.GetOutCar); }
/// <summary> /// Enter vehicle. /// </summary> /// <param name="vehicle">The vehicle to enter.</param> /// <param name="passenger">Is player entering vehicle as passenger?</param> public override void EnterVehicle(NetVehicle vehicle, bool passenger) { base.EnterVehicle(vehicle, passenger); Messages.VehicleEnterMessage msg = new Messages.VehicleEnterMessage(); msg.vehicleId = vehicle.NetId; msg.passenger = false; netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable); }
/// <summary> /// Write full world synchronization message. /// </summary> /// <param name="msg">The message to write to.</param> public void WriteFullWorldSync(Messages.FullWorldSyncMessage msg) { // Write doors List <Game.Objects.GameDoor> doors = Game.GameDoorsManager.Instance.doors; int doorsCount = doors.Count; msg.doors = new Messages.DoorsInitMessage[doorsCount]; for (int i = 0; i < doorsCount; ++i) { var doorMsg = new Messages.DoorsInitMessage(); Game.Objects.GameDoor door = doors[i]; doorMsg.position = Utils.GameVec3ToNet(door.Position); doorMsg.open = door.IsOpen; msg.doors[i] = doorMsg; } // Write vehicles. int vehiclesCount = vehicles.Count; msg.vehicles = new Messages.VehicleInitMessage[vehiclesCount]; for (int i = 0; i < vehiclesCount; ++i) { var vehicleMsg = new Messages.VehicleInitMessage(); NetVehicle vehicle = vehicles[i]; vehicleMsg.id = vehicle.NetId; vehicleMsg.transform.position = Utils.GameVec3ToNet(vehicle.GetPosition()); vehicleMsg.transform.rotation = Utils.GameQuatToNet(vehicle.GetRotation()); msg.vehicles[i] = vehicleMsg; } // Write pickupables. msg.pickupables = new Messages.PickupableSpawnMessage[netPickupables.Count]; int idx = 0; foreach (var kv in netPickupables) { NetPickupable pickupable = kv.Value; var pickupableMsg = new Messages.PickupableSpawnMessage(); pickupableMsg.id = pickupable.NetId; // Logger.Log($"Serializing pickupable: {pickupableMsg.id}. {pickupable.gameObject}"); var metaData = pickupable.gameObject.GetComponent <Game.Components.PickupableMetaDataComponent>(); pickupableMsg.prefabId = metaData.prefabId; Transform transform = pickupable.gameObject.transform; pickupableMsg.transform.position = Utils.GameVec3ToNet(transform.position); pickupableMsg.transform.rotation = Utils.GameQuatToNet(transform.rotation); msg.pickupables[idx++] = pickupableMsg; } }
/// <summary> /// Enter vehicle. /// </summary> /// <param name="vehicle">The vehicle to enter.</param> /// <param name="passenger">Is player entering vehicle as passenger?</param> public virtual void EnterVehicle(NetVehicle vehicle, bool passenger) { Client.Assert(currentVehicle == null, "Entered vehicle but player is already in vehicle."); Client.Assert(state == State.OnFoot, "Entered vehicle but player is not on foot."); // Set vehicle and put player inside it. currentVehicle = vehicle; currentVehicle.SetPlayer(this, passenger); SitInCurrentVehicle(); // Set state of the player. SwitchState(passenger ? State.Passenger : State.DrivingVehicle); }
/// <summary> /// Enter vehicle. /// </summary> /// <param name="vehicle">The vehicle to enter.</param> /// <param name="passenger">Is player entering vehicle as passenger?</param> public virtual void EnterVehicle(NetVehicle vehicle, bool passenger) { Client.Assert(currentVehicle == null, "Entered vehicle but player is already in vehicle."); Client.Assert(state == State.OnFoot, "Entered vehicle but player is not on foot."); // Set vehicle and put player inside it. currentVehicle = vehicle; currentVehicle.SetPlayer(this, passenger); // Make sure player character is attached as we will not update it's position until he leaves vehicle. if (characterGameObject != null) { characterGameObject.transform.SetParent(currentVehicle.GameObject.VehicleTransform, false); } // Set state of the player. SwitchState(passenger ? State.Passenger : State.DrivingVehicle); }
/// <summary> /// Leave vehicle player is currently sitting in. /// </summary> public virtual void LeaveVehicle() { Client.Assert(currentVehicle != null && state != State.OnFoot, "Player is leaving vehicle but he is not in vehicle."); // Detach character game object from vehicle. if (IsSpawned) { characterGameObject.transform.SetParent(null); Game.Objects.GameVehicle vehicleGameObject = currentVehicle.GameObject; Transform seatTransform = vehicleGameObject.SeatTransform; Teleport(seatTransform.position, seatTransform.rotation); } // Notify vehicle that the player left. currentVehicle.ClearPlayer(state == State.Passenger); currentVehicle = null; // Set state of the player. SwitchState(State.OnFoot); }
/// <summary> /// Handle full world sync message. /// </summary> /// <param name="msg">The message to handle.</param> public void HandleFullWorldSync(Messages.FullWorldSyncMessage msg) { // Read time Game.GameWorld gameWorld = Game.GameWorld.Instance; gameWorld.WorldTime = msg.dayTime; gameWorld.WorldDay = msg.day; // Read mailbox name gameWorld.PlayerLastName = msg.mailboxName; // Doors. foreach (Messages.DoorsInitMessage door in msg.doors) { Vector3 position = Utils.NetVec3ToGame(door.position); Game.Objects.GameDoor doors = Game.GameDoorsManager.Instance.FindGameDoors(position); Client.Assert(doors != null, $"Unable to find doors at: {position}."); if (doors.IsOpen != door.open) { doors.Open(door.open); } } // Lights. foreach (Messages.LightSwitchMessage light in msg.lights) { Vector3 position = Utils.NetVec3ToGame(light.pos); Game.Objects.LightSwitch lights = Game.LightSwitchManager.Instance.FindLightSwitch(position); Client.Assert(lights != null, $"Unable to find light switch at: {position}."); if (lights.SwitchStatus != light.toggle) { lights.TurnOn(light.toggle); } } // Weather. Game.GameWeatherManager.Instance.SetWeather(msg.currentWeather); // Vehicles. foreach (Messages.VehicleInitMessage vehicleMsg in msg.vehicles) { Vector3 pos = Utils.NetVec3ToGame(vehicleMsg.transform.position); Quaternion rot = Utils.NetQuatToGame(vehicleMsg.transform.rotation); NetVehicle vehicle = GetVehicle(vehicleMsg.id); Client.Assert(vehicle != null, $"Received info about non existing vehicle {vehicleMsg.id} in full world sync. (pos: {pos}, rot: {rot})"); vehicle.Teleport(pos, rot); } // Pickupables List <ushort> pickupablesIds = new List <ushort>(); foreach (var kv in netPickupables) { pickupablesIds.Add(kv.Key); } foreach (Messages.PickupableSpawnMessage pickupableMsg in msg.pickupables) { SpawnPickupable(pickupableMsg); pickupablesIds.Remove(pickupableMsg.id); } // Remove spawned (and active) pickupables that we did not get info about. foreach (ushort id in pickupablesIds) { GameObject gameObject = netPickupables[id].gameObject; if (gameObject && !gameObject.activeSelf) { continue; } DestroyPickupableLocal(id); } }
/// <summary> /// Write full world synchronization message. /// </summary> /// <param name="msg">The message to write to.</param> public void WriteFullWorldSync(Messages.FullWorldSyncMessage msg) { // Write time Game.GameWorld gameWorld = Game.GameWorld.Instance; msg.dayTime = gameWorld.WorldTime; msg.day = gameWorld.WorldDay; // Write mailbox name msg.mailboxName = gameWorld.PlayerLastName; // Write doors List <Game.Objects.GameDoor> doors = Game.GameDoorsManager.Instance.doors; int doorsCount = doors.Count; msg.doors = new Messages.DoorsInitMessage[doorsCount]; for (int i = 0; i < doorsCount; ++i) { var doorMsg = new Messages.DoorsInitMessage(); Game.Objects.GameDoor door = doors[i]; doorMsg.position = Utils.GameVec3ToNet(door.Position); doorMsg.open = door.IsOpen; msg.doors[i] = doorMsg; } // Write light switches. List <Game.Objects.LightSwitch> lights = Game.LightSwitchManager.Instance.lightSwitches; int lightCount = lights.Count; msg.lights = new Messages.LightSwitchMessage[lightCount]; for (int i = 0; i < lightCount; i++) { var lightMsg = new Messages.LightSwitchMessage(); Game.Objects.LightSwitch light = lights[i]; lightMsg.pos = Utils.GameVec3ToNet(light.Position); lightMsg.toggle = light.SwitchStatus; msg.lights[i] = lightMsg; } // Write weather Game.GameWeatherManager.Instance.WriteWeather(msg.currentWeather); // Write vehicles. int vehiclesCount = vehicles.Count; msg.vehicles = new Messages.VehicleInitMessage[vehiclesCount]; for (int i = 0; i < vehiclesCount; ++i) { var vehicleMsg = new Messages.VehicleInitMessage(); NetVehicle vehicle = vehicles[i]; vehicleMsg.id = vehicle.NetId; vehicleMsg.transform.position = Utils.GameVec3ToNet(vehicle.GetPosition()); vehicleMsg.transform.rotation = Utils.GameQuatToNet(vehicle.GetRotation()); msg.vehicles[i] = vehicleMsg; } // Write pickupables. var pickupableMessages = new List <Messages.PickupableSpawnMessage>(); foreach (var kv in netPickupables) { NetPickupable pickupable = kv.Value; if (pickupable.gameObject == null) { Logger.Log($"Null ptr of the pickupable game object {pickupable.NetId}"); continue; } var pickupableMsg = new Messages.PickupableSpawnMessage(); pickupableMsg.id = pickupable.NetId; var metaData = pickupable.gameObject.GetComponent <Game.Components.PickupableMetaDataComponent>(); pickupableMsg.prefabId = metaData.prefabId; Transform transform = pickupable.gameObject.transform; pickupableMsg.transform.position = Utils.GameVec3ToNet(transform.position); pickupableMsg.transform.rotation = Utils.GameQuatToNet(transform.rotation); pickupableMsg.active = pickupable.gameObject.activeSelf; List <float> data = new List <float>(); //Beercases if (metaData.PrefabDescriptor.type == Game.GamePickupableDatabase.PrefabType.BeerCase && pickupable.gameObject.name != "beer case") { Game.Objects.BeerCase beer = Game.BeerCaseManager.Instance.FindBeerCase(pickupable.gameObject); data.Add(Game.BeerCaseManager.Instance.FullCaseBottles - beer.UsedBottles); } if (data.Count != 0) { pickupableMsg.Data = data.ToArray(); } pickupableMessages.Add(pickupableMsg); } msg.pickupables = pickupableMessages.ToArray(); netManager.GetLocalPlayer().WriteSpawnState(msg); }
/// <summary> /// Register world related network message handlers. /// </summary> /// <param name="netMessageHandler">The network message handler to register messages to.</param> void RegisterNetworkMessagesHandlers(NetMessageHandler netMessageHandler) { netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.PickupableSetPositionMessage msg) => { Client.Assert(netPickupables.ContainsKey(msg.id), $"Tried to move pickupable that is not spawned {msg.id}."); GameObject gameObject = netPickupables[msg.id].gameObject; gameObject.transform.position = Utils.NetVec3ToGame(msg.position); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.PickupableActivateMessage msg) => { GameObject gameObject = null; if (netPickupables.ContainsKey(msg.id)) { gameObject = netPickupables[msg.id].gameObject; } if (msg.activate) { Client.Assert(gameObject != null, "Tried to activate pickupable but its not spawned!"); gameObject.SetActive(true); } else { if (gameObject != null) { gameObject.SetActive(false); } } }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.PickupableSpawnMessage msg) => { SpawnPickupable(msg); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.PickupableDestroyMessage msg) => { if (!netPickupables.ContainsKey(msg.id)) { return; } NetPickupable pickupable = netPickupables[msg.id]; GameObject.Destroy(pickupable.gameObject); netPickupables.Remove(msg.id); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.WorldPeriodicalUpdateMessage msg) => { // Game reports 'next hour' - we want to have transition so correct it. Game.GameWorld.Instance.WorldTime = (float)msg.sunClock - 2.0f; Game.GameWorld.Instance.WorldDay = (int)msg.worldDay; Game.GameWeatherManager.Instance.SetWeather(msg.currentWeather); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.RemoveBottleMessage msg) => { GameObject beerGO = GetPickupableGameObject(msg.netId); Game.Objects.BeerCase beer = Game.BeerCaseManager.Instance.FindBeerCase(beerGO); if (beer == null) { Logger.Log($"Player tried to drink beer, however, the beercase cannot be found."); return; } beer.RemoveBottles(1); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.PlayerSyncMessage msg) => { NetPlayer player = netManager.GetPlayer(sender); if (player == null) { Logger.Log($"Received synchronization packet from {sender} but there is not player registered using this id."); return; } player.HandleSynchronize(msg); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.OpenDoorsMessage msg) => { NetPlayer player = netManager.GetPlayer(sender); if (player == null) { Logger.Log($"Received OpenDoorsMessage however there is no matching player {sender}! (open: {msg.open}"); return; } Game.Objects.GameDoor doors = Game.GameDoorsManager.Instance.FindGameDoors(Utils.NetVec3ToGame(msg.position)); if (doors == null) { Logger.Log($"Player tried to open door, however, the door could not be found!"); return; } doors.Open(msg.open); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.FullWorldSyncMessage msg) => { NetPlayer player = netManager.GetPlayer(sender); // This one should never happen - if happens there is something done miserably wrong. Client.Assert(player != null, $"There is no player matching given steam id {sender}."); // Handle full world state synchronization. HandleFullWorldSync(msg); // Spawn host character. player.Spawn(); // Set player state. player.Teleport(Utils.NetVec3ToGame(msg.spawnPosition), Utils.NetQuatToGame(msg.spawnRotation)); if (msg.occupiedVehicleId != NetVehicle.INVALID_ID) { var vehicle = GetVehicle(msg.occupiedVehicleId); Client.Assert(vehicle != null, $"Player {player.GetName()} ({player.SteamId}) you tried to join reported that he drives car that does not exists in your game. Vehicle id: {msg.occupiedVehicleId}, passenger: {msg.passenger}"); player.EnterVehicle(vehicle, msg.passenger); } if (msg.pickedUpObject != NetPickupable.INVALID_ID) { player.PickupObject(msg.pickedUpObject); } // World is loaded! Notify network manager about that. netManager.OnNetworkWorldLoaded(); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.AskForWorldStateMessage msg) => { var msgF = new Messages.FullWorldSyncMessage(); WriteFullWorldSync(msgF); netManager.BroadcastMessage(msgF, Steamworks.EP2PSend.k_EP2PSendReliable); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.VehicleEnterMessage msg) => { NetPlayer player = netManager.GetPlayer(sender); if (player == null) { Logger.Error($"Steam user of id {sender} send message however there is no active player matching this id."); return; } NetVehicle vehicle = GetVehicle(msg.vehicleId); if (vehicle == null) { Logger.Error("Player " + player.SteamId + " tried to enter vehicle " + msg.vehicleId + " but there is no vehicle with such id."); return; } player.EnterVehicle(vehicle, msg.passenger); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.VehicleLeaveMessage msg) => { NetPlayer player = netManager.GetPlayer(sender); if (player == null) { Logger.Error($"Steam user of id {sender} send message however there is no active player matching this id."); return; } player.LeaveVehicle(); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.VehicleSyncMessage msg) => { NetPlayer player = netManager.GetPlayer(sender); if (player == null) { Logger.Error($"Steam user of id {sender} send message however there is no active player matching this id."); return; } player.HandleVehicleSync(msg); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.PickupObjectMessage msg) => { NetPlayer player = netManager.GetPlayer(sender); if (player == null) { Logger.Error($"Steam user of id {sender} send message however there is no active player matching this id."); return; } player.PickupObject(msg.netId); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.ReleaseObjectMessage msg) => { NetPlayer player = netManager.GetPlayer(sender); if (player == null) { Logger.Error($"Steam user of id {sender} send message however there is no active player matching this id."); return; } player.ReleaseObject(msg.drop); }); netMessageHandler.BindMessageHandler((Steamworks.CSteamID sender, Messages.LightSwitchMessage msg) => { Game.Objects.LightSwitch light = Game.LightSwitchManager.Instance.FindLightSwitch(Utils.NetVec3ToGame(msg.pos)); light.TurnOn(msg.toggle); }); }
public NetManager() { this.netManagerCreationTime = DateTime.UtcNow; netWorld = new NetWorld(this); // Setup local player. players[0] = new NetLocalPlayer(this, netWorld, Steamworks.SteamUser.GetSteamID()); p2pSessionRequestCallback = Steamworks.Callback <Steamworks.P2PSessionRequest_t> .Create((Steamworks.P2PSessionRequest_t result) => { if (!Steamworks.SteamNetworking.AcceptP2PSessionWithUser(result.m_steamIDRemote)) { Logger.Log("Accepted p2p session with " + result.m_steamIDRemote.ToString()); } }); gameLobbyJoinRequestedCallback = Steamworks.Callback <Steamworks.GameLobbyJoinRequested_t> .Create(OnGameLobbyJoinRequested); lobbyCreatedCallResult = new Steamworks.CallResult <Steamworks.LobbyCreated_t>((Steamworks.LobbyCreated_t result, bool ioFailure) => { if (result.m_eResult != Steamworks.EResult.k_EResultOK) { Logger.Log("Oh my f*****g god i failed to create a lobby for you. Please forgive me. (result: " + result.m_eResult + ")"); MPGUI.Instance.ShowMessageBox("Failed to create lobby due to steam error.\n" + result.m_eResult, () => { MPController.Instance.LoadLevel("MainMenu"); }); return; } Logger.Log("Hey you! I have lobby id for you! " + result.m_ulSteamIDLobby); mode = Mode.Host; state = State.Playing; currentLobbyId = new Steamworks.CSteamID(result.m_ulSteamIDLobby); netWorld.RegisterPickupables(); }); lobbyEnterCallResult = new Steamworks.CallResult <Steamworks.LobbyEnter_t>((Steamworks.LobbyEnter_t result, bool ioFailure) => { if (result.m_EChatRoomEnterResponse != (uint)Steamworks.EChatRoomEnterResponse.k_EChatRoomEnterResponseSuccess) { Logger.Log("Oh my f*****g god i failed to join the lobby for you. Please forgive me. (reponse: " + result.m_EChatRoomEnterResponse + ")"); players[1] = null; return; } Logger.Log("Oh hello! " + result.m_ulSteamIDLobby); mode = Mode.Player; state = State.LoadingGameWorld; currentLobbyId = new Steamworks.CSteamID(result.m_ulSteamIDLobby); SendHandshake(); }); // TODO: Move message handlers to some class. BindMessageHandler((Steamworks.CSteamID sender, Messages.HandshakeMessage msg) => { remoteClock = msg.clock; HandleHandshake(sender, msg); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.PlayerSyncMessage msg) => { if (players[1] == null) { Logger.Log("Received synchronization packet but no remote player is currently connected."); return; } players[1].HandleSynchronize(msg); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.HeartbeatMessage msg) => { var message = new Messages.HeartbeatResponseMessage(); message.clientClock = msg.clientClock; message.clock = GetNetworkClock(); BroadcastMessage(message, Steamworks.EP2PSend.k_EP2PSendReliable); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.HeartbeatResponseMessage msg) => { ping = (uint)(GetNetworkClock() - msg.clientClock); // TODO: Some smart lag compensation. remoteClock = msg.clock; timeSinceLastHeartbeat = 0.0f; }); BindMessageHandler((Steamworks.CSteamID sender, Messages.DisconnectMessage msg) => { HandleDisconnect(false); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.OpenDoorsMessage msg) => { NetPlayer player = players[1]; // 1.5 is a length of the ray used to check interaction with doors in game scripts. Vector3 interactionPosition = player.GetPosition() + player.GetRotation() * Vector3.forward * 1.5f; Game.Objects.GameDoor doors = Game.GameDoorsManager.Instance.FindGameDoors(interactionPosition); if (doors == null) { Logger.Log($"Player tried to open doors however he is not close to any: {interactionPosition}."); return; } doors.Open(msg.open); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.FullWorldSyncMessage msg) => { netWorld.HandleFullWorldSync(msg); // Now spawn player. if (players[1] != null) { players[1].Spawn(); } // World loaded we are playing! state = State.Playing; }); BindMessageHandler((Steamworks.CSteamID sender, Messages.AskForWorldStateMessage msg) => { var msgF = new Messages.FullWorldSyncMessage(); netWorld.WriteFullWorldSync(msgF); BroadcastMessage(msgF, Steamworks.EP2PSend.k_EP2PSendReliable); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.VehicleEnterMessage msg) => { NetPlayer player = players[1]; if (player == null) { return; } NetVehicle vehicle = netWorld.GetVehicle(msg.vehicleId); if (vehicle == null) { Logger.Log("Player " + player.SteamId + " tried to enter vehicle " + msg.vehicleId + " but there is no vehicle with such id."); return; } player.EnterVehicle(vehicle, msg.passenger); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.VehicleLeaveMessage msg) => { NetPlayer player = players[1]; if (player == null) { return; } player.LeaveVehicle(); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.VehicleSyncMessage msg) => { NetPlayer player = players[1]; if (player == null) { return; } player.HandleVehicleSync(msg); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.PickupObjectMessage msg) => { NetPlayer player = players[1]; if (player == null) { return; } player.PickupObject(msg.netId); }); BindMessageHandler((Steamworks.CSteamID sender, Messages.ReleaseObjectMessage msg) => { NetPlayer player = players[1]; if (player == null) { return; } player.ReleaseObject(msg.drop); }); }