我有一个小游戏,我实现了一些碰撞检测.现在我想得到一个特定类型的所有项目的列表,这些项目与当前的"实体"对象发生冲突.我想做这样的事情:
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>();
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Instance argument: cannot convert from "System.Linq.ParallelQuery<GameName.GameObjects.Entity>" to "System.Collections.Generic.IEnumerable<T>"
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释,为什么会这样?
谢谢!