Barotrauma Client
Loading...
Searching...
No Matches
Barotrauma.PhysicsBody Class Reference

Public Types

enum  Shape { Circle , Rectangle , Capsule , HorizontalCapsule }
 

Public Member Functions

float TransformRotation (float rotation)
 
 PhysicsBody (XElement element, float scale=1.0f, bool findNewContacts=true)
 
 PhysicsBody (ColliderParams cParams, bool findNewContacts=true)
 
 PhysicsBody (LimbParams lParams, bool findNewContacts=true)
 
 PhysicsBody (float width, float height, float radius, float density, BodyType bodyType, Category collisionCategory, Category collidesWith, bool findNewContacts=true)
 
 PhysicsBody (Body farseerBody)
 
 PhysicsBody (ColliderParams colliderParams, Vector2 position, bool findNewContacts=true)
 
 PhysicsBody (LimbParams limbParams, Vector2 position, bool findNewContacts=true)
 
 PhysicsBody (XElement element, Vector2 position, float scale=1.0f, float? forceDensity=null, Category collisionCategory=Physics.CollisionItem, Category collidesWith=Physics.CollisionWall|Physics.CollisionLevel|Physics.CollisionPlatform, bool findNewContacts=true)
 
Vector2 GetLocalFront (float? spritesheetRotation=null)
 Returns the farthest point towards the forward of the body. For capsules and circles, the front is at the top. For horizontal capsules, the front is at the right-most point. For rectangles, the front is either at the top or at the right, depending on which one of the two is greater: width or height. The rotation is in radians.
 
float GetMaxExtent ()
 
Vector2 GetSize ()
 
void SetSize (Vector2 size)
 
bool IsValidValue (float value, string valueName, float minValue=float.MinValue, float maxValue=float.MaxValue)
 
void ResetDynamics ()
 
void ApplyLinearImpulse (Vector2 impulse)
 
void ApplyLinearImpulse (Vector2 impulse, float maxVelocity)
 Apply an impulse to the body without increasing it's velocity above a specific limit.
 
void ApplyLinearImpulse (Vector2 impulse, Vector2 point)
 
void ApplyLinearImpulse (Vector2 impulse, Vector2 point, float maxVelocity)
 Apply an impulse to the body without increasing it's velocity above a specific limit.
 
void ApplyForce (Vector2 force, float maxVelocity=NetConfig.MaxPhysicsBodyVelocity)
 
void ApplyForce (Vector2 force, Vector2 point)
 
void ApplyTorque (float torque)
 
bool SetTransform (Vector2 simPosition, float rotation, bool setPrevTransform=true)
 
bool SetTransformIgnoreContacts (Vector2 simPosition, float rotation, bool setPrevTransform=true)
 
void SetPrevTransform (Vector2 simPosition, float rotation)
 
void MoveToTargetPosition (bool lerp=true)
 
void MoveToPos (Vector2 simPosition, float force, Vector2? pullPos=null)
 
void ApplyWaterForces ()
 Applies buoyancy, drag and angular drag caused by water.
 
void Update ()
 
void UpdateDrawPosition (bool interpolate=true)
 
void CorrectPosition< T > (List< T > positionBuffer, out Vector2 newPosition, out Vector2 newVelocity, out float newRotation, out float newAngularVelocity)
 
void SmoothRotate (float targetRotation, float force=10.0f, bool wrapAngle=true)
 Rotate the body towards the target rotation in the "shortest direction", taking into account the current angular velocity to prevent overshooting.
 
float WrapAngleToSameNumberOfRevolutions (float angle)
 Wraps the angle so it has "has the same number of revolutions" as this body, i.e. that the angles are at most 180 degrees apart. For example, if the angle of this body was 720, an angle of 5 would get wrapped to 725.
 
void Remove ()
 

Static Public Member Functions

static float TransformRotation (float rot, float dir)
 
static void RemoveAll ()
 
static bool IsValidShape (float radius, float height, float width)
 
static Shape DefineBodyShape (float radius, float width, float height)
 

Public Attributes

float? PositionSmoothingFactor
 
Submarine Submarine
 

Static Public Attributes

const float MinDensity = 0.01f
 
const float DefaultAngularDamping = 5.0f
 

Protected Attributes

Vector2 prevPosition
 
float prevRotation
 
Vector2targetPosition
 
float? targetRotation
 

Properties

static List< PhysicsBodyList [get]
 
bool Removed [get]
 
Vector2 LastSentPosition [get]
 
float Height [get]
 
float Width [get]
 
float Radius [get]
 
Shape BodyShape [get]
 
Vector2TargetPosition [get, set]
 
float? TargetRotation [get, set]
 
Vector2 DrawPosition [get]
 
float DrawRotation [get]
 
float Dir [get, set]
 
bool Enabled [get, set]
 
bool PhysEnabled [get, set]
 
Vector2 SimPosition [get]
 
Vector2 Position [get]
 
Vector2 DrawPositionOffset [get]
 Offset of the DrawPosition from the Position (i.e. how much the interpolated draw position is offset from the "actual position"). In display units.
 
Vector2 PrevPosition [get]
 
float Rotation [get]
 
float TransformedRotation [get]
 Takes flipping (Dir) into account.
 
Vector2 LinearVelocity [get, set]
 
float AngularVelocity [get, set]
 
float Mass [get]
 
float Density [get]
 
Body FarseerBody [get]
 
object UserData [get, set]
 
float Friction [set]
 
BodyType BodyType [get, set]
 
Category CollisionCategories [get, set]
 
Category CollidesWith [get, set]
 
bool SuppressSmoothRotationCalls [get, set]
 Ignore rotation calls for the rest of this and the next update. Automatically disabled after that. Used for temporarily suppressing the SmoothRotate calls to prevent conflicting or unitentionally amplified rotations.
 

Member Enumeration Documentation

◆ Shape

Enumerator
Circle 
Rectangle 
Capsule 
HorizontalCapsule 

Constructor & Destructor Documentation

◆ PhysicsBody() [1/8]

Barotrauma.PhysicsBody.PhysicsBody ( XElement element,
float scale = 1::0f,
bool findNewContacts = true )

◆ PhysicsBody() [2/8]

Barotrauma.PhysicsBody.PhysicsBody ( ColliderParams cParams,
bool findNewContacts = true )

◆ PhysicsBody() [3/8]

Barotrauma.PhysicsBody.PhysicsBody ( LimbParams lParams,
bool findNewContacts = true )

◆ PhysicsBody() [4/8]

Barotrauma.PhysicsBody.PhysicsBody ( float width,
float height,
float radius,
float density,
BodyType bodyType,
Category collisionCategory,
Category collidesWith,
bool findNewContacts = true )

◆ PhysicsBody() [5/8]

Barotrauma.PhysicsBody.PhysicsBody ( Body farseerBody)

◆ PhysicsBody() [6/8]

Barotrauma.PhysicsBody.PhysicsBody ( ColliderParams colliderParams,
Vector2 position,
bool findNewContacts = true )

◆ PhysicsBody() [7/8]

Barotrauma.PhysicsBody.PhysicsBody ( LimbParams limbParams,
Vector2 position,
bool findNewContacts = true )

◆ PhysicsBody() [8/8]

Barotrauma.PhysicsBody.PhysicsBody ( XElement element,
Vector2 position,
float scale = 1::0f,
float? forceDensity = null,
Category collisionCategory = Physics::CollisionItem,
Category collidesWith = Physics::CollisionWall | Physics::CollisionLevel | Physics::CollisionPlatform,
bool findNewContacts = true )

Member Function Documentation

◆ ApplyForce() [1/2]

void Barotrauma.PhysicsBody.ApplyForce ( Vector2 force,
float maxVelocity = NetConfig::MaxPhysicsBodyVelocity )

◆ ApplyForce() [2/2]

void Barotrauma.PhysicsBody.ApplyForce ( Vector2 force,
Vector2 point )

◆ ApplyLinearImpulse() [1/4]

void Barotrauma.PhysicsBody.ApplyLinearImpulse ( Vector2 impulse)

◆ ApplyLinearImpulse() [2/4]

void Barotrauma.PhysicsBody.ApplyLinearImpulse ( Vector2 impulse,
float maxVelocity )

Apply an impulse to the body without increasing it's velocity above a specific limit.

◆ ApplyLinearImpulse() [3/4]

void Barotrauma.PhysicsBody.ApplyLinearImpulse ( Vector2 impulse,
Vector2 point )

◆ ApplyLinearImpulse() [4/4]

void Barotrauma.PhysicsBody.ApplyLinearImpulse ( Vector2 impulse,
Vector2 point,
float maxVelocity )

Apply an impulse to the body without increasing it's velocity above a specific limit.

◆ ApplyTorque()

void Barotrauma.PhysicsBody.ApplyTorque ( float torque)

◆ ApplyWaterForces()

void Barotrauma.PhysicsBody.ApplyWaterForces ( )

Applies buoyancy, drag and angular drag caused by water.

◆ CorrectPosition< T >()

void Barotrauma.PhysicsBody.CorrectPosition< T > ( List< T > positionBuffer,
out Vector2 newPosition,
out Vector2 newVelocity,
out float newRotation,
out float newAngularVelocity )
Type Constraints
T :PosInfo 

◆ DefineBodyShape()

static Shape Barotrauma.PhysicsBody.DefineBodyShape ( float radius,
float width,
float height )
static

◆ GetLocalFront()

Vector2 Barotrauma.PhysicsBody.GetLocalFront ( float? spritesheetRotation = null)

Returns the farthest point towards the forward of the body. For capsules and circles, the front is at the top. For horizontal capsules, the front is at the right-most point. For rectangles, the front is either at the top or at the right, depending on which one of the two is greater: width or height. The rotation is in radians.

◆ GetMaxExtent()

float Barotrauma.PhysicsBody.GetMaxExtent ( )

◆ GetSize()

Vector2 Barotrauma.PhysicsBody.GetSize ( )

◆ IsValidShape()

static bool Barotrauma.PhysicsBody.IsValidShape ( float radius,
float height,
float width )
static

◆ IsValidValue()

bool Barotrauma.PhysicsBody.IsValidValue ( float value,
string valueName,
float minValue = float::MinValue,
float maxValue = float::MaxValue )

◆ MoveToPos()

void Barotrauma.PhysicsBody.MoveToPos ( Vector2 simPosition,
float force,
Vector2? pullPos = null )

◆ MoveToTargetPosition()

void Barotrauma.PhysicsBody.MoveToTargetPosition ( bool lerp = true)

◆ Remove()

void Barotrauma.PhysicsBody.Remove ( )

◆ RemoveAll()

static void Barotrauma.PhysicsBody.RemoveAll ( )
static

◆ ResetDynamics()

void Barotrauma.PhysicsBody.ResetDynamics ( )

◆ SetPrevTransform()

void Barotrauma.PhysicsBody.SetPrevTransform ( Vector2 simPosition,
float rotation )

◆ SetSize()

void Barotrauma.PhysicsBody.SetSize ( Vector2 size)

◆ SetTransform()

bool Barotrauma.PhysicsBody.SetTransform ( Vector2 simPosition,
float rotation,
bool setPrevTransform = true )

◆ SetTransformIgnoreContacts()

bool Barotrauma.PhysicsBody.SetTransformIgnoreContacts ( Vector2 simPosition,
float rotation,
bool setPrevTransform = true )

◆ SmoothRotate()

void Barotrauma.PhysicsBody.SmoothRotate ( float targetRotation,
float force = 10::0f,
bool wrapAngle = true )

Rotate the body towards the target rotation in the "shortest direction", taking into account the current angular velocity to prevent overshooting.

Parameters
targetRotationDesired rotation in radians
forceHow fast the body should be rotated. Does not represent any real unit, you may want to experiment with different values to get the desired effect.
wrapAngleShould the angles be wrapped. Set to false if it makes a difference whether the angle of the body is 0.0f or 360.0f.

◆ TransformRotation() [1/2]

static float Barotrauma.PhysicsBody.TransformRotation ( float rot,
float dir )
static

◆ TransformRotation() [2/2]

float Barotrauma.PhysicsBody.TransformRotation ( float rotation)

◆ Update()

void Barotrauma.PhysicsBody.Update ( )

◆ UpdateDrawPosition()

void Barotrauma.PhysicsBody.UpdateDrawPosition ( bool interpolate = true)

◆ WrapAngleToSameNumberOfRevolutions()

float Barotrauma.PhysicsBody.WrapAngleToSameNumberOfRevolutions ( float angle)

Wraps the angle so it has "has the same number of revolutions" as this body, i.e. that the angles are at most 180 degrees apart. For example, if the angle of this body was 720, an angle of 5 would get wrapped to 725.

Member Data Documentation

◆ DefaultAngularDamping

const float Barotrauma.PhysicsBody.DefaultAngularDamping = 5.0f
static

◆ MinDensity

const float Barotrauma.PhysicsBody.MinDensity = 0.01f
static

◆ PositionSmoothingFactor

float? Barotrauma.PhysicsBody.PositionSmoothingFactor

◆ prevPosition

Vector2 Barotrauma.PhysicsBody.prevPosition
protected

◆ prevRotation

float Barotrauma.PhysicsBody.prevRotation
protected

◆ Submarine

Submarine Barotrauma.PhysicsBody.Submarine

◆ targetPosition

Vector2? Barotrauma.PhysicsBody.targetPosition
protected

◆ targetRotation

float? Barotrauma.PhysicsBody.targetRotation
protected

Property Documentation

◆ AngularVelocity

float Barotrauma.PhysicsBody.AngularVelocity
getset

◆ BodyShape

Shape Barotrauma.PhysicsBody.BodyShape
get

◆ BodyType

BodyType Barotrauma.PhysicsBody.BodyType
getset

◆ CollidesWith

Category Barotrauma.PhysicsBody.CollidesWith
getset

◆ CollisionCategories

Category Barotrauma.PhysicsBody.CollisionCategories
getset

◆ Density

float Barotrauma.PhysicsBody.Density
get

◆ Dir

float Barotrauma.PhysicsBody.Dir
getset

◆ DrawPosition

Vector2 Barotrauma.PhysicsBody.DrawPosition
get

◆ DrawPositionOffset

Vector2 Barotrauma.PhysicsBody.DrawPositionOffset
get

Offset of the DrawPosition from the Position (i.e. how much the interpolated draw position is offset from the "actual position"). In display units.

◆ DrawRotation

float Barotrauma.PhysicsBody.DrawRotation
get

◆ Enabled

bool Barotrauma.PhysicsBody.Enabled
getset

◆ FarseerBody

Body Barotrauma.PhysicsBody.FarseerBody
get

◆ Friction

float Barotrauma.PhysicsBody.Friction
set

◆ Height

float Barotrauma.PhysicsBody.Height
get

◆ LastSentPosition

Vector2 Barotrauma.PhysicsBody.LastSentPosition
get

◆ LinearVelocity

Vector2 Barotrauma.PhysicsBody.LinearVelocity
getset

◆ List

List<PhysicsBody> Barotrauma.PhysicsBody.List
staticget

◆ Mass

float Barotrauma.PhysicsBody.Mass
get

◆ PhysEnabled

bool Barotrauma.PhysicsBody.PhysEnabled
getset

◆ Position

Vector2 Barotrauma.PhysicsBody.Position
get

◆ PrevPosition

Vector2 Barotrauma.PhysicsBody.PrevPosition
get

◆ Radius

float Barotrauma.PhysicsBody.Radius
get

◆ Removed

bool Barotrauma.PhysicsBody.Removed
get

◆ Rotation

float Barotrauma.PhysicsBody.Rotation
get

◆ SimPosition

Vector2 Barotrauma.PhysicsBody.SimPosition
get

◆ SuppressSmoothRotationCalls

bool Barotrauma.PhysicsBody.SuppressSmoothRotationCalls
getset

Ignore rotation calls for the rest of this and the next update. Automatically disabled after that. Used for temporarily suppressing the SmoothRotate calls to prevent conflicting or unitentionally amplified rotations.

◆ TargetPosition

Vector2? Barotrauma.PhysicsBody.TargetPosition
getset

◆ TargetRotation

float? Barotrauma.PhysicsBody.TargetRotation
getset

◆ TransformedRotation

float Barotrauma.PhysicsBody.TransformedRotation
get

Takes flipping (Dir) into account.

◆ UserData

object Barotrauma.PhysicsBody.UserData
getset

◆ Width

float Barotrauma.PhysicsBody.Width
get

The documentation for this class was generated from the following file: