1
This commit is contained in:
parent
d530cadb27
commit
826e7b871d
@ -45,9 +45,9 @@ behaviac::EBTStatus AndroidAgent::DoIdle(int min_time, int max_time)
|
||||
std::weak_ptr<EventHandlerPtr> handler = GetOwner()->GetTrigger()->AddListener
|
||||
(
|
||||
kAttacked,
|
||||
[this, last_attacker, last_attacked_frameno] (const std::vector<std::any>& args)
|
||||
[this, last_attacker, last_attacked_frameno] (const a8::Args& args)
|
||||
{
|
||||
Creature* c = std::any_cast<Creature*>(args.at(0));
|
||||
Creature* c = args.Get<Creature*>(0);
|
||||
*last_attacker = c->GetWeakPtrRef();
|
||||
*last_attacked_frameno = c->room->GetFrameNo();
|
||||
});
|
||||
@ -105,9 +105,9 @@ behaviac::EBTStatus AndroidAgent::DoRandomWalk()
|
||||
std::weak_ptr<EventHandlerPtr> handler = GetOwner()->GetTrigger()->AddListener
|
||||
(
|
||||
kAttacked,
|
||||
[this, last_attacker, last_attacked_frameno] (const std::vector<std::any>& args)
|
||||
[this, last_attacker, last_attacked_frameno] (const a8::Args& args)
|
||||
{
|
||||
Creature* c = std::any_cast<Creature*>(args.at(0));
|
||||
Creature* c = args.Get<Creature*>(0);
|
||||
*last_attacker = c->GetWeakPtrRef();
|
||||
*last_attacked_frameno = c->room->GetFrameNo();
|
||||
});
|
||||
@ -160,9 +160,9 @@ behaviac::EBTStatus AndroidAgent::DoRandomShot()
|
||||
std::weak_ptr<EventHandlerPtr> handler = GetOwner()->GetTrigger()->AddListener
|
||||
(
|
||||
kAttacked,
|
||||
[this, last_attacker, last_attacked_frameno] (const std::vector<std::any>& args)
|
||||
[this, last_attacker, last_attacked_frameno] (const a8::Args& args)
|
||||
{
|
||||
Creature* c = std::any_cast<Creature*>(args.at(0));
|
||||
Creature* c = args.Get<Creature*>(0);
|
||||
*last_attacker = c->GetWeakPtrRef();
|
||||
*last_attacked_frameno = c->room->GetFrameNo();
|
||||
});
|
||||
|
@ -440,9 +440,7 @@ bool App::HasTask()
|
||||
|
||||
void App::DispatchMsg()
|
||||
{
|
||||
#ifdef PERFT
|
||||
long long begin_tick = a8::XGetTickCount();
|
||||
#endif
|
||||
if (!work_node_ && top_node_) {
|
||||
msg_mutex_->lock();
|
||||
work_node_ = top_node_;
|
||||
@ -483,12 +481,10 @@ void App::DispatchMsg()
|
||||
if (!work_node_) {
|
||||
working_msgnode_size_ = 0;
|
||||
}
|
||||
#ifdef PERFT
|
||||
a8::tick_t end_tick = a8::XGetTickCount();
|
||||
if (end_tick - begin_tick > PerfMonitor::Instance()->max_dispatchmsg_time) {
|
||||
PerfMonitor::Instance()->max_dispatchmsg_time = end_tick - begin_tick;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::ProcessGameGateMsg(f8::MsgHdr& hdr)
|
||||
|
@ -1050,10 +1050,10 @@ void Buff::ProcMachineGun()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kSkillBulletPreCreateEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
int delay_time = std::any_cast<int>(params.at(0));
|
||||
MetaData::Skill* bullet_skill_meta = std::any_cast<MetaData::Skill*>(params.at(1));
|
||||
int delay_time = args.Get<int>(0);
|
||||
MetaData::Skill* bullet_skill_meta = args.Get<MetaData::Skill*>(1);
|
||||
int passed_frames = (owner->room->GetFrameNo() - add_frameno);
|
||||
int raw_frames = skill_meta->number_meta->float_time * 1000 / FRAME_RATE_MS;
|
||||
if (skill_meta == bullet_skill_meta &&
|
||||
@ -1073,9 +1073,9 @@ void Buff::ProcMachineGun()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kFlyHookCreateEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
Bullet* bullet = std::any_cast<Bullet*>(params.at(0));
|
||||
Bullet* bullet = args.Get<Bullet*>(0);
|
||||
int passed_frames = (owner->room->GetFrameNo() - add_frameno);
|
||||
int raw_frames = skill_meta->number_meta->float_time * 1000 / FRAME_RATE_MS;
|
||||
owner->room->xtimer.ModifyTimer
|
||||
@ -1091,7 +1091,7 @@ void Buff::ProcMachineGun()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kFlyHookDestoryEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
int passed_frames = (owner->room->GetFrameNo() - add_frameno);
|
||||
int raw_frames = skill_meta->number_meta->float_time * 1000 / FRAME_RATE_MS;
|
||||
@ -1347,9 +1347,9 @@ void Buff::PreProcess()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kTriggerBulletHitBuffEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
Bullet* bullet = std::any_cast<Bullet*>(params.at(0));
|
||||
Bullet* bullet = args.Get<Bullet*>(0);
|
||||
ProcSputteringFunc(bullet);
|
||||
}));
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ void Explosion::ProcDamage()
|
||||
if (sender_.Get() && sender_.Get()->IsProperTarget(c)) {
|
||||
if (custom_check_cb_) {
|
||||
bool is_hit = false;
|
||||
custom_check_cb_({&is_hit, (Entity*)c});
|
||||
custom_check_cb_(a8::Args({&is_hit, (Entity*)c}));
|
||||
if (is_hit) {
|
||||
objects.insert(c);
|
||||
}
|
||||
@ -101,7 +101,7 @@ void Explosion::ProcDamage()
|
||||
} else {
|
||||
if (custom_check_cb_) {
|
||||
bool is_hit = false;
|
||||
custom_check_cb_({&is_hit, (Entity*)c});
|
||||
custom_check_cb_(a8::Args({&is_hit, (Entity*)c}));
|
||||
if (is_hit) {
|
||||
objects.insert(c);
|
||||
}
|
||||
@ -130,7 +130,7 @@ void Explosion::ProcDamage()
|
||||
}
|
||||
if (custom_check_cb_) {
|
||||
bool is_hit = false;
|
||||
custom_check_cb_({&is_hit, entity});
|
||||
custom_check_cb_(a8::Args({&is_hit, entity}));
|
||||
if (is_hit) {
|
||||
objects.insert(entity);
|
||||
}
|
||||
@ -152,7 +152,7 @@ void Explosion::ProcDamage()
|
||||
target->OnExplosionHit(this);
|
||||
}
|
||||
if (hit_cb_) {
|
||||
hit_cb_({target});
|
||||
hit_cb_(a8::Args({target}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ class Explosion : public std::enable_shared_from_this<Explosion>
|
||||
bool IsPreBattleExplosion();
|
||||
int GetExplosionEffect() { return explosion_effect_; };
|
||||
void SetDamageDelay(int delay) { explosion_damage_delay_ = delay; };
|
||||
void SetHitCb(CommonCbProc cb) { hit_cb_ = cb; };
|
||||
void SetCustomCheckCb(CommonCbProc cb) { custom_check_cb_ = cb; };
|
||||
void SetHitCb(a8::CommonCbProc cb) { hit_cb_ = cb; };
|
||||
void SetCustomCheckCb(a8::CommonCbProc cb) { custom_check_cb_ = cb; };
|
||||
void SetThrough(bool through) { through_ = through; };
|
||||
bool IsThrough() { return through_; };
|
||||
void SetNoSync() { no_sync_ = true; };
|
||||
@ -54,8 +54,8 @@ protected:
|
||||
Position center_;
|
||||
long long special_damage_type_ = 0;
|
||||
long long create_frameno_ = 0;
|
||||
CommonCbProc custom_check_cb_;
|
||||
CommonCbProc hit_cb_;
|
||||
a8::CommonCbProc custom_check_cb_;
|
||||
a8::CommonCbProc hit_cb_;
|
||||
bool through_ = false;
|
||||
bool no_sync_ = false;
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define GAMESERVER_SRC 1
|
||||
#define PERFT 1
|
||||
|
||||
#include <any>
|
||||
|
||||
#include <a8/a8.h>
|
||||
#include <a8/udplog.h>
|
||||
#include <a8/vec2.h>
|
||||
@ -13,21 +8,11 @@
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
typedef std::function<void(const std::vector<std::any>&)> CommonCbProc;
|
||||
|
||||
#include "constant.h"
|
||||
#include "constant_export.h"
|
||||
#include "types.h"
|
||||
#include "global.h"
|
||||
|
||||
namespace google
|
||||
{
|
||||
namespace protobuf
|
||||
{
|
||||
class Message;
|
||||
}
|
||||
}
|
||||
|
||||
#include "f8/types.h"
|
||||
#include "f8/protoutils.h"
|
||||
|
||||
|
@ -340,11 +340,11 @@ void Skill::ProcSJXY()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kBulletHitEvent,
|
||||
[this, shot_times, hited_objs] (const std::vector<std::any>& params) mutable
|
||||
[this, shot_times, hited_objs] (const a8::Args& args) mutable
|
||||
{
|
||||
++shot_times;
|
||||
IBullet* bullet = std::any_cast<IBullet*>(params.at(0));
|
||||
Creature* target = std::any_cast<Creature*>(params.at(1));
|
||||
IBullet* bullet = args.Get<IBullet*>(0);
|
||||
Creature* target = args.Get<Creature*>(1);
|
||||
int rnd = rand();
|
||||
bool is_hit = false;
|
||||
bool is_immune = false;
|
||||
@ -402,7 +402,7 @@ void Skill::ProcSSJS()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kReceiveDmgEvent,
|
||||
[this, add_speed_timer] (const std::vector<std::any>& params) mutable
|
||||
[this, add_speed_timer] (const a8::Args& args) mutable
|
||||
{
|
||||
int rnd = rand();
|
||||
MetaData::Skill* skill_meta = meta;
|
||||
@ -465,9 +465,9 @@ void Skill::ProcJSHX()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kKillEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
int weapon_id = std::any_cast<int>(params.at(2));
|
||||
int weapon_id = args.Get<int>(2);
|
||||
if (owner->GetCurrWeapon()->meta->i->id() != weapon_id) {
|
||||
return;
|
||||
}
|
||||
@ -507,9 +507,9 @@ void Skill::ProcSWZB()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kPreDieEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
int killer_id = std::any_cast<int>(params.at(0));
|
||||
int killer_id = args.Get<int>(0);
|
||||
CreatureWeakPtr sender = owner->GetWeakPtrRef();
|
||||
MetaData::Skill* skill_meta = meta;
|
||||
Position center = owner->GetPos();
|
||||
@ -518,10 +518,10 @@ void Skill::ProcSWZB()
|
||||
e->SetNoSync();
|
||||
e->SetHitCb
|
||||
(
|
||||
[sender, center, skill_meta] (const std::vector<std::any>& params) mutable
|
||||
[sender, center, skill_meta] (const a8::Args& args) mutable
|
||||
{
|
||||
if (sender.Get()) {
|
||||
Entity* e = std::any_cast<Entity*>(params.at(0));
|
||||
Entity* e = args.Get<Entity*>(0);
|
||||
if (e->IsCreature(sender.Get()->room)) {
|
||||
Creature* c = (Creature*)e;
|
||||
if (c->IsInvincible()) {
|
||||
@ -588,7 +588,7 @@ void Skill::ProcSWZB()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kDieEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
#if 0
|
||||
int killer_id = std::any_cast<int>(params.at(0));
|
||||
@ -605,7 +605,7 @@ void Skill::ProcCMXD()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kShieldDestoryEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this] (const a8::Args& params)
|
||||
{
|
||||
Buff* hold_shield_buff = owner->GetBuffByEffectId(kBET_HoldShield);
|
||||
if (hold_shield_buff) {
|
||||
@ -618,10 +618,11 @@ void Skill::ProcCMXD()
|
||||
e->SetThrough(true);
|
||||
e->SetCustomCheckCb
|
||||
(
|
||||
[sender, skill_meta, this_skill_meta, shield_buff_meta] (const std::vector<std::any>& params) mutable
|
||||
[sender, skill_meta, this_skill_meta, shield_buff_meta]
|
||||
(const a8::Args& args) mutable
|
||||
{
|
||||
bool* is_hit = std::any_cast<bool*>(params.at(0));
|
||||
Entity* e = std::any_cast<Entity*>(params.at(1));
|
||||
bool* is_hit = args.Get<bool*>(0);
|
||||
Entity* e = args.Get<Entity*>(1);
|
||||
if (sender.Get() && e->IsCreature(sender.Get()->room)) {
|
||||
// 999
|
||||
#if 1
|
||||
@ -648,10 +649,10 @@ void Skill::ProcCMXD()
|
||||
);
|
||||
e->SetHitCb
|
||||
(
|
||||
[sender, skill_meta] (const std::vector<std::any>& params) mutable
|
||||
[sender, skill_meta] (const a8::Args& args) mutable
|
||||
{
|
||||
if (sender.Get()) {
|
||||
Entity* e = std::any_cast<Entity*>(params.at(0));
|
||||
Entity* e = args.Get<Entity*>(0);
|
||||
if (e->IsCreature(sender.Get()->room)) {
|
||||
Creature* c = (Creature*)e;
|
||||
if (c->IsInvincible()) {
|
||||
@ -721,9 +722,10 @@ void Skill::ProcMYXY()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kUseSkillEvent,
|
||||
[this, speed_rate, atk_rate, immune_buff_uniid] (const std::vector<std::any>& params)
|
||||
[this, speed_rate, atk_rate, immune_buff_uniid]
|
||||
(const a8::Args& args)
|
||||
{
|
||||
Skill* skill = std::any_cast<Skill*>(params.at(0));
|
||||
Skill* skill = args.Get<Skill*>(0);
|
||||
if (skill->meta->GetMagicId() != MAGIC_HJHX) {
|
||||
return;
|
||||
}
|
||||
@ -772,9 +774,9 @@ void Skill::ProcGZJS()
|
||||
(
|
||||
kFlyHookCreateEvent,
|
||||
[this, dmg_ruduce_rate, dmg_ruduce_timer, immune_buff_uniid, hold_gun_buff_uniid]
|
||||
(const std::vector<std::any>& params) mutable
|
||||
(const a8::Args& args) mutable
|
||||
{
|
||||
Bullet* bullet = std::any_cast<Bullet*>(params.at(0));
|
||||
Bullet* bullet = args.Get<Bullet*>(0);
|
||||
if (!bullet->skill_meta || bullet->skill_meta->GetMagicId() != MAGIC_FG) {
|
||||
return;
|
||||
}
|
||||
@ -831,7 +833,8 @@ void Skill::ProcGZJS()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kFlyHookDestoryEvent,
|
||||
[this, dmg_ruduce_rate, immune_buff_uniid, hold_gun_buff_uniid] (const std::vector<std::any>& params)
|
||||
[this, dmg_ruduce_rate, immune_buff_uniid, hold_gun_buff_uniid]
|
||||
(const a8::Args& args)
|
||||
{
|
||||
if (*immune_buff_uniid) {
|
||||
owner->RemoveBuffByUniId(*immune_buff_uniid);
|
||||
@ -853,9 +856,9 @@ void Skill::ProcJYFH()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kStartRescueEvent,
|
||||
[this, buff_id, buff_time] (const std::vector<std::any>& params)
|
||||
[this, buff_id, buff_time] (const a8::Args& args)
|
||||
{
|
||||
Human* target = std::any_cast<Human*>(params.at(0));
|
||||
Human* target = args.Get<Human*>(0);
|
||||
owner->TryAddBuffAndSetTime(owner, buff_id, buff_time * 1000, meta);
|
||||
target->TryAddBuffAndSetTime(owner, buff_id, buff_time * 1000, meta);
|
||||
}
|
||||
@ -863,9 +866,9 @@ void Skill::ProcJYFH()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kEndRescueEvent,
|
||||
[this, buff_id] (const std::vector<std::any>& params)
|
||||
[this, buff_id] (const a8::Args& args)
|
||||
{
|
||||
Human* target = std::any_cast<Human*>(params.at(0));
|
||||
Human* target = args.Get<Human*>(0);
|
||||
owner->RemoveBuffById(buff_id);
|
||||
target->RemoveBuffById(buff_id);
|
||||
}
|
||||
@ -891,9 +894,9 @@ void Skill::ProcFH()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kDieEvent,
|
||||
[this, relive_times] (const std::vector<std::any>& params) mutable
|
||||
[this, relive_times] (const a8::Args& args) mutable
|
||||
{
|
||||
int killer_id = std::any_cast<int>(params.at(0));
|
||||
int killer_id = args.Get<int>(0);
|
||||
if (relive_times <= 0) {
|
||||
++relive_times;
|
||||
if (killer_id != owner->GetUniId()) {
|
||||
@ -948,9 +951,9 @@ void Skill::ProcYSHF()
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kYsRemoveEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
Buff* buff = std::any_cast<Buff*>(params.at(0));
|
||||
Buff* buff = args.Get<Buff*>(0);
|
||||
if (buff->remover_timer && !buff->owner->dead) {
|
||||
int buff_time = owner->room->xtimer.GetRemainTime(buff->remover_timer) * FRAME_RATE_MS;
|
||||
int remain_time = buff_time - meta->number_meta->float_time * 1000;
|
||||
|
@ -395,7 +395,7 @@ void Trigger::RemoveBuffs(int cond, std::vector<int>& buffids)
|
||||
}
|
||||
}
|
||||
|
||||
std::weak_ptr<EventHandlerPtr> Trigger::AddListener(int event_id, CommonCbProc cb)
|
||||
std::weak_ptr<EventHandlerPtr> Trigger::AddListener(int event_id, a8::CommonCbProc cb)
|
||||
{
|
||||
auto itr = listeners_hash_.find(event_id);
|
||||
if (itr == listeners_hash_.end()) {
|
||||
|
@ -14,7 +14,7 @@ struct EventHandlerPtr
|
||||
|
||||
struct EventHandler
|
||||
{
|
||||
CommonCbProc cb;
|
||||
a8::CommonCbProc cb;
|
||||
list_head entry;
|
||||
std::shared_ptr<EventHandlerPtr> ptr;
|
||||
};
|
||||
@ -79,7 +79,7 @@ public:
|
||||
void BulletHitBuff(Bullet* bullet);
|
||||
void Attacked(Creature* sender);
|
||||
|
||||
std::weak_ptr<EventHandlerPtr> AddListener(int event_id, CommonCbProc cb);
|
||||
std::weak_ptr<EventHandlerPtr> AddListener(int event_id, a8::CommonCbProc cb);
|
||||
void RemoveEventHandler(std::weak_ptr<EventHandlerPtr> handler_ptr);
|
||||
void DispatchEvent(int event_id, const std::vector<std::any>& params);
|
||||
|
||||
|
2
third_party/a8
vendored
2
third_party/a8
vendored
@ -1 +1 @@
|
||||
Subproject commit fdce7c90252715cce8d4e9c72f45b129506d3c68
|
||||
Subproject commit 358c62df57da601e0c2c14f38e705b17fa0fc87c
|
Loading…
x
Reference in New Issue
Block a user