Torque3D/Templates/Modules/spectatorGameplay/SpectatorGameplay.cs
Areloch d680dc9934 Initial implementation of the new Base Game Template and some starting modules.
This makes some tweaks to the engine to support this, specifically, it tweaks the hardcoded shaderpaths to defer to a pref variable, so none of the shader paths are hardcoded.

Also tweaks how post effects read in texture files, removing a bizzare filepath interpretation choice, where if the file path didn't start with "/" it forcefully appended the script's file path. This made it impossible to have images not in the same dir as the script file defining the post effect.

This was changed and the existing template's post effects tweaked for now to just add "./" to those few paths impacted, as well as the perf vars to support the non-hardcoded shader paths in the engine.
2017-02-24 02:40:56 -06:00

69 lines
2.8 KiB
C#

// The general flow of a gane - server's creation, loading and hosting clients, and then destruction is as follows:
// First, a client will always create a server in the event that they want to host a single player
// game. Torque3D treats even single player connections as a soft multiplayer game, with some stuff
// in the networking short-circuited to sidestep around lag and packet transmission times.
// initServer() is called, loading the default server scripts.
// After that, if this is a dedicated server session, initDedicated() is called, otherwise initClient is called
// to prep a playable client session.
// When a local game is started - a listen server - via calling StartGame() a server is created and then the client is
// connected to it via createAndConnectToLocalServer().
function SpectatorGameplay::create( %this )
{
//server scripts
exec("./scripts/server/camera.cs");
exec("./scripts/server/DefaultGame.cs");
exec("./scripts/server/VolumetricFog.cs");
//add DBs
if(isObject(DatablockFilesList))
{
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/camera.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/defaultParticle.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/lights.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/managedDatablocks.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/managedDecalData.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/managedForestItemData.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/managedParticleData.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/managedParticleEmitterData.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/markers.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/ribbons.cs" );
DatablockFilesList.add( "data/spectatorGameplay/scripts/datablocks/sounds.cs" );
}
if(isObject(LevelFilesList))
{
for( %file = findFirstFile( "data/spectatorGameplay/levels/*.mis" );
%file !$= "";
%file = findNextFile( "data/spectatorGameplay/levels/*.mis" ))
{
LevelFilesList.add(%file);
}
}
if (!$Server::Dedicated)
{
//client scripts
$KeybindPath = "data/spectatorGameplay/scripts/client/default.keybinds.cs";
exec($KeybindPath);
%prefPath = getPrefpath();
if(isFile(%prefPath @ "/keybinds.cs"))
exec(%prefPath @ "/keybinds.cs");
exec("data/spectatorGameplay/scripts/client/inputCommands.cs");
//guis
exec("./scripts/gui/playGui.gui");
exec("./scripts/gui/playGui.cs");
}
}
function SpectatorGameplay::destroy( %this )
{
}