|
@@ -1,123 +1,60 @@
|
|
|
-//This is our create function. It's pointed to, by name, via a field defined in
|
|
|
-//the ExampleModule.module file, which contains our module definition. It is called
|
|
|
-//when the module is initially loaded by the engine. Generally, only common, base-level
|
|
|
-//stuff is created(or destroyed, in the companion function), like things utilized or
|
|
|
-//shared on both the client and server, or things that need to be loaded before anything
|
|
|
-//else.
|
|
|
function ExampleModule::onCreate(%this)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-//Similar to the create function, this is defined in thye module file, and called
|
|
|
-//when the module is destroyed, usually as part of the game shutting down.
|
|
|
function ExampleModule::onDestroy(%this)
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-//This is called when the server part of the application is initially created. Torque3D
|
|
|
-//assumes, even in a single player context, that there is ultimately a 'server' and a 'client'
|
|
|
-//So during initial launch and startup of the engine, the server side is initialized in
|
|
|
-//core/clientServer/scripts/server/server.tscript - in the initServer() function where this is called.
|
|
|
-//This is called on all modules that have this function defined. This is important for
|
|
|
-//any persistant parts of the server that always need to run such as gameplay scripts
|
|
|
-//
|
|
|
-//Importantly, when the gane session server is created, several functions are called to as part of the gamemode logic
|
|
|
-//The script below contains the callbacks so the gamemode can actually be set up, but the server-side callbacks in question:
|
|
|
-//ExampleGameMode::onMissionStart
|
|
|
-//ExampleGameMode::onMissionEnded
|
|
|
-//ExampleGameMode::onMissionReset
|
|
|
-//Are called during the startup, shut down, and resetting of any and all active gamemodes, as informed by the loaded scenes
|
|
|
-//when the game server is processed.
|
|
|
-//These callbacks are activated in core/clientServer/scripts/server/levelLoad.tscript
|
|
|
+//This is called when the server is initially set up by the game application
|
|
|
function ExampleModule::initServer(%this)
|
|
|
{
|
|
|
- //This script contains our ExampleGameMode logic
|
|
|
- %this.queueExec("./scripts/ExampleGamemodeScript");
|
|
|
+ %this.queueExec("./scripts/server/ExampleGameMode");
|
|
|
}
|
|
|
|
|
|
-//This is called when a game session server is actually created so the game may be played. It's called
|
|
|
-//from core/clientServer/scripts/server/server.tscript - in the createServer() function, which is called when
|
|
|
-//A game session is actually launched, and the server is generated so game clients can connect to it.
|
|
|
-//This is utilized to set up common things that need to be set up each time the game session server is
|
|
|
-//created, such as common variables, datablocks to be transmitted to the client, etc.
|
|
|
+//This is called when the server is created for an actual game/map to be played
|
|
|
function ExampleModule::onCreateGameServer(%this)
|
|
|
{
|
|
|
- //In particular, the default client/server module handles the transmission of datablocks from
|
|
|
- //server to client automatically as part of the connection and prepping process alongside
|
|
|
- //validation and tramission of level objects. It does this in an abstracted way by adding
|
|
|
- //the file paths to a master DatablockFilesList array as per below. When the server is created in
|
|
|
- //onServerCreated(), it loads the datablocks via this array, and when when the server goes
|
|
|
- //to pass data to the client, it iterates over this list and processes it, ensuring all datablocks
|
|
|
- //are the most up to date possible for transmission to the connecting client
|
|
|
- //%this.registerDatablock("./datablocks/ExampleDatablock." @ $TorqueScriptFileExtension);
|
|
|
-}
|
|
|
-
|
|
|
-//This is called when a game session server is destroyed, when the game shuts down. It's called from
|
|
|
-//core/clientServer/scripts/server/server.tscript - in the destroyServer() function, which just cleans up anything
|
|
|
-//The module may have set up as part of the game server being created.
|
|
|
+ //These are common managed data files. For any datablock-based stuff that gets generated by the editors
|
|
|
+ //(that doesn't have a specific associated file, like data for a player class) will go into these.
|
|
|
+ //So we'll register them now if they exist.
|
|
|
+ if(isFile("./scripts/managedData/managedDatablocks." @ $TorqueScriptFileExtension))
|
|
|
+ %this.registerDatablock("./scripts/managedData/managedDatablocks");
|
|
|
+ if(isFile("./scripts/managedData/managedForestItemData." @ $TorqueScriptFileExtension))
|
|
|
+ %this.registerDatablock("./scripts/managedData/managedForestItemData");
|
|
|
+ if(isFile("./scripts/managedData/managedForestBrushData." @ $TorqueScriptFileExtension))
|
|
|
+ %this.registerDatablock("./scripts/managedData/managedForestBrushData");
|
|
|
+ if(isFile("./scripts/managedData/managedParticleEmitterData." @ $TorqueScriptFileExtension))
|
|
|
+ %this.registerDatablock("./scripts/managedData/managedParticleEmitterData");
|
|
|
+ if(isFile("./scripts/managedData/managedParticleData." @ $TorqueScriptFileExtension))
|
|
|
+ %this.registerDatablock("./scripts/managedData/managedParticleData");
|
|
|
+}
|
|
|
+
|
|
|
+//This is called when the server is shut down due to the game/map being exited
|
|
|
function ExampleModule::onDestroyGameServer(%this)
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-//Similar to initServer, this is called during the initial launch of the application and the client component
|
|
|
-//is set up. The difference is that the client may not actually be created, such as in the case for dedicated servers
|
|
|
-//Where no UI or gameplay interface is required. It's called from core/clientServer/scripts/client/client.tscript -
|
|
|
-//in the initClient() function. It sets up common elements that the client will always need, such as scripts, GUIs
|
|
|
-//and the like
|
|
|
+//This is called when the client is initially set up by the game application
|
|
|
function ExampleModule::initClient(%this)
|
|
|
{
|
|
|
- AssetDatabase.acquireAsset("ExampleModule:exampleDatablock");
|
|
|
- AssetDatabase.acquireAsset("ExampleModule:examplePostEffect");
|
|
|
- AssetDatabase.acquireAsset("ExampleModule:exampleGUI");
|
|
|
-
|
|
|
- //client scripts
|
|
|
- //Here, we exec out keybind scripts so the player is able to move when they get into a game
|
|
|
- %this.queueExec("./scripts/default.keybinds");
|
|
|
+ %this.queueExec("./scripts/client/inputCommands");
|
|
|
+
|
|
|
+ //client scripts
|
|
|
+ exec("./scripts/client/defaultkeybinds");
|
|
|
|
|
|
%prefPath = getPrefpath();
|
|
|
- if(isFile(%prefPath @ "/keybinds." @ $TorqueScriptFileExtension))
|
|
|
- exec(%prefPath @ "/keybinds." @ $TorqueScriptFileExtension);
|
|
|
-
|
|
|
- %this.queueExec("./scripts/inputCommands");
|
|
|
+ if(isScriptFile(%prefPath @ "/keybinds"))
|
|
|
+ exec(%prefPath @ "/keybinds");
|
|
|
}
|
|
|
|
|
|
-//This is called when a game session client successfuly connects to a game server.
|
|
|
-//It's called from core/clientServer/scripts/client/connectionToServer.tscript - in the GameConnection::onConnectionAccepted() function
|
|
|
-//It's used for any client-side specific game session stuff that the client needs to load or pass to the server, such as profile data
|
|
|
-//account progress, preferences, etc.
|
|
|
-//
|
|
|
-//When a client is connected, the gamemode logic also has a callback activated - ExampleGameMode::onClientEnterGame().
|
|
|
+//This is called when a client connects to a server
|
|
|
function ExampleModule::onCreateClientConnection(%this)
|
|
|
{
|
|
|
- //This will push our keybind movemap onto the input stack, so we can control our camera in our ExampleGameMode
|
|
|
- ExampleMoveMap.push();
|
|
|
+ ExampleMovemap.push();
|
|
|
}
|
|
|
|
|
|
-//This is called when a client game session disconnects from a game server
|
|
|
-//It's called from core/clientServer/scripts/client/connectionToServer.tscript - in the disconnectedCleanup() function
|
|
|
-//It's used to clean up and potentially write out any client-side stuff that needs housekeeping when disconnecting for any reason.
|
|
|
-//It will be called if the connection is manually terminated, or lost due to any sort of connection issue.
|
|
|
-//
|
|
|
-//When a client disconnects, the gamemode logic has a callback activated - ExampleGameMode::onClientLeaveGame().
|
|
|
+//This is called when a client disconnects from a server
|
|
|
function ExampleModule::onDestroyClientConnection(%this)
|
|
|
{
|
|
|
- //This will pop the keybind, cleaning it up from the input stack, as it no longer applies
|
|
|
- ExampleMoveMap.pop();
|
|
|
-}
|
|
|
-
|
|
|
-function ExampleModule::populateOptionsMenuCategories(%this)
|
|
|
-{
|
|
|
- addOptionsMenuCategory("Example Options", "testExampleOptions();");
|
|
|
}
|
|
|
-
|
|
|
-function testExampleOptions()
|
|
|
-{
|
|
|
- OptionsMenuSettingsList.clear();
|
|
|
-
|
|
|
- OptionName.setText("");
|
|
|
- OptionDescription.setText("");
|
|
|
-
|
|
|
- addListOption("Test Option", "This is a test option", $testOptionValue, "OptionA\tOptionB");
|
|
|
-}
|