Difference between revisions of "User:FallenAvatar/Code Based Mod"
FallenAvatar (Talk | contribs) m (fixing image) |
FallenAvatar (Talk | contribs) m |
||
Line 10: | Line 10: | ||
To create a new Code Based Mod: | To create a new Code Based Mod: | ||
+ | [[File:code-based-mod_new-project.png|thumb|x150px|Your New Project dialog may not look exactly like this.]] | ||
* '''Open''' Visual Studio | * '''Open''' Visual Studio | ||
* '''Create''' a New Project (File > New > Project) | * '''Create''' a New Project (File > New > Project) | ||
Line 18: | Line 19: | ||
* Pick where you want your mod saved | * Pick where you want your mod saved | ||
* Click '''Ok''' | * Click '''Ok''' | ||
− | |||
− | |||
− | |||
== Setting Up The Project == | == Setting Up The Project == | ||
− | Now the project needs to be setup to recognize Staxel's code and | + | Now the project needs to be setup to recognize Staxel's code and build itself correctly for debugging. |
− | * '''Add a Reference | + | [[File:code-based-mod_add-reference.png|thumb|x150px|Add References]] |
+ | * '''Add a Reference''' by Right-Clicking the Project and selecting Add > Reference | ||
+ | ** Click Browse at the bottom right and navigate to where Staxel is installed, and open the bin folder. | ||
+ | *** For Staxel on Steam on Windows, this is likely "C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin" | ||
+ | ** Hold Ctrl (Control) and select: | ||
+ | *** Plukit.Base.dll | ||
+ | *** Staxel.dll | ||
+ | ** Click Add | ||
+ | ** Click Ok | ||
− | + | ''The project is now able to be built and loaded as a Mod, of course it doesn't do much at the moment'' | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | * Add a new Text File and name it StaxelMod.mod | ||
+ | ** Replace StaxelMod with what you named your project | ||
+ | ** Simply add "{}" without the quotation marks to the file and save it. | ||
+ | *** This file is a config file. However nothing is supported in it yet. In the future, this ''might'' change. | ||
+ | * Rename the Class1 class to Mod and allow Visual Studio to rename all references to it. | ||
+ | * Open Mod.cs and replace its content with: | ||
<pre> | <pre> | ||
− | |||
using Plukit.Base; | using Plukit.Base; | ||
using Staxel.Items; | using Staxel.Items; | ||
Line 53: | Line 46: | ||
using Staxel.Tiles; | using Staxel.Tiles; | ||
− | namespace | + | namespace StaxelMod { |
− | { | + | public class Mod : Staxel.Modding.IModHookV2 { |
− | + | #region Loading | |
− | + | public void GameContextInitializeInit() {} | |
− | + | public void ClientContextInitializeInit() {} | |
− | + | public void ClientContextInitializeBefore() {} | |
+ | public void GameContextInitializeBefore() {} | ||
+ | public void GameContextInitializeAfter() {} | ||
+ | public void ClientContextInitializeAfter() {} | ||
+ | #endregion | ||
− | + | #region Running | |
− | + | #region Every From | |
− | + | public void UniverseUpdateAfter() {} | |
+ | public void UniverseUpdateBefore( Universe universe, Timestep step ) {} | ||
+ | #endregion | ||
− | + | public bool CanPlaceTile( Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags ) { | |
− | + | return true; | |
− | + | } | |
− | + | public bool CanRemoveTile( Entity entity, Vector3I location, TileAccessFlags accessFlags ) { | |
− | + | return true; | |
− | + | } | |
− | + | public bool CanReplaceTile( Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags ) { | |
− | + | return true; | |
− | + | } | |
+ | #endregion | ||
− | + | #region Closing | |
− | + | public void CleanupOldSession() { } | |
− | + | public void GameContextDeinitialize() { } | |
+ | public void ClientContextDeinitialize() { } | ||
+ | public void Dispose() { } | ||
+ | #endregion | ||
− | + | #region Reloading | |
− | + | public void ClientContextReloadBefore() { } | |
− | + | public void GameContextReloadBefore() { } | |
+ | public void GameContextReloadAfter() { } | ||
+ | public void ClientContextReloadAfter() { } | ||
+ | #endregion | ||
+ | } | ||
+ | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
− | + | ** Again, replace "StaxelMod" as necessary. | |
− | + | ** '' '''Note''': Currently ClientContextDeinitialize is called during initialization intead of ClientContextInitializeInit | |
− | + | * | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | ''' | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
= Interface Documentation = | = Interface Documentation = |
Revision as of 20:51, 2 February 2018
[[Category:Modding]] Staxel also supports adding in your own code which can attach itself to interfaces within Staxel's code. This attachment is fairly rudimentary, and isn't tested as much as the other features. However, if you've ever wanted to add new features to Staxel, this is the way to do it.
Creating The Project
This page assumes that you are running Visual Studio 2017. If you run other versions of Visual Studio, locations of things may have changed. Other IDE's will definitely have different methods for some actions.
You should not need any external dependencies to develop Mods for Staxel. However, complex changes to the game may need XNA. In that case you can find what you need here: MXA
To create a new Code Based Mod:
- Open Visual Studio
- Create a New Project (File > New > Project)
- Select a Class Library (Installed > Visual C# > Windows Classic Desktop > Class Library (.NET Framework))
- Note You should be able to use your .Net Language of choice, but all sample code is in C#.
- You may name it how you like, and use the newest version of the framework.
- Tested with up to 4.7.1
- Pick where you want your mod saved
- Click Ok
Setting Up The Project
Now the project needs to be setup to recognize Staxel's code and build itself correctly for debugging.
- Add a Reference by Right-Clicking the Project and selecting Add > Reference
- Click Browse at the bottom right and navigate to where Staxel is installed, and open the bin folder.
- For Staxel on Steam on Windows, this is likely "C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin"
- Hold Ctrl (Control) and select:
- Plukit.Base.dll
- Staxel.dll
- Click Add
- Click Ok
- Click Browse at the bottom right and navigate to where Staxel is installed, and open the bin folder.
The project is now able to be built and loaded as a Mod, of course it doesn't do much at the moment
- Add a new Text File and name it StaxelMod.mod
- Replace StaxelMod with what you named your project
- Simply add "{}" without the quotation marks to the file and save it.
- This file is a config file. However nothing is supported in it yet. In the future, this might change.
- Rename the Class1 class to Mod and allow Visual Studio to rename all references to it.
- Open Mod.cs and replace its content with:
using Plukit.Base; using Staxel.Items; using Staxel.Logic; using Staxel.Tiles; namespace StaxelMod { public class Mod : Staxel.Modding.IModHookV2 { #region Loading public void GameContextInitializeInit() {} public void ClientContextInitializeInit() {} public void ClientContextInitializeBefore() {} public void GameContextInitializeBefore() {} public void GameContextInitializeAfter() {} public void ClientContextInitializeAfter() {} #endregion #region Running #region Every From public void UniverseUpdateAfter() {} public void UniverseUpdateBefore( Universe universe, Timestep step ) {} #endregion public bool CanPlaceTile( Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags ) { return true; } public bool CanRemoveTile( Entity entity, Vector3I location, TileAccessFlags accessFlags ) { return true; } public bool CanReplaceTile( Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags ) { return true; } #endregion #region Closing public void CleanupOldSession() { } public void GameContextDeinitialize() { } public void ClientContextDeinitialize() { } public void Dispose() { } #endregion #region Reloading public void ClientContextReloadBefore() { } public void GameContextReloadBefore() { } public void GameContextReloadAfter() { } public void ClientContextReloadAfter() { } #endregion } }
- Again, replace "StaxelMod" as necessary.
- Note: Currently ClientContextDeinitialize is called during initialization intead of ClientContextInitializeInit
Interface Documentation
- IAchievementComponentBuilder
- IBiomeBuilder
- ICommandBuilder
- IComponentBuilder
- IEffectBuilder
- IEntityAction
- IEntityLogicBuilder
- IEntityPainterBuilder
- IFarmAnimalEntityBehaviourBuilder
- IItemBuilder
- IItemComponentBuilder
- IModHookV2
- INotificationBuilder
- IPlayerExtendedCommand
- IScript
- ISubProcessHandler
- ITileComponentBuilder
- ITileConfigurationBuilder
- ITileStateBuilder
- ITileStateBuilder
- IVillagerEntityCommand
- IVillagerEntityInstinct
- IWeatherComponentBuilder