1
This commit is contained in:
parent
05c3ed01cf
commit
e896c08c6a
@ -6,3 +6,31 @@
|
||||
BtContext::~BtContext()
|
||||
{
|
||||
}
|
||||
|
||||
void BtContext::AddHandler(std::weak_ptr<Player> target, std::weak_ptr<EventHandler> handler)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BtContext::AddEvent(std::shared_ptr<BtEvent> event)
|
||||
{
|
||||
}
|
||||
|
||||
bool BtContext::HasEvent()
|
||||
{
|
||||
if (!events_.empty()) {
|
||||
auto event = events_.at(events_.size() - 1);
|
||||
return event->HasEvent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BtContext::FireEvent(BaseAgent* agent)
|
||||
{
|
||||
if (!events_.empty()) {
|
||||
auto event = events_.at(events_.size() - 1);
|
||||
if (event->HasEvent()) {
|
||||
event->FireEvent(agent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
class Player;
|
||||
class BtEvent;
|
||||
class BaseAgent;
|
||||
class EventHandler;
|
||||
class BtContext : public std::enable_shared_from_this<BtContext>
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~BtContext();
|
||||
void AddHandler(std::weak_ptr<Player> target, std::weak_ptr<EventHandler> handler);
|
||||
void AddEvent(std::shared_ptr<BtEvent> event);
|
||||
bool HasEvent();
|
||||
void FireEvent(BaseAgent* agent);
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<BtEvent>> events_;
|
||||
|
||||
std::vector<std::tuple<std::weak_ptr<Player>, std::weak_ptr<EventHandler>>> handlers_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user