DamageInfo
Sandbox.Game
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

DamageFlags Flags { get; set; }

Damage flags, extra information about this attack

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)

Entity Weapon { get; set; }

The weapon that the attacker is using

Methods

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

Creates a new DamageInfo with the DamageFlag Blast

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

Creates a new DamageInfo with the DamageFlag Bullet

static DamageInfo Generic( float damage, )

Creates a new DamageInfo with the DamageFlag Generic

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

Add flag(s)

Sets the force

Sets the hit physics body

Sets the position

Set the attacker