Given a set of selected objects, what kind of connections are possible
| 183 | |
| 184 | // Given a set of selected objects, what kind of connections are possible |
| 185 | static Object::ConnectionType GetConnectionType(const std::vector<Object*>& selected) { |
| 186 | if (selected.empty()) { |
| 187 | return Object::kCTNone; |
| 188 | } |
| 189 | bool movement_objects_only = true; |
| 190 | bool single_item_object = (selected.size() == 1); |
| 191 | bool env_objects_only = true; |
| 192 | bool path_points_only = true; |
| 193 | bool navmesh_connection_objects_only = true; |
| 194 | bool single_placeholder_object = (selected.size() == 1); |
| 195 | bool hotspots_only = true; |
| 196 | for (auto obj : selected) { |
| 197 | EntityType type = obj->GetType(); |
| 198 | if (type != _movement_object) { |
| 199 | movement_objects_only = false; |
| 200 | } |
| 201 | if (type != _item_object) { |
| 202 | single_item_object = false; |
| 203 | } |
| 204 | if (type != _env_object && type != _group && type != _prefab) { |
| 205 | env_objects_only = false; |
| 206 | } |
| 207 | if (type != _path_point_object) { |
| 208 | path_points_only = false; |
| 209 | } |
| 210 | if (type != _placeholder_object || !((PlaceholderObject*)obj)->connectable()) { |
| 211 | single_placeholder_object = false; |
| 212 | } |
| 213 | if (type != _navmesh_connection_object) { |
| 214 | navmesh_connection_objects_only = false; |
| 215 | } |
| 216 | if (type != _hotspot_object) { |
| 217 | hotspots_only = false; |
| 218 | } |
| 219 | } |
| 220 | if (movement_objects_only) { |
| 221 | return Object::kCTMovementObjects; |
| 222 | } else if (single_item_object) { |
| 223 | return Object::kCTItemObjects; |
| 224 | } else if (env_objects_only) { |
| 225 | return Object::kCTEnvObjectsAndGroups; |
| 226 | } else if (path_points_only) { |
| 227 | return Object::kCTPathPoints; |
| 228 | } else if (single_placeholder_object) { |
| 229 | return Object::kCTPlaceholderObjects; |
| 230 | } else if (navmesh_connection_objects_only) { |
| 231 | return Object::kCTNavmeshConnections; |
| 232 | } else if (hotspots_only) { |
| 233 | return Object::kCTHotspots; |
| 234 | } else { |
| 235 | return Object::kCTNone; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | static void DrawObjInfo(Object* obj) { |
| 240 | Engine::Instance()->gui.AddDebugText("selecteda", obj->obj_file, 10.0f); |
no test coverage detected