mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 17:58:20 +00:00
a0d51e21ca
* allow usage of NiPoint3 and NiQuaternion in constexpr context * removed .cpp files entirely * moving circular dependency circumvention stuff to an .inl file * real world usage!!!!! * reverting weird branch cross-pollination * removing more weird branch cross-pollination * remove comment * added inverse header guard to inl file * Update NiPoint3.inl * trying different constructor syntax * reorganize into .inl files for readability * uncomment include * moved non-constexpr definitions to cpp file * moved static definitions back to inl files * testing fix * moved constants into seperate namespace * Undo change in build-and-test.yml * nodiscard
89 lines
2.4 KiB
C++
89 lines
2.4 KiB
C++
#ifndef SPAWNER_H
|
|
#define SPAWNER_H
|
|
|
|
#include "NiPoint3.h"
|
|
#include "NiQuaternion.h"
|
|
#include "Entity.h"
|
|
#include "dZMCommon.h"
|
|
#include <vector>
|
|
#include <string>
|
|
#include <functional>
|
|
#include "LDFFormat.h"
|
|
#include "EntityInfo.h"
|
|
|
|
struct SpawnerNode {
|
|
NiPoint3 position = NiPoint3Constant::ZERO;
|
|
NiQuaternion rotation = NiQuaternionConstant::IDENTITY;
|
|
uint32_t nodeID = 0;
|
|
uint32_t nodeMax = 1;
|
|
std::vector<LWOOBJID> entities;
|
|
std::vector<LDFBaseData*> 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<SpawnerNode*> nodes = {};
|
|
bool isNetwork = false;
|
|
bool spawnsOnSmash = false;
|
|
std::string spawnOnSmashGroupName = "";
|
|
std::vector<std::string> 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<SpawnerNode*> 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<std::string> GetGroups() { return m_Info.groups; };
|
|
void AddSpawnedEntityDieCallback(std::function<void()> callback);
|
|
void AddEntitySpawnedCallback(std::function<void(Entity*)> callback);
|
|
void SetSpawnLot(LOT lot);
|
|
void Reset();
|
|
void DestroyAllEntities();
|
|
void SoftReset();
|
|
void SetRespawnTime(float time);
|
|
void SetNumToMaintain(int32_t value);
|
|
bool GetIsSpawnSmashGroup() const { return m_SpawnSmashFoundGroup; };
|
|
std::vector<LWOOBJID> GetSpawnedObjectIDs() const;
|
|
|
|
SpawnerInfo m_Info;
|
|
bool m_Active = true;
|
|
private:
|
|
std::vector<std::function<void()>> m_SpawnedEntityDieCallbacks = {};
|
|
std::vector<std::function<void(Entity*)>> m_EntitySpawnedCallbacks = {};
|
|
|
|
|
|
bool m_SpawnSmashFoundGroup = false;
|
|
std::vector<float> m_WaitTimes = {};
|
|
bool m_NeedsUpdate = true;
|
|
std::map<LWOOBJID, SpawnerNode*> m_Entities = {};
|
|
EntityInfo m_EntityInfo;
|
|
int32_t m_AmountSpawned = 0;
|
|
bool m_Start = false;
|
|
Spawner* m_SpawnOnSmash = nullptr;
|
|
};
|
|
|
|
#endif // SPAWNER_H
|