Author Topic: Modding Difficulties  (Read 4370 times)

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Modding Difficulties
« on: March 01, 2017, 09:41:13 pm »
I am trying to do a test of the modding capabilities of AI War 2 on my linux box to try to make it easier to get more Science. I note there's already a "Debug Give Science", which is what I'm looking for, but for some unknown reason it's not showing up in the in-game UI. 

That aside, when I try to build the AIWarExternalCode.csproj project, I get some errors. I tried xbuild and monodevelop and get the same error in this snippet of code. Here is the output from xbuild:

Errors:

/home/steam/AIWar2/AIWarExternalCode/AIWarExternalCode.csproj (default targets) ->
/usr/lib/mono/xbuild/14.0/bin/Microsoft.CSharp.targets (CoreCompile target) ->

   src/UIs/Window_InGameNonUnitActionMenu.cs(117,28): error CS1110: `Arcen.AIW2.External.NonUnitActionMenuModeExtensionMethods.GetIsAllowed(this Arcen.AIW2.External.NonUnitActionMenuMode)': Extension methods require `System.Runtime.CompilerServices.ExtensionAttribute' type to be available. Are you missing an assembly reference?
   src/UIs/Window_InGamePlanetActionMenu.cs(173,28): error CS1110: `Arcen.AIW2.External.PlanetActionMenuModeExtensionMethods.GetIsAllowedFor(this Arcen.AIW2.External.PlanetActionMenuMode, Arcen.AIW2.Core.Planet)': Extension methods require `System.Runtime.CompilerServices.ExtensionAttribute' type to be available. Are you missing an assembly reference?
   src/UIs/Window_InGameUnitActionMenu.cs(223,28): error CS1110: `Arcen.AIW2.External.UnitActionMenuModeExtensionMethods.GetIsAllowedFor(this Arcen.AIW2.External.UnitActionMenuMode, Arcen.AIW2.Core.GameEntity)': Extension methods require `System.Runtime.CompilerServices.ExtensionAttribute' type to be available. Are you missing an assembly reference?


    public static class NonUnitActionMenuModeExtensionMethods
    {
        public static bool GetIsAllowed( this NonUnitActionMenuMode Item ) <==== This seems to be one of the troublesome lines
        {
            switch ( Item )
            {
                case NonUnitActionMenuMode.Tech:
                    return true;
                case NonUnitActionMenuMode.DebugTracing:
                    return true;
                default:
                    return false;
            }
        }
    }

I am running mono 4.4.2

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: Modding Difficulties
« Reply #1 on: March 01, 2017, 09:52:36 pm »
I found a workaround to this; posting here if anyone else needs it. I created the following  file:

 [user@hostname UIs]$ pwd
~/AIWar2/AIWarExternalCode/src/UIs
[
user@hostname UIs]$ cat ExtenstionAttribute.cs
 namespace System.Runtime.CompilerServices
 {
   public class ExtensionAttribute : Attribute { }
 }

And now it compiles happily, and I'm pleased to inform you that rewiring the "Give Metal" button to "Give Science" works.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Modding Difficulties
« Reply #2 on: March 01, 2017, 10:07:00 pm »
Wonderful! Thanks for testing, and for reporting how it went :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: Modding Difficulties
« Reply #3 on: March 01, 2017, 10:07:40 pm »
If you're here, why doesn't the "Give Science" button appear? The code all seems to be there.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Modding Difficulties
« Reply #4 on: March 01, 2017, 10:11:02 pm »
As shipped, it's commented out in the xml.

     <!--
     <element type="Button" x="0.0" y="48.0" width="10" height="6" type_name="bGiveScience" />
     -->
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: Modding Difficulties
« Reply #5 on: March 01, 2017, 10:17:43 pm »
Ah, wonderful. Okay, I can now enable the Give Science button. I also added a new Turretry class called FancyTurretry (Basic is sooo boring) by creating a new FancyTurretry.cs, editing it a bit, then adding a reference to it in the appropriate xml file.

I report that modding a couple things works, and should be well within the skillset of a decent programmer (even one who doesn't know C#).

Kudos to Keith for having it work first try!

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: Modding Difficulties
« Reply #6 on: March 01, 2017, 11:05:45 pm »
I'm a bit curious if there's a way to put music into the game that wouldn't require an asset bundle. I'm imagining editing
CMP_MusicDefinitions.xml to include mp3 files directly

  <music name="RickrollTitleMusic" type="TitleScreen" filename="~/NeverGonnaGiveYouUp.mp3" />

I figure the answer is "No", right?

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Modding Difficulties
« Reply #7 on: March 02, 2017, 09:57:04 am »
We had to change music pipelines very last-minute before alpha, so exactly how those can be modded is still up in the air.

So for now: No :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!