WIP porting collision code from C#