移植 C# 代码。这是对全局对象的引用吗?

Porting C# code. Is this a reference to a global object?

我正在尝试将 Aether.Physics2D 库从 C# 移植到 Xojo。这本质上是 Farseer 物理引擎的调整版本。大部分都完成了,但有一部分源代码我无法解决(可能是因为 C# 不是我的主要语言)。

Dynamics/Contacts/Contact.cs 中有多个对看起来像全局 Collision 对象的引用,但我找不到它的定义。例如,第 405 行,在 switch:

case ContactType.Polygon:
  Collision.Collision.CollidePolygons(ref manifold, (PolygonShape)FixtureA.Shape, ref transformA, (PolygonShape)FixtureB.Shape, ref transformB);
  break;

我已经移植了 Collision class 及其 CollidePolygons 静态方法(定义 here)但是为什么这段代码不只是:

Collision.CollidePolygons(ref manifold, (PolygonShape)FixtureA.Shape, ref transformA, (PolygonShape)FixtureB.Shape, ref transformB);

而不是:

Collision.Collision.CollidePolygons(ref manifold, (PolygonShape)FixtureA.Shape, ref transformA, (PolygonShape)FixtureB.Shape, ref transformB);

本质上,为什么会有 两个 Collision 调用?

非常感谢任何帮助。

不,那只是因为它是一个名为 Collision 的 class,位于名为 Collision:

的命名空间中
namespace tainicom.Aether.Physics2D.Collision
{
    public static class Collision
    {
    }
}

如果您无论如何都要移植代码,我强烈建议您 fix this mistake

您还可以使用 using 指令更改调用代码:

using Collision = tainicom.Aether.Physics2D.Collision.Collision;
...
// Calling the method is simpler now
Collision.CollidePolygons(...);

您可能想为您的别名提供一个不同的名称,实际上:

// TODO: Think of a better name to use :)
using CollisionClass = tainicom.Aether.Physics2D.Collision.Collision;
...
CollisionClass.CollidePolygons(...);

这样,名称 Collision 根本不会改变其含义,但您无需在任何地方使用 Collision.Collision