-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from Baldie-dev/building-drones-sync
Player's drone sync + labor division
- Loading branch information
Showing
22 changed files
with
495 additions
and
14 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
17 changes: 17 additions & 0 deletions
17
NebulaClient/PacketProcessors/Players/NewDroneOrderProcessor.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,17 @@ | ||
using NebulaModel.Attributes; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets.Players; | ||
using NebulaModel.Packets.Processors; | ||
using NebulaWorld; | ||
|
||
namespace NebulaClient.PacketProcessors.Players | ||
{ | ||
[RegisterPacketProcessor] | ||
class NewDroneOrderProcessor : IPacketProcessor<NewDroneOrderPacket> | ||
{ | ||
public void ProcessPacket(NewDroneOrderPacket packet, NebulaConnection conn) | ||
{ | ||
SimulatedWorld.UpdateRemotePlayerDrone(packet); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
NebulaClient/PacketProcessors/Players/RemoveDroneOrdersProcessor.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,20 @@ | ||
using NebulaModel.Networking; | ||
using NebulaHost.PacketProcessors.Players; | ||
using NebulaModel.Packets.Processors; | ||
|
||
namespace NebulaClient.PacketProcessors.Players | ||
{ | ||
class RemoveDroneOrdersProcessor : IPacketProcessor<RemoveDroneOrdersPacket> | ||
{ | ||
public void ProcessPacket(RemoveDroneOrdersPacket packet, NebulaConnection conn) | ||
{ | ||
if (packet.QueuedEntityIds != null) | ||
{ | ||
for (int i = 0; i < packet.QueuedEntityIds.Length; i++) | ||
{ | ||
GameMain.mainPlayer.mecha.droneLogic.serving.Remove(packet.QueuedEntityIds[i]); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
NebulaHost/PacketProcessors/Players/NewDroneOrderProcessor.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,45 @@ | ||
using NebulaModel.Attributes; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets.Players; | ||
using NebulaModel.Packets.Processors; | ||
using NebulaWorld; | ||
using NebulaWorld.Player; | ||
|
||
namespace NebulaHost.PacketProcessors.Players | ||
{ | ||
[RegisterPacketProcessor] | ||
class NewDroneOrderProcessor : IPacketProcessor<NewDroneOrderPacket> | ||
{ | ||
private PlayerManager playerManager; | ||
|
||
public NewDroneOrderProcessor() | ||
{ | ||
playerManager = MultiplayerHostSession.Instance.PlayerManager; | ||
} | ||
|
||
public void ProcessPacket(NewDroneOrderPacket packet, NebulaConnection conn) | ||
{ | ||
//Host does not need to know about flying drones of other players if he is not on the same planet | ||
if (GameMain.mainPlayer.planetId != packet.PlanetId) | ||
{ | ||
return; | ||
} | ||
|
||
Player player = playerManager.GetPlayer(conn); | ||
|
||
if (player != null) | ||
{ | ||
if (packet.Stage == 1 || packet.Stage == 2) | ||
{ | ||
DroneManager.AddPlayerDronePlan(player.Id, packet.EntityId); | ||
} | ||
else if (packet.Stage == 3) | ||
{ | ||
DroneManager.RemovePlayerDronePlan(player.Id, packet.EntityId); | ||
} | ||
|
||
SimulatedWorld.UpdateRemotePlayerDrone(packet); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
NebulaHost/PacketProcessors/Routers/PlanetBroadcastProcessor.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,28 @@ | ||
using NebulaModel.Attributes; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets.Processors; | ||
using NebulaModel.Packets.Routers; | ||
|
||
namespace NebulaHost.PacketProcessors.Routers | ||
{ | ||
[RegisterPacketProcessor] | ||
class PlanetBroadcastProcessor : IPacketProcessor<PlanetBroadcastPacket> | ||
{ | ||
private PlayerManager playerManager; | ||
public PlanetBroadcastProcessor() | ||
{ | ||
playerManager = MultiplayerHostSession.Instance.PlayerManager; | ||
} | ||
public void ProcessPacket(PlanetBroadcastPacket packet, NebulaConnection conn) | ||
{ | ||
Player player = playerManager.GetPlayer(conn); | ||
if (player != null) | ||
{ | ||
//Forward packet to other users | ||
playerManager.SendRawPacketToPlanet(packet.PacketObject, packet.PlanetId, conn); | ||
//Forward packet to the host | ||
MultiplayerHostSession.Instance.PacketProcessor.EnqueuePacketForProcessing(packet.PacketObject, conn); | ||
} | ||
} | ||
} | ||
} |
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,23 @@ | ||
namespace NebulaModel.Packets.Players | ||
{ | ||
public class NewDroneOrderPacket | ||
{ | ||
public int PlanetId { get; set; } | ||
public int DroneId { get; set; } | ||
public int EntityId { get; set; } | ||
public ushort PlayerId { get; set; } | ||
public int Stage { get; set; } | ||
public int Priority { get; set; } | ||
|
||
public NewDroneOrderPacket() { } | ||
public NewDroneOrderPacket(int planetId, int droneId, int entityId, ushort playerId, int stage, int priority) | ||
{ | ||
PlanetId = planetId; | ||
DroneId = droneId; | ||
EntityId = entityId; | ||
PlayerId = playerId; | ||
Stage = stage; | ||
Priority = priority; | ||
} | ||
} | ||
} |
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,14 @@ | ||
namespace NebulaHost.PacketProcessors.Players | ||
{ | ||
public class RemoveDroneOrdersPacket | ||
{ | ||
public int[] QueuedEntityIds { get; set; } | ||
|
||
public RemoveDroneOrdersPacket() { } | ||
|
||
public RemoveDroneOrdersPacket(int[] queuedEntityIds) | ||
{ | ||
QueuedEntityIds = queuedEntityIds; | ||
} | ||
} | ||
} |
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 @@ | ||
namespace NebulaModel.Packets.Routers | ||
{ | ||
public class PlanetBroadcastPacket | ||
{ | ||
public byte[] PacketObject { get; set; } | ||
public int PlanetId { get; set; } | ||
|
||
public PlanetBroadcastPacket() { } | ||
public PlanetBroadcastPacket(byte[] packetObject, int planetId) | ||
{ | ||
PacketObject = packetObject; | ||
PlanetId = planetId; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.