mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-20 13:44:21 +00:00
feat: spawner weights (#2006)
* feat: spawner weights * remove ref * default weights to 1
This commit is contained in:
@@ -11,12 +11,41 @@
|
||||
#include "LDFFormat.h"
|
||||
#include "EntityInfo.h"
|
||||
|
||||
/**
|
||||
* Any given spawner owns a certain number of spawner nodes
|
||||
* these nodes are where entities are actually spawned
|
||||
* The first spawner nodes waypoint in any given network contains the base config for all the spawner nodes
|
||||
* Then each spawner node after the first may contain duplicate settings which override the base ones
|
||||
* If spawner node 1 has an attached_path of "1", then all spawner nodes in this spawner network will have
|
||||
* an attached_path of "1".
|
||||
* Each spawner node can also specify attached_path of any other value and it will override the one provided by node 1.
|
||||
* If a spawner node does NOT provide an override, the first one will be used
|
||||
* I have no clue why the nodes are pointers, beats me
|
||||
* sn = SpawnerNode
|
||||
* Spawner
|
||||
* ----------------
|
||||
* | sn |
|
||||
* | sn |
|
||||
* | sn |
|
||||
* | |
|
||||
* | sn |
|
||||
* | sn |
|
||||
* -----------------
|
||||
*/
|
||||
struct SpawnerNode {
|
||||
// This spawner nodes position in the world
|
||||
NiPoint3 position = NiPoint3Constant::ZERO;
|
||||
// The rotation of this spawner in the world
|
||||
NiQuaternion rotation = QuatUtils::IDENTITY;
|
||||
// This spawners nodes ID in this spawner network
|
||||
uint32_t nodeID = 0;
|
||||
// The max number of entities that can be spawned by this node
|
||||
uint32_t nodeMax = 1;
|
||||
// The weight (chance) this spawner node has. Higher is more common
|
||||
int32_t weight = 1;
|
||||
// The IDs of entities spawned by this spawner node
|
||||
std::vector<LWOOBJID> entities;
|
||||
// The config of all entities spawned by this node
|
||||
LwoNameValue config;
|
||||
};
|
||||
|
||||
@@ -45,11 +74,10 @@ struct SpawnerInfo {
|
||||
|
||||
class Spawner {
|
||||
public:
|
||||
Spawner(SpawnerInfo info);
|
||||
~Spawner();
|
||||
Spawner(const SpawnerInfo& info);
|
||||
|
||||
Entity* Spawn();
|
||||
Entity* Spawn(std::vector<SpawnerNode*> freeNodes, bool force = false);
|
||||
Entity* Spawn(const std::vector<SpawnerNode*>& freeNodes, bool force = false);
|
||||
void Update(float deltaTime);
|
||||
void NotifyOfEntityDeath(const LWOOBJID& objectID);
|
||||
void Activate();
|
||||
@@ -57,16 +85,16 @@ public:
|
||||
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 AddSpawnedEntityDieCallback(const std::function<void()> callback);
|
||||
void AddEntitySpawnedCallback(const std::function<void(Entity*)> callback);
|
||||
void SetSpawnLot(const LOT lot);
|
||||
void Reset();
|
||||
void DestroyAllEntities();
|
||||
void SoftReset();
|
||||
void SetRespawnTime(float time);
|
||||
void SetNumToMaintain(int32_t value);
|
||||
void SetRespawnTime(const float time);
|
||||
void SetNumToMaintain(const int32_t value);
|
||||
bool GetIsSpawnSmashGroup() const { return m_SpawnSmashFoundGroup; };
|
||||
std::vector<LWOOBJID> GetSpawnedObjectIDs() const;
|
||||
const std::vector<LWOOBJID> GetSpawnedObjectIDs() const;
|
||||
|
||||
SpawnerInfo m_Info;
|
||||
bool m_Active = true;
|
||||
|
||||
Reference in New Issue
Block a user