-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move player join broadcast to after initial sync completed, and ensur…
…e player entity is spawned in priority
- Loading branch information
1 parent
151a2bb
commit 82671c4
Showing
6 changed files
with
60 additions
and
62 deletions.
There are no files selected for viewing
41 changes: 22 additions & 19 deletions
41
NitroxClient/Communication/Packets/Processors/PlayerJoinedMultiplayerSessionProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Collections; | ||
using NitroxClient.Communication.Packets.Processors.Abstract; | ||
using NitroxClient.GameLogic; | ||
using NitroxModel.Packets; | ||
using NitroxModel_Subnautica.DataStructures; | ||
using UWE; | ||
|
||
namespace NitroxClient.Communication.Packets.Processors | ||
namespace NitroxClient.Communication.Packets.Processors; | ||
|
||
public class PlayerJoinedMultiplayerSessionProcessor : ClientPacketProcessor<PlayerJoinedMultiplayerSession> | ||
{ | ||
public class PlayerJoinedMultiplayerSessionProcessor : ClientPacketProcessor<PlayerJoinedMultiplayerSession> | ||
{ | ||
private readonly PlayerManager playerManager; | ||
private readonly PlayerManager playerManager; | ||
private readonly Entities entities; | ||
|
||
public PlayerJoinedMultiplayerSessionProcessor(PlayerManager playerManager) | ||
{ | ||
this.playerManager = playerManager; | ||
} | ||
public PlayerJoinedMultiplayerSessionProcessor(PlayerManager playerManager, Entities entities) | ||
{ | ||
this.playerManager = playerManager; | ||
this.entities = entities; | ||
} | ||
|
||
public override void Process(PlayerJoinedMultiplayerSession packet) | ||
{ | ||
List<TechType> techTypes = packet.EquippedTechTypes.Select(techType => techType.ToUnity()).ToList(); | ||
List<Pickupable> items = new List<Pickupable>(); | ||
public override void Process(PlayerJoinedMultiplayerSession packet) | ||
{ | ||
CoroutineHost.StartCoroutine(SpawnRemotePlayer(packet)); | ||
} | ||
|
||
playerManager.Create(packet.PlayerContext); | ||
private IEnumerator SpawnRemotePlayer(PlayerJoinedMultiplayerSession packet) | ||
{ | ||
playerManager.Create(packet.PlayerContext); | ||
yield return entities.SpawnEntityAsync(packet.PlayerWorldEntity, true, true); | ||
|
||
Log.Info($"{packet.PlayerContext.PlayerName} joined the game"); | ||
Log.InGame(Language.main.Get("Nitrox_PlayerJoined").Replace("{PLAYER}", packet.PlayerContext.PlayerName)); | ||
} | ||
Log.Info($"{packet.PlayerContext.PlayerName} joined the game"); | ||
Log.InGame(Language.main.Get("Nitrox_PlayerJoined").Replace("{PLAYER}", packet.PlayerContext.PlayerName)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using NitroxModel.DataStructures; | ||
using NitroxModel.DataStructures.GameLogic; | ||
using NitroxModel.DataStructures.GameLogic.Entities; | ||
using NitroxModel.DataStructures.Util; | ||
using NitroxModel.MultiplayerSession; | ||
|
||
namespace NitroxModel.Packets | ||
namespace NitroxModel.Packets; | ||
|
||
[Serializable] | ||
public class PlayerJoinedMultiplayerSession : Packet | ||
{ | ||
[Serializable] | ||
public class PlayerJoinedMultiplayerSession : Packet | ||
{ | ||
public PlayerContext PlayerContext { get; } | ||
public Optional<NitroxId> SubRootId { get; } | ||
public List<NitroxTechType> EquippedTechTypes { get; } | ||
public PlayerContext PlayerContext { get; } | ||
public Optional<NitroxId> SubRootId { get; } | ||
public PlayerWorldEntity PlayerWorldEntity { get; } | ||
|
||
public PlayerJoinedMultiplayerSession(PlayerContext playerContext, Optional<NitroxId> subRootId, List<NitroxTechType> equippedTechTypes) | ||
{ | ||
PlayerContext = playerContext; | ||
SubRootId = subRootId; | ||
EquippedTechTypes = equippedTechTypes; | ||
} | ||
public PlayerJoinedMultiplayerSession(PlayerContext playerContext, Optional<NitroxId> subRootId, PlayerWorldEntity playerWorldEntity) | ||
{ | ||
PlayerContext = playerContext; | ||
SubRootId = subRootId; | ||
PlayerWorldEntity = playerWorldEntity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters