1+ #pragma once
2+
3+ #include " Unreal/NameTypes.hpp"
4+ #include " Unreal/UnrealCoreStructs.hpp"
5+ #include " Unreal/Rotator.hpp"
6+ #include " Loader/PalModLoaderBase.h"
7+ #include " Loader/Spawner/SpawnerInfo.h"
8+ #include " nlohmann/json.hpp"
9+
10+ namespace RC ::Unreal {
11+ class UWorld ;
12+ class UDataTable ;
13+ }
14+
15+ namespace UECustom {
16+ class UWorldPartitionRuntimeLevelStreamingCell ;
17+ }
18+
19+ namespace Palworld {
20+ class AMonoNPCSpawner ;
21+
22+ class PalSpawnLoader : public PalModLoaderBase {
23+ public:
24+ PalSpawnLoader ();
25+
26+ ~PalSpawnLoader ();
27+
28+ void Initialize ();
29+
30+ void Load (const std::filesystem::path::string_type& modName, const nlohmann::json& data);
31+
32+ void Reload (const std::filesystem::path::string_type& modName, const nlohmann::json& data);
33+
34+ void OnWorldCleanup (RC::Unreal::UWorld* World);
35+
36+ // This is called whenever a world partition is loaded within the main world.
37+ void OnCellLoaded (UECustom::UWorldPartitionRuntimeLevelStreamingCell* cell);
38+
39+ // This is called whenever a world partition is unloaded within the main world.
40+ void OnCellUnloaded (UECustom::UWorldPartitionRuntimeLevelStreamingCell* cell);
41+ private:
42+ RC::Unreal::UDataTable* m_bossSpawnerLocationData = nullptr ;
43+
44+ // Storing loaded cells here for mod reloading purposes.
45+ RC::Unreal::TArray<UECustom::UWorldPartitionRuntimeLevelStreamingCell*> m_loadedCells;
46+ std::vector<PS::SpawnerInfo> m_spawns;
47+
48+ void RegisterSpawn (const std::filesystem::path::string_type& modName, const nlohmann::json& value);
49+ void RegisterSheet (const std::filesystem::path::string_type& modName, PS::SpawnerInfo& spawnerInfo, const nlohmann::json& value);
50+ void RegisterMonoNPC (const std::filesystem::path::string_type& modName, PS::SpawnerInfo& spawnerInfo, const nlohmann::json& value);
51+
52+ void ProcessCellSpawners (UECustom::UWorldPartitionRuntimeLevelStreamingCell* cell);
53+ void CreateSpawner (UECustom::UWorldPartitionRuntimeLevelStreamingCell* cell, PS::SpawnerInfo& spawnerInfo);
54+ void SpawnMonoNPC (UECustom::UWorldPartitionRuntimeLevelStreamingCell* cell, PS::SpawnerInfo& spawnerInfo);
55+ void SpawnSheet (UECustom::UWorldPartitionRuntimeLevelStreamingCell* cell, PS::SpawnerInfo& spawnerInfo);
56+
57+ void AddBossSpawnLocationToMap (PS::SpawnerInfo& spawnerInfo);
58+ void RemoveBossSpawnLocationFromMap (PS::SpawnerInfo& spawnerInfo);
59+
60+ void DestroySpawnersInCell (UECustom::UWorldPartitionRuntimeLevelStreamingCell* cell);
61+
62+ void UnloadMod (const std::filesystem::path::string_type& modName);
63+ };
64+ }
0 commit comments