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

0 Members and 1 Guest are viewing this topic.

JAZZ 0R KILLER

  • Jr. Member
  • **
  • Posts: 93
  • YT - Solo Crew
    • View Profile
    • YouTube
    • Awards
  • Xbox: JAZZ 0R KILLER
[WIP] 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

  • Jr. Member
  • **
  • Posts: 93
  • YT - Solo Crew
    • View Profile
    • YouTube
    • Awards
  • 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: 6645
  • Dig Deep
  • Awards Developer 5 years on site 4 years on site 3 years on site 2 years on site Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • 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

  • Jr. Member
  • **
  • Posts: 93
  • YT - Solo Crew
    • View Profile
    • YouTube
    • Awards
  • 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

  • Jr. Member
  • **
  • Posts: 93
  • YT - Solo Crew
    • View Profile
    • YouTube
    • Awards
  • 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!

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6645
  • Dig Deep
  • Awards Developer 5 years on site 4 years on site 3 years on site 2 years on site Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: C# (Need help)
« Reply #20 on: April 04, 2018, 08:35:37 PM »
Start the game via Steam, In Visual Studio, Debug -> Attach to Process, select the total miner process, turn on 'Break On Exception' or put a break point in the InitializeGame method, activate the mod in game and start a world, and use the debugger to find out what is wrong in the InitializeGame method.

JAZZ 0R KILLER

  • Jr. Member
  • **
  • Posts: 93
  • YT - Solo Crew
    • View Profile
    • YouTube
    • Awards
  • Xbox: JAZZ 0R KILLER
Re: C# (Need help)
« Reply #21 on: April 04, 2018, 09:55:31 PM »
Alright, I found out that my problem here is it's not locating  my sound file. Is there a certain location I should move that to?

Spoiler for Hidden Content:
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.TotalMiner.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.Engine.Net.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.Engine.Integration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.Engine.Services.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.Engine.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Xact\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Xact.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.Engine.Game.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.Engine.GUI.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.TotalMiner.API.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Game\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Game.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Graphics\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Graphics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.Engine.Renderers.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Xna.Framework.Input.Touch\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Input.Touch.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.BlockWorld.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Steam\steamapps\common\Total Miner\StudioForge.Engine.GamerServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Xna.Framework.GamerServices\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.GamerServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
The thread 0x1e0c has exited with code 0 (0x0).
The thread 0x1434 has exited with code 0 (0x0).
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Users\My.Name\Documents\My Games\TotalMinerBeta\Mods\SoundEffects\MyTestMod.dll'. Symbols loaded.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'Microsoft.GeneratedCode'.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'StudioForge.TotalMiner.exe' (CLR v4.0.30319: StudioForge.TotalMiner.exe): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PrivateAssemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[7080] StudioForge.TotalMiner.exe' has exited with code 1073807364 (0x40010004).

I honestly feel terrible for keeping you busy with this. I'm sure that you're busy with other things
« Last Edit: April 04, 2018, 10:16:27 PM by JAZZ 0R KILLER »
Look at you being all cool!

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6645
  • Dig Deep
  • Awards Developer 5 years on site 4 years on site 3 years on site 2 years on site Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: C# (Need help)
« Reply #22 on: April 04, 2018, 11:09:12 PM »
The sound file is stored in the mod folder, just like that Lockpick mod I linked you to. So when you build, copy both the DLL and the sound file into your mod folder.

JAZZ 0R KILLER

  • Jr. Member
  • **
  • Posts: 93
  • YT - Solo Crew
    • View Profile
    • YouTube
    • Awards
  • Xbox: JAZZ 0R KILLER
Re: C# (Need help)
« Reply #23 on: April 05, 2018, 10:28:14 AM »
Okay, I put the sound file into the mod folder, but I still get the same error.

*UPDATE* My apologies for taking your time. I found my small error and got it fixed, though the sound doesn't play. I'm sure I can find that error. Thanks for sticking around with me, it really means a lot!
Look at you being all cool!

JAZZ 0R KILLER

  • Jr. Member
  • **
  • Posts: 93
  • YT - Solo Crew
    • View Profile
    • YouTube
    • Awards
  • Xbox: JAZZ 0R KILLER
Re: C# (Need help)
« Reply #24 on: April 05, 2018, 10:51:41 AM »
I'm trying to set it to play the sound effect at the press of a key, I press the key, but no sound

*UPDATE* I have it set to notify me when the button is pressed. That all works, but it still doesn't play the sound. How do I execute the script (what is the script) to play the sound at the press of a key? As I said, when I press the assigned key, I get the notification, but no sound is played.
« Last Edit: April 06, 2018, 10:24:30 AM by JAZZ 0R KILLER »
Look at you being all cool!

Rorthic

  • Jr. Member
  • **
  • Posts: 12
    • View Profile
    • Awards
Re: C# (Edit)
« Reply #25 on: April 08, 2018, 01:08:46 AM »
Not sure if this has been answered yet but his works, I tested it. Without seeing your code we cant help much. But if you get the notification when you press the button but no sound it makes me think there is a problem with the sound file. 

Code: [Select]
if (InputManager.IsKeyPressed(tmPlayer.PlayerIndex, Keys.P))
{
     SoundEffect sound = game.AudioManager.LoadSoundEffectFromStream(FileSystem.RootPath + Mod.Path + "357_reload1.wav");
     sound.Play();
}

p.s. if you havent joined TM discord I would suggest it, these question usually get answered pretty quickly in the modding section. http://totalminerforums.net/index.php?topic=18450.0

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6645
  • Dig Deep
  • Awards Developer 5 years on site 4 years on site 3 years on site 2 years on site Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: C# (Edit)
« Reply #26 on: April 08, 2018, 02:47:54 AM »
Code: [Select]
if (InputManager.IsKeyPressed(tmPlayer.PlayerIndex, Keys.P))
{
     SoundEffect sound = game.AudioManager.LoadSoundEffectFromStream(FileSystem.RootPath + Mod.Path + "357_reload1.wav");
     sound.Play();
}
While this code works, it has some flaws.

It will be loading and playing the sound effect 60 times a second. That will likely be problematic. Better to use InputManager.IsKeyPressedNew or InputManager.IsKeyReleasedNew. This ensures the sound effect is only played once per key press.

Also it is inefficient to load a sound effect from disk every time you want to play it. It will likely cause frame rate stutters. It is better to cache all sound effects by loading them once when the mod is initiailized (see the LockPick example on github).

Also if you plan on using the sound effect rapidly, like say for machine gun fire, then it is better to use the SoundEffectInstance type over the SoundEffect type. It allows more control the playing of several instances of the sound effect better, even if the sound overlaps each other, and gives other control you don't have with SoundEffect.

JAZZ 0R KILLER

  • Jr. Member
  • **
  • Posts: 93
  • YT - Solo Crew
    • View Profile
    • YouTube
    • Awards
  • Xbox: JAZZ 0R KILLER
Re: C# (Edit)
« Reply #27 on: April 08, 2018, 09:13:20 AM »
"The name 'tmPlayer' does not exist in the current context"
Look at you being all cool!