Create a free account to remove all ad content.

Author Topic: [WIP] C# (Edit)  (Read 1542 times)

0 Members and 1 Guest are viewing this topic.

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Re: C# (Need help)
« Reply #10 on: April 03, 2018, 07:54:47 PM »
I'm going to create a Getting Started video for C# soon, probably later today. You might be best waiting for that.

JAZZ 0R KILLER

  • Member
  • *
  • Posts: 117
  • YT - Solo Crew
    • View Profile
    • YouTube
  • Xbox: JAZZ 0R KILLER
Re: C# (Need help)
« Reply #11 on: April 03, 2018, 07:55:23 PM »
Will do, I'll be looking for it
Look at you being all cool!

Rorthic

  • Jr. Member
  • *
  • Posts: 17
    • View Profile
Re: C# (Need help)
« Reply #12 on: April 03, 2018, 08:56:21 PM »
I typed this up a while ago as a reminder to myself on how to do a mod. I briefly read through it and I believe it is still correct.

Spoiler for Hidden Content:
1) Install XNA Game Studio in Visual Studio 2017 follow this tutorial: http://totalminerforums.net/index.php?topic=19324.0
2) Open Visual studio and create a new project for XNA Game Studio Windows Game Library(4.0) with your mod name for the name  ex: TM_ExampleMod.
3) In the Solution Explorer right click on References select add reference
4) Click Browse and navigate to your Total Miner steam Directory                             
  (C:\Program Files (x86)\Steam\steamapps\common\Total Miner)
5) Select all the .dll files and click add, or add 1 at a time, currently there are 7 in total: StudioForge.Engine.Core.dll, StudioForge.Engine.GUI.dll, StudioForge.Engine.Services.dll, StudioForge.Engine.Integration.dll, StudioForge.Engine.Game.dll, StudioForge.BlockWorld.dll, StudioForge.TotalMiner.API.dll
6) After adding them select the ones you need with check marks and click ok
7) Rename the default class1.cs file to the mod name TM_ExampleMod1.cs by right clicking on it and choosing rename.
8 ) Open the cs file for editing
9) At the top add
using StudioForge.TotalMiner.API;
using StudioForge.TotalMiner;
10) change the class name to match your mod name and make it extend ITMPlugin public class Class1 to
public class TM_ExampleMod1 : ITMPlugin
11)  Add the required interfaces to the class:                                                           
public void WorldSaved(int version){}
       public void PlayerJoined(ITMPlayer player){}
       public void PlayerLeft(ITMPlayer player){}
       public void Initialize(ITMPluginManager manager, string path){}
       public void InitializeGame(ITMGame game){}
       public bool HandleInput(ITMPlayer player){return false;}
       public void Update(ITMPlayer player){}
       public void Update(){}
       public void Draw(ITMPlayer player, ITMPlayer virtualPlayer){}
12)  In solution explorer right click on your mod name not the solution name and choose add new item
13)  find Code File C# highlight it and click add
14) Rename it to TMPluginProvider.cs  note: this is the required name
15)  open the file for editing with required code and implement required interfaces:             
using StudioForge.TotalMiner.API;

       namespace TM_ExampleMod
   {
       class TMPluginProvider : ITMPluginProvider
       {
            public ITMPlugin GetPlugin()
      {
         return new TM_ExampleMod1();
      }
           public ITMPluginBlocks GetPluginBlocks(){return null;}
           public ITMPluginArcade GetPluginArcade(){return null;}
          public ITMPluginGUI GetPluginGUI(){return null;}
       }
   }
note: namespace TM_ExampleMod is mod namespace name, return new TM_ExampleMod1() is constructor for mod name
16) Code your mod, build your solution, copy your modname.dll to the mod folder for TM in a folder of the mod name
   C:\Users\YourName\Documents\My Games\TotalMiner\Mods\ TM_ExampleMod1
17) Run Total Miner and test your mod.

Optional Settings

1) Right click on mod project file and choose properties
2) under XNA Game Studio select Use HiDef to access the complete API
3) go to Build Events and for Post-Build event command line: add     
   xcopy /Y /E /I "$(TargetPath)" "$(ProjectDir)\Install\"   
   xcopy /Y /E /I "$(ProjectDir)\Content" "$(ProjectDir)\Install"     
   xcopy /Y /E /I "$(ProjectDir)\Install" "$(HOMEDRIVE)$    (HOMEPATH)\Documents\MyGames\TotalMiner\Mods\$(ProjectName)"
   note: this copies the mod files to the mod directory automatically. make sure the path is correct.

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Re: C# (Need help)
« Reply #13 on: April 03, 2018, 11:29:18 PM »
Heres the first video

I'll post a 2nd video for Arcade Block Games later.

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Re: C# (Need help)
« Reply #14 on: April 04, 2018, 03:15:58 AM »
Arcade block

JAZZ 0R KILLER

  • Member
  • *
  • Posts: 117
  • YT - Solo Crew
    • View Profile
    • YouTube
  • Xbox: JAZZ 0R KILLER
Re: C# (Need help)
« Reply #15 on: April 04, 2018, 09:12:10 AM »
*Ignore*
« Last Edit: April 04, 2018, 02:52:28 PM by JAZZ 0R KILLER »
Look at you being all cool!

JAZZ 0R KILLER

  • Member
  • *
  • Posts: 117
  • YT - Solo Crew
    • View Profile
    • YouTube
  • Xbox: JAZZ 0R KILLER
Re: C# (Need help)
« Reply #16 on: April 04, 2018, 02:51:28 PM »
These videos have been extremely  helpful. I was following an outdated tutorial this whole time and didn't know it. I do have one more question, how would I add a sound effect?
Look at you being all cool!

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Re: C# (Need help)
« Reply #17 on: April 04, 2018, 06:16:42 PM »
I do have one more question, how would I add a sound effect?
This mod adds a sound effect.

JAZZ 0R KILLER

  • Member
  • *
  • Posts: 117
  • YT - Solo Crew
    • View Profile
    • YouTube
  • Xbox: JAZZ 0R KILLER
Re: C# (Need help)
« Reply #18 on: April 04, 2018, 06:30:46 PM »
Thanks!
Look at you being all cool!

JAZZ 0R KILLER

  • Member
  • *
  • Posts: 117
  • YT - Solo Crew
    • View Profile
    • YouTube
  • Xbox: JAZZ 0R KILLER
Re: C# (Need help)
« Reply #19 on: April 04, 2018, 07:14:47 PM »
When I go to load my mod, it says "Index was outside of the bounds of the array of InitializeGame"
Look at you being all cool!