@@ -11,23 +11,23 @@ namespace arena::logic {
11
11
auto princess_tower = entity_data_manager.getEntityDataByName (" PrincessTower" );
12
12
auto king_tower = entity_data_manager.getEntityDataByName (" KingTower" );
13
13
14
- add_arena_tower (princess_tower, " princess" , " blue" , this ->blue_side_tower_skin , 171 , 788 );
15
- add_arena_tower (princess_tower, " princess" , " blue" , this ->blue_side_tower_skin , 548 , 788 );
16
- add_arena_tower (king_tower, " king" , " blue" , this ->blue_side_tower_skin , 360 , 875 );
14
+ add_arena_tower (princess_tower, " princess" , " blue" , this ->blue_side_tower_skin , SkV2{ 171 , 788 } );
15
+ add_arena_tower (princess_tower, " princess" , " blue" , this ->blue_side_tower_skin , SkV2{ 548 , 788 } );
16
+ add_arena_tower (king_tower, " king" , " blue" , this ->blue_side_tower_skin , SkV2{ 360 , 875 } );
17
17
18
- add_arena_tower (princess_tower, " princess" , " red" , this ->red_side_tower_skin , 171 , 262 );
19
- add_arena_tower (princess_tower, " princess" , " red" , this ->red_side_tower_skin , 548 , 262 );
20
- add_arena_tower (king_tower, " king" , " red" , this ->red_side_tower_skin , 360 , 167 );
18
+ add_arena_tower (princess_tower, " princess" , " red" , this ->red_side_tower_skin , SkV2{ 171 , 262 } );
19
+ add_arena_tower (princess_tower, " princess" , " red" , this ->red_side_tower_skin , SkV2{ 548 , 262 } );
20
+ add_arena_tower (king_tower, " king" , " red" , this ->red_side_tower_skin , SkV2{ 360 , 167 } );
21
21
}
22
22
23
- void Arena::add_arena_tower (pEntityData entity_data, std::string character, std::string team_side, TowerSkin tower_skin, int x, int y )
23
+ void Arena::add_arena_tower (pEntityData entity_data, std::string character, std::string team_side, TowerSkin tower_skin, SkV2 position )
24
24
{
25
25
auto result = try_get_arena_tower_path (character, team_side, tower_skin);
26
26
if (!result.has_value ()) throw std::exception (result.error ().c_str ());
27
27
auto building_instance_result = Entity::create (entity_data, result.value ());
28
28
if (!building_instance_result.has_value ()) throw std::exception (building_instance_result.error ().c_str ());
29
29
pEntity building = std::make_shared<Entity>(building_instance_result.value ());
30
- building->setPosition (x, y );
30
+ building->setPosition (position );
31
31
this ->ground_entities .push_back (building);
32
32
}
33
33
@@ -71,15 +71,18 @@ namespace arena::logic {
71
71
72
72
bool Arena::try_add_character (pEntity character)
73
73
{
74
+ SkV2 character_position = character->position ;
74
75
for (auto entity : this ->ground_entities ) {
75
- double distance = sqrt (pow (entity->x - character->x , 2 ) + pow (entity->y - character->y , 2 )) * 32 ;
76
+ SkV2 entity_position = entity->position ;
77
+ double distance = sqrt (pow (entity_position.x - character_position.x , 2 ) + pow (entity_position.y - character_position.y , 2 )) * 32 ;
76
78
bool inside_bounds = distance <= (entity->entity_data ->getCollisionRadius () * Global::scale) + (character->entity_data ->getCollisionRadius () * Global::scale);
77
79
spdlog::debug (" CurrentName:{}|Name:{}|Distance:{}|Inside_Bounds:{}" , character->entity_data ->getName (), entity->entity_data ->getName (), distance, inside_bounds);
78
80
if (inside_bounds)
79
81
return false ;
80
82
}
81
83
for (auto entity : this ->air_entities ) {
82
- double distance = sqrt (pow (entity->x - character->x , 2 ) + pow (entity->y - character->y , 2 )) * 32 ;
84
+ SkV2 entity_position = entity->position ;
85
+ double distance = sqrt (pow (entity_position.x - character_position.x , 2 ) + pow (entity_position.y - character_position.y , 2 )) * 32 ;
83
86
bool inside_bounds = distance <= (entity->entity_data ->getCollisionRadius () * 4 * Global::scale) + (character->entity_data ->getCollisionRadius () * Global::scale);
84
87
spdlog::debug (" CurrentName:{}|Name:{}|Distance:{}|Inside_Bounds:{}" , character->entity_data ->getName (), entity->entity_data ->getName (), distance, inside_bounds);
85
88
if (inside_bounds)
@@ -98,12 +101,12 @@ namespace arena::logic {
98
101
{
99
102
std::sort (this ->ground_entities .begin (), this ->ground_entities .end (), [](const pEntity& entity_1, const pEntity& entity_2) -> bool
100
103
{
101
- return entity_1->y < entity_2->y ;
104
+ return entity_1->position . y < entity_2->position . y ;
102
105
}
103
106
);
104
107
std::sort (this ->air_entities .begin (), this ->air_entities .end (), [](const pEntity& entity_1, const pEntity& entity_2) -> bool
105
108
{
106
- return entity_1->y < entity_2->y ;
109
+ return entity_1->position . y < entity_2->position . y ;
107
110
}
108
111
);
109
112
for (auto & entity : this ->ground_entities ) {
0 commit comments