#ifndef SPAWNER_H #define SPAWNER_H #include "NiPoint3.h" #include "NiQuaternion.h" #include "Entity.h" #include "dZMCommon.h" #include #include #include #include "LDFFormat.h" #include "EntityInfo.h" struct SpawnerNode { NiPoint3 position = NiPoint3::ZERO; NiQuaternion rotation = NiQuaternion::IDENTITY; uint32_t nodeID = 0; uint32_t nodeMax = 1; std::vector entities; std::vector config; }; struct SpawnerInfo { LWOOBJID spawnerID = LWOOBJID_EMPTY; LOT templateID = -1; std::string name = ""; float templateScale = 1; float respawnTime = 0.0f; int32_t maxToSpawn = -1; uint32_t amountMaintained = 1; bool activeOnLoad = true; std::vector nodes = {}; bool isNetwork = false; bool spawnsOnSmash = false; std::string spawnOnSmashGroupName = ""; std::vector groups = {}; bool noAutoSpawn = false; bool noTimedSpawn = false; std::string grpNameQBShowBricks = ""; bool spawnActivator = true; bool emulated = false; LWOOBJID emulator = LWOOBJID_EMPTY; }; class Spawner { public: Spawner(SpawnerInfo info); ~Spawner(); Entity* Spawn(); Entity* Spawn(std::vector freeNodes, bool force = false); void Update(float deltaTime); void NotifyOfEntityDeath(const LWOOBJID& objectID); void Activate(); void Deactivate() { m_Active = false; }; int32_t GetAmountSpawned() { return m_AmountSpawned; }; std::string GetName() { return m_Info.name; }; std::vector GetGroups() { return m_Info.groups; }; void AddSpawnedEntityDieCallback(std::function callback); void AddEntitySpawnedCallback(std::function callback); void SetSpawnLot(LOT lot); void Reset(); void SoftReset(); void SetRespawnTime(float time); void SetNumToMaintain(int32_t value); bool GetIsSpawnSmashGroup() const { return m_SpawnSmashFoundGroup; }; SpawnerInfo m_Info; bool m_Active = true; private: std::vector> m_SpawnedEntityDieCallbacks = {}; std::vector> m_EntitySpawnedCallbacks = {}; bool m_SpawnSmashFoundGroup = false; std::vector m_WaitTimes = {}; bool m_NeedsUpdate = true; std::map m_Entities = {}; EntityInfo m_EntityInfo; int32_t m_AmountSpawned = 0; bool m_Start = false; Spawner* m_SpawnOnSmash = nullptr; }; #endif // SPAWNER_H