Barotrauma Client Doc
Barotrauma.AnimController Class Referenceabstract
Inheritance diagram for Barotrauma.AnimController:
Barotrauma.Ragdoll Barotrauma.FishAnimController Barotrauma.HumanoidAnimController

Public Types

enum class  Animation {
  None , Climbing , UsingItem , Struggle ,
  CPR , UsingItemWhileClimbing
}
 

Public Member Functions

 AnimController (Character character, string seed, RagdollParams ragdollParams=null)
 
abstract void UpdateAnim (float deltaTime)
 
abstract void DragCharacter (Character target, float deltaTime)
 
virtual float GetSpeed (AnimationType type)
 
float GetCurrentSpeed (bool useMaxSpeed)
 
AnimationParams GetAnimationParamsFromType (AnimationType type)
 
float GetHeightFromFloor ()
 
void LockFlipping (float time=0.2f)
 
void UpdateUseItem (bool allowMovement, Vector2 handWorldPos)
 
void Grab (Vector2 rightHandPos, Vector2 leftHandPos)
 
void HoldItem (float deltaTime, Item item, Vector2[] handlePos, Vector2 holdPos, Vector2 aimPos, bool aim, float holdAngle, float itemAngleRelativeToHoldAngle=0.0f, bool aimMelee=false)
 
void HandIK (Limb hand, Vector2 pos, float armTorque=1.0f, float handTorque=1.0f, float maxAngularVelocity=float.PositiveInfinity)
 
void ApplyPose (Vector2 leftHandPos, Vector2 rightHandPos, Vector2 leftFootPos, Vector2 rightFootPos, float footMoveForce=10)
 
void ApplyTestPose ()
 
override void Recreate (RagdollParams ragdollParams=null)
 Call this to create the ragdoll from the RagdollParams. More...
 
void StartUsingItem ()
 
void StartClimbing ()
 
void StopUsingItem ()
 
void StopClimbing ()
 
- Public Member Functions inherited from Barotrauma.Ragdoll
bool TryGetCollider (int index, out PhysicsBody collider)
 
void SubtractMass (Limb limb)
 
 Ragdoll (Character character, string seed, RagdollParams ragdollParams=null)
 
void SaveRagdoll (string fileNameWithoutExtension=null)
 Saves all serializable data in the currently selected ragdoll params. This method should properly handle character flipping. More...
 
void ResetRagdoll (bool forceReload=false)
 Resets the serializable data to the currently selected ragdoll params. Force reloading always loads the xml stored on the disk. More...
 
void ResetJoints ()
 Resets the current joint values to the serialized joint params. More...
 
void ResetLimbs ()
 Resets the current limb values to the serialized limb params. More...
 
void AddJoint (JointParams jointParams)
 
void AddLimb (Limb limb)
 
void RemoveLimb (Limb limb)
 
bool OnLimbCollision (Fixture f1, Fixture f2, Contact contact)
 
float GetImpactDamage (float impact, float? impactTolerance=null)
 
bool SeverLimbJoint (LimbJoint limbJoint)
 
virtual void Flip ()
 
Vector2 GetCenterOfMass ()
 
void MoveLimb (Limb limb, Vector2 pos, float amount, bool pullFromCenter=false)
 
Parameters
pullFromCenterif false, force is applied to the position of pullJoint
More...
 
void ResetPullJoints (Func< Limb, bool > condition=null)
 
void FindHull (Vector2? worldPosition=null, bool setSubmarine=true)
 
void Teleport (Vector2 moveAmount, Vector2 velocityChange, bool detachProjectiles=true)
 
void Update (float deltaTime, Camera cam)
 
void ForceRefreshFloorY ()
 
float GetSurfaceY ()
 Get the position of the surface of water at the position of the character, in display units (taking into account connected hulls above the hull the character is in) More...
 
void SetPosition (Vector2 simPosition, bool lerp=false, bool ignorePlatforms=true, bool forceMainLimbToCollider=false, bool detachProjectiles=true)
 
void Hang ()
 
Limb GetLimb (LimbType limbType, bool excludeSevered=true)
 Note that if there are multiple limbs of the same type, only the first (valid) limb is returned. More...
 
Vector2? GetMouthPosition ()
 
Vector2 GetColliderBottom ()
 
Limb FindLowestLimb ()
 
void ReleaseStuckLimbs ()
 
void HideAndDisable (LimbType limbType, float duration=0, bool ignoreCollisions=true)
 
void RestoreTemporarilyDisabled ()
 
void Remove ()
 
void PlayImpactSound (Limb limb)
 
void Draw (SpriteBatch spriteBatch, Camera cam)
 
float GetDepthOffset ()
 Offset added to the default draw depth of the character's limbs. For example, climbing on ladders affects the depth of the character to get it to render behind the ladders. More...
 
void DebugDraw (SpriteBatch spriteBatch)
 

Public Attributes

Animation Anim
 
- Public Attributes inherited from Barotrauma.Ragdoll
LimbJoint[] LimbJoints
 
Vector2 movement
 
Structure Stairs
 
Direction TargetDir
 
bool forceStanding
 
bool forceNotStanding
 

Protected Member Functions

float? GetValidOrNull (AnimationParams p, float? v)
 
Vector2? GetValidOrNull (AnimationParams p, Vector2 v)
 
void CalculateArmLengths ()
 
LimbJoint GetJointBetweenLimbs (LimbType limbTypeA, LimbType limbTypeB)
 
LimbJoint GetJoint (LimbType matchingType, IEnumerable< LimbType > ignoredTypes)
 
- Protected Member Functions inherited from Barotrauma.Ragdoll
void CreateColliders ()
 
void CreateJoints ()
 
void CreateLimbs ()
 
void AddLimb (LimbParams limbParams)
 
List< LimbGetConnectedLimbs (Limb limb)
 
void LogAccessedRemovedCharacterError ()
 
void TrySetLimbPosition (Limb limb, Vector2 original, Vector2 simPosition, float rotation, bool lerp=false, bool ignorePlatforms=true)
 
void CheckDistFromCollider ()
 

Protected Attributes

LimbJoint rightShoulder
 
float upperArmLength
 
float useItemTimer
 
bool aiming
 
bool wasAiming
 
bool aimingMelee
 
bool wasAimingMelee
 
float deathAnimTimer
 
- Protected Attributes inherited from Barotrauma.Ragdoll
Hull currentHull
 
Character character
 
float strongestImpact
 
Vector2 targetMovement
 
Vector2 overrideTargetMovement
 
float floorY
 
Fixture floorFixture
 
Vector2 floorNormal = Vector2.UnitY
 
float surfaceY
 
bool inWater
 
bool onGround
 
Direction dir
 
List< PhysicsBodycollider
 
int colliderIndex = 0
 
bool levitatingCollider = true
 
Limb[] inversedLimbDrawOrder
 Inversed draw order, which is used for drawing the limbs in 3d (deformable sprites). More...
 

Properties

Vector2 RightHandIKPos [get, protected set]
 
Vector2 LeftHandIKPos [get, protected set]
 
bool IsAiming [get]
 
bool IsAimingMelee [get]
 
bool Aiming [get]
 
float ArmLength [get]
 
abstract GroundedMovementParams WalkParams [get, set]
 
abstract GroundedMovementParams RunParams [get, set]
 
abstract SwimParams SwimSlowParams [get, set]
 
abstract SwimParams SwimFastParams [get, set]
 
AnimationParamsCurrentAnimationParams [get]
 
AnimationType ForceSelectAnimationType [get, set]
 
GroundedMovementParamsCurrentGroundedParams [get]
 
SwimParamsCurrentSwimParams [get]
 
bool CanWalk [get]
 
bool IsMovingBackwards [get]
 
bool IsMovingFast [get]
 Note: Presupposes that the slow speed is lower than the high speed. Otherwise will give invalid results. More...
 
List< AnimationParamsAllAnimParams [get]
 Note: creates a new list every time, because the params might have changed. If there is a need to access the property frequently, change the implementation to an array, where the slot is updated when the param is updated(?) Currently it's not simple to implement, since the properties are not implemented here, but in the derived classes. Would require to change the params virtual and to call the base property getter/setter or something. More...
 
bool IsUsingItem [get]
 
bool IsClimbing [get]
 
Vector2 AimSourceWorldPos [get]
 
Vector2 AimSourcePos [get]
 
virtual Vector2 AimSourceSimPos [get]
 
override? float HeadPosition [get]
 
override? float TorsoPosition [get]
 
override? float HeadAngle [get]
 
override? float TorsoAngle [get]
 
virtual ? Vector2 StepSize [get]
 
bool AnimationTestPose [get, set]
 
float WalkPos [get, protected set]
 
bool IsAboveFloor [get]
 
float FlipLockTime [get]
 
- Properties inherited from Barotrauma.Ragdoll
abstract RagdollParams RagdollParams [get, protected set]
 
Limb[] Limbs [get]
 
bool HasMultipleLimbsOfSameType [get]
 
bool?? Frozen [get, set]
 
Character Character [get]
 
bool OnGround [get]
 
float ColliderHeightFromFloor [get]
 In sim units. Joint scale applied. More...
 
bool IsStuck [get]
 
PhysicsBodyCollider [get]
 
int ColliderIndex [get, set]
 
float FloorY [get]
 
float Mass [get]
 
Limb?? MainLimb [get]
 
Vector2? WorldPosition [get]
 
bool? SimplePhysicsEnabled [get, set]
 
Vector2? TargetMovement [get, set]
 
abstract ? float HeadPosition [get]
 
abstract ? float HeadAngle [get]
 
abstract ? float TorsoPosition [get]
 
abstract ? float TorsoAngle [get]
 
float?? ImpactTolerance [get]
 
bool Draggable [get]
 
bool CanEnterSubmarine [get]
 
float Dir [get]
 
Direction Direction [get]
 
bool InWater [get]
 
bool HeadInWater [get]
 
HullCurrentHull [get, set]
 
bool IgnorePlatforms [get, set]
 
bool IsFlipped [get]
 
bool? BodyInRest [get, set]
 
bool Invalid [get]
 
bool IsHanging [get, protected set]
 
HashSet< SpriteDeformationSpriteDeformations = new HashSet<SpriteDeformation>() [get, protected set]
 

Additional Inherited Members

- Static Public Member Functions inherited from Barotrauma.Ragdoll
static void UpdateAll (float deltaTime, Camera cam)
 
static void RemoveAll ()
 
- Static Public Attributes inherited from Barotrauma.Ragdoll
const float MAX_SPEED = 20
 

Detailed Description

Definition at line 11 of file AnimController.cs.

Member Enumeration Documentation

◆ Animation

Enumerator
None 
Climbing 
UsingItem 
Struggle 
CPR 
UsingItemWhileClimbing 

Definition at line 137 of file AnimController.cs.

Constructor & Destructor Documentation

◆ AnimController()

Barotrauma.AnimController.AnimController ( Character  character,
string  seed,
RagdollParams  ragdollParams = null 
)

Definition at line 179 of file AnimController.cs.

Member Function Documentation

◆ ApplyPose()

void Barotrauma.AnimController.ApplyPose ( Vector2  leftHandPos,
Vector2  rightHandPos,
Vector2  leftFootPos,
Vector2  rightFootPos,
float  footMoveForce = 10 
)

Definition at line 645 of file AnimController.cs.

◆ ApplyTestPose()

void Barotrauma.AnimController.ApplyTestPose ( )

Definition at line 682 of file AnimController.cs.

◆ CalculateArmLengths()

void Barotrauma.AnimController.CalculateArmLengths ( )
protected

Definition at line 695 of file AnimController.cs.

◆ DragCharacter()

abstract void Barotrauma.AnimController.DragCharacter ( Character  target,
float  deltaTime 
)
pure virtual

◆ GetAnimationParamsFromType()

AnimationParams Barotrauma.AnimController.GetAnimationParamsFromType ( AnimationType  type)

Definition at line 251 of file AnimController.cs.

◆ GetCurrentSpeed()

float Barotrauma.AnimController.GetCurrentSpeed ( bool  useMaxSpeed)

Definition at line 216 of file AnimController.cs.

◆ GetHeightFromFloor()

float Barotrauma.AnimController.GetHeightFromFloor ( )

◆ GetJoint()

LimbJoint Barotrauma.AnimController.GetJoint ( LimbType  matchingType,
IEnumerable< LimbType ignoredTypes 
)
protected

Definition at line 751 of file AnimController.cs.

◆ GetJointBetweenLimbs()

LimbJoint Barotrauma.AnimController.GetJointBetweenLimbs ( LimbType  limbTypeA,
LimbType  limbTypeB 
)
protected

Definition at line 744 of file AnimController.cs.

◆ GetSpeed()

virtual float Barotrauma.AnimController.GetSpeed ( AnimationType  type)
virtual

Reimplemented in Barotrauma.HumanoidAnimController.

Definition at line 185 of file AnimController.cs.

◆ GetValidOrNull() [1/2]

float? Barotrauma.AnimController.GetValidOrNull ( AnimationParams  p,
float?  v 
)
protected

Definition at line 156 of file AnimController.cs.

◆ GetValidOrNull() [2/2]

Vector2? Barotrauma.AnimController.GetValidOrNull ( AnimationParams  p,
Vector2  v 
)
protected

Definition at line 163 of file AnimController.cs.

◆ Grab()

void Barotrauma.AnimController.Grab ( Vector2  rightHandPos,
Vector2  leftHandPos 
)

Definition at line 362 of file AnimController.cs.

◆ HandIK()

void Barotrauma.AnimController.HandIK ( Limb  hand,
Vector2  pos,
float  armTorque = 1.0f,
float  handTorque = 1.0f,
float  maxAngularVelocity = float.PositiveInfinity 
)

Definition at line 588 of file AnimController.cs.

◆ HoldItem()

void Barotrauma.AnimController.HoldItem ( float  deltaTime,
Item  item,
Vector2[]  handlePos,
Vector2  holdPos,
Vector2  aimPos,
bool  aim,
float  holdAngle,
float  itemAngleRelativeToHoldAngle = 0.0f,
bool  aimMelee = false 
)

Definition at line 379 of file AnimController.cs.

◆ LockFlipping()

void Barotrauma.AnimController.LockFlipping ( float  time = 0.2f)

Definition at line 282 of file AnimController.cs.

◆ Recreate()

override void Barotrauma.AnimController.Recreate ( RagdollParams  ragdollParams = null)
virtual

Call this to create the ragdoll from the RagdollParams.

Reimplemented from Barotrauma.Ragdoll.

Reimplemented in Barotrauma.HumanoidAnimController.

Definition at line 758 of file AnimController.cs.

◆ StartClimbing()

void Barotrauma.AnimController.StartClimbing ( )

◆ StartUsingItem()

void Barotrauma.AnimController.StartUsingItem ( )

◆ StopClimbing()

void Barotrauma.AnimController.StopClimbing ( )

◆ StopUsingItem()

void Barotrauma.AnimController.StopUsingItem ( )

◆ UpdateAnim()

abstract void Barotrauma.AnimController.UpdateAnim ( float  deltaTime)
pure virtual

◆ UpdateUseItem()

void Barotrauma.AnimController.UpdateUseItem ( bool  allowMovement,
Vector2  handWorldPos 
)

Definition at line 287 of file AnimController.cs.

Member Data Documentation

◆ aiming

bool Barotrauma.AnimController.aiming
protected

Definition at line 19 of file AnimController.cs.

◆ aimingMelee

bool Barotrauma.AnimController.aimingMelee
protected

Definition at line 21 of file AnimController.cs.

◆ Anim

Animation Barotrauma.AnimController.Anim

Definition at line 138 of file AnimController.cs.

◆ deathAnimTimer

float Barotrauma.AnimController.deathAnimTimer
protected

Definition at line 93 of file AnimController.cs.

◆ rightShoulder

LimbJoint Barotrauma.AnimController.rightShoulder
protected

Definition at line 16 of file AnimController.cs.

◆ upperArmLength

float Barotrauma.AnimController.upperArmLength
protected

Definition at line 17 of file AnimController.cs.

◆ useItemTimer

float Barotrauma.AnimController.useItemTimer
protected

Definition at line 18 of file AnimController.cs.

◆ wasAiming

bool Barotrauma.AnimController.wasAiming
protected

Definition at line 20 of file AnimController.cs.

◆ wasAimingMelee

bool Barotrauma.AnimController.wasAimingMelee
protected

Definition at line 22 of file AnimController.cs.

Property Documentation

◆ Aiming

bool Barotrauma.AnimController.Aiming
getprotected

Definition at line 27 of file AnimController.cs.

◆ AimSourcePos

Vector2 Barotrauma.AnimController.AimSourcePos
get

Definition at line 153 of file AnimController.cs.

◆ AimSourceSimPos

virtual Vector2 Barotrauma.AnimController.AimSourceSimPos
get

Definition at line 154 of file AnimController.cs.

◆ AimSourceWorldPos

Vector2 Barotrauma.AnimController.AimSourceWorldPos
get

Definition at line 143 of file AnimController.cs.

◆ AllAnimParams

List<AnimationParams> Barotrauma.AnimController.AllAnimParams
get

Note: creates a new list every time, because the params might have changed. If there is a need to access the property frequently, change the implementation to an array, where the slot is updated when the param is updated(?) Currently it's not simple to implement, since the properties are not implemented here, but in the derived classes. Would require to change the params virtual and to call the base property getter/setter or something.

Definition at line 117 of file AnimController.cs.

◆ AnimationTestPose

bool Barotrauma.AnimController.AnimationTestPose
getset

Definition at line 175 of file AnimController.cs.

◆ ArmLength

float Barotrauma.AnimController.ArmLength
get

Definition at line 29 of file AnimController.cs.

◆ CanWalk

bool Barotrauma.AnimController.CanWalk
get

Definition at line 89 of file AnimController.cs.

◆ CurrentAnimationParams

AnimationParams? Barotrauma.AnimController.CurrentAnimationParams
get

Definition at line 36 of file AnimController.cs.

◆ CurrentGroundedParams

GroundedMovementParams? Barotrauma.AnimController.CurrentGroundedParams
get

Definition at line 51 of file AnimController.cs.

◆ CurrentSwimParams

SwimParams? Barotrauma.AnimController.CurrentSwimParams
get

Definition at line 74 of file AnimController.cs.

◆ FlipLockTime

float Barotrauma.AnimController.FlipLockTime
get

Definition at line 281 of file AnimController.cs.

◆ ForceSelectAnimationType

AnimationType Barotrauma.AnimController.ForceSelectAnimationType
getset

Definition at line 50 of file AnimController.cs.

◆ HeadAngle

override? float Barotrauma.AnimController.HeadAngle
get

Definition at line 171 of file AnimController.cs.

◆ HeadPosition

override? float Barotrauma.AnimController.HeadPosition
get

Definition at line 169 of file AnimController.cs.

◆ IsAboveFloor

bool Barotrauma.AnimController.IsAboveFloor
get

Definition at line 279 of file AnimController.cs.

◆ IsAiming

bool Barotrauma.AnimController.IsAiming
get

Definition at line 24 of file AnimController.cs.

◆ IsAimingMelee

bool Barotrauma.AnimController.IsAimingMelee
get

Definition at line 25 of file AnimController.cs.

◆ IsClimbing

bool Barotrauma.AnimController.IsClimbing
get

Definition at line 141 of file AnimController.cs.

◆ IsMovingBackwards

bool Barotrauma.AnimController.IsMovingBackwards
get

Definition at line 90 of file AnimController.cs.

◆ IsMovingFast

bool Barotrauma.AnimController.IsMovingFast
get

Note: Presupposes that the slow speed is lower than the high speed. Otherwise will give invalid results.

Definition at line 98 of file AnimController.cs.

◆ IsUsingItem

bool Barotrauma.AnimController.IsUsingItem
get

Definition at line 140 of file AnimController.cs.

◆ LeftHandIKPos

Vector2 Barotrauma.AnimController.LeftHandIKPos
getprotected set

Definition at line 14 of file AnimController.cs.

◆ RightHandIKPos

Vector2 Barotrauma.AnimController.RightHandIKPos
getprotected set

Definition at line 13 of file AnimController.cs.

◆ RunParams

abstract GroundedMovementParams Barotrauma.AnimController.RunParams
getset

Definition at line 32 of file AnimController.cs.

◆ StepSize

virtual ? Vector2 Barotrauma.AnimController.StepSize
get

Definition at line 173 of file AnimController.cs.

◆ SwimFastParams

abstract SwimParams Barotrauma.AnimController.SwimFastParams
getset

Definition at line 34 of file AnimController.cs.

◆ SwimSlowParams

abstract SwimParams Barotrauma.AnimController.SwimSlowParams
getset

Definition at line 33 of file AnimController.cs.

◆ TorsoAngle

override? float Barotrauma.AnimController.TorsoAngle
get

Definition at line 172 of file AnimController.cs.

◆ TorsoPosition

override? float Barotrauma.AnimController.TorsoPosition
get

Definition at line 170 of file AnimController.cs.

◆ WalkParams

abstract GroundedMovementParams Barotrauma.AnimController.WalkParams
getset

Definition at line 31 of file AnimController.cs.

◆ WalkPos

float Barotrauma.AnimController.WalkPos
getprotected set

Definition at line 177 of file AnimController.cs.