-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdraftapi.txt
82 lines (62 loc) · 1.85 KB
/
draftapi.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class SceneManager {
// ECS implementation.
}
class World {
World(); // create basic test world.
Node* background_scene_node;
// Future API:
using u32 = SystemId;
void loadGalaxy(const String& galaxy_file);
void loadSystem(SystemId system);
void unloadSystem(SystemId system);
SystemNode* systemRootNode(SystemId system);
// Scene file: Contains system id to be used as root node.
void loadScene(const String& scene_file);
}
class GameState {
void onStart();
void onEnd();
}
struct GameSessionInfo {
// Scene url examples
// connecting to a game: 172.16.2.15:5555
// connecting to a game using in memory transport: 172.16.2.15:5555?transport=mem
// start a game in TestScene. host on port 5555 using default transport: TestScene?host=:5555
// start a game in TestScene. host on port 5555 using in memory transport. TestScene?host=:5555&transport=mem
static Option<GameSessionInfo> parseUrl(const String& url);
enum Mode {
CreateNewGame,
JoinExistingGame
}
Mode mode;
// Networking.
String host_ip;
u16 port;
NetInstance::Transport transport;
// Scene to use when creating a new game.
String scene_name;
// Other parameters.
HashMap<String, String> params;
}
class GameSession {
public:
GameSession(const GameSessionInfo& gsi);
protected:
UniquePtr<NetInstance> net_instance;
UniquePtr<World> world;
UniquePtr<GameState> game_state;
UniquePtr<Player> player;
}
class ShooterGameSession : GameSession {
ShooterGameSession(const GameSessionInfo& gsi) {
GameSession::defaultInit(gsi);
}
void onLoadScene(...) {
// Set up scene.
}
// Server side.
bool acceptPlayer(const PlayerInfo& info) {
// return true to accept, false to reject.
}
void onAccept(const AcceptInfo&)
}