-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cs
87 lines (68 loc) · 2.36 KB
/
main.cs
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
83
84
85
86
87
//-----------------------------------------------------------------------------
// Entry point to the engine. Everything begins here.
// Make TorqueScript a bit more familiar to users of other languages.
exec("ts/shim.cs");
// Some useful functions.
exec("ts/std.cs");
// Seed the random generator.
setRandomSeed(getRealTime());
// Console does something.
setLogMode(2);
// Disable script trace.
trace(false);
//-----------------------------------------------------------------------------
// Load up scripts to initialise subsystems.
exec("sys/main.cs");
// The canvas needs to be initialized before any gui scripts are run since
// some of the controls assume that the canvas exists at load time.
createCanvas("vlrtt");
// Start rendering and stuff.
initRenderManager();
initLightingSystems("Advanced Lighting");
initPostEffects();
// Start audio.
sfxStartup();
// Provide stubs so we don't get console spam.
function onDatablockObjectReceived() {}
function onGhostAlwaysObjectReceived() {}
function onGhostAlwaysStarted() {}
function updateTSShapeLoadProgress() {}
// Convenience function: execute the main.cs file of some directory in modules/.
function execModule(%name) {
exec("modules/" @ %name @ "/main.cs");
}
//-----------------------------------------------------------------------------
// Load console.
execModule("console");
execModule("metrics");
// Load up game code.
execModule("game");
// Called when we connect to the local game.
function GameConnection::onConnect(%client) {
%client.transmitDataBlocks(0);
}
// Called when all datablocks from above have been transmitted.
function GameConnection::onDataBlocksDone(%client) {
// Start sending ghosts to the client.
%client.activateGhosting();
// Enter game callback.
%client.onEnterGame();
}
// Create a local game server and connect to it.
new SimGroup(ServerGroup);
new GameConnection(ServerConnection);
// This calls GameConnection::onConnect.
ServerConnection.connectLocal();
// Start game-specific scripts. Defined in modules/game/main.cs
onStart();
//-----------------------------------------------------------------------------
// Called when the engine is shutting down.
function onExit() {
// Clean up game objects and so on.
onEnd();
// Delete the connection if it's still there.
ServerConnection.delete();
ServerGroup.delete();
// Delete all the datablocks.
deleteDataBlocks();
}