using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib;
using REPOLib.Modules;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Narvath")]
[assembly: AssemblyConfiguration("release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+101f6e8021c59f10f3269393272fc8dfe8c20d33")]
[assembly: AssemblyProduct("ValuablePriceOverride")]
[assembly: AssemblyTitle("ValuablePriceOverride")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 ValuablePriceOverride
{
public static class Settings
{
[HarmonyPatch(typeof(ValuableObject))]
private static class ValuableObjectPatch
{
[HarmonyPrefix]
[HarmonyPatch("DollarValueSetLogic")]
private static void Start_Prefix(ValuableObject __instance)
{
int overridePrice = GetOverridePrice(__instance);
if (overridePrice != 0)
{
__instance.dollarValueOverride = overridePrice;
Logger.LogInfo((object)$"{((Object)((Component)__instance).gameObject).name} value set to {overridePrice}");
}
}
}
public static ManualLogSource Logger { get; private set; } = null;
private static ConfigFile Config { get; set; } = null;
public static IDictionary<string, ConfigEntry<float>> PriceOverrides { get; private set; } = new Dictionary<string, ConfigEntry<float>>();
private static bool ValuablesInitialized { get; set; } = false;
internal static void Initialize(ConfigFile config, ManualLogSource logger)
{
Config = config;
Logger = logger;
BundleLoader.OnAllBundlesLoaded += InitializeConfigs;
}
internal static int GetOverridePrice(ValuableObject _valuable)
{
string name = ((Object)((Component)_valuable).gameObject).name;
name = name.Replace("(Clone)", "");
Logger.LogDebug((object)$"{name} : {((object)_valuable).GetType()}");
if (PriceOverrides.ContainsKey(name))
{
return (int)(PriceOverrides[name].Value * 1000f);
}
return 0;
}
internal static void InitializeConfigs()
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
if (ValuablesInitialized)
{
return;
}
IReadOnlyList<PrefabRef> allValuables = Valuables.AllValuables;
foreach (PrefabRef item in allValuables)
{
ConfigEntry<float> value = Config.Bind<float>("Price (in K)", item.prefabName ?? "", 0f, new ConfigDescription(item.prefabName.Replace("Valuable ", "") ?? "", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
PriceOverrides.Add(item.prefabName, value);
}
Logger.LogInfo((object)"Initialize Valuables Config");
ValuablesInitialized = true;
}
}
[BepInPlugin("Narvath.ValuablePriceOverride", "ValuablePriceOverride", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ValuablePriceOverride : BaseUnityPlugin
{
private const string PluginGuid = "Narvath.ValuablePriceOverride";
private const string PluginName = "ValuablePriceOverride";
private const string PluginVersion = "1.1.0";
private readonly Harmony _harmony = new Harmony("Narvath.ValuablePriceOverride");
private static readonly ManualLogSource ManualLogSource = Logger.CreateLogSource("Narvath.ValuablePriceOverride");
internal static ValuablePriceOverride Instance { get; private set; } = null;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Settings.Initialize(((BaseUnityPlugin)this).Config, ManualLogSource);
_harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Unpatch()
{
_harmony.UnpatchSelf();
}
}
}