> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/glue-reference/entities/implements-idamagearea.md).

# Implements IDamageArea

### Introduction

The IDamageArea interface creates a standard way to define that an entity can deal damage to other entities. It has built-in support for teams and damage over time.

### Setting Implements IDamageArea

To set an entity as a damage area, set the property on entity in the Properties tab.

![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-889cd34aeffba5d361836fe8e6a8529169e89c8c%2F2021-05-img_60a125377d75d.png?alt=media)

A game which has entities implementing IDamageArea will also need entities which implement IDamageable.

### Example - Damaging Enemies with Bullets

For this example uses two entities:

1. Bullet - an entity which implements IDamageArea and is ICollidable
2. Enemy - an entity which implements IDamageable and is ICollidable

![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-4ff7624d84be076b5daa8255b223a0f995ee4d95%2F2021-05-img_60a65c5549716.png?alt=media)

The GameScreen also has a list for each and a collision relationship with an event.

![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-b7be2b2743c726d0bb2eee78f8fd3f27a58bf5c8%2F2021-05-img_60a65cb463bcd.png?alt=media)

When the bullet and enemy collide, the ShouldTakeDamage method can be used to determine if the enemy should take damage from the bullet, as shown in the following code snippet.

```
void OnEnemyListVsBulletListCollisionOccurred (Entities.Enemy enemy, Entities.Bullet bullet)
{
    if(enemy.ShouldTakeDamage(bullet))
    {
        enemy.TakeDamage(bullet.DamageAmount);
    }
}
```

The ShouldTakeDamage method is available on the Enemy since it implements the IDamageable interface, but the enemy.TakeDamage and bullet.DamageAmount are not provided automatically and must be implemented in custom code.

### DamageDealer

The IDamageArea interface includes a DamageDealer property which can be used to store a reference to the damage dealer. This is typically used if the damage area is created by another entity, and that entity needs to be referenced upon collision. For example, in a multi-player game, each player may have a separate score. If an enemy is killed by a bullet, then the player who fired that bullet should be awarded points. For example, the following code could be used to assign the DamageDealer on a bullet created inside the Player class:

```
if(WasShootPressed)
{
  var bullet = Factories.BulletFactory.CreateNew(this.X, this.Y);
  bullet.XVelocity = 100;
  bullet.DamageDealer = this;
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/flatredball/glue-reference/entities/implements-idamagearea.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
