using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using BetterEndGame.Patches;
using EquinoxsModUtils;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BetterEndGame")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterEndGame")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("abdc1f84-f257-463c-823c-8cf31bd33135")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterEndGame
{
[BepInPlugin("com.equinox.BetterEndGame", "BetterEndGame", "1.1.0")]
public class BetterEndGamePlugin : BaseUnityPlugin
{
private const string MyGUID = "com.equinox.BetterEndGame";
private const string PluginName = "BetterEndGame";
private const string VersionString = "1.1.0";
private static readonly Harmony Harmony = new Harmony("com.equinox.BetterEndGame");
public static ManualLogSource Log = new ManualLogSource("BetterEndGame");
private const string electricEngine = "Electric Engine";
private const string heatsink = "Heatsink";
private const string motherboard = "Motherboard";
private const string sturdyFrame = "Sturdy Frame";
private const string primeComponents = "Prime Components";
private bool updatedQuestText = false;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: BetterEndGame, VersionString: 1.1.0 is loading...");
Harmony.PatchAll();
ModUtils.GameDefinesLoaded += OnGameDefinesLoaded;
ModUtils.GameLoaded += OnGameLoaded;
ModUtils.GameSaved += OnGameSaved;
ApplyPatches();
ModUtils.AddNewSchematicsSubHeader("Prime Components", "Intermediates", 8, false);
CreateNewItems();
InfiniteUnlocks.CreateUnlocks();
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: BetterEndGame, VersionString: 1.1.0 is loaded.");
Log = ((BaseUnityPlugin)this).Logger;
}
private void FixedUpdate()
{
if (!ModUtils.hasGameLoaded)
{
return;
}
if (TechTreeState.instance.IsUnlockActive(InfiniteUnlocks.miningSpeed.id))
{
InfiniteUnlocks.UptickUnlockTier(InfiniteUnlocks.miningSpeed.id);
}
if (TechTreeState.instance.IsUnlockActive(InfiniteUnlocks.oreConsumption.id))
{
InfiniteUnlocks.UptickUnlockTier(InfiniteUnlocks.oreConsumption.id);
}
if (TechTreeState.instance.IsUnlockActive(InfiniteUnlocks.fuelEfficiency.id))
{
InfiniteUnlocks.UptickUnlockTier(InfiniteUnlocks.fuelEfficiency.id);
}
if (TechTreeState.instance.IsUnlockActive(InfiniteUnlocks.powerEfficiency.id))
{
InfiniteUnlocks.UptickUnlockTier(InfiniteUnlocks.powerEfficiency.id);
}
if (TechTreeState.instance.IsUnlockActive(InfiniteUnlocks.walkSpeed.id))
{
InfiniteUnlocks.UptickUnlockTier(InfiniteUnlocks.walkSpeed.id);
}
if (TechTreeState.instance.IsUnlockActive(InfiniteUnlocks.moleSpeed.id))
{
InfiniteUnlocks.UptickUnlockTier(InfiniteUnlocks.moleSpeed.id);
}
if (updatedQuestText)
{
return;
}
updatedQuestText = true;
Dictionary<int, QuestData> dictionary = (Dictionary<int, QuestData>)ModUtils.GetPrivateField<PlayerQuestSystem>("_questsToIds", PlayerQuestSystem.instance);
foreach (QuestData value in dictionary.Values)
{
if (value.GetDisplayText().Contains("1950 MJ Accumulated Power"))
{
string text = "Supply and maximise Production Terminal VICTOR by depositing:<br><br>1000 Electrical Engines<br>1000 Heatsinks<br>1000 Motherboards<br>1000 Sturdy Frames<br>2000 MJ Accumulated Power<rsc: Accumulator>";
string hashString = LocsUtility.GetHashString(text);
ModUtils.hashTranslations.Add(hashString, text);
value.displayTextHash = hashString;
}
}
ModUtils.SetPrivateField<PlayerQuestSystem>("_questsToIds", PlayerQuestSystem.instance, (object)dictionary);
}
private void OnGameDefinesLoaded(object sender, EventArgs e)
{
InfiniteUnlocks.FetchUnlocks();
InfiniteUnlocks.UpdateUnlockDetails();
UpdateNewItems();
foreach (GatedDoorConfiguration gatedDoorConfiguration in GameDefines.instance.gatedDoorConfigurations)
{
if (gatedDoorConfiguration.displayName == "Tech Tier 10")
{
gatedDoorConfiguration.reqTypes = (ResourceInfo[])(object)new ResourceInfo[4]
{
ModUtils.GetResourceInfoByName("Electric Engine", false),
ModUtils.GetResourceInfoByName("Heatsink", false),
ModUtils.GetResourceInfoByName("Motherboard", false),
ModUtils.GetResourceInfoByName("Sturdy Frame", false)
};
gatedDoorConfiguration.reqQuantities = new int[4] { 1000, 1000, 1000, 1000 };
gatedDoorConfiguration.energyReqInMJ = 2000;
}
}
}
private void OnGameSaved(object sender, EventArgs e)
{
InfiniteUnlocks.Save(sender.ToString());
}
private void OnGameLoaded(object sender, EventArgs e)
{
InfiniteUnlocks.Load(SaveState.instance.metadata.worldName);
}
private void ApplyPatches()
{
Harmony.CreateAndPatchAll(typeof(GameStatePatch), (string)null);
Harmony.CreateAndPatchAll(typeof(GenericMachineInstanceRefPatch), (string)null);
Harmony.CreateAndPatchAll(typeof(PendingVoxelChangesPatch), (string)null);
Harmony.CreateAndPatchAll(typeof(QuestDataPatch), (string)null);
Harmony.CreateAndPatchAll(typeof(TechTreeStatePatch), (string)null);
Harmony.CreateAndPatchAll(typeof(TechTreeNodePatch), (string)null);
}
private void CreateNewItems()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Expected O, but got Unknown
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Expected O, but got Unknown
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Expected O, but got Unknown
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_0384: Unknown result type (might be due to invalid IL or missing references)
//IL_038d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
//IL_03cb: Expected O, but got Unknown
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Unknown result type (might be due to invalid IL or missing references)
//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_040a: Unknown result type (might be due to invalid IL or missing references)
//IL_0414: Unknown result type (might be due to invalid IL or missing references)
//IL_042e: Unknown result type (might be due to invalid IL or missing references)
//IL_0438: Unknown result type (might be due to invalid IL or missing references)
//IL_0452: Unknown result type (might be due to invalid IL or missing references)
//IL_045e: Unknown result type (might be due to invalid IL or missing references)
//IL_0467: Unknown result type (might be due to invalid IL or missing references)
//IL_0481: Unknown result type (might be due to invalid IL or missing references)
//IL_048d: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
//IL_04a5: Expected O, but got Unknown
//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0508: Unknown result type (might be due to invalid IL or missing references)
//IL_0512: Unknown result type (might be due to invalid IL or missing references)
//IL_052c: Unknown result type (might be due to invalid IL or missing references)
//IL_0538: Unknown result type (might be due to invalid IL or missing references)
//IL_0541: Unknown result type (might be due to invalid IL or missing references)
//IL_055b: Unknown result type (might be due to invalid IL or missing references)
//IL_0567: Unknown result type (might be due to invalid IL or missing references)
//IL_056e: Unknown result type (might be due to invalid IL or missing references)
//IL_057f: Expected O, but got Unknown
ModUtils.AddNewResource(new NewResourceDetails
{
name = "Electric Engine",
craftingMethod = (CraftingMethod)0,
craftTierRequired = 0,
description = "Drives vehicles and machines with greater power than Electric Motors",
fuelAmount = 0f,
maxStackCount = 500,
miningTierRequired = 0,
parentName = "Relay Circuit",
sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.Items.Engine.png", false),
sortPriority = 0,
subHeaderTitle = "Prime Components",
unlockName = "Advanced Optimization"
});
ModUtils.AddNewResource(new NewResourceDetails
{
name = "Heatsink",
craftingMethod = (CraftingMethod)0,
craftTierRequired = 0,
description = "Dissipating excess heat generated by electronic components.",
fuelAmount = 0f,
maxStackCount = 500,
miningTierRequired = 0,
parentName = "Relay Circuit",
sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.Items.Heatsink.png", false),
sortPriority = 1,
subHeaderTitle = "Prime Components",
unlockName = "Advanced Optimization"
});
ModUtils.AddNewResource(new NewResourceDetails
{
name = "Motherboard",
craftingMethod = (CraftingMethod)0,
craftTierRequired = 0,
description = "A central hub connecting circuits and enabling seamless communication between them.",
fuelAmount = 0f,
maxStackCount = 500,
miningTierRequired = 0,
parentName = "Relay Circuit",
sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.Items.Motherboard.png", false),
sortPriority = 2,
subHeaderTitle = "Prime Components",
unlockName = "Advanced Optimization"
});
ModUtils.AddNewResource(new NewResourceDetails
{
name = "Sturdy Frame",
craftingMethod = (CraftingMethod)0,
craftTierRequired = 0,
description = "A robust and durable structural component for stabilising machines.",
fuelAmount = 0f,
maxStackCount = 500,
miningTierRequired = 0,
parentName = "Relay Circuit",
sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.Items.SturdyFrame.png", false),
sortPriority = 3,
subHeaderTitle = "Prime Components",
unlockName = "Advanced Optimization"
});
ModUtils.AddNewRecipe(new NewRecipeDetails
{
craftingMethod = (CraftingMethod)0,
craftTierRequired = 0,
duration = 60,
ingredients = new List<RecipeResourceInfo>
{
new RecipeResourceInfo
{
name = "Electric Motor",
quantity = 2
},
new RecipeResourceInfo
{
name = "Wire Spindle",
quantity = 8
},
new RecipeResourceInfo
{
name = "Gearbox",
quantity = 8
}
},
outputs = new List<RecipeResourceInfo>
{
new RecipeResourceInfo
{
name = "Electric Engine",
quantity = 1
}
},
sortPriority = 0,
unlockName = "Advanced Optimization"
}, false);
ModUtils.AddNewRecipe(new NewRecipeDetails
{
craftingMethod = (CraftingMethod)0,
craftTierRequired = 0,
duration = 60,
ingredients = new List<RecipeResourceInfo>
{
new RecipeResourceInfo
{
name = "Iron Mechanism",
quantity = 10
},
new RecipeResourceInfo
{
name = "Copper Mechanism",
quantity = 10
},
new RecipeResourceInfo
{
name = "Ceramic Tiles",
quantity = 10
}
},
outputs = new List<RecipeResourceInfo>
{
new RecipeResourceInfo
{
name = "Heatsink",
quantity = 1
}
},
sortPriority = 1,
unlockName = "Advanced Optimization"
}, false);
ModUtils.AddNewRecipe(new NewRecipeDetails
{
craftingMethod = (CraftingMethod)0,
craftTierRequired = 0,
duration = 60,
ingredients = new List<RecipeResourceInfo>
{
new RecipeResourceInfo
{
name = "Relay Circuit",
quantity = 2
},
new RecipeResourceInfo
{
name = "Electrical Set",
quantity = 2
},
new RecipeResourceInfo
{
name = "Processor Array",
quantity = 2
}
},
outputs = new List<RecipeResourceInfo>
{
new RecipeResourceInfo
{
name = "Motherboard",
quantity = 1
}
},
sortPriority = 2,
unlockName = "Advanced Optimization"
}, false);
ModUtils.AddNewRecipe(new NewRecipeDetails
{
craftingMethod = (CraftingMethod)0,
craftTierRequired = 0,
duration = 60,
ingredients = new List<RecipeResourceInfo>
{
new RecipeResourceInfo
{
name = "Steel Frame",
quantity = 8
},
new RecipeResourceInfo
{
name = "Reinforced Iron Frame",
quantity = 4
},
new RecipeResourceInfo
{
name = "Reinforced Copper Frame",
quantity = 4
}
},
outputs = new List<RecipeResourceInfo>
{
new RecipeResourceInfo
{
name = "Sturdy Frame",
quantity = 1
}
},
sortPriority = 3,
unlockName = "Advanced Optimization"
}, false);
}
private void UpdateNewItems()
{
ResourceInfo resourceInfoByName = ModUtils.GetResourceInfoByName("Electric Engine", false);
ResourceInfo resourceInfoByName2 = ModUtils.GetResourceInfoByName("Heatsink", false);
ResourceInfo resourceInfoByName3 = ModUtils.GetResourceInfoByName("Motherboard", false);
ResourceInfo resourceInfoByName4 = ModUtils.GetResourceInfoByName("Sturdy Frame", false);
resourceInfoByName.headerType = ModUtils.GetSchematicsSubHeaderByTitle("Prime Components", false);
resourceInfoByName2.headerType = ModUtils.GetSchematicsSubHeaderByTitle("Prime Components", false);
resourceInfoByName3.headerType = ModUtils.GetSchematicsSubHeaderByTitle("Prime Components", false);
resourceInfoByName4.headerType = ModUtils.GetSchematicsSubHeaderByTitle("Prime Components", false);
}
}
public static class InfiniteUnlocks
{
public static InfiniteUnlock miningSpeed = new InfiniteUnlock
{
id = -1,
name = "MDR Speed ∞",
tier = 0,
boost = 5,
increaseModifier = true
};
public static InfiniteUnlock oreConsumption = new InfiniteUnlock
{
id = -1,
name = "Ore Consumption ∞",
tier = 0,
boost = 10,
increaseModifier = false
};
public static InfiniteUnlock fuelEfficiency = new InfiniteUnlock
{
id = -1,
name = "BioDense ∞",
tier = 0,
boost = 10,
increaseModifier = true
};
public static InfiniteUnlock powerEfficiency = new InfiniteUnlock
{
id = -1,
name = "Power Trim ∞",
tier = 0,
boost = 5,
increaseModifier = false
};
public static InfiniteUnlock walkSpeed = new InfiniteUnlock
{
id = -1,
name = "Suit Speed ∞",
tier = 0,
boost = 5,
increaseModifier = true
};
public static InfiniteUnlock moleSpeed = new InfiniteUnlock
{
id = -1,
name = "M.O.L.E. Speed ∞",
tier = 0,
boost = 5,
increaseModifier = true
};
private static Dictionary<int, InfiniteUnlock> infiniteUnlocks = new Dictionary<int, InfiniteUnlock>();
private static string dataFolder = Application.persistentDataPath + "/BetterEndGame";
public static void CreateUnlocks()
{
SetDescriptions();
CreateMinerSpeedUnlock();
CreateOreConsumptionUnlock();
CreateFuelEfficiencyUnlock();
CreatePowerEfficiencyUnlock();
CreateWalkSpeedUnlock();
CreateMoleSpeedUnlock();
}
public static void FetchUnlocks()
{
miningSpeed.id = ((UniqueIdScriptableObject)ModUtils.GetUnlockByName(miningSpeed.name, false)).uniqueId;
oreConsumption.id = ((UniqueIdScriptableObject)ModUtils.GetUnlockByName(oreConsumption.name, false)).uniqueId;
fuelEfficiency.id = ((UniqueIdScriptableObject)ModUtils.GetUnlockByName(fuelEfficiency.name, false)).uniqueId;
powerEfficiency.id = ((UniqueIdScriptableObject)ModUtils.GetUnlockByName(powerEfficiency.name, false)).uniqueId;
walkSpeed.id = ((UniqueIdScriptableObject)ModUtils.GetUnlockByName(walkSpeed.name, false)).uniqueId;
moleSpeed.id = ((UniqueIdScriptableObject)ModUtils.GetUnlockByName(moleSpeed.name, false)).uniqueId;
infiniteUnlocks.Add(miningSpeed.id, miningSpeed);
infiniteUnlocks.Add(oreConsumption.id, oreConsumption);
infiniteUnlocks.Add(fuelEfficiency.id, fuelEfficiency);
infiniteUnlocks.Add(powerEfficiency.id, powerEfficiency);
infiniteUnlocks.Add(walkSpeed.id, walkSpeed);
infiniteUnlocks.Add(moleSpeed.id, moleSpeed);
}
public static void UpdateUnlockDetails()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
Unlock unlockByName = ModUtils.GetUnlockByName("M.O.L.E. Speed IV", false);
Unlock unlockByName2 = ModUtils.GetUnlockByName("MDR Speed III", false);
miningSpeed.unlock.treePosition = unlockByName2.treePosition;
miningSpeed.unlock.requiredTier = unlockByName.requiredTier;
miningSpeed.unlock.sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.MinerInfUnlock.png", false);
Unlock unlockByName3 = ModUtils.GetUnlockByName("Mining Drill MKII", false);
oreConsumption.unlock.treePosition = unlockByName3.treePosition;
oreConsumption.unlock.requiredTier = unlockByName.requiredTier;
oreConsumption.unlock.sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.OreInfUnlock.png", false);
Unlock unlockByName4 = ModUtils.GetUnlockByName("BioDense V", false);
fuelEfficiency.unlock.treePosition = unlockByName4.treePosition;
fuelEfficiency.unlock.requiredTier = unlockByName.requiredTier;
fuelEfficiency.unlock.sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.FuelInfUnlock.png", false);
Unlock unlockByName5 = ModUtils.GetUnlockByName("CrankSpan", false);
powerEfficiency.unlock.treePosition = unlockByName5.treePosition;
powerEfficiency.unlock.requiredTier = unlockByName.requiredTier;
powerEfficiency.unlock.sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.PowerInfUnlock.png", false);
Unlock unlockByName6 = ModUtils.GetUnlockByName("SuitSpeed IV", false);
walkSpeed.unlock.treePosition = unlockByName6.treePosition;
walkSpeed.unlock.requiredTier = unlockByName.requiredTier;
walkSpeed.unlock.sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.WalkInfUnlock.png", false);
Unlock unlockByName7 = ModUtils.GetUnlockByName("M.O.L.E. T-99 (Tunneling)", false);
moleSpeed.unlock.treePosition = unlockByName7.treePosition;
moleSpeed.unlock.requiredTier = unlockByName.requiredTier;
moleSpeed.unlock.sprite = ModUtils.LoadSpriteFromFile("BetterEndGame.Images.MoleInfUnlock.png", false);
}
public static void UptickUnlockTier(int id)
{
infiniteUnlocks[id].IncreaseTier();
TechTreeState.instance.unlockStates[id].isActive = false;
UIManager.instance.techTreeMenu.SetSidebarInfo(infiniteUnlocks[id].unlock);
}
private static void SetDescriptions()
{
miningSpeed.description = $"Boosts Miner Drill's ore production rate by {miningSpeed.boost}% per level.";
oreConsumption.description = $"Reduces the vein destruction of Miner Drills by {oreConsumption.boost}% per level.";
fuelEfficiency.description = $"Increase each fuel's burn time by {fuelEfficiency.boost}% per level.";
powerEfficiency.description = $"Reduces each machine's power usage by {powerEfficiency.boost}% per level.";
walkSpeed.description = $"Increases walk and fly speed by {walkSpeed.boost}% per level.";
moleSpeed.description = $"Increases the M.O.L.E's dig speed by {moleSpeed.boost}% per level.";
}
private static void CreateMinerSpeedUnlock()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
ModUtils.AddNewUnlock(new NewUnlockDetails
{
category = (TechCategory)0,
coreTypeNeeded = (CoreType)2,
coreCountNeeded = 100,
description = miningSpeed.description,
displayName = miningSpeed.name,
numScansNeeded = 0,
requiredTier = (ResearchTier)1,
treePosition = 0
}, false);
}
private static void CreateOreConsumptionUnlock()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
ModUtils.AddNewUnlock(new NewUnlockDetails
{
category = (TechCategory)0,
coreTypeNeeded = (CoreType)2,
coreCountNeeded = 100,
description = oreConsumption.description,
displayName = oreConsumption.name,
numScansNeeded = 0,
requiredTier = (ResearchTier)1,
treePosition = 0
}, false);
}
private static void CreateFuelEfficiencyUnlock()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
ModUtils.AddNewUnlock(new NewUnlockDetails
{
category = (TechCategory)1,
coreTypeNeeded = (CoreType)2,
coreCountNeeded = 100,
description = fuelEfficiency.description,
displayName = fuelEfficiency.name,
numScansNeeded = 0,
requiredTier = (ResearchTier)1,
treePosition = 0
}, false);
}
private static void CreatePowerEfficiencyUnlock()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
ModUtils.AddNewUnlock(new NewUnlockDetails
{
category = (TechCategory)4,
coreTypeNeeded = (CoreType)2,
coreCountNeeded = 100,
description = powerEfficiency.description,
displayName = powerEfficiency.name,
numScansNeeded = 0,
requiredTier = (ResearchTier)1,
treePosition = 0
}, false);
}
private static void CreateWalkSpeedUnlock()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
ModUtils.AddNewUnlock(new NewUnlockDetails
{
category = (TechCategory)3,
coreTypeNeeded = (CoreType)2,
coreCountNeeded = 100,
description = walkSpeed.description,
displayName = walkSpeed.name,
numScansNeeded = 0,
requiredTier = (ResearchTier)1,
treePosition = 0
}, false);
}
private static void CreateMoleSpeedUnlock()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
ModUtils.AddNewUnlock(new NewUnlockDetails
{
category = (TechCategory)0,
coreTypeNeeded = (CoreType)2,
coreCountNeeded = 100,
description = moleSpeed.description,
displayName = moleSpeed.name,
numScansNeeded = 0,
requiredTier = (ResearchTier)1,
treePosition = 0
}, false);
}
public static int GetCostForTier(int tier)
{
return Mathf.FloorToInt(100f * Mathf.Pow(1.1f, (float)tier));
}
public static void Save(string worldName)
{
Directory.CreateDirectory(dataFolder);
string path = dataFolder + "/" + worldName + ".txt";
string contents = $"{miningSpeed.tier}|{oreConsumption.tier}|{fuelEfficiency.tier}|" + $"{powerEfficiency.tier}|{walkSpeed.tier}|{moleSpeed.tier}";
File.WriteAllText(path, contents);
}
public static void Load(string worldName)
{
string text = dataFolder + "/" + worldName + ".txt";
if (!File.Exists(text))
{
BetterEndGamePlugin.Log.LogInfo((object)("Could not find save file '" + text + "'"));
return;
}
BetterEndGamePlugin.Log.LogInfo((object)"Loading Data...");
string text2 = File.ReadAllText(text);
string[] array = text2.Split(new char[1] { '|' });
miningSpeed.SetTier(int.Parse(array[0]));
oreConsumption.SetTier(int.Parse(array[1]));
fuelEfficiency.SetTier(int.Parse(array[2]));
powerEfficiency.SetTier(int.Parse(array[3]));
walkSpeed.SetTier(int.Parse(array[4]));
moleSpeed.SetTier(int.Parse(array[5]));
int num = 0;
num += miningSpeed.GetCumulativeCost();
num += oreConsumption.GetCumulativeCost();
num += fuelEfficiency.GetCumulativeCost();
num += powerEfficiency.GetCumulativeCost();
num += walkSpeed.GetCumulativeCost();
num += moleSpeed.GetCumulativeCost();
BetterEndGamePlugin.Log.LogInfo((object)$"coresSpent: {num}");
TechTreeState.instance.usedResearchCores[2] += num;
BetterEndGamePlugin.Log.LogInfo((object)"Loaded Data");
}
}
public class InfiniteUnlock
{
public int id;
public string name;
public string description;
public int tier;
public int boost;
public bool increaseModifier;
public float multiplier = 1f;
public Unlock unlock => ModUtils.GetUnlockByID(id, false);
public void SetMultiplier()
{
if (increaseModifier)
{
multiplier = Mathf.Pow(1f + (float)boost / 100f, (float)tier);
}
else
{
multiplier = Mathf.Pow((100f - (float)boost) / 100f, (float)tier);
}
}
public void SetTier(int newTier)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
tier = newTier;
unlock.coresNeeded = new List<RequiredCores>
{
new RequiredCores
{
type = (CoreType)2,
number = InfiniteUnlocks.GetCostForTier(tier)
}
};
SetMultiplier();
string text = $"{description}\nLevel: {tier}\nBoost: {multiplier * 100f:#.##}%";
string hashString = LocsUtility.GetHashString(text);
ModUtils.hashTranslations.Add(hashString, text);
unlock.descriptionHash = hashString;
if (name == InfiniteUnlocks.fuelEfficiency.name)
{
for (int i = 0; i < GameState.instance.fuelMultipliers.Length; i++)
{
GameState.instance.fuelMultipliers[i] += multiplier - 1f;
}
}
}
public void IncreaseTier()
{
SetTier(tier + 1);
}
public int GetCumulativeCost()
{
int num = 0;
for (int i = 0; i < tier; i++)
{
num += InfiniteUnlocks.GetCostForTier(i);
}
return num;
}
}
}
namespace BetterEndGame.Patches
{
internal class GameStatePatch
{
[HarmonyPatch(typeof(GameState), "PrepForStateRefresh")]
[HarmonyPostfix]
private static void ApplyBiofuelBoost()
{
float num = GameState.instance.upgradeStates[38].floatVal + InfiniteUnlocks.fuelEfficiency.multiplier;
foreach (ResourceInfo item in GameDefines.instance.upgradeableFuel)
{
GameState.instance.fuelMultipliers[((UniqueIdScriptableObject)item).uniqueId] = num;
}
}
[HarmonyPatch(typeof(GameState), "get_walkSpeed")]
[HarmonyPostfix]
private static void ApplyWalkSpeedBoost(ref float __result)
{
__result = InfiniteUnlocks.walkSpeed.multiplier - 1f + GameState.instance.upgradeStates[4].floatVal;
}
[HarmonyPatch(typeof(GameState), "get_terraformSpeed")]
[HarmonyPostfix]
private static void ApplyMOLESpeedBoost(ref float __result)
{
__result = InfiniteUnlocks.moleSpeed.multiplier - 1f + GameState.instance.upgradeStates[12].floatVal;
}
}
internal class GenericMachineInstanceRefPatch
{
[HarmonyPatch(typeof(GenericMachineInstanceRef), "get_CurPowerConsumption")]
[HarmonyPostfix]
private static void ApplyPowerMultplier(GenericMachineInstanceRef __instance, ref int __result)
{
__result = Mathf.FloorToInt(InfiniteUnlocks.powerEfficiency.multiplier * (float)((GenericMachineInstanceRef)(ref __instance)).GetPowerInfo().curPowerConsumption);
}
}
public class PendingVoxelChangesPatch
{
public static int maxIntegrity = 10000;
[HarmonyPatch(typeof(PendingVoxelChanges), "TryDig")]
[HarmonyPostfix]
private static void ReduceVeinDamage(PendingVoxelChanges __instance, Vector3Int coord, int digStrength, int miningTier, ref int numResourcesTaken, bool __result)
{
if (!__result && numResourcesTaken > 0)
{
int x = ((Vector3Int)(ref coord)).x;
int y = ((Vector3Int)(ref coord)).y;
int z = ((Vector3Int)(ref coord)).z;
int chunkId = VoxelManager.GetChunkId(ref x, ref y, ref z);
int orCreateIndexForChunk = __instance.GetOrCreateIndexForChunk(ref chunkId);
ref ChunkPendingVoxelChanges reference = ref __instance.chunkData[orCreateIndexForChunk];
x = ((Vector3Int)(ref coord)).x;
y = ((Vector3Int)(ref coord)).y;
z = ((Vector3Int)(ref coord)).z;
int index = ((ChunkPendingVoxelChanges)(ref reference)).GetIndex(ref x, ref y, ref z);
ref ModifiedCoordData orAdd = ref ((ChunkPendingVoxelChanges)(ref reference)).GetOrAdd(index);
int num = Mathf.CeilToInt((float)numResourcesTaken * (1f - InfiniteUnlocks.oreConsumption.multiplier));
int num2 = Math.Min(numResourcesTaken - num, maxIntegrity - orAdd.integrity);
orAdd.integrity += num2;
}
}
}
internal class QuestDataPatch
{
[HarmonyPatch(typeof(QuestData), "GetDisplayText")]
public class DisplayTextPatch
{
[HarmonyPrefix]
public static bool Prefix(ref string __result, QuestData __instance)
{
if (string.IsNullOrEmpty(__instance.displayTextHash))
{
__result = "";
return false;
}
string text = LocsUtility.TranslateStringFromHash(__instance.displayTextHash, (string)null, (Object)null);
MethodInfo method = typeof(QuestData).GetMethod("ReplaceProductionTerminalUpgradeCosts", BindingFlags.Static | BindingFlags.NonPublic);
if (method != null)
{
text = (string)method.Invoke(null, new object[1] { text });
}
text = RemoveSpriteTags(text);
text = GameDefines.instance.patternsList.Replace(text);
__result = text;
return false;
}
private static string RemoveSpriteTags(string input)
{
return Regex.Replace(input, "<sprite=\"\" index=0>", string.Empty);
}
}
}
internal class TechTreeNodePatch
{
[HarmonyPatch(typeof(TechTreeNode), "RefreshState")]
[HarmonyPostfix]
private static void UpdateCost(TechTreeNode __instance)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
Unlock unlockRef = TechTreeState.instance.unlockStates[__instance.unlockId].unlockRef;
__instance.coreSquare.Set(FHG_Utils.First<RequiredCores>(unlockRef.coresNeeded).type, FHG_Utils.First<RequiredCores>(unlockRef.coresNeeded).number);
}
}
internal class TechTreeStatePatch
{
[HarmonyPatch(typeof(TechTreeState), "HandleEndOfFrame")]
[HarmonyPrefix]
public static bool DisableClusters()
{
TechTreeState.instance.freeCores = 0;
TechTreeState.instance.freeCoresAssembling = 0f;
TechTreeState.instance.freeCoresMining = InfiniteUnlocks.miningSpeed.multiplier - 1f;
TechTreeState.instance.freeCoresPowerOutput = 0f;
TechTreeState.instance.freeCoresSmelting = 0f;
TechTreeState.instance.freeCoresThreshing = 0f;
return false;
}
}
}