/// <summary> /// Constructs a new <see cref="StaticBody"/>. /// </summary> /// <param name="position">The world-space position of the new <see cref="StaticBody"/>.</param> /// <param name="collider">The collidable representation of the new <see cref="StaticBody"/>.</param> /// <param name="material">The <see cref="PhysicsMaterial"/> representing the new <see cref="StaticBody"/>.</param> public StaticBody(WorldPoint position, ICollider collider, PhysicsMaterial material) { if (collider == null) { Log.Warning("constructed a StaticBody with no collider"); } Position = position; Collider = collider; Material = material; }
RigidBody(RigidBody old, WorldPoint?position = null, ICollider collider = null, float?mass = null, PhysicsMaterial material = null, Vector2?velocity = null, Vector2?forces = null) { if (mass <= 0) { Log.Warning("RigidBody mass must be greater than 0"); mass = float.Epsilon; } Position = position ?? old?.Position ?? WorldPoint.Zero; Collider = collider ?? old?.Collider; Mass = mass ?? old?.Mass ?? 1; Material = material ?? old?.Material ?? new PhysicsMaterial(0, 0, 1); Velocity = velocity ?? old?.Velocity ?? Vector2.Zero; Forces = forces ?? old?.Forces ?? Vector2.Zero; }
/// <summary> /// Constructs a new <see cref="RigidBody"/>. /// </summary> /// <param name="position">The world-space position of the new <see cref="RigidBody"/>.</param> /// <param name="collider">The collidable representation of the new <see cref="RigidBody"/>.</param> /// <param name="mass">The total mass of the new <see cref="RigidBody"/>.</param> /// <param name="material">The <see cref="PhysicsMaterial"/> representing the new <see cref="RigidBody"/>.</param> public RigidBody(WorldPoint position, ICollider collider, float mass, PhysicsMaterial material) : this(null, position, collider, mass, material, Vector2.Zero, Vector2.Zero) { }