# The Architecture How are files structured and named? General development guidelines. # Project Structure ## Directories ### *cache* As the name suggests this directory contains all the cache-data saved and used by EvoSC. This directory must not be populated with files by anyone other than EvoSC. There is one exception to that: If you want to tell EvoSC to restart through the filesystem, create a file called "restart\_evosc" inside the cache-directory. EvoSC looks for the existence of that file and reboots itself when found. This can be used for update scripts, or if you just dont want to join the server. A graceful shutdown is always better for the players online, than killing the process. ### *config* This directory contains all the configuration files that EvoSC uses. This is the one and only place a config should be changed by a user. A user must not change the files inside core (more specific the ones in the modules). The *default* sub-directory contains the default configs, which do not belong to any module. On controller start, all default configs from the modules and the default directory get copied to the config directory, if they are missing. All existing configs are compared to the defaults, so if a new value was added, it gets added to the json in *config.* Also when removing a key in the default, it will be deleted in the json in *config*. The filename is also the root id to call values. Example: To get the **log file prefix** from **server.config.json** you would call `config('server.log.prefix')` ### *core* Here's where the code resides, only devs should touch this directory.
ClassesSome classes to help out structure commonly used data and structures.
CommandsThis directory contains all callable CLI commands.
ControllersControllers are thought to be mandatory parts of EvoSC, that must run to make it work and provide informations for the modules.
DictionaryA base for the not yet used language support.
ExceptionsEvoSCs Exceptions.
InterfacesInterfaces.
ModelsEloquent database models more here: https://laravel.com/docs/7.x/eloquent#eloquent-model-conventions
ModulesModules that ship with EvoSC reside in this directory.
TemplateComponentsDifferent reusable templates and scripts to use for ManiaLink creation with latte-template-engine.
TestsTests.
**global-functions.php** contains methods that are available throughout the whole project at any time. ### *logs* Logging files are created here. ### *Migrations* EvoSC uses incremental database creation through migrations. Migrations created with the CLI command are created in this directory and may be copied to your module from there, if you want to create a thrird-party module. ### *modules* Put third-party modules (which are not part of EvoSC) into this directory. ### *vendor* All the php libraries installed by composer. # Events/Hooks The server communicates with the controller through callbacks/events. Some of the more important events are preprocessed by EvoSC to make them easier to use. All those events called "Hooks" will be listed below. ### Registering a Hook To bind a method to an EvoSC-Hook or TM-Event, you simply call ```PHP Hook::add('NameOfHookOrEvent', [FullyQualifiedClassName, 'methodName'); ``` inside the start method of the module. You can always create a hook for the methods listed in [https://github.com/maniaplanet/script-xmlrpc/blob/master/XmlRpcListing.md#callbacks](https://github.com/maniaplanet/script-xmlrpc/blob/master/XmlRpcListing.md#callbacks) ### Hooks
**Name****Passed arguments****Description**
PlayerConnect**Player** $playerCalled when a player spawns in the server
PlayerDisconnect**Player** $playerCalled when a player leaves the server
PlayerFinish**Player** $player, **int** $timeInMilliseconds, **string** $checkpointsCommaSeparatedCalled when a player finishes or resets, then the time is 0
PlayerCheckpoint**Player** $player, **int** $timeInMilliseconds, **int** $checkpointNumber, **bool** $isFinishCalled when a player passes a checkpoint
PlayerStartCountdown**Player** $playerCalled when the 3-2-1-countdown starts for a player
PlayerPb**Player** $player, **int** $timeInMillisecondsCalled when player drives a new personal best
BeginMatch-Called when the countdown/match starts
EndMatch-Called when the match ended
BeginMap**Map** $mapCalled when a map starts and when EvoSC boots
EndMap**Map** $mapCalled when a map ends
MatchSettingsLoaded**string** $matchSettingsFileCalled when a match-settings is loaded
AddedTimeChanged**int** $addedSecondsCalled when the timelimit was in/decreased
MapPoolUpdated-Called when the maplist changed
MatchTrackerUpdated**Collection** $scoresCalled when scores affecting the match changed (player finished with better time, got points, etc...)
MapQueueUpdated**Collection** $mapsInQueueCalled when a map was added/removed to/from the jukebox
WarmUpStart-Called when the warmup phase starts
WarmUpEnd-Called when the warmup phase ends
AnnounceWinner**Player** $winnerCalled on match end, when the winner is decided
ShowScores**Collection** $allPlayersThatParticipatedInMatchCalled when ther end result is displayed after the match ended
GroupChanged**Player** $playerCalled when the group of a player was changed