载入中...
搜索中...
未找到
LootSystem.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
13#include "common/Result.h"
14
15#include <cstdint>
16#include <random>
17#include <string>
18#include <vector>
19
20namespace eve::inventory {
21class Bag;
22}
23
24namespace eve::rpg {
25
27enum class LootSelectMode {
29 Weighted,
30};
31
33struct LootEntry {
34 std::string itemId;
35 double chance = 0.0;
36 int minQty = 1;
37 int maxQty = 1;
38 double weight = 0.0;
39 bool unique = false;
40};
41
48
56 double luck = 0.0;
57};
58
64public:
66 static void registerTable(const LootTableDefinition &def);
68 static int registerTablesFromJson(const std::string &json);
70 static const LootTableDefinition *find(const std::string &id);
72 static void clear();
74 static int count();
75
86 static int roll(const std::string &tableId, eve::inventory::Bag *bag, std::mt19937 &rng);
87
94 [[nodiscard]] static eve::Result<int> rollDetailed(const std::string &tableId, eve::inventory::Bag *bag,
95 std::mt19937 &rng, const LootRollRequest &request = {});
96};
97
98} // namespace eve::rpg
#define EVENGINE_API_PLATFORM
Definition Export.h:107
const GltfImportRequest & request
Move-only, checked operation results for the common layer.
int count
Move-only operation result carrying either a value or Status.
Definition Result.h:176
格子型物品容器(脚本可直接操作)。
Definition Bag.h:22
掉落系统:进程级掉落表 + 随机 roll 入包。 @thread 在 Bag 与注册表的 owning simulation thread 执行,不支持并发修改。
Definition LootSystem.h:63
运行时容器:固定格数的背包 / 箱子 / 商店栏等。 行为由 InventorySystem 提供;本类暴露便于脚本绑定的薄封装方法。
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
LootSelectMode
How a loot table chooses among its entries.
Definition LootSystem.h:27
掉落表里的一条掉落。
Definition LootSystem.h:33
double chance
[0,1],Independent 模式下 roll 值小于 chance 才掉落
Definition LootSystem.h:35
double weight
Weighted 模式下的相对权重(必须 > 0 才参与)
Definition LootSystem.h:38
std::string itemId
Definition LootSystem.h:34
Optional modifiers for a single loot roll.
Definition LootSystem.h:50
double luck
Multiplicative chance boost for Independent tables.
Definition LootSystem.h:56
std::vector< LootEntry > entries
Definition LootSystem.h:45