-
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.
Fix destroyed vehicle also destroying their children player entities
- Loading branch information
1 parent
4421247
commit 3807b79
Showing
12 changed files
with
127 additions
and
34 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using NitroxModel.DataStructures; | ||
|
||
namespace NitroxModel.Packets; | ||
|
||
[Serializable] | ||
public class VehicleDestroyed : Packet | ||
{ | ||
public NitroxId Id { get; } | ||
|
||
public VehicleDestroyed(NitroxId id) | ||
{ | ||
Id = id; | ||
} | ||
} |
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
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
43 changes: 43 additions & 0 deletions
43
NitroxServer/Communication/Packets/Processors/VehicleDestroyedPacketProcessor.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using NitroxModel.DataStructures.GameLogic; | ||
using NitroxModel.DataStructures.GameLogic.Entities; | ||
using NitroxModel.Packets; | ||
using NitroxServer.Communication.Packets.Processors.Abstract; | ||
using NitroxServer.GameLogic; | ||
using NitroxServer.GameLogic.Entities; | ||
|
||
namespace NitroxServer.Communication.Packets.Processors; | ||
|
||
public class VehicleDestroyedPacketProcessor : AuthenticatedPacketProcessor<VehicleDestroyed> | ||
{ | ||
private readonly PlayerManager playerManager; | ||
private readonly EntitySimulation entitySimulation; | ||
private readonly WorldEntityManager worldEntityManager; | ||
|
||
public VehicleDestroyedPacketProcessor(PlayerManager playerManager, EntitySimulation entitySimulation, WorldEntityManager worldEntityManager) | ||
{ | ||
this.playerManager = playerManager; | ||
this.worldEntityManager = worldEntityManager; | ||
this.entitySimulation = entitySimulation; | ||
} | ||
|
||
public override void Process(VehicleDestroyed packet, Player destroyingPlayer) | ||
{ | ||
entitySimulation.EntityDestroyed(packet.Id); | ||
|
||
if (worldEntityManager.TryDestroyEntity(packet.Id, out Entity entity)) | ||
{ | ||
if (entity is VehicleWorldEntity vehicleWorldEntity) | ||
{ | ||
worldEntityManager.MovePlayerChildrenToRoot(vehicleWorldEntity); | ||
} | ||
foreach (Player player in playerManager.GetConnectedPlayers()) | ||
{ | ||
bool isOtherPlayer = player != destroyingPlayer; | ||
if (isOtherPlayer && player.CanSee(entity)) | ||
{ | ||
player.SendPacket(packet); | ||
} | ||
} | ||
} | ||
} | ||
} |
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