Skip to content

Commit

Permalink
Added some settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Epicguru committed May 30, 2020
1 parent 3769234 commit f21d251
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Languages/English/Keyed/Keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<AA.Days>days</AA.Days>
<AA.Quadrums>quadrums</AA.Quadrums>

<!-- Settings -->
<AA.PowerGenMulti>Power generation multiplier: {0}%</AA.PowerGenMulti>
<AA.FuelConsumeRate>Fuel consumption multiplier: {0}%</AA.FuelConsumeRate>
<AA.EnableEasterEggs>Enable easter eggs:</AA.EnableEasterEggs>

<!-- PowerNet Console -->
<AA.OpenConsole>Open console</AA.OpenConsole>
<AA.OpenConsoleDesc>Shows detailed information about the connected power network, and allows you to turn power on and off.</AA.OpenConsoleDesc>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
<Compile Include="Patches\Patch_BatteryComp_SetStoredEnergyPct.cs" />
<Compile Include="Patches\Patch_BatteryComp_GetStoredEnergyPct.cs" />
<Compile Include="Patches\Patch_CompExplosive.cs" />
<Compile Include="Settings.cs" />
<Compile Include="ThingComps\CompGreedyBattery.cs" />
<Compile Include="ThingComps\CompAutoAttack.cs" />
<Compile Include="ThingComps\CompProperties_GreedyBattery.cs" />
Expand Down
3 changes: 3 additions & 0 deletions Source/AntimatterAnnihilation/Buildings/Building_Megumin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ private void StopFireLaser()

private void DoEasterEgg()
{
if (!Settings.EnableEasterEggs)
return;

// It's a trash anime btw. Genuine waste of time.
// You're better off watching JoJo or Cowboy Bebob or KillLaKill.
AADefOf.Explosion_Voice_AA.PlayOneShotOnCamera();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,49 @@ public float FuelBurnRate
{
get
{
float b;
switch (PowerMode)
{
case 0:
return 1.5f;
b = 1.5f;
break;
case 1:
return 2f;
b = 2f;
break;
case 2:
return 4f;
b = 4f;
break;
default:
return 1.5f;
b = 1.5f;
break;
}

return b * Settings.FuelConsumeRate;
}
}

public float PowerOutputMultiplier
{
get
{
float b;
switch (PowerMode)
{
case 0:
return 1f; // 30 KW, 1.5 fuel per day.
b = 1f; // 30 KW, 1.5 fuel per day.
break;
case 1:
return 1.5f; // 45 KW, 2 fuel per day (more efficient, but uses all the fuel 1 accelerator produces so no extra).
b = 1.5f; // 45 KW, 2 fuel per day (more efficient, but uses all the fuel 1 accelerator produces so no extra).
break;
case 2:
return 4f; // 120 KW, 4 fuel per day (the most efficient, but requires at least 2 accelerators).
b = 4f; // 120 KW, 4 fuel per day (the most efficient, but requires at least 2 accelerators).
break;
default:
return 1f;
b = 1f;
break;
}

return b * Settings.PowerGenMulti;
}
}

Expand Down
12 changes: 12 additions & 0 deletions Source/AntimatterAnnihilation/ModCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public ModCore(ModContentPack content) : base(content)

PatchAll();
Log($"Patched {HarmonyInstance.GetPatchedMethods().Count()} methods.");

GetSettings<Settings>(); // Required.
}

private void AddHook()
Expand Down Expand Up @@ -50,5 +52,15 @@ public static void Trace(string msg)
{
Verse.Log.Message(msg ?? "<null>");
}

public override string SettingsCategory()
{
return "Antimatter Annihilation";
}

public override void DoSettingsWindowContents(Rect inRect)
{
Settings.DoWindow(inRect);
}
}
}
46 changes: 46 additions & 0 deletions Source/AntimatterAnnihilation/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using UnityEngine;
using Verse;

namespace AntimatterAnnihilation
{
public class Settings : ModSettings
{
public static float PowerGenMulti = 1f;
public static float FuelConsumeRate = 1f;
public static bool EnableEasterEggs = true;

public override void ExposeData()
{
Scribe_Values.Look(ref PowerGenMulti, "PowerGenMulti", 1f);
Scribe_Values.Look(ref FuelConsumeRate, "FuelConsumeRate", 1f);
Scribe_Values.Look(ref EnableEasterEggs, "EnableEasterEggs", true);
}

public static void DoWindow(Rect window)
{
DoLabel("AA.PowerGenMulti".Translate($"{PowerGenMulti*100f:F0}"));
PowerGenMulti = Widgets.HorizontalSlider(new Rect(window.x, window.y, window.width * 0.5f, 32), PowerGenMulti, 0.1f, 5f, leftAlignedLabel: "10%", rightAlignedLabel: "500%", roundTo: 0.05f);
MoveDown(32 + 10f);

DoLabel("AA.FuelConsumeRate".Translate($"{FuelConsumeRate * 100f:F0}"));
FuelConsumeRate = Widgets.HorizontalSlider(new Rect(window.x, window.y, window.width * 0.5f, 32), FuelConsumeRate, 0.05f, 5f, leftAlignedLabel: "5%", rightAlignedLabel: "500%", roundTo: 0.05f);
MoveDown(32 + 10f);

Widgets.CheckboxLabeled(new Rect(window.x, window.y, 350, 32), "AA.EnableEasterEggs".Translate(), ref EnableEasterEggs, placeCheckboxNearText: true);
MoveDown(32 + 10f);

void DoLabel(string label)
{
const float HEIGHT = 32;
Widgets.Label(new Rect(window.x, window.y, window.width, HEIGHT), label);
MoveDown(HEIGHT + 10);
}

void MoveDown(float amount)
{
window.y += amount;
window.height -= amount;
}
}
}
}

0 comments on commit f21d251

Please sign in to comment.