using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using LethalExpansionCore;
using LethalExpansionCore.Utils;
using LethalSDK.ScriptableObjects;
using LethalSDK.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("LECP")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("LethalExpansionCore KR Localization")]
[assembly: AssemblyFileVersion("1.0.5")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("LECP")]
[assembly: AssemblyTitle("LECP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace LECP
{
public class LECPluginInfo
{
public const string LEC_ASEEM_NAME = "LethalExpansionCore";
public const string LEC_PLUGIN_GUID = "com.github.lethalmods.lethalexpansioncore";
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("LECP", "LECP", "1.0.4")]
public class LECP : BaseUnityPlugin
{
public static bool bContentAdded = false;
public static bool bTerminalUpdated = false;
public static LECP instance;
public bool bOverrodieScrapName = false;
private static Dictionary<string, string> _defaultMoonLocalization = new Dictionary<string, string>
{
{ "41 익스페리멘테이션", "41 Experimentation" },
{ "220 어슈어런스", "220 Assurance" },
{ "56 보우", "56 Vow" },
{ "21 오펜스", "21 Offense" },
{ "61 머치", "61 March" },
{ "85 렌드", "85 Rend" },
{ "7 다인", "7 Dine" },
{ "8 타이탄", "8 Titan" }
};
private static Dictionary<string, string> _defaultScrapLocalization = new Dictionary<string, string>
{
{ "Wine bottle", "와인 병" },
{ "Traffic cone", "라바콘" },
{ "Fire hydrant", "소화전" },
{ "Library lamp", "무드등" },
{ "Suitcase", "여행 가방" },
{ "Toaster", "토스터" },
{ "Keyboard", "키보드" },
{ "Fire extinguisher", "소화기" },
{ "Fan", "선풍기" },
{ "Plant", "화분" },
{ "Bucket", "양동이" },
{ "Plunger", "뚜러뻥" },
{ "Clock", "알람시계" },
{ "Anvil", "모루" },
{ "Wrench", "렌치" },
{ "Brick", "벽돌" },
{ "Jerrycan", "구형 연료통" },
{ "Fancy Painting", "고급 그림" },
{ "Screwdriver", "스크류드라이버" },
{ "Retro Toy", "레트로 게임기" },
{ "Wheel", "타이어" },
{ "Toolbox", "도구 상자" },
{ "Watering Can", "물뿌리개" },
{ "Food can", "통조림" },
{ "Fireaxe", "소방 도끼" },
{ "Baseball bat", "야구 배트" },
{ "Beer can", "맥주캔" },
{ "Can paint", "페인트캔" },
{ "Sink", "세면대" },
{ "Lantern", "조명" },
{ "Broken engine", "고장난 엔진" },
{ "Vent", "환풍구 뚜껑" },
{ "Top hat", "중절모" },
{ "Canteen", "수통" },
{ "Alcohol Flask", "포켓 위스키" },
{ "Garbage", "쓰레기 봉투" },
{ "Car battery", "차량용 배터리" },
{ "Squeaky toy", "닭삑삑이" },
{ "Gameboy", "게임 보이" },
{ "Clamp", "클램프" },
{ "Pliers", "펜치" },
{ "Hammer", "망치" },
{ "Socket Wrench", "소켓 렌치" },
{ "ToyHammer", "뿅망치" },
{ "Syringe", "주사기" },
{ "Syringe Gun", "주사총" },
{ "Corner Pipe", "코너 파이프" },
{ "Small Pipe", "작은 파이프" },
{ "Flow Pipe", "파이프" },
{ "Brain Jar", "뇌가 닮긴 병" },
{ "Toy Nutcracker", "호두까기 장난감" },
{ "Test Tube", "테스트 튜브" },
{ "Test Tube Rack", "테스트 튜브랙" },
{ "Nutcracker Eye", "호두까기 눈" },
{ "Blue Test Tube", "파란색 실험 튜브" },
{ "Yellow Test Tube", "노란색 실험 튜브" },
{ "Red Test Tube", "빨간색 실험 튜브" },
{ "Green Test Tube", "초록색 실험 튜브" },
{ "Tape Player Log 1", "테스트 기록테이프 1" },
{ "Tape Player Log 2", "테스트 기록테이프 2" },
{ "Tape Player Log 3", "테스트 기록테이프 3" },
{ "Tape Player Log 4", "테스트 기록테이프 4" }
};
private static Dictionary<string, string> moonLocalization = new Dictionary<string, string>();
private static Dictionary<string, string> scrapLocalization = new Dictionary<string, string>();
public void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
instance = this;
Harmony val = new Harmony("com.github.lethalmods.lethalexpansioncore");
val.PatchAll(typeof(LECP));
bOverrodieScrapName = ((BaseUnityPlugin)this).Config.Bind<bool>("Scrap Item Localization setting", "Allow naming override?", false, "You can change the name at alert on ship enter with it.\n But overriding item name may break mod functionalities based on it's name.").Value;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LECP is loaded!");
}
[HarmonyPriority(309)]
[HarmonyPatch(typeof(StartOfRound), "Awake")]
[HarmonyPostfix]
private static void StartOfRound_Awake()
{
LethalExpansion.Log.LogInfo((object)"[LECP] Patch start !!");
UpdateAllScrapSpawnRate();
}
public static void UpdateAllScrapSpawnRate()
{
foreach (KeyValuePair<string, (AssetBundle, ModManifest)> contentAssetBundle in AssetBundlesManager.Instance.contentAssetBundles)
{
var (val, val2) = AssetBundlesManager.Instance.Load(contentAssetBundle.Key);
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || val2.scraps == null)
{
continue;
}
Scrap[] scraps = val2.scraps;
foreach (Scrap val3 in scraps)
{
if (AssetBundlesManager.Instance.IsScrapCompatible(val3))
{
try
{
UpdateScrapSpawnRate(val3);
}
catch (Exception arg)
{
LethalExpansion.Log.LogError((object)$"[LECP] Failed to update scrap '{val3.itemName}' spawn rate. {arg}");
}
}
}
}
}
private static void UpdateScrapSpawnRate(Scrap scrap)
{
Scrap obj = scrap;
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
GameObject prefab = obj.prefab;
obj2 = ((prefab == null) ? null : prefab.GetComponent<GrabbableObject>()?.itemProperties);
}
Item val = (Item)obj2;
if ((Object)(object)val == (Object)null)
{
return;
}
string[] value = StartOfRound.Instance.levels.Select((SelectableLevel level) => level.PlanetName).ToArray();
string availableLevel = "Please type which moon's rarity will be overrided.\available values: " + string.Join(", ", value);
SelectableLevel[] levels = StartOfRound.Instance.levels;
foreach (SelectableLevel val2 in levels)
{
try
{
int? num = GetSpawnableItemRarity(val2);
if (num.HasValue)
{
UpdateOrAddItemSpawnRate(val2, val, num.Value);
}
}
catch (Exception ex)
{
LethalExpansion.Log.LogError((object)("[LECP] Failed to add scrap '" + scrap.itemName + "' spawn chance to moon '" + val2.PlanetName + "'. " + ex.Message));
}
}
int? GetSpawnableItemRarity(SelectableLevel level)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
if (scrap.useGlobalSpawnWeight)
{
return null;
}
ScrapSpawnChancePerScene[] array = scrap.perPlanetSpawnWeight();
ScrapSpawnChancePerScene[] array2 = array;
foreach (ScrapSpawnChancePerScene val3 in array2)
{
if (!(val3.SceneName == level.PlanetName))
{
if (!moonLocalization.ContainsKey(level.PlanetName))
{
string text = (_defaultMoonLocalization.ContainsKey(level.PlanetName) ? _defaultMoonLocalization[level.PlanetName] : "Others");
ConfigEntry<string> val4 = ((BaseUnityPlugin)instance).Config.Bind<string>("ScrapRarity Mapping", level.PlanetName, text, availableLevel);
moonLocalization.Add(level.PlanetName, val4.Value);
}
if (moonLocalization[level.PlanetName] == val3.SceneName)
{
LethalExpansion.DebugLog.LogInfo((object)("[LECP] " + scrap.itemName + " is patched to moon '" + level.PlanetName));
return val3.SpawnWeight;
}
}
}
return null;
}
}
public static void UpdateOrAddItemSpawnRate(SelectableLevel level, Item item, int rarity)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
int num = level.spawnableScrap.FindIndex((SpawnableItemWithRarity spawnableScrap) => (Object)(object)spawnableScrap.spawnableItem == (Object)(object)item);
if (num == -1)
{
LethalExpansion.DebugLog.LogInfo((object)$"[LECP] Added new spawn rate '{rarity}' for scrap '{item.itemName}' on moon '{level.PlanetName}'");
level.spawnableScrap.Add(new SpawnableItemWithRarity
{
spawnableItem = item,
rarity = rarity
});
return;
}
SpawnableItemWithRarity val = level.spawnableScrap[num];
if (val.rarity != rarity)
{
LethalExpansion.DebugLog.LogInfo((object)$"[LECP] Updated spawn rate from '{val.rarity}' to '{rarity}' for scrap '{item.itemName}' on moon '{level.PlanetName}'");
level.spawnableScrap[num] = new SpawnableItemWithRarity
{
spawnableItem = item,
rarity = rarity
};
}
}
[HarmonyPatch(typeof(VanillaItemInstancier), "AddItemToScrap")]
[HarmonyPostfix]
private static void AddItemToScrap_Postfix(Scrap scrap, Sprite scrapSprite)
{
Transform val = scrap.prefab.transform.Find("ScanNode");
if ((Object)(object)val == (Object)null)
{
return;
}
ScanNodeProperties component = ((Component)val).gameObject.GetComponent<ScanNodeProperties>();
if (!((Object)(object)component == (Object)null) && (!instance.bOverrodieScrapName || !scrapLocalization.ContainsValue(scrap.itemName)))
{
if (!scrapLocalization.ContainsKey(scrap.itemName))
{
string text = (_defaultScrapLocalization.ContainsKey(scrap.itemName) ? _defaultScrapLocalization[scrap.itemName] : scrap.itemName);
ConfigEntry<string> val2 = ((BaseUnityPlugin)instance).Config.Bind<string>("Scrap Item Localization", scrap.itemName, text, (ConfigDescription)null);
scrapLocalization.Add(scrap.itemName, val2.Value);
}
component.headerText = scrapLocalization[scrap.itemName];
if (instance.bOverrodieScrapName)
{
scrap.itemName = scrapLocalization[scrap.itemName];
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LECP";
public const string PLUGIN_NAME = "LECP";
public const string PLUGIN_VERSION = "1.0.4";
}
}