IDamage
public interface IDamage
{
int GetDamage();
HitType GetHitType();
List<ICollisionShape> GetDamageShapes();
SVector GetAttackOrigin();
void HitSomething(IHittable hittable);
void KilledSomething(IHittable hittable);
int GetCreatorEntityId();
}
This interface helps describe something that deals damage in the world including its collision shape and damage.
Methods
int GetDamage()
How much damage to inflict on others implementing IHittable. If you link this to a variable rather then returning a constant you can control when it deals damage too (e.g return 0 when standing around, return 10 when punching)
HitType GetHitType()
Returns hit type. Add new hit types to the enum to add more variety to your game
List<ICollisionShape> GetDamageShapes()
Get the collision shapes for this damaging thing
SVector GetAttackOrigin()
A vector describing the centre of the damage. This can be used to work out which direction to send hit enemies flying. E.g put the attack origin in the middle of the punch collision box
void HitSomething(IHittable hittable)
Recommended that when things implementing the IDamage interface call this method when taking damage from the attacker passed in if any. Useful for situations where hitting someone adds up a combo counter or heals health etc
void KilledSomething(IHittable hittable)
Recommended that when things implementing the IDamage interface call this method when taking damage and have died from the attacker passed in if any. Useful for situations where hitting someone adds up a combo counter or heals health etc
int GetCreatorEntityId()
For bullets or similar its useful to set their creator’s entityID here to make sure this thing does not hurt the creator of it. I use this to make sure when shooting you can’t shoot yourself when spawning the bullets