Modding:Modding Efficiently: Difference between revisions

From Vintage Story Wiki
Line 24: Line 24:
* Browse through the many utility classes provided by the VS API, you might be able to save a lot of coding efforts! (e.g. [https://github.com/anegostudios/vsapi/blob/master/Math/ColorUtil.cs ColorUtil], [https://github.com/anegostudios/vsapi/blob/master/Math/GameMath.cs GameMath], [https://github.com/anegostudios/vsapi/blob/master/Util/ArrayExtensions.cs ArrayExtensions], [https://github.com/anegostudios/vsapi/blob/master/Util/DictExtensions.cs DictExtensions], [https://github.com/anegostudios/vsapi/blob/master/Util/HashsetExtensions.cs HashsetExtensions], [https://github.com/anegostudios/vsapi/blob/master/Util/JsonUtil.cs JsonUtil], [https://github.com/anegostudios/vsapi/blob/master/Util/JsonUtil.cs ReaderWriterExtensions], [https://github.com/anegostudios/vsapi/blob/master/Util/SerializerUtil.cs SerializerUtil], [https://github.com/anegostudios/vsapi/blob/master/Util/WildcardUtil.cs WildcardUtil]
* Browse through the many utility classes provided by the VS API, you might be able to save a lot of coding efforts! (e.g. [https://github.com/anegostudios/vsapi/blob/master/Math/ColorUtil.cs ColorUtil], [https://github.com/anegostudios/vsapi/blob/master/Math/GameMath.cs GameMath], [https://github.com/anegostudios/vsapi/blob/master/Util/ArrayExtensions.cs ArrayExtensions], [https://github.com/anegostudios/vsapi/blob/master/Util/DictExtensions.cs DictExtensions], [https://github.com/anegostudios/vsapi/blob/master/Util/HashsetExtensions.cs HashsetExtensions], [https://github.com/anegostudios/vsapi/blob/master/Util/JsonUtil.cs JsonUtil], [https://github.com/anegostudios/vsapi/blob/master/Util/JsonUtil.cs ReaderWriterExtensions], [https://github.com/anegostudios/vsapi/blob/master/Util/SerializerUtil.cs SerializerUtil], [https://github.com/anegostudios/vsapi/blob/master/Util/WildcardUtil.cs WildcardUtil]
* If you don't know it already, the [https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/ LINQ] extension, part of the .net framework, is an extremely powerful tool to make code more expressive.
* If you don't know it already, the [https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/ LINQ] extension, part of the .net framework, is an extremely powerful tool to make code more expressive.
* You can use edit&continue feature of Visual Studio to modify code while the game is running, to see your changes immediately without restarting the world.
* Use the [https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/ Hot reload] feature of Visual Studio to modify code while the game is running, to see your changes immediately without restarting the world.
** Note that this feature works if you use the [[Modding:Setting_up_your_Development_Environment|official mod template]] and set up your mod as a "compiled" mod. It does not work if you set up your mod as a "source" mod, and it may not work with all other development environment setups.
** Note that this feature works if you use the [[Modding:Setting_up_your_Development_Environment|official mod template]] and set up your mod as a "compiled" mod. It does not work if you set up your mod as a "source" mod, and it may not work with all other development environment setups.
* If you don't have already make sure the games log output ends up in the Visual Studio output window
* If you don't have already make sure the games log output ends up in the Visual Studio output window
* If you are working with shaders, you can reload them with <code>.reload shaders</code>
* If you are working with shaders, you can reload them with <code>.reload shaders</code>
* Do not hold static references unless its primitive data. Static references are not garbage collected when the player leaves a server / game world. Example: Holding a static reference of a <code>Block</code> will keep that block in memory, which in turn keeps the API Instance in memory, which in turn keeps the entire game world in memory.
* Do not hold static references unless its primitive data. Static references are not garbage collected when the player leaves a server / game world. Example: Holding a static reference of a <code>Block</code> will keep that block in memory, which in turn keeps the API Instance in memory, which in turn keeps the entire game world in memory.
* Use the [https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/ Hot reload] feature of Visual Studio to edit your game code without restarting.


=== Efficient Search Methods ===
=== Efficient Search Methods ===
Confirmedusers, Bureaucrats, editor, Administrators
1,779

edits