DamageInfo
Derives from ValueType

Properties

Entity Attacker { get; set; }

The player or NPC or exploding barrel (etc)1 that is attacking

PhysicsBody Body { get; set; }

The physics body that was hit

int BoneIndex { get; set; }

The bone index that the hitbox was attached to

float Damage { get; set; }

The actual amount of damage this attack causes

Vector3 Force { get; set; }

The force of the damage - for moving physics etc. This would be the trajectory of the bullet multiplied by the speed and mass.

Hitbox Hitbox { get; set; }

The hitbox (if any) that was hit

Vector3 Position { get; set; }

The position the damage is being inflicted (the bullet entry point)

HashSet<string> Tags { get; set; }

Damage tags, extra information about this attack

Entity Weapon { get; set; }

The weapon that the attacker is using

Methods

static DamageInfo FromBullet( Vector3 hitPosition, Vector3 hitForce, float damage, )

Creates a new DamageInfo with the "bullet" tag

static DamageInfo FromExplosion( Vector3 sourcePosition, Vector3 force, float damage, )

Creates a new DamageInfo with the "explosion" tag

static DamageInfo Generic( float damage, )

Creates a new DamageInfo with no tags

bool HasAllTags( string[] tags, )

Returns true if this DamageInfo has ALL of the following tags

bool HasAnyTag( string[] tags, )

Returns true if this DamageInfo has ANY of the following tags

bool HasTag( string tag, )

Do we have a tag that matches this string?

Fills in the PhysicsBody and Hitbox from the trace result

DamageInfo WithAttacker( Entity attacker, Entity weapon = null, )

Set the attacker

DamageInfo WithBone( int bone, )

Sets the bone index

DamageInfo WithDamage( float damage, )

Sets the amount of damage

Sets the force

Sets the hit physics body

Sets the position

DamageInfo WithTag( string tag, )

Includes one tag to this damage info. Can be accessed via DamageInfo.HasTag and DamageInfo.Tags for a full list.

DamageInfo WithTags( string[] tags, )

Includes any number of tags to this damage info. Can be accessed via DamageInfo.HasTag and DamageInfo.Tags for a full list.

Set the attacker

Referencing Members

virtual void Entity.TakeDamage( DamageInfo, )
override void BasePhysics.TakeDamage( DamageInfo, )
override void GlassShard.TakeDamage( DamageInfo, )
override void VoxelChunk.TakeDamage( DamageInfo, )
override void Water.TakeDamage( DamageInfo, )
override void BrushEntity.TakeDamage( DamageInfo, )
override void ButtonEntity.TakeDamage( DamageInfo, )
override void DoorEntity.TakeDamage( DamageInfo, )
override void Prop.TakeDamage( DamageInfo, )
override void Player.TakeDamage( DamageInfo, )