| 270 | } |
| 271 | |
| 272 | Asset::LoadResult BehaviorTree::load() |
| 273 | { |
| 274 | // Load graph |
| 275 | const auto surfaceChunk = GetChunk(0); |
| 276 | if (surfaceChunk == nullptr) |
| 277 | return LoadResult::MissingDataChunk; |
| 278 | MemoryReadStream surfaceStream(surfaceChunk->Get(), surfaceChunk->Size()); |
| 279 | PROFILE_MEM(AI); |
| 280 | if (Graph.Load(&surfaceStream, true)) |
| 281 | { |
| 282 | LOG(Warning, "Failed to load graph \'{0}\'", ToString()); |
| 283 | return LoadResult::Failed; |
| 284 | } |
| 285 | Graph.Setup(this); |
| 286 | |
| 287 | #if USE_EDITOR |
| 288 | Level::ScriptsReloadStart.Bind<BehaviorTree, &BehaviorTree::OnScriptsReloadStart>(this); |
| 289 | Level::ScriptsReloadEnd.Bind<BehaviorTree, &BehaviorTree::OnScriptsReloadEnd>(this); |
| 290 | #endif |
| 291 | |
| 292 | return LoadResult::Ok; |
| 293 | } |
| 294 | |
| 295 | void BehaviorTree::unload(bool isReloading) |
| 296 | { |