Exemplo n.º 1
0
        public void UpdateSlots(SyncSession session, GestureQuickSlotsUpdateRequest request)
        {
            foreach (uint id in request.Values)
            {
                if (id == 0)
                {
                    continue;
                }

                if (!_tables.Gesture.TryGetValue((ushort)id, out GestureTableEntity? gesture))
                {
                    NetworkUtils.DropBadAction();
                }

                if (gesture !.Hero != session.Character.Hero && gesture !.Hero != Hero.None)
                {
                    NetworkUtils.DropBadAction();
                }
            }

            using CharacterContext context = _characterRepository.CreateDbContext();

            CharacterModel model = context.Characters.First(s => s.Id == session.Character.Id);

            model.Gestures = request.Values.ToArray();

            context.UseAndSave(c => c.Update(model));

            session.SendDeferred(new CharacterGestureUpdateSlotsResponse()
            {
                Values = request.Values
            });
        }