fix: fix dead state for hero

This commit is contained in:
Иванов Иван 2024-08-23 17:29:50 +02:00
parent e0ffa3a62e
commit ca86371137
5 changed files with 2 additions and 30 deletions

View File

@ -93,10 +93,6 @@ namespace L2Bot::Domain::Entities
{
m_AttackerIds.clear();
}
void MarkAsDead()
{
m_VitalStats.MarkAsDead();
}
const std::vector<Serializers::Node> BuildSerializationNodes() const override
{

View File

@ -34,10 +34,6 @@ namespace L2Bot::Domain::Entities
{
return "player";
}
void MarkAsDead()
{
m_VitalStats.MarkAsDead();
}
const std::vector<Serializers::Node> BuildSerializationNodes() const override
{

View File

@ -12,7 +12,7 @@ namespace L2Bot::Domain::ValueObjects
public:
const bool IsDead() const
{
return m_IsDead || (m_MaxHp > 0 && m_Hp < 0);
return m_IsDead || (m_MaxHp > 0 && m_Hp <= 0);
}
const uint32_t GetMaxHp() const
{
@ -70,7 +70,7 @@ namespace L2Bot::Domain::ValueObjects
{ L"mp", std::to_wstring(m_Mp) },
{ L"maxCp", std::to_wstring(m_MaxCp) },
{ L"cp", std::to_wstring(m_Cp) },
{ L"isDead", std::to_wstring(m_IsDead) }
{ L"isDead", std::to_wstring(IsDead()) }
};
}
void MarkAsDead()

View File

@ -83,7 +83,6 @@ namespace Interlude
{
Services::ServiceLocator::GetInstance().GetLogger()->App(L"{} died", m_Hero->GetFullName().GetNickname());
m_Hero->ClearAttackers();
m_Hero->MarkAsDead();
}
else
{

View File

@ -46,13 +46,6 @@ namespace Interlude
m_Players.clear();
}
void Init() override
{
Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::CreatureDiedEvent::name, [this](const Events::Event& evt) {
OnCreatureDied(evt);
});
}
PlayerRepository(const NetworkHandlerWrapper& networkHandler, const PlayerFactory& factory, const uint16_t radius) :
m_NetworkHandler(networkHandler),
m_Factory(factory),
@ -64,18 +57,6 @@ namespace Interlude
PlayerRepository() = delete;
virtual ~PlayerRepository() = default;
void OnCreatureDied(const Events::Event& evt)
{
std::shared_lock<std::shared_timed_mutex>(m_Mutex);
if (evt.GetName() == Events::CreatureDiedEvent::name)
{
const auto casted = static_cast<const Events::CreatureDiedEvent&>(evt);
if (m_Players.find(casted.GetCreatureId()) != m_Players.end()) {
m_Players[casted.GetCreatureId()]->MarkAsDead();
}
}
}
private:
const PlayerFactory& m_Factory;
const NetworkHandlerWrapper& m_NetworkHandler;