# CollisionContent record

> Converted collision content: the shapes something collides with, and what it weighs. A model's is <model>/collision, made from Source's .phy for Garry's Mod, and a Plugin makes its own to give BodySpec for IPhysicsWorld.Add. Every length is in metres on Godot's axes, about the body's origin.

Namespace `EvilEngine.Formats.Collision`, assembly `EvilEngine.Formats`. Engine commit 4ff877b1.

```csharp
public sealed record CollisionContent
```

Converted collision content: the shapes something collides with, and what it weighs. A model's is `<model>/collision`, made from Source's `.phy` for Garry's Mod, and a Plugin makes its own to give [BodySpec](/docs/api/bodyspec) for [IPhysicsWorld.Add](/docs/api/iphysicsworld#add). Every length is in metres on Godot's axes, about the body's origin.

A box crate and a ball, each one [Collider](/docs/api/collider):

```csharp
using System.Numerics;
using EvilEngine.Api.Physics;
using EvilEngine.Formats.Collision;
using EvilEngine.Formats.Maps;

var crate = new CollisionContent([new Collider(new ColliderShape.Box(new Vector3(0.8f, 0.8f, 0.8f)), ["solid"])]);
var ball = new CollisionContent([new Collider(new ColliderShape.Sphere(0.25f), ["solid"])])
{
    Motion = new CollisionMotion { Mass = 2 }
};

context.Physics?.Add(new BodySpec(crate) { Position = new MapVector(0, 2, 0), Mass = 30 });
context.Physics?.Add(new BodySpec(ball) { Position = new MapVector(1, 2, 0) });
```

A collision of several colliders is one rigid body of all of them, each placed by its own [Position](/docs/api/collider#position) and [Rotation](/docs/api/collider#rotation). A dynamic body takes only convex shapes, so one holding a [Mesh](/docs/api/collidershape-mesh) can only be static or kinematic.

## Members

### CollisionContent (constructor)

```csharp
public CollisionContent(IReadOnlyList<Collider> Colliders)
```

Makes a collision of `colliders`, with no motion and no jointed bodies.

### Empty (field)

```csharp
public static readonly CollisionContent Empty
```

A collision with no colliders, what something that collides with nothing has.

### Colliders (property)

```csharp
public IReadOnlyList<Collider> Colliders { get; init; }
```

The [colliders](/docs/api/collider), each a shape, what it's made of and where it sits. A jointed collision's [Bodies](#bodies) name them by their index here.

### Motion (property)

```csharp
public CollisionMotion? Motion { get; init; }
```

The [CollisionMotion](/docs/api/collisionmotion) of a collision that's one moving body, or `null`. Only its mass is read: [IPhysicsWorld.Add](/docs/api/iphysicsworld#add) gives a body it, unless [BodySpec.Mass](/docs/api/bodyspec#mass) is set. Source's `.phy` gives one for a prop of one solid, with the solid's `mass`. A jointed collision has none: each of its bodies gives its own mass.

### Bodies (property)

```csharp
public IReadOnlyList<CollisionBody> Bodies { get; init; }
```

A jointed collision's [bodies](/docs/api/collisionbody), such as a ragdoll's parts, each owning some of the [Colliders](#colliders). Empty for a collision that's one body. Every collider must be in exactly one body for it to be written. [IPhysicsWorld.Add](/docs/api/iphysicsworld#add) doesn't read them and makes one body of every collider. A death ragdoll is made from them by the host, one physics body for each, and Source's `.phy` gives them for a model with more than one solid.

### Joints (property)

```csharp
public IReadOnlyList<CollisionJoint> Joints { get; init; }
```

The [joints](/docs/api/collisionjoint) between [Bodies](#bodies), each joining two of them by index. Empty unless the collision is jointed.

### Jointed (property)

```csharp
public bool Jointed { get; }
```

Whether the collision has [Bodies](#bodies), so it's a set of jointed parts rather than one body.
