Decompiled source of WaterElectrolysis v1.2.3

Water electrolysis.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using CommonAPI;
using CommonAPI.Systems.ModLocalization;
using HarmonyLib;
using UnityEngine;
using xiaoye97;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Water electrolysis")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Water electrolysis")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7c9af07a-64ff-409f-b5bc-b78e172b5e36")]
[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 Water_electrolysis;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Gnimaerd.DSP.plugin.WaterElectrolysis", "WaterElectrolysis", "1.2")]
[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "LocalizationModule" })]
public class WaterElectrolysis : BaseUnityPlugin
{
	private Sprite icon;

	private static ConfigEntry<bool> BalanceAdjustment;

	private void Start()
	{
		AssetBundle val = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("Water_electrolysis.waterelecicon"));
		BalanceAdjustment = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "BalanceAdjustment", true, "是否(true或false)进行氢气能量和轨道采集器功耗等平衡调整。Whether to change the hydrogen energy and the power consumption of the orbital collector (by setting true or false.)");
		icon = val.LoadAsset<Sprite>("WaterElec3");
		if (BalanceAdjustment.Value)
		{
			LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ChangeHeat));
			LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ChangeCollectorEnergyNeed));
		}
		AddTranslate();
		LDBTool.PostAddDataAction = (Action)Delegate.Combine(LDBTool.PostAddDataAction, new Action(AddWaterToH));
	}

	private void ChangeHeat(Proto proto)
	{
		if (BalanceAdjustment.Value)
		{
			if (proto is ItemProto && proto.ID == 1120)
			{
				ItemProto val = (ItemProto)(object)((proto is ItemProto) ? proto : null);
				val.HeatValue = 439600L;
			}
			else if (proto is ItemProto && proto.ID == 1114)
			{
				ItemProto val2 = (ItemProto)(object)((proto is ItemProto) ? proto : null);
				val2.HeatValue = 8000000L;
			}
		}
	}

	private void ChangeCollectorEnergyNeed(Proto proto)
	{
		if (BalanceAdjustment.Value && proto is ItemProto && proto.ID == 2105)
		{
			ItemProto val = (ItemProto)(object)((proto is ItemProto) ? proto : null);
			val.prefabDesc.workEnergyPerTick = 30000L;
		}
	}

	private void AddWaterToH()
	{
		RecipeProto val = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(23);
		RecipeProto val2 = MethedEx.Copy<RecipeProto>(val);
		((Proto)val2).ID = 443;
		val2.Explicit = true;
		((Proto)val2).Name = "催化电解";
		((Proto)val2).name = Localization.Translate("催化电解");
		val2.Items = new int[1] { 1000 };
		val2.ItemCounts = new int[1] { 1 };
		val2.Results = new int[1] { 1120 };
		val2.ResultCounts = new int[1] { 1 };
		val2.GridIndex = 1810;
		((Proto)val2).SID = "1110";
		((Proto)val2).sid = Localization.Translate("1110");
		Traverse.Create((object)val2).Field("_iconSprite").SetValue((object)icon);
		val2.TimeSpend = 30;
		val2.Description = "催化电解描述";
		val2.description = Localization.Translate("催化电解描述");
		val2.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1121);
		ItemProto val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1120);
		val3.recipes.Add(val2);
		LDBTool.PostAddProto((ProtoType)6, (Proto)(object)val2);
	}

	private void AddTranslate()
	{
		LocalizationModule.RegisterTranslation("催化电解", "Water Electrolysis", "催化电解", "");
		LocalizationModule.RegisterTranslation("催化电解描述", "Electrolysis of water to produce hydrogen.", "电解水并获取氢气。", "");
	}
}