public override void Process(PlayerJoiningMultiplayerSession packet, Connection connection) { Player player = playerManager.CreatePlayer(connection, packet.ReservationKey); player.SendPacket(new TimeChange(timeKeeper.GetCurrentTime())); Optional <EscapePodModel> newlyCreatedEscapePod; string assignedEscapePodGuid = world.EscapePodManager.AssignPlayerToEscapePod(player.Id, out newlyCreatedEscapePod); if (newlyCreatedEscapePod.IsPresent()) { AddEscapePod addEscapePod = new AddEscapePod(newlyCreatedEscapePod.Get()); playerManager.SendPacketToOtherPlayers(addEscapePod, player); } PlayerJoinedMultiplayerSession playerJoinedPacket = new PlayerJoinedMultiplayerSession(player.PlayerContext); playerManager.SendPacketToOtherPlayers(playerJoinedPacket, player); InitialPlayerSync initialPlayerSync = new InitialPlayerSync(player.Id.ToString(), world.EscapePodData.EscapePods, assignedEscapePodGuid, world.PlayerData.GetEquippedItemsForInitialSync(player.Name), world.BaseData.GetBasePiecesForNewlyConnectedPlayer(), world.VehicleData.GetVehiclesForInitialSync(), world.InventoryData.GetAllItemsForInitialSync(), world.GameData.PDAState.GetInitialPdaData(), world.PlayerData.PlayerSpawn(player.Name), world.PlayerData.GetSubRootGuid(player.Name), world.PlayerData.Stats(player.Name), getRemotePlayerData(player), world.EntityData.GetGlobalRootEntities()); player.SendPacket(initialPlayerSync); }
public override void Process(PlayerJoiningMultiplayerSession packet, NitroxConnection connection) { bool wasBrandNewPlayer; Player player = playerManager.CreatePlayer(connection, packet.ReservationKey, out wasBrandNewPlayer); timeKeeper.SendCurrentTimePacket(player); Optional <EscapePodModel> newlyCreatedEscapePod; NitroxId assignedEscapePodId = world.EscapePodManager.AssignPlayerToEscapePod(player.Id, out newlyCreatedEscapePod); if (newlyCreatedEscapePod.IsPresent()) { AddEscapePod addEscapePod = new AddEscapePod(newlyCreatedEscapePod.Get()); playerManager.SendPacketToOtherPlayers(addEscapePod, player); } List <EquippedItemData> equippedItems = world.PlayerData.GetEquippedItemsForInitialSync(player.Name); List <TechType> techTypes = equippedItems.Select(equippedItem => equippedItem.TechType).ToList(); PlayerJoinedMultiplayerSession playerJoinedPacket = new PlayerJoinedMultiplayerSession(player.PlayerContext, techTypes); playerManager.SendPacketToOtherPlayers(playerJoinedPacket, player); // Make players on localhost admin by default. if (IPAddress.IsLoopback(connection.Endpoint.Address)) { world.PlayerData.SetPermissions(player.Name, Perms.ADMIN); } Perms initialPerms = world.PlayerData.GetPermissions(player.Name); InitialPlayerSync initialPlayerSync = new InitialPlayerSync(player.GameObjectId, wasBrandNewPlayer, world.EscapePodData.EscapePods, assignedEscapePodId, equippedItems, world.BaseData.GetBasePiecesForNewlyConnectedPlayer(), world.VehicleData.GetVehiclesForInitialSync(), world.InventoryData.GetAllItemsForInitialSync(), world.InventoryData.GetAllStorageItemsForInitialSync(), world.GameData.PDAState.GetInitialPdaData(), world.GameData.StoryGoals.GetInitialStoryGoalData(), world.PlayerData.GetPlayerSpawn(player.Name), world.PlayerData.GetSubRootId(player.Name), world.PlayerData.GetPlayerStats(player.Name), getRemotePlayerData(player), world.EntityData.GetGlobalRootEntities(), world.GameMode, initialPerms); player.SendPacket(initialPlayerSync); }
public override void Process(PlayerJoiningMultiplayerSession packet, NitroxConnection connection) { bool wasBrandNewPlayer; Player player = playerManager.CreatePlayer(connection, packet.ReservationKey, out wasBrandNewPlayer); timeKeeper.SendCurrentTimePacket(player); Optional <EscapePodModel> newlyCreatedEscapePod; string assignedEscapePodGuid = world.EscapePodManager.AssignPlayerToEscapePod(player.Id, out newlyCreatedEscapePod); if (newlyCreatedEscapePod.IsPresent()) { AddEscapePod addEscapePod = new AddEscapePod(newlyCreatedEscapePod.Get()); playerManager.SendPacketToOtherPlayers(addEscapePod, player); } List <EquippedItemData> equippedItems = world.PlayerData.GetEquippedItemsForInitialSync(player.Name); List <NitroxModel.DataStructures.TechType> techTypes = equippedItems.Select(equippedItem => equippedItem.TechType).ToList(); PlayerJoinedMultiplayerSession playerJoinedPacket = new PlayerJoinedMultiplayerSession(player.PlayerContext, techTypes); playerManager.SendPacketToOtherPlayers(playerJoinedPacket, player); InitialPlayerSync initialPlayerSync = new InitialPlayerSync(player.Id.ToString(), wasBrandNewPlayer, world.EscapePodData.EscapePods, assignedEscapePodGuid, equippedItems, world.BaseData.GetBasePiecesForNewlyConnectedPlayer(), world.VehicleData.GetVehiclesForInitialSync(), world.InventoryData.GetAllItemsForInitialSync(), world.InventoryData.GetAllStorageItemsForInitialSync(), world.GameData.PDAState.GetInitialPdaData(), world.GameData.StoryGoals.GetInitialStoryGoalData(), world.PlayerData.GetPlayerSpawn(player.Name), world.PlayerData.GetSubRootGuid(player.Name), world.PlayerData.GetPlayerStats(player.Name), getRemotePlayerData(player), world.EntityData.GetGlobalRootEntities(), world.GameMode, world.PlayerData.GetPermissions(player.Name)); player.SendPacket(initialPlayerSync); }
public override void Process(PlayerJoiningMultiplayerSession packet, NitroxConnection connection) { bool wasBrandNewPlayer; Player player = playerManager.PlayerConnected(connection, packet.ReservationKey, out wasBrandNewPlayer); timeKeeper.SendCurrentTimePacket(player); Optional <EscapePodModel> newlyCreatedEscapePod; NitroxId assignedEscapePodId = world.EscapePodManager.AssignPlayerToEscapePod(player.Id, out newlyCreatedEscapePod); if (newlyCreatedEscapePod.HasValue) { AddEscapePod addEscapePod = new AddEscapePod(newlyCreatedEscapePod.Value); playerManager.SendPacketToOtherPlayers(addEscapePod, player); } List <EquippedItemData> equippedItems = player.GetEquipment(); List <NitroxTechType> techTypes = equippedItems.Select(equippedItem => equippedItem.TechType).ToList(); PlayerJoinedMultiplayerSession playerJoinedPacket = new PlayerJoinedMultiplayerSession(player.PlayerContext, techTypes); playerManager.SendPacketToOtherPlayers(playerJoinedPacket, player); // Make players on localhost admin by default. if (IPAddress.IsLoopback(connection.Endpoint.Address)) { player.Permissions = Perms.ADMIN; } List <NitroxId> simulations = world.EntitySimulation.AssignGlobalRootEntities(player).ToList(); IEnumerable <VehicleModel> vehicles = world.VehicleManager.GetVehicles(); foreach (VehicleModel vehicle in vehicles) { if (world.SimulationOwnershipData.TryToAcquire(vehicle.Id, player, SimulationLockType.TRANSIENT)) { simulations.Add(vehicle.Id); } } InitialPlayerSync initialPlayerSync = new InitialPlayerSync(player.GameObjectId, wasBrandNewPlayer, world.EscapePodManager.GetEscapePods(), assignedEscapePodId, equippedItems, player.GetModules(), world.BaseManager.GetBasePiecesForNewlyConnectedPlayer(), vehicles, world.InventoryManager.GetAllInventoryItems(), world.InventoryManager.GetAllStorageSlotItems(), world.GameData.PDAState.GetInitialPDAData(), world.GameData.StoryGoals.GetInitialStoryGoalData(), player.Position, player.SubRootId, player.Stats, GetRemotePlayerData(player), world.EntityManager.GetGlobalRootEntities(), simulations, world.GameMode, player.Permissions); player.SendPacket(initialPlayerSync); }