#include "2s2h/resource/type/2shResourceType.h" #include "2s2h/resource/importer/SceneFactory.h" #include "2s2h/resource/type/Scene.h" #include "2s2h/resource/type/scenecommand/SceneCommand.h" #include "2s2h/resource/importer/scenecommand/SetLightingSettingsFactory.h" #include "2s2h/resource/importer/scenecommand/SetWindSettingsFactory.h" #include "2s2h/resource/importer/scenecommand/SetExitListFactory.h" #include "2s2h/resource/importer/scenecommand/SetTimeSettingsFactory.h" #include "2s2h/resource/importer/scenecommand/SetSkyboxModifierFactory.h" #include "2s2h/resource/importer/scenecommand/SetEchoSettingsFactory.h" #include "2s2h/resource/importer/scenecommand/SetSoundSettingsFactory.h" #include "2s2h/resource/importer/scenecommand/SetSkyboxSettingsFactory.h" #include "2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h" #include "2s2h/resource/importer/scenecommand/SetCsCameraFactory.h" #include "2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.h" #include "2s2h/resource/importer/scenecommand/SetRoomListFactory.h" #include "2s2h/resource/importer/scenecommand/SetCollisionHeaderFactory.h" #include "2s2h/resource/importer/scenecommand/SetEntranceListFactory.h" #include "2s2h/resource/importer/scenecommand/SetSpecialObjectsFactory.h" #include "2s2h/resource/importer/scenecommand/SetObjectListFactory.h" #include "2s2h/resource/importer/scenecommand/SetStartPositionListFactory.h" #include "2s2h/resource/importer/scenecommand/SetActorListFactory.h" #include "2s2h/resource/importer/scenecommand/SetTransitionActorListFactory.h" #include "2s2h/resource/importer/scenecommand/EndMarkerFactory.h" #include "2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.h" #include "2s2h/resource/importer/scenecommand/SetPathwaysFactory.h" #include "2s2h/resource/importer/scenecommand/SetCutscenesFactory.h" #include "2s2h/resource/importer/scenecommand/SetLightListFactory.h" #include "2s2h/resource/importer/scenecommand/SetMeshFactory.h" #include "2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.h" #include "2s2h/resource/importer/scenecommand/SetMinimapListFactory.h" #include "2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.h" #include "2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.h" #include namespace SOH { ResourceFactoryBinarySceneV0::ResourceFactoryBinarySceneV0() { sceneCommandFactories[SceneCommandID::SetLightingSettings] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetWind] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetExitList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetTimeSettings] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetSkyboxModifier] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetEchoSettings] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetSoundSettings] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetSkyboxSettings] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetRoomBehavior] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetCsCamera] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetCameraSettings] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetRoomList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetCollisionHeader] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetEntranceList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetSpecialObjects] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetObjectList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetStartPositionList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetActorList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetTransitionActorList] = std::make_shared(); sceneCommandFactories[SceneCommandID::EndMarker] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetAlternateHeaders] = std::make_shared(); // TODO should we use a different custom scene command like cutscenes? sceneCommandFactories[SceneCommandID::SetPathways] = std::make_shared(); // sceneCommandFactories[SceneCommandID::SetCutscenes] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetLightList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetMesh] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetCutscenesMM] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetAnimatedMaterialList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetMinimapList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetMinimapChests] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetActorCutsceneList] = std::make_shared(); } void ResourceFactoryBinarySceneV0::ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader) { uint32_t commandCount = reader->ReadUInt32(); scene->commands.reserve(commandCount); for (uint32_t i = 0; i < commandCount; i++) { scene->commands.push_back(ParseSceneCommand(scene, reader, i)); } } std::shared_ptr ResourceFactoryBinarySceneV0::ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index) { SceneCommandID cmdID = (SceneCommandID)reader->ReadInt32(); reader->Seek(-sizeof(int32_t), Ship::SeekOffsetType::Current); std::shared_ptr result = nullptr; auto commandFactory = ResourceFactoryBinarySceneV0::sceneCommandFactories[cmdID]; if (commandFactory != nullptr) { auto initData = std::make_shared(); initData->Id = scene->GetInitData()->Id; initData->Type = static_cast(ResourceType::SOH_SceneCommand); initData->Path = scene->GetInitData()->Path + "/SceneCommand" + std::to_string(index); initData->ResourceVersion = scene->GetInitData()->ResourceVersion; result = std::static_pointer_cast(commandFactory->ReadResource(initData, reader)); // Cache the resource? } if (result == nullptr) { SPDLOG_ERROR("Failed to load scene command of type {} in scene {}", (uint32_t)cmdID, scene->GetInitData()->Path); } return result; } std::shared_ptr ResourceFactoryBinarySceneV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } auto scene = std::make_shared(initData); auto reader = std::get>(file->Reader); ParseSceneCommands(scene, reader); return scene; }; } // namespace SOH