public List <object> QueryGame(string playerName, int intQueryType, int[] arguments) { var queryType = (GameQueryType)intQueryType; var result = new List <object> { intQueryType }; var player = FindPlayer(playerName); if (player?.Entity.Being.IsAlive != true) { return(result); } var manager = player.Entity.Manager; var context = new SerializationContext(_dbContext, player.Entity, _gameServices); switch (queryType) { case GameQueryType.SlottableAbilities: var slot = arguments[0]; result.Add(slot); var abilities = new List <object>(); result.Add(abilities); foreach (var slottableAbilityEntity in manager.AbilitiesToAffectableRelationship[player.EntityId]) { var ability = slottableAbilityEntity.Ability; if (!ability.IsUsable) { continue; } if (slot == AbilitySlottingSystem.DefaultMeleeAttackSlot) { if (ability.Template?.Type == AbilityType.DefaultAttack && ((WieldingAbility)ability.Template).ItemType == ItemType.WeaponMelee) { abilities.Add(AbilitySnapshot.Serialize(slottableAbilityEntity, null, context)); } } else if (slot == AbilitySlottingSystem.DefaultRangedAttackSlot) { if (ability.Template?.Type == AbilityType.DefaultAttack && ((WieldingAbility)ability.Template).ItemType == ItemType.WeaponRanged) { abilities.Add(AbilitySnapshot.Serialize(slottableAbilityEntity, null, context)); } } else if ((ability.Activation & ActivationType.Slottable) != 0 && ability.Template?.Type != AbilityType.DefaultAttack) { abilities.Add(AbilitySnapshot.Serialize(slottableAbilityEntity, null, context)); } } break; case GameQueryType.PlayerAttributes: result.Add(LevelActorSnapshot.SerializeAttributes(player.Entity, SenseType.Sight, context)); break; case GameQueryType.PlayerAdaptations: result.Add(PlayerSnapshot.SerializeAdaptations(player.Entity, context)); break; case GameQueryType.PlayerSkills: result.Add(PlayerSnapshot.SerializeSkills(player.Entity, context)); break; case GameQueryType.ActorAttributes: var actorKnowledge = manager.FindEntity(arguments[0])?.Knowledge; result.Add(LevelActorSnapshot.SerializeAttributes( actorKnowledge?.KnownEntity, actorKnowledge?.SensedType ?? SenseType.None, context)); break; case GameQueryType.ItemAttributes: var itemEntity = manager.FindEntity(arguments[0]); var item = itemEntity?.Item; var itemKnowledge = itemEntity?.Knowledge; if (item != null) { result.Add(InventoryItemSnapshot.SerializeAttributes(itemEntity, SenseType.Sight, context)); } else { result.Add(InventoryItemSnapshot.SerializeAttributes( itemKnowledge?.KnownEntity, itemKnowledge?.SensedType ?? SenseType.None, context)); } break; case GameQueryType.AbilityAttributes: var abilityEntity = manager.FindEntity(arguments[0]); var ownerEntity = abilityEntity.Ability.OwnerEntity; var activatorEntity = abilityEntity.Ability.OwnerEntity.HasComponent(EntityComponent.Item) ? player.Entity : ownerEntity; result.Add(AbilitySnapshot.SerializeAttributes(abilityEntity, activatorEntity, context)); break; default: throw new InvalidOperationException($"Query type {intQueryType} not supported"); } return(result); }