Skip to content

Commit

Permalink
Minor Fixes to Resources Mod
Browse files Browse the repository at this point in the history
- Adds download URL to Melon assembly info
- Removes magic numbers
  • Loading branch information
data-bomb committed Jul 14, 2024
1 parent e4002a9 commit af76486
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Si_Resources/Si_Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,22 @@ You should have received a copy of the GNU General Public License
using System;
using System.Linq;

[assembly: MelonInfo(typeof(ResourceConfig), "Resource Configuration", "1.2.0", "databomb")]
[assembly: MelonInfo(typeof(ResourceConfig), "Resource Configuration", "1.2.1", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]
[assembly: MelonOptionalDependencies("Admin Mod")]

namespace Si_Resources
{
public class ResourceConfig : MelonMod
{
const int defaultStartingResources = 8000;

enum EResource
{
Balterium = 0,
Biotics = 1
}

static MelonPreferences_Category _modCategory = null!;
static MelonPreferences_Entry<int> Pref_Resources_Centauri_StartingAmount = null!;
static MelonPreferences_Entry<int> Pref_Resources_Sol_StartingAmount = null!;
Expand All @@ -50,9 +58,9 @@ public class ResourceConfig : MelonMod
public override void OnInitializeMelon()
{
_modCategory ??= MelonPreferences.CreateCategory("Silica");
Pref_Resources_Centauri_StartingAmount ??= _modCategory.CreateEntry<int>("Resources_Centauri_StartingAmount", 8000);
Pref_Resources_Sol_StartingAmount ??= _modCategory.CreateEntry<int>("Resources_Sol_StartingAmount", 8000);
Pref_Resources_Aliens_StartingAmount ??= _modCategory.CreateEntry<int>("Resources_Aliens_StartingAmount", 8000);
Pref_Resources_Centauri_StartingAmount ??= _modCategory.CreateEntry<int>("Resources_Centauri_StartingAmount", defaultStartingResources);
Pref_Resources_Sol_StartingAmount ??= _modCategory.CreateEntry<int>("Resources_Sol_StartingAmount", defaultStartingResources);
Pref_Resources_Aliens_StartingAmount ??= _modCategory.CreateEntry<int>("Resources_Aliens_StartingAmount", defaultStartingResources);
Pref_Resources_Aliens_RevealClosestArea ??= _modCategory.CreateEntry<bool>("Resources_Aliens_RevealClosestAreaOnStart", false);
Pref_Resources_Humans_RevealClosestArea ??= _modCategory.CreateEntry<bool>("Resources_Humans_RevealClosestAreaOnStart", true);
}
Expand Down Expand Up @@ -280,15 +288,15 @@ static UnityEngine.Vector3 GetTeamStartingPosition(Team team)
case (int)SiConstants.ETeam.Alien:
// "Biotics"
#if NET6_0
return Resource.Resources[1];
return Resource.Resources[(int)EResource.Biotics];
#else
return Resource.Resources.Find(r => r.ResourceName.StartsWith("Bi"));
#endif
case (int)SiConstants.ETeam.Sol:
case (int)SiConstants.ETeam.Centauri:
// "Balterium"
#if NET6_0
return Resource.Resources[0];
return Resource.Resources[(int)EResource.Balterium];
#else
return Resource.Resources.Find(r => r.ResourceName.StartsWith("Ba"));
#endif
Expand All @@ -310,7 +318,7 @@ static int GetTeamStartingResources(Team team)
return Pref_Resources_Sol_StartingAmount.Value;
default:
MelonLogger.Warning("Could not determine starting resources for team: " + team.TeamShortName);
return 8000;
return defaultStartingResources;
}
}
}
Expand Down

0 comments on commit af76486

Please sign in to comment.