Code Based Mod
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 ever wanted to add new features to Staxel, this is the way to do it.
Setting Up For Staxel
Before starting be sure to install XNA for your IDE. For Visual Studio 2015, you can head to https://mxa.codeplex.com/releases to download a compatible version.
The rest of this page, assumes your running Visual Studio 2015, 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.
To set up Visual Studio, first create a new solution. Name this solution whatever you want, and select "Class Library". This sets it so that it builds in a manner that Staxel will be able to access. After this, let it create the solution.
After this file is set up, it's time to add references to Staxels .dll's. Right-Click on the project (Not the solution) in the Solution explorer then go to "Add" and then "Reference..."
When the window opens, click on browse at the bottom of the window, then navigate to where Staxel stores its files. When there, head to the "bin" folder and select both "Staxel.dll" and "Plukit.Base.dll" as both of these are needed for the code below. Other dll's may be needed at a later time.
You are now setup for creating a mod.
Contents of a mod
For the most part, contents of code is left up to the user. Yet there is a need to implement interfaces for Staxel to run your program's code.
A good starting place would be to implement this interface made for modding;
using System; using Plukit.Base; using Staxel.Logic; using Staxel.Tiles; namespace ClassLibrary1 { public class Class1 : Staxel.Modding.IModHook { public bool CanPlaceTile(Entity entity, Vector3I location, Tile tile, bool preview) { throw new NotImplementedException(); } public bool CanRemoveTile(Entity entity, Vector3I location, bool preview) { throw new NotImplementedException(); } public bool CanReplaceTile(Entity entity, Vector3I location, Tile tile, bool preview) { throw new NotImplementedException(); } public void Dispose() { throw new NotImplementedException(); } public void GameContextDeinitialize() { throw new NotImplementedException(); } public void GameContextInitializeAfter() { throw new NotImplementedException(); } public void GameContextInitializeBefore() { throw new NotImplementedException(); } public void GameContextInitializeInit() { throw new NotImplementedException(); } public void GameContextReloadAfter() { throw new NotImplementedException(); } public void GameContextReloadBefore() { throw new NotImplementedException(); } public void UniverseUpdateAfter() { throw new NotImplementedException(); } public void UniverseUpdateBefore(Universe universe, Timestep step) { throw new NotImplementedException(); } } }
You can look around for other types of interfaces within Staxel's code/dll and as an added bonus, Visual Studio will offer to help you implement these interfaces when you find them, with the appropriate methods and "usings".
A list of some of these Interfaces you can implement are:
IAchievementComponentBuilder, IBiomeBuilder, ICommandBuilder, IComponentBuilder, IEffectBuilder, IEntityAction, IEntityLogicBuilder, IEntityPainterBuilder, IFarmAnimalEntityBehaviourBuilder, IItemBuilder, IItemComponentBuilder, IModHook, INotificationBuilder, IPlayerExtendedCommand, IScript, ISubProcessHandler, ITileComponentBuilder, ITileConfigurationBuilder, ITileStateBuilder ITileStateBuilder, IVillagerEntityCommand, IVillagerEntityInstinct, IWeatherComponentBuilder
Past this point it's up to you to look around and find out what you can. One recommendation is to find out how to decompile Staxel.dll, as it is not obfuscated, and have a look at the actual code.
Be aware: Exceptions will cause the game to crash, try to avoid leaving NotImplementExceptions in unused methods.
Loading A Mod Into Staxel
After you have written your code, be sure to build your file. You can then navigate to your solutions bin folder. In that folder, will be a bunch of files, select the ones you have made and then copy and paste them into the bin folder in Staxel's directory. (That is, copy and paste those files into "pathToStaxel/bin")
Once this copy is done, make a new text file and name it the same as you .dll file except replace .dll with .mod. Then inside of this .mod file, simply add {} and save. Eventually this may include more information but for now it is empty.
If all goes well, your mod will now be loaded into Staxel. Have fun coding!