-
Notifications
You must be signed in to change notification settings - Fork 53
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 #239 from alborrajo/feature/lostpawn
Handlers for pawn death requests
- Loading branch information
Showing
7 changed files
with
120 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Linq; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class PawnPawnLostHandler : GameStructurePacketHandler<C2SPawnPawnLostReq> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(PawnPawnLostHandler)); | ||
|
||
public PawnPawnLostHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SPawnPawnLostReq> packet) | ||
{ | ||
// TODO: Lost pawns system | ||
Pawn pawn = client.Character.Pawns.Where(pawn => pawn.PawnId == packet.Structure.PawnId).Single(); | ||
client.Send(new S2CPawnPawnLostRes() | ||
{ | ||
PawnId = pawn.PawnId, | ||
PawnName = pawn.Name, | ||
IsLost = false | ||
}); | ||
} | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SPawnPawnLostReq.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 Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Shared.Network; | ||
|
||
namespace Arrowgene.Ddon.Shared.Entity.PacketStructure | ||
{ | ||
public class C2SPawnPawnLostReq : IPacketStructure | ||
{ | ||
public PacketId Id => PacketId.C2S_PAWN_PAWN_LOST_REQ; | ||
|
||
public uint PawnId { get; set; } | ||
|
||
public class Serializer : PacketEntitySerializer<C2SPawnPawnLostReq> | ||
{ | ||
public override void Write(IBuffer buffer, C2SPawnPawnLostReq obj) | ||
{ | ||
WriteUInt32(buffer, obj.PawnId); | ||
} | ||
|
||
public override C2SPawnPawnLostReq Read(IBuffer buffer) | ||
{ | ||
C2SPawnPawnLostReq obj = new C2SPawnPawnLostReq(); | ||
obj.PawnId = ReadUInt32(buffer); | ||
return obj; | ||
} | ||
} | ||
|
||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
Arrowgene.Ddon.Shared/Entity/PacketStructure/S2CPawnPawnLostRes.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,40 @@ | ||
using Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Shared.Network; | ||
|
||
namespace Arrowgene.Ddon.Shared.Entity.PacketStructure | ||
{ | ||
public class S2CPawnPawnLostRes : ServerResponse | ||
{ | ||
public override PacketId Id => PacketId.S2C_PAWN_PAWN_LOST_RES; | ||
|
||
public S2CPawnPawnLostRes() | ||
{ | ||
PawnName = string.Empty; | ||
} | ||
|
||
public uint PawnId { get; set; } | ||
public string PawnName { get; set; } | ||
public bool IsLost { get; set; } | ||
|
||
public class Serializer : PacketEntitySerializer<S2CPawnPawnLostRes> | ||
{ | ||
public override void Write(IBuffer buffer, S2CPawnPawnLostRes obj) | ||
{ | ||
WriteServerResponse(buffer, obj); | ||
WriteUInt32(buffer, obj.PawnId); | ||
WriteMtString(buffer, obj.PawnName); | ||
WriteBool(buffer, obj.IsLost); | ||
} | ||
|
||
public override S2CPawnPawnLostRes Read(IBuffer buffer) | ||
{ | ||
S2CPawnPawnLostRes obj = new S2CPawnPawnLostRes(); | ||
ReadServerResponse(buffer, obj); | ||
obj.PawnId = ReadUInt32(buffer); | ||
obj.PawnName = ReadMtString(buffer); | ||
obj.IsLost = ReadBool(buffer); | ||
return obj; | ||
} | ||
} | ||
} | ||
} |