tiny_link/src/components/hurtable.h

26 lines
571 B
C
Raw Normal View History

2021-01-04 07:11:49 +08:00
#pragma once
#include "../world.h"
#include "collider.h"
#include <blah.h>
#include <functional>
using namespace Blah;
namespace TL
{
// Automatically checks if the provided collider ever overlaps
// with something in the `hurt_by` mask. Makes it easy for enemies
// to check if they were hit by `Mask::player_attack`
2021-01-04 07:11:49 +08:00
class Hurtable : public Component
{
public:
2021-01-04 09:03:48 +08:00
float stun_timer = 0;
float flicker_timer = 0;
2021-01-04 07:11:49 +08:00
Collider* collider = nullptr;
uint32_t hurt_by = 0;
std::function<void(Hurtable* self)> on_hurt;
2021-01-04 13:54:18 +08:00
void hurt();
2021-01-04 07:11:49 +08:00
void update() override;
};
}