-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.NPC; | ||
|
||
namespace EOLib.Net.Translators | ||
{ | ||
[AutoMappedType] | ||
public class NPCFromPacketFactory : INPCFromPacketFactory | ||
{ | ||
public NPCFromPacketFactory() | ||
{ | ||
} | ||
|
||
public INPC CreateNPC(IPacket packet) | ||
{ | ||
var index = packet.ReadChar(); | ||
var id = packet.ReadShort(); | ||
var x = packet.ReadChar(); | ||
var y = packet.ReadChar(); | ||
var direction = (EODirection)packet.ReadChar(); | ||
|
||
INPC npc = new NPC(id, index); | ||
npc = npc.WithX(x).WithY(y).WithDirection(direction).WithFrame(NPCFrame.Standing); | ||
return npc; | ||
} | ||
} | ||
|
||
public interface INPCFromPacketFactory | ||
{ | ||
INPC CreateNPC(IPacket 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