| 299 | String Level::Layers[32]; |
| 300 | |
| 301 | bool LevelImpl::spawnActor(Actor* actor, Actor* parent) |
| 302 | { |
| 303 | if (actor == nullptr) |
| 304 | { |
| 305 | Log::ArgumentNullException(TEXT("Cannot spawn null actor.")); |
| 306 | return true; |
| 307 | } |
| 308 | |
| 309 | if (actor->GetType().ManagedClass->IsAbstract()) |
| 310 | { |
| 311 | Log::Exception(TEXT("Cannot spawn abstract actor type.")); |
| 312 | return true; |
| 313 | } |
| 314 | |
| 315 | if (actor->Is<Scene>()) |
| 316 | { |
| 317 | // Spawn scene |
| 318 | actor->InitializeHierarchy(); |
| 319 | actor->OnTransformChanged(); |
| 320 | { |
| 321 | SceneBeginData beginData; |
| 322 | actor->BeginPlay(&beginData); |
| 323 | beginData.OnDone(); |
| 324 | } |
| 325 | CallSceneEvent(SceneEventType::OnSceneLoaded, (Scene*)actor, actor->GetID()); |
| 326 | } |
| 327 | else |
| 328 | { |
| 329 | // Spawn actor |
| 330 | if (Level::Scenes.IsEmpty()) |
| 331 | { |
| 332 | Log::InvalidOperationException(TEXT("Cannot spawn actor. No scene loaded.")); |
| 333 | return true; |
| 334 | } |
| 335 | if (parent == nullptr) |
| 336 | parent = Level::Scenes[0]; |
| 337 | |
| 338 | actor->SetPhysicsScene(parent->GetPhysicsScene()); |
| 339 | actor->SetParent(parent, true, true); |
| 340 | } |
| 341 | |
| 342 | return false; |
| 343 | } |
| 344 | |
| 345 | bool LevelImpl::deleteActor(Actor* actor) |
| 346 | { |
nothing calls this directly
no test coverage detected