public override void Process(InitialPlayerSync packet) { EscapePodModel escapePod = packet.EscapePodsData.Find(x => x.Id.Equals(packet.AssignedEscapePodId)); escapePodManager.AssignPlayerToEscapePod(escapePod); escapePodManager.SyncEscapePodIds(packet.EscapePodsData); }
public override void Process(InitialPlayerSync packet) { SetPlayerGameObjectId(packet.PlayerGameObjectId); AddStartingItemsToPlayer(packet.FirstTimeConnecting); SetPlayerStats(packet.PlayerStatsData); SetPlayerGameMode((GameModeOption)Enum.Parse(typeof(GameModeOption), packet.GameMode)); }
public override void Process(InitialPlayerSync packet) { using (packetSender.Suppress <ModuleAdded>()) { equipmentSlots.AddItems(packet.Modules); } }
public override void Process(PlayerJoiningMultiplayerSession packet, Connection connection) { Player player = playerManager.CreatePlayer(connection, packet.ReservationKey); player.SendPacket(new TimeChange(timeKeeper.GetCurrentTime())); escapePodManager.AssignPlayerToEscapePod(player.Id); BroadcastEscapePods broadcastEscapePods = new BroadcastEscapePods(escapePodManager.GetEscapePods()); playerManager.SendPacketToAllPlayers(broadcastEscapePods); PlayerJoinedMultiplayerSession playerJoinedPacket = new PlayerJoinedMultiplayerSession(player.PlayerContext); playerManager.SendPacketToOtherPlayers(playerJoinedPacket, player); InitialPlayerSync initialPlayerSync = new InitialPlayerSync(player.Id.ToString(), 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 IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { int remotePlayersSynced = 0; foreach (InitialRemotePlayerData playerData in packet.RemotePlayerData) { waitScreenItem.SetProgress(remotePlayersSynced, packet.RemotePlayerData.Count); List <TechType> equippedTechTypes = playerData.EquippedTechTypes.Select(techType => techType.Enum()).ToList(); RemotePlayer player = remotePlayerManager.Create(playerData.PlayerContext, equippedTechTypes); if (playerData.SubRootId.IsPresent()) { Optional <GameObject> sub = NitroxEntity.GetObjectFrom(playerData.SubRootId.Get()); if (sub.IsPresent()) { player.SetSubRoot(sub.Get().GetComponent <SubRoot>()); } else { Log.Error("Could not spawn remote player into subroot with id: " + playerData.SubRootId.Get()); } } remotePlayersSynced++; yield return(null); } }
public override void Process(PlayerJoiningMultiplayerSession packet, Connection connection) { Player player = playerManager.CreatePlayer(connection, packet.ReservationKey); player.SendPacket(new TimeChange(timeKeeper.GetCurrentTime())); escapePodManager.AssignPlayerToEscapePod(player.Id); BroadcastEscapePods broadcastEscapePods = new BroadcastEscapePods(escapePodManager.GetEscapePods()); playerManager.SendPacketToAllPlayers(broadcastEscapePods); PlayerJoinedMultiplayerSession playerJoinedPacket = new PlayerJoinedMultiplayerSession(player.PlayerContext); playerManager.SendPacketToOtherPlayers(playerJoinedPacket, player); InitialPlayerSync initialPlayerSync = new InitialPlayerSync(world.PlayerData.Inventory(player.Name), world.PlayerData.GetEquippedItemsForInitialSync(player.Name), world.BaseData.GetBasePiecesForNewlyConnectedPlayer(), world.VehicleData.GetVehiclesForInitialSync(), world.InventoryData.GetAllItemsForInitialSync()); player.SendPacket(initialPlayerSync); foreach (Player otherPlayer in playerManager.GetPlayers()) { if (!player.Equals(otherPlayer)) { playerJoinedPacket = new PlayerJoinedMultiplayerSession(otherPlayer.PlayerContext); player.SendPacket(playerJoinedPacket); } } }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { int storageSlotsSynced = 0; HashSet <NitroxId> onlinePlayers = new HashSet <NitroxId> { packet.PlayerGameObjectId }; onlinePlayers.AddRange(packet.RemotePlayerData.Select(playerData => playerData.PlayerContext.PlayerNitroxId)); // Removes any batteries which are in inventories from offline players List <ItemData> currentlyIgnoredItems = packet.InventoryItems.Where(item => !onlinePlayers.Any(player => player.Equals(item.ContainerId))).ToList(); packet.StorageSlotItems.RemoveAll(storageItem => currentlyIgnoredItems.Any(ignoredItem => ignoredItem.ItemId.Equals(storageItem.ContainerId))); using (packetSender.Suppress <StorageSlotItemAdd>()) { foreach (ItemData itemData in packet.StorageSlotItems) { waitScreenItem.SetProgress(storageSlotsSynced, packet.StorageSlotItems.Count); GameObject item = SerializationHelper.GetGameObject(itemData.SerializedData); Log.Debug($"Initial StorageSlot item data for {item.name} giving to container {itemData.ContainerId}"); NitroxEntity.SetNewId(item, itemData.ItemId); slots.AddItem(item, itemData.ContainerId, true); storageSlotsSynced++; yield return(null); } } }
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 IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { SetEncyclopediaEntry(packet.PDAData.EncyclopediaEntries); waitScreenItem.SetProgress(0.17f); yield return(null); SetPDAEntryComplete(packet.PDAData.UnlockedTechTypes); waitScreenItem.SetProgress(0.33f); yield return(null); SetPDAEntryPartial(packet.PDAData.PartiallyUnlockedTechTypes); waitScreenItem.SetProgress(0.5f); yield return(null); SetKnownTech(packet.PDAData.KnownTechTypes, packet.PDAData.AnalyzedTechTypes); waitScreenItem.SetProgress(0.67f); yield return(null); SetPDALog(packet.PDAData.PDALogEntries); waitScreenItem.SetProgress(0.83f); yield return(null); SetCachedProgress(packet.PDAData.CachedProgress); waitScreenItem.SetProgress(1f); yield return(null); }
public override void Process(InitialPlayerSync packet) { SetPlayerGuid(packet.PlayerGuid); AddStartingItemsToPlayer(packet.FirstTimeConnecting); SetPlayerStats(packet.PlayerStatsData); SetPlayerGameMode(packet.GameMode); }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { using (packetSender.Suppress <ModuleAdded>()) { equipmentSlots.AddItems(packet.Modules); yield return(null); } }
public override void Process(InitialPlayerSync packet) { foreach (VehicleModel vehicle in packet.Vehicles) { // TODO: create an AsyncInitialSyncProcessor that creates cyclops before seamoth (as seamoth can be docked in cyclops) vehicles.CreateVehicle(vehicle); } }
public override void Process(InitialPlayerSync packet) { SetEncyclopediaEntry(packet.PDAData.EncyclopediaEntries); SetPDAEntryComplete(packet.PDAData.UnlockedTechTypes); SetPDAEntryPartial(packet.PDAData.PartiallyUnlockedTechTypes); SetKnownTech(packet.PDAData.KnownTechTypes); SetPDALog(packet.PDAData.PDALogEntries); }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { EscapePodModel escapePod = packet.EscapePodsData.Find(x => x.Id.Equals(packet.AssignedEscapePodId)); escapePodManager.AssignPlayerToEscapePod(escapePod); yield return(null); escapePodManager.SyncEscapePodIds(packet.EscapePodsData); }
public override void Process(InitialPlayerSync packet) { foreach (VehicleModel vehicle in packet.Vehicles) { if (vehicle.TechType.Enum() != TechType.Cyclops) { vehicles.CreateVehicle(vehicle); } } }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { int totalItemDataSynced = 0; using (packetSender.Suppress <ItemContainerAdd>()) { ItemGoalTracker itemGoalTracker = (ItemGoalTracker)typeof(ItemGoalTracker).GetField("main", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null); Dictionary <TechType, List <ItemGoal> > goals = (Dictionary <TechType, List <ItemGoal> >)(typeof(ItemGoalTracker).GetField("goals", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(itemGoalTracker)); foreach (ItemData itemdata in packet.InventoryItems) { waitScreenItem.SetProgress(totalItemDataSynced, packet.InventoryItems.Count); GameObject item; try { item = SerializationHelper.GetGameObject(itemdata.SerializedData); } catch (Exception ex) { Log.Error(ex, $"Error deserializing item data. Id: {itemdata.ItemId}"); continue; } Log.Debug($"Initial item data for {item.name} giving to container {itemdata.ContainerId}"); Pickupable pickupable = item.GetComponent <Pickupable>(); if (pickupable != null && itemdata.ContainerId == packet.PlayerGameObjectId) { goals.Remove(pickupable.GetTechType()); // Remove Notification Goal Event On Item Player Already have On Any Container ItemsContainer container = Inventory.Get().container; InventoryItem inventoryItem = new InventoryItem(pickupable); inventoryItem.container = container; inventoryItem.item.Reparent(container.tr); container.UnsafeAdd(inventoryItem); } else { itemContainers.AddItem(item, itemdata.ContainerId); ContainerAddItemPostProcessor postProcessor = ContainerAddItemPostProcessor.From(item); postProcessor.process(item, itemdata); } totalItemDataSynced++; yield return(null); } } Log.Info($"Received initial sync with {totalItemDataSynced} inventory items"); }
public override void Process(InitialPlayerSync packet) { foreach (VehicleModel vehicle in packet.Vehicles) { // TODO: create an AsyncInitialSyncProcessor that creates cyclops before seamoth and exosuit (as seamoth can be docked in cyclops) if (vehicle.TechType.Enum() != TechType.Cyclops) { vehicles.CreateVehicle(vehicle); } } }
public override void Process(InitialPlayerSync packet) { using (packetSender.Suppress <StorageSlotItemAdd>()) { foreach (ItemData itemData in packet.StorageSlots) { GameObject item = SerializationHelper.GetGameObject(itemData.SerializedData); NitroxEntity.SetNewId(item, itemData.ItemId); slots.AddItem(item, itemData.ContainerId, true); } } }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { int totalEquippedItemsDone = 0; using (packetSender.Suppress <ItemContainerAdd>()) { foreach (EquippedItemData equippedItem in packet.EquippedItems) { waitScreenItem.SetProgress(totalEquippedItemsDone, packet.EquippedItems.Count); GameObject gameObject = SerializationHelper.GetGameObject(equippedItem.SerializedData); NitroxEntity.SetNewId(gameObject, equippedItem.ItemId); Pickupable pickupable = gameObject.RequireComponent <Pickupable>(); Optional <GameObject> opGameObject = NitroxEntity.GetObjectFrom(equippedItem.ContainerId); if (opGameObject.HasValue) { GameObject owner = opGameObject.Value; Optional <Equipment> opEquipment = EquipmentHelper.FindEquipmentComponent(owner); if (opEquipment.HasValue) { Equipment equipment = opEquipment.Value; InventoryItem inventoryItem = new(pickupable); inventoryItem.container = equipment; inventoryItem.item.Reparent(equipment.tr); Dictionary <string, InventoryItem> itemsBySlot = equipment.equipment; itemsBySlot[equippedItem.Slot] = inventoryItem; equipment.UpdateCount(pickupable.GetTechType(), true); Equipment.SendEquipmentEvent(pickupable, 0, owner, equippedItem.Slot); equipment.NotifyEquip(equippedItem.Slot, inventoryItem); } else { Log.Info("Could not find equipment type for " + gameObject.name); } } else { Log.Info("Could not find Container for " + gameObject.name); } totalEquippedItemsDone++; yield return(null); } } Log.Info("Recieved initial sync with " + totalEquippedItemsDone + " pieces of equipped items"); }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { int idsSynced = 0; foreach (NitroxId entityId in packet.InitialSimulationOwnerships) { waitScreenItem.SetProgress(idsSynced++, packet.InitialSimulationOwnerships.Count); // Initial locks are transient simulationOwnership.SimulateEntity(entityId, SimulationLockType.TRANSIENT); Log.Debug($"Transient simulation ownership for {entityId} from initial sync"); } yield return(null); }
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 IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { Vector3 position = packet.PlayerSpawnData.ToUnity(); if (Math.Abs(position.x) < 0.0002 && Math.Abs(position.y) < 0.0002 && Math.Abs(position.z) < 0.0002) { position = Player.mainObject.transform.position; } Player.main.SetPosition(position); // Player.Update is setting SubRootID to null after Player position is set using (packetSender.Suppress <EscapePodChanged>()) { Player.main.ValidateEscapePod(); } // Player position is relative to a subroot if in a subroot Optional <NitroxId> subRootId = packet.PlayerSubRootId; if (!subRootId.HasValue) { yield break; } Optional <GameObject> sub = NitroxEntity.GetObjectFrom(subRootId.Value); if (!sub.HasValue) { Log.Error("Could not spawn player into subroot with id: " + subRootId.Value); yield break; } if (!sub.Value.TryGetComponent(out SubRoot subRoot)) { Log.Debug("SubRootId-GameObject has no SubRoot component, so it's assumed to be the EscapePod"); yield break; } // If player is not swimming Player.main.SetCurrentSub(subRoot); if (subRoot.isBase) { yield break; } Transform rootTransform = subRoot.transform; Quaternion vehicleAngle = rootTransform.rotation; position = vehicleAngle * position; position = position + rootTransform.position; Player.main.SetPosition(position); }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { SetCompletedStoryGoals(packet.StoryGoalData.CompletedGoals); waitScreenItem.SetProgress(0.33f); yield return(null); SetRadioQueue(packet.StoryGoalData.RadioQueue); waitScreenItem.SetProgress(0.66f); yield return(null); SetGoalUnlocks(packet.StoryGoalData.GoalUnlocks); waitScreenItem.SetProgress(1f); yield return(null); }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { int remotePlayersSynced = 0; foreach (InitialRemotePlayerData playerData in packet.RemotePlayerData) { waitScreenItem.SetProgress(remotePlayersSynced, packet.RemotePlayerData.Count); List <TechType> equippedTechTypes = playerData.EquippedTechTypes.Select(techType => techType.ToUnity()).ToList(); RemotePlayer player = remotePlayerManager.Create(playerData.PlayerContext, equippedTechTypes); if (playerData.SubRootId.HasValue) { Optional <GameObject> sub = NitroxEntity.GetObjectFrom(playerData.SubRootId.Value); if (sub.HasValue) { Log.Debug($"sub value set to {sub.Value}. Try to find subroot"); SubRoot subroot = null; sub.Value.TryGetComponent <SubRoot>(out subroot); if (subroot != null) { Log.Debug("Found subroot for player. Will add him and update animation."); player.SetSubRoot(subroot); // Set the animation for the remote player to standing instead of swimming if player is not in a flooded subroot if (!subroot.IsUnderwater(player.Body.transform.position)) { player.UpdateAnimation(AnimChangeType.UNDERWATER, AnimChangeState.OFF); } } Log.Debug("Trying to find escape pod."); EscapePod escapePod = null; sub.Value.TryGetComponent <EscapePod>(out escapePod); if (escapePod != null) { Log.Debug("Found escape pod for player. Will add him and update animation."); player.UpdateAnimation(AnimChangeType.UNDERWATER, AnimChangeState.OFF); } } else { Log.Error("Could not spawn remote player into subroot/escape pod with id: " + playerData.SubRootId.Value); } } remotePlayersSynced++; yield return(null); } }
public override void Process(InitialPlayerSync packet) { List <BasePiece> basePieces = packet.BasePieces; Log.Info("Received initial sync packet with " + basePieces.Count + " base pieces"); if (basePieces.Count == 0) { MarkCompleted(); } else { QueueUpPieces(packet.BasePieces); ThrottledBuilder.main.QueueDrained += FinishedBuildingBasePieces; } }
public override void Process(InitialPlayerSync packet) { using (packetSender.Suppress <ItemContainerAdd>()) { foreach (EquippedItemData equippedItem in packet.EquippedItems) { GameObject gameObject = SerializationHelper.GetGameObject(equippedItem.SerializedData); // Mark this entity as spawned by the server gameObject.AddComponent <NitroxEntity>(); Pickupable pickupable = gameObject.RequireComponent <Pickupable>(); Optional <GameObject> opGameObject = GuidHelper.GetObjectFrom(equippedItem.ContainerGuid); if (opGameObject.IsPresent()) { GameObject owner = opGameObject.Get(); Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner); if (opEquipment.IsPresent()) { Equipment equipment = opEquipment.Get(); InventoryItem inventoryItem = new InventoryItem(pickupable); inventoryItem.container = equipment; inventoryItem.item.Reparent(equipment.tr); Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment"); itemsBySlot[equippedItem.Slot] = inventoryItem; equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true }); Equipment.SendEquipmentEvent(pickupable, 0, owner, equippedItem.Slot); equipment.ReflectionCall("NotifyEquip", false, false, new object[] { equippedItem.Slot, inventoryItem }); } else { Log.Info("Could not find equipment type for " + gameObject.name); } } else { Log.Info("Could not find Container for " + gameObject.name); } } } }
public override void Process(InitialPlayerSync packet) { vehicles.VehicleCreated += OnVehicleCreated; foreach (VehicleModel vehicle in packet.Vehicles) { if (vehicle.TechType.Enum() == TechType.Cyclops) { cyclopsStillLoading++; vehicles.CreateVehicle(vehicle); } } // If no cyclops is created, just send the finish right away if (cyclopsStillLoading == 0) { FinishedCreating(); } }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { Vector3 position = packet.PlayerSpawnData; Optional <NitroxId> subRootId = packet.PlayerSubRootId; if (position.x == 0 && position.y == 0 && position.z == 0) { position = Player.mainObject.transform.position; } Player.main.SetPosition(position); if (subRootId.IsPresent()) { Optional <GameObject> sub = NitroxEntity.GetObjectFrom(subRootId.Get()); if (sub.IsPresent()) { SubRoot root = sub.Get().GetComponent <SubRoot>(); // Player position is relative to a subroot if in a subroot if (root != null) { // If player is not swimming Player.main.SetCurrentSub(root); if (!root.isBase) // Additionally, if player is not in base (has to be a vehicle) { Quaternion vehicleAngle = root.transform.rotation; position = vehicleAngle * position; position = position + root.transform.position; Player.main.SetPosition(position); } } else { Log.Error("Could not find subroot for player for subroot with id: " + subRootId.Get()); } } else { Log.Error("Could not spawn player into subroot with id: " + subRootId.Get()); } } yield return(null); }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { Vector3 position = packet.PlayerSpawnData.ToUnity(); if (Math.Abs(position.x) < 0.0002 && Math.Abs(position.y) < 0.0002 && Math.Abs(position.z) < 0.0002) { position = Player.mainObject.transform.position; } Player.main.SetPosition(position); // Player position is relative to a subroot if in a subroot Optional <NitroxId> subRootId = packet.PlayerSubRootId; if (!subRootId.HasValue) { yield break; } Optional <GameObject> sub = NitroxEntity.GetObjectFrom(subRootId.Value); if (!sub.HasValue) { Log.Error("Could not spawn player into subroot with id: " + subRootId.Value); yield break; } SubRoot root = sub.Value.GetComponent <SubRoot>(); if (root == null) { Log.Error("Could not find subroot for player for subroot with id: " + subRootId.Value); yield break; } // If player is not swimming Player.main.SetCurrentSub(root); if (root.isBase) { yield break; } Transform rootTransform = root.transform; Quaternion vehicleAngle = rootTransform.rotation; position = vehicleAngle * position; position = position + rootTransform.position; Player.main.SetPosition(position); }
public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { SetPlayerGameObjectId(packet.PlayerGameObjectId); waitScreenItem.SetProgress(0.25f); yield return(null); AddStartingItemsToPlayer(packet.FirstTimeConnecting); waitScreenItem.SetProgress(0.5f); yield return(null); SetPlayerStats(packet.PlayerStatsData); waitScreenItem.SetProgress(0.75f); yield return(null); SetPlayerGameMode(packet.GameMode); waitScreenItem.SetProgress(1f); yield return(null); }