public void DrawGamePlayer(ObjectId playerId, ModelId bodyType, Location3D location, Direction direction, MovementType movementType, Color color) { var drawGamePlayerPacket = new DrawGamePlayerPacket(playerId, bodyType, location, direction, movementType, color); Send(drawGamePlayerPacket.RawPacket); }
private void HandleDrawGamePlayerPacket(DrawGamePlayerPacket packet) { if (packet.PlayerId == player.PlayerId) { player.Location = packet.Location; player.PredictedLocation = packet.Location; player.Direction = packet.Direction; player.MovementType = packet.MovementType; player.PredictedDirection = player.Direction; player.ResetWalkRequestQueue(); player.Flags = packet.Flags; player.CurrentSequenceKey = 0; player.Color = packet.Color; player.BodyType = packet.BodyType; if (gameObjects[packet.PlayerId] is Mobile mobile) { gameObjects.UpdateObject(mobile.Update(packet.BodyType, packet.Location, packet.Color, packet.Direction, packet.MovementType, Notoriety.Friend, packet.Flags)); } else { mobile = new Mobile(packet.PlayerId, packet.BodyType, packet.Location, packet.Color, packet.Direction, packet.MovementType, Notoriety.Friend, packet.Flags); gameObjects.AddObject(mobile); } OnWalkRequestDequeued(); } }
public void Can_deserialize() { var rawPacket = FakePackets.Instantiate(new byte[] { 0x20, // packet 0x00, 0x00, 0x00, 0x01, // id 0x01, 0x90, // body type 0x00, // unknown 0x83, 0xEA, // skin color hue 0x00, // flag byte 0x12, 0x9C, // xloc 0x05, 0x52, // yloc 0x00, 0x00, // unknown 0x04, // direction 0x0A, // zloc }); var packet = new DrawGamePlayerPacket(); packet.Deserialize(rawPacket); packet.PlayerId.Should().Be(new ObjectId(0x00000001)); packet.BodyType.Should().Be((ModelId)0x0190); packet.Location.X.Should().Be(0x129C); packet.Location.Y.Should().Be(0x0552); packet.Location.Z.Should().Be(0x0A); packet.Color.Should().Be((Color)0x83EA); packet.MovementType.Should().Be(MovementType.Walk); packet.Direction.Should().Be(Direction.South); }
public void Can_deserialize_packet_with_negative_z_coord() { var rawPacket = FakePackets.Instantiate(new byte[] { 0x20, // packet 0x00, 0x00, 0x00, 0x01, // id 0x01, 0x90, // body type 0x00, // unknown 0x83, 0xEA, // skin color hue 0x00, // flag byte 0x12, 0x9C, // xloc 0x05, 0x52, // yloc 0x00, 0x00, // unknown 0x04, // direction 0xF0, // zloc }); var packet = new DrawGamePlayerPacket(); packet.Deserialize(rawPacket); unchecked { packet.Location.Z.Should().Be((sbyte)0xF0); } }
private void EnterGameSA() { SendToClient(new CharLocaleAndBodyPacket() { PlayerId = legacyApi.Me.PlayerId, BodyType = legacyApi.Me.BodyType, Direction = legacyApi.Me.Direction, MovementType = legacyApi.Me.MovementType, Location = legacyApi.Me.Location, }.Serialize()); SendToClient(new SetMapPacket(reloginInfo.MapId).RawPacket); var enableFeaturesPacket = packetRegistry.Instantiate <EnableLockedClientFeaturesPacket>(0xB9); enableFeaturesPacket.Flags = reloginInfo.EnabledFeatureFlags; SendToClient(enableFeaturesPacket.Serialize()); var drawPlayer = new DrawGamePlayerPacket(legacyApi.Me.PlayerId, legacyApi.Me.BodyType, legacyApi.Me.Location, legacyApi.Me.Direction, legacyApi.Me.MovementType, legacyApi.Me.Color); SendToClient(drawPlayer.Serialize()); foreach (var obj in UO.Items.OnGround()) { var objectInfo = new ObjectInfoPacket(obj.Id, obj.Type, obj.Location, obj.Color, obj.Amount); SendToClient(objectInfo.RawPacket); } foreach (var mobile in UO.Mobiles) { var drawPacket = packetRegistry.Instantiate <DrawObjectPacket>(0x78); drawPacket.Color = mobile.Color.HasValue ? mobile.Color.Value : (Color)0; drawPacket.Direction = mobile.Orientation.HasValue ? mobile.Orientation.Value : Direction.North; drawPacket.Flags = mobile.Flags; drawPacket.Id = mobile.Id; drawPacket.Location = mobile.Location; drawPacket.MovementType = mobile.CurrentMovementType.HasValue ? mobile.CurrentMovementType.Value : MovementType.Walk; drawPacket.Notoriety = mobile.Notoriety.HasValue ? mobile.Notoriety.Value : Notoriety.Innocent; drawPacket.Type = mobile.Type; var items = UO.Items.InContainer(mobile.Id).Where(i => i.Layer.HasValue).ToArray(); drawPacket.Items = items; SendToClient(drawPacket.Serialize()); } drawPlayer = new DrawGamePlayerPacket(legacyApi.Me.PlayerId, legacyApi.Me.BodyType, legacyApi.Me.Location, legacyApi.Me.Direction, legacyApi.Me.MovementType, legacyApi.Me.Color); SendToClient(drawPlayer.Serialize()); SendToClient(new Packet(new byte[] { 0x55 })); }