我有一个小游戏,我在其中实现了一些碰撞检测。现在我想获取与当前“实体”对象发生冲突的特定类型的所有项目的列表。我想做这样的事情:
public List<T> GetCollidingObjects<T>() where T : Entity
{
return this.Game.World.Entities
.AsParallel()
.Where(e => e.IsColliding(this))
.Where(e => e is T)
.ToList<T>();
}
我收到以下错误:
Instance argument: cannot convert from "System.Linq.ParallelQuery<GameName.GameObjects.Entity>" to "System.Collections.Generic.IEnumerable<T>"
谁能解释一下,为什么会这样?
谢谢!