1
This commit is contained in:
parent
66a9a3b210
commit
59d5a0680f
@ -14,7 +14,7 @@ class Context : public BtContext \
|
||||
~Context() { if (_destory_cb) { _destory_cb(); };}; \
|
||||
}; \
|
||||
auto context = std::make_shared<Context>(); \
|
||||
context->owner = owner; \
|
||||
context->SetOwner(owner); \
|
||||
return context; \
|
||||
}(GetOwner()->GetWeakPtrRef(), this)
|
||||
|
||||
|
@ -7,15 +7,16 @@ class BtContext : public std::enable_shared_from_this<BtContext>
|
||||
{
|
||||
public:
|
||||
|
||||
CreatureWeakPtr owner;
|
||||
|
||||
virtual ~BtContext();
|
||||
void SetOwner(CreatureWeakPtr owner) { owner_ = owner;}
|
||||
CreatureWeakPtr GetOwner() { return owner_; }
|
||||
void AddHandler(CreatureWeakPtr target, std::weak_ptr<EventHandlerPtr> handler);
|
||||
void AddEvent(std::shared_ptr<BtEvent> event);
|
||||
bool HasEvent();
|
||||
void FireEvent(BaseAgent* agent);
|
||||
|
||||
private:
|
||||
CreatureWeakPtr owner_;
|
||||
std::vector<std::shared_ptr<BtEvent>> events_;
|
||||
std::vector<std::tuple<CreatureWeakPtr, std::weak_ptr<EventHandlerPtr>>> handlers_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user