载入中...
搜索中...
未找到
EconomySystem.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
6
7#include <functional>
8#include <memory>
9#include <string>
10#include <unordered_map>
11#include <vector>
13
14namespace eve::economy {
15
18 int player = 0;
19 std::string type;
20 std::string action; // "credit" | "debit" | "waste"
21 int amount = 0;
22};
23
24using EconomyHook = std::function<void(const EconomyEvent&)>;
25
30public:
32 static void clear();
33
35 static int credit(int player, const std::string& type, int amount);
37 static bool debit(int player, const std::string& type, int amount);
38
40 static int get(int player, const std::string& type);
42 static int getCap(int player, const std::string& type);
44 static int getWasted(int player, const std::string& type);
46 static int getIncome(int player, const std::string& type);
48 static int getExpense(int player, const std::string& type);
49
55 [[nodiscard]] static EconomyLedger::Snapshot snapshot(int player);
56
58 static void registerHook(const std::string& name, EconomyHook fn);
60 static void unregisterHook(const std::string& name);
61
63 static void clearEvents();
65 static int eventCount();
67 static const EconomyEvent& eventAt(int index);
68
73 [[nodiscard]] static std::shared_ptr<resource::IResourceAccount> resourceAccount(int player);
74
75private:
76 static EconomyLedger& ledger(int player);
77 static void emit(const EconomyEvent& ev);
78
79 static std::unordered_map<int, EconomyLedger>& ledgers();
80 static std::vector<EconomyEvent>& events();
81 static std::unordered_map<std::string, EconomyHook>& hooks();
82};
83
84} // namespace eve::economy
std::string name
Definition ECS.cpp:154
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
Snapshot snapshot
std::vector< particles::ParticleRecordEvent > events
Strongly typed, transaction-friendly resource cost protocol.
uint32_t index
单个玩家的资源账本:当前量、上限、收支与浪费统计。
经济系统门面:按玩家持有账本、转发事件、注册钩子。
std::function< void(const EconomyEvent &)> EconomyHook
SettlementPipeline::Stage fn
一次经济事件(credit / debit / waste)。
Owning deterministic copy of all balance and accounting counters.