game2006/server/gameserver/mt/InGameVoice.cc
aozhiwei e30f9e2274 1
2024-03-29 16:41:37 +08:00

80 lines
2.3 KiB
C++

#include "precompile.h"
#include <a8/magicenum.h>
#include "mt/InGameVoice.h"
IMPL_TABLE(mt::InGameVoice)
int mt::InGameVoice::s_play_interval = 0;
int mt::InGameVoice::s_series_kill_interval = 0;
std::map<int, std::vector<const mt::InGameVoice*>> mt::InGameVoice::s_type_hash_;
namespace mt
{
static InGameVoiceNotifyObject_e ParseNotifyObject(const std::string& type)
{
if (type == "global") {
return InGameVoiceNotifyObject_e::kGlobal;
} else if (type == "killer") {
return InGameVoiceNotifyObject_e::kKiller;
} else if (type == "!killer") {
return InGameVoiceNotifyObject_e::kNoKiller;
} else if (type == "killer_team") {
return InGameVoiceNotifyObject_e::kKillerTeam;
} else if (type == "!killer_team") {
return InGameVoiceNotifyObject_e::kNoKillerTeam;
} else if (type == "dead") {
return InGameVoiceNotifyObject_e::kDead;
} else if (type == "!dead") {
return InGameVoiceNotifyObject_e::kNoDead;
} else if (type == "dead_team") {
return InGameVoiceNotifyObject_e::kDeadTeam;
} else if (type == "!dead_team") {
return InGameVoiceNotifyObject_e::kNoDeadTeam;
} else if (type == "teammate_exclude_dead") {
return InGameVoiceNotifyObject_e::kTeammateExcludeDead;
} else {
A8_ABORT();
}
}
void InGameVoice::Init1()
{
if (a8::GetEnumName<InGameVoiceEventType_e>(event_type()).empty()) {
A8_ABORT();
}
_notify_object = ParseNotifyObject(notify_object());
{
auto itr = s_type_hash_.find(event_type());
if (itr != s_type_hash_.end()) {
itr->second.push_back(this);
} else {
s_type_hash_[event_type()] = std::vector<const mt::InGameVoice*>({this});
}
}
if (play_interval() > 0) {
s_play_interval = play_interval();
}
if (series_kill_interval() > 0) {
s_series_kill_interval = series_kill_interval();
}
}
void InGameVoice::Init2()
{
}
InGameVoiceNotifyObject_e InGameVoice::GetNotifyObject() const
{
return _notify_object;
}
void InGameVoice::Traverse(std::function<bool (const InGameVoice*)> cb)
{
}
}