Area *XMLAreaLoader::LoadAreaFromXMLFile(const char* filename, WorldGameState *world) { tinyxml2::XMLDocument doc; doc.LoadFile(filename); if (doc.ErrorID() != 0) // There was an error opening the file return nullptr; auto *areaElement = doc.FirstChildElement("Area"); return LoadArea(areaElement, world); }
void RegisterServices() { CreateServiceFunction(SERVICE_AREAS_LOAD_AREA, [](uintptr_t p) -> int { AreasLoadAreaService* e = (AreasLoadAreaService*) p; CNWSArea* a = LoadArea(e->resref); e->areaId = a != nullptr ? a->ObjectID : OBJECT_INVALID; return 1; }); CreateServiceFunction(SERVICE_AREAS_DESTROY_AREA, [](uintptr_t p) -> int { AreasDestroyAreaService* e = (AreasDestroyAreaService*) p; e->success = UnloadArea(e->areaId); return 1; }); }
bool RoomContainer::LoadArea(AreaEntry& area) { //MOSResource* mos = gResManager->GetMOS(area.LoadingScreenName()); /*MOSResource* mos = gResManager->GetMOS("BACK"); if (mos != NULL) { Bitmap* loadingScreen = mos->Image(); if (loadingScreen != NULL) { GraphicsEngine::Get()->BlitToScreen(loadingScreen, NULL, NULL); GraphicsEngine::Get()->Flip(); SDL_Delay(2000); loadingScreen->Release(); } gResManager->ReleaseResource(mos); }*/ bool result = LoadArea(area.Name(), area.LongName()); return result; }
void RoomContainer::Clicked(uint16 x, uint16 y) { IE::point point = {int16(x), int16(y)}; ConvertToArea(point); if (fWorldMap != NULL) { for (uint32 i = 0; i < fWorldMap->CountAreaEntries(); i++) { AreaEntry& area = fWorldMap->AreaEntryAt(i); if (rect_contains(area.Rect(), point)) { LoadArea(area); break; } } return; } if (fSelectedActor != NULL) fSelectedActor.Target()->ClearActionList(); // TODO: Temporary, for testing if (Door* door = dynamic_cast<Door*>(fMouseOverObject.Target())) { if (fSelectedActor != NULL) fSelectedActor.Target()->ClickedOn(door); return; } if (Actor* actor = dynamic_cast<Actor*>(fMouseOverObject.Target())) { if (fSelectedActor != actor) { /*if (fSelectedActor != NULL) fSelectedActor->Select(false); fSelectedActor = actor; if (fSelectedActor != NULL) fSelectedActor->Select(true); */ if (fSelectedActor != NULL) fSelectedActor.Target()->ClickedOn(actor); } return; } if (Region* region = _RegionAtPoint(point)) { // TODO: if (fSelectedActor != NULL) fSelectedActor.Target()->ClickedOn(region); if (region->Type() == IE::REGION_TYPE_TRAVEL) { LoadArea(region->DestinationArea(), "foo", region->DestinationEntrance()); return; } else if (region->Type() == IE::REGION_TYPE_INFO) { int32 strRef = region->InfoTextRef(); if (strRef >= 0) Core::Get()->DisplayMessage(strRef); return; } } else if (Container* container = _ContainerAtPoint(point)) { // TODO: if (fSelectedActor != NULL) fSelectedActor.Target()->ClickedOn(container); } if (fSelectedActor != NULL) { WalkTo* walkTo = new WalkTo(fSelectedActor.Target(), point); fSelectedActor.Target()->AddAction(walkTo); } }
Player::Player(JsonBox::Value& _saveData, JsonBox::Value& _areaData, EntityManager* _manager) : Player() { Load(_saveData, _manager); LoadArea(_areaData, _manager); }