These docs are out-of-date
- Visual Studio 2017
- Git
- Unity Editor
- Make a directory for your plugin
- Initialize git in the directory using
git init
- Add the Distance Standalone Server as a git submodule using
git submodule add https://github.com/Corecii/Distance-Server DistanceServerStandalone
- Initialize the submodule using
git submodule update --init --recursive
- Add a patched
Distance.dll
to the Distance Standalone Server directory - In Visual Studio, create a new solution in your plugin directory
- Add
Assembly-CSharp.csproj
,Assembly-CSharp-firstpass.csproj
, andDistanceServer.csproj
to your solution - If you plan on using any plugins, add their projects to your solution
- In your solution, add a C# Class Library
.NET Framework 4.6.1
project - Add references to the other added projects
- Add a reference to
Distance.dll
, and give it theDistance
alias instead ofglobal
. If you need to access it in a file, you must addextern alias Distance;
to the top of the file. - Add a post-build event to copy the plugin files to the server directory:
xcopy "$(TargetDir)$(TargetName).*" "$(SolutionDir)DistanceServerStandalone/DistanceServer/Plugins" /Y
- Write your plugin. Building it should copy the dll files to the test server's plugin directory, which you can run in the Unity Editor to test your plugin.
A git submodule is used so that the exact version of DistanceServerStandalone is tracked and easy for other contributors to grab. This makes it easy for others to work on your project and easy for you to come back to. This also makes upgrading easy: pull the new version of DistanceServerStandlone, then update all of your code for the new version.
- Open the server solution
- Do steps 9 through 13 above. Use
xcopy "$(TargetDir)$(TargetName).*" "$(SolutionDir)Plugins" /Y
instead.
You don't need git or Unity Editor, and you can probably do without Visual Studio or use a different version.
Download DistanceServerStandalone, and reference the projects as you normally would. Modify the xcopy command to copy to the correct directory.
Download the compiled server and plugin dlls, and generate a patched Distance.dll
. Reference the dlls directly instead of the projects.
Download the server, and set xcopy to copy to the server's plugins directory. Launch the server, and read its log file for debugging.
Copy manually, or use a different copying executable.
Add references to the required DLLs, as in "Without downloading the project". Copy your compiled dlls to the server's plugins directory.
The distance server first loads all plugin dlls, then sorts them by their Priority
and loads them.
The distance server will find all classes in the plugin which are subclasses of DistanceServerPlugin
, are not abstract, and have an empty constructor. It makes one of each it finds and calls Start
on each.
Since the distance server can load multiple entry points per plugin, you can specify multiple entry points with different priorities so that your plugin can load before and after other plugins, if needed.
The distance server provides a T GetPlugin<T>()
method, which returns the loaded instance of the given plugin type T
. Add a reference to the other plugin type, and use GetPlugin<T>
to get its plugin instance. Alternatively, just add a reference to the other plugin dll and use its static methods. Since the distance server loads all plugins before calling any plugin code, you should always get the already-loaded plugin.
The BasicAutoServer plugin provides methods to customize server behavior, filter levels, and set a custom playlist. The WorkshopSearch plugin provides methods to search the workshop by parsing the user-facing workshop pages.
Plugins must indicate the server version that they are compatible with. This is used to warn the user of incompatible plugins, or indicate forks that may have different features at different versions.
Until version 1.x.x, all minor version may contain breaking changes. See the readme for more information.