Example #1
0
        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();
            }
        }
Example #2
0
 private void HandleAddItemToContainer(AddItemToContainerPacket packet)
 {
     if (gameObjects.TryGet(packet.ItemId, out GameObject existingObject) && existingObject is Item existingItem)
     {
         gameObjects.UpdateObject(existingItem.Update(packet.Type, packet.Amount, (Location3D)packet.Location,
                                                      packet.Color,
                                                      packet.ContainerId, null));
     }
     else
     {
         var item = new Item(packet.ItemId, packet.Type, packet.Amount, (Location3D)packet.Location,
                             packet.Color, packet.ContainerId, null);
         gameObjects.AddObject(item);
         OnItemEnteredView(item);
     }
 }