36 lines
1.3 KiB
C++
36 lines
1.3 KiB
C++
#include <td/simulation/CommandApply.h>
|
|
|
|
namespace td {
|
|
namespace sim {
|
|
|
|
CommandApply::CommandApply(const game::World& a_World, WorldSnapshot& a_Snapshot) : m_World(a_World), m_Snapshot(a_Snapshot) {}
|
|
|
|
void CommandApply::Handle(const protocol::commands::EndCommand& a_End) {
|
|
(void) m_World;
|
|
}
|
|
|
|
void CommandApply::Handle(const protocol::commands::PlaceTowerCommand& a_PlaceTower) {
|
|
static game::TowerFactory factory;
|
|
|
|
auto tower = std::shared_ptr<game::Tower>(factory.CreateMessage(*a_PlaceTower->m_Type).release());
|
|
tower->m_Builder = *a_PlaceTower->m_Placer;
|
|
tower->SetCenter(utils::shape::Point(a_PlaceTower->m_Position.x, a_PlaceTower->m_Position.y));
|
|
|
|
m_Snapshot.m_Towers.push_back(tower);
|
|
}
|
|
|
|
void CommandApply::Handle(const protocol::commands::PlayerJoinCommand& a_PlayerJoin) {}
|
|
|
|
void CommandApply::Handle(const protocol::commands::SpawnTroopCommand& a_SpawnTroop) {
|
|
auto zombie = std::make_shared<game::Zombie>();
|
|
zombie->m_Position = a_SpawnTroop->m_Position;
|
|
m_Snapshot.m_Mobs.push_back(zombie);
|
|
}
|
|
|
|
void CommandApply::Handle(const protocol::commands::TeamChangeCommand& a_TeamChange) {}
|
|
void CommandApply::Handle(const protocol::commands::UpgradeTowerCommand& a_UpgradeTower) {}
|
|
void CommandApply::Handle(const protocol::commands::UseItemCommand& a_UseItem) {}
|
|
|
|
} // namespace sim
|
|
} // namespace td
|