载入中...
搜索中...
未找到
EconomySystem.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
6
7#include <functional>
8#include <string>
9#include <unordered_map>
10#include <vector>
11
12namespace eve::economy {
13
16 int player = 0;
17 std::string type;
18 std::string action; // "credit" | "debit" | "waste"
19 int amount = 0;
20};
21
22using EconomyHook = std::function<void(const EconomyEvent&)>;
23
28public:
30 static void clear();
31
33 static int credit(int player, const std::string& type, int amount);
35 static bool debit(int player, const std::string& type, int amount);
36
38 static int get(int player, const std::string& type);
40 static int getCap(int player, const std::string& type);
42 static int getWasted(int player, const std::string& type);
44 static int getIncome(int player, const std::string& type);
46 static int getExpense(int player, const std::string& type);
47
53 [[nodiscard]] static EconomyLedger::Snapshot snapshot(int player);
54
56 static void registerHook(const std::string& name, EconomyHook fn);
58 static void unregisterHook(const std::string& name);
59
61 static void clearEvents();
63 static int eventCount();
65 static const EconomyEvent& eventAt(int index);
66
67private:
68 static EconomyLedger& ledger(int player);
69 static void emit(const EconomyEvent& ev);
70
71 static std::unordered_map<int, EconomyLedger>& ledgers();
72 static std::vector<EconomyEvent>& events();
73 static std::unordered_map<std::string, EconomyHook>& hooks();
74};
75
76} // namespace eve::economy
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
std::string name
Battle::Events events
uint32_t index
单个玩家的资源账本:当前量、上限、收支与浪费统计。
经济系统门面:按玩家持有账本、转发事件、注册钩子。
std::function< void(const EconomyEvent &)> EconomyHook
SettlementPipeline::Stage fn
一次经济事件(credit / debit / waste)。
Owning deterministic copy of all balance and accounting counters.