| 66 | } |
| 67 | |
| 68 | bool AFCMapModule::SwitchMap(const AFGUID& self, const int target_map, const int target_inst, const AFVector3D& pos, |
| 69 | const float fOrient, const AFIDataList& args) |
| 70 | { |
| 71 | auto pEntity = m_pKernelModule->GetEntity(self); |
| 72 | if (pEntity == nullptr) |
| 73 | { |
| 74 | ARK_LOG_ERROR("Cannot find entity, id = {}", self); |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | int32_t old_map = pEntity->GetInt32(AFEntityMetaBaseEntity::map_id()); |
| 79 | int32_t old_inst = pEntity->GetInt32(AFEntityMetaBaseEntity::map_inst_id()); |
| 80 | |
| 81 | std::shared_ptr<AFMapInfo> pOldMapInfo = map_infos_.find_value(old_map); |
| 82 | std::shared_ptr<AFMapInfo> pNewMapInfo = map_infos_.find_value(target_map); |
| 83 | |
| 84 | if (nullptr == pOldMapInfo) |
| 85 | { |
| 86 | ARK_LOG_ERROR("cannot find this map, id={}", old_map); |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | if (nullptr == pNewMapInfo) |
| 91 | { |
| 92 | ARK_LOG_ERROR("cannot tind this map, id = {}", target_map); |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | if (!pNewMapInfo->ExistInstance(target_inst)) |
| 97 | { |
| 98 | ARK_LOG_ERROR("Cannot find this map instance, map={} inst={}", target_map, target_inst); |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | pOldMapInfo->RemoveEntityFromInstance(old_inst, self, true); |
| 103 | |
| 104 | //if (target_map != old_map) |
| 105 | //{ |
| 106 | // pEntity->SetInt32(AFEntityMetaBaseEntity::map_id(), 0); |
| 107 | // pEntity->SetInt32(AFEntityMetaBaseEntity::map_id(), target_map); |
| 108 | //} |
| 109 | |
| 110 | //pEntity->SetInt32(AFEntityMetaBaseEntity::map_inst_id(), target_inst); |
| 111 | |
| 112 | //pEntity->SetDouble("X", pos.x); |
| 113 | //pEntity->SetDouble("Y", pos.y); |
| 114 | //pEntity->SetDouble("Z", pos.z); |
| 115 | pEntity->SwitchScene(target_map, target_inst, pos); |
| 116 | |
| 117 | return pNewMapInfo->AddEntityToInstance(target_inst, self, true); |
| 118 | } |
| 119 | |
| 120 | bool AFCMapModule::CreateMap(const int map_id) |
| 121 | { |
nothing calls this directly
no test coverage detected