using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("JotunnModExample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JotunnModExample")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace Brew;
public class SpawnPicked : MonoBehaviour
{
public void Awake()
{
ZNetView component = ((Component)this).GetComponent<ZNetView>();
if ((Object)(object)component == (Object)null)
{
return;
}
ZDO zDO = component.GetZDO();
if (zDO != null && zDO.GetLong(ZDOVars.s_pickedTime, 0L) == 0L)
{
Pickable component2 = ((Component)this).GetComponent<Pickable>();
if ((Object)(object)component2 != (Object)null)
{
component2.SetPicked(true);
}
}
}
}
[BepInPlugin("org.bepinex.plugins.bid.brew", "Brew", "0.2.6")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class Brew : BaseUnityPlugin
{
[HarmonyPatch(typeof(ZNetScene), "Awake")]
public static class ZNetScene_Awake
{
private static void Postfix(ZNetScene __instance)
{
ZNetScene.instance.GetPrefab("Boar").GetComponent<MonsterAI>().m_consumeItems.Add(PrefabManager.Instance.GetPrefab("item_hops").GetComponent<ItemDrop>());
ZNetScene.instance.GetPrefab("Lox").GetComponent<MonsterAI>().m_consumeItems.Add(PrefabManager.Instance.GetPrefab("item_hops").GetComponent<ItemDrop>());
}
}
public const string PluginGUID = "org.bepinex.plugins.bid.brew";
public const string PluginName = "Brew";
public const string PluginVersion = "0.2.6";
private readonly Harmony harmony = new Harmony("org.bepinex.plugins.bid.brew");
private void Awake()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
AssetBundle val = AssetUtils.LoadAssetBundleFromResources("brew");
if ((Object)(object)val == (Object)null)
{
MonoBehaviour.print((object)"Error loading assetbundle brew");
return;
}
CreateConfigValues();
AddStatusEffects();
AddCustomItemConversions();
AddItemsWithConfigs();
try
{
AddItems(val);
AddCreatures(val);
AddPieces(val);
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while adding custom creatures/items/pieces: {arg}");
}
finally
{
val.Unload(false);
}
PrefabManager.OnVanillaPrefabsAvailable += AddClonedItems;
AddRecipes();
new Harmony("org.bepinex.plugins.bid.brew").PatchAll();
}
private void OnDestroy()
{
harmony.UnpatchSelf();
}
private void CreateConfigValues()
{
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr)
{
if (attr.InitialSynchronization)
{
Logger.LogMessage((object)"Initial Config sync event received");
}
else
{
Logger.LogMessage((object)"Config sync event received");
}
};
}
private void AddStatusEffects()
{
}
private void AddCustomItemConversions()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
FermenterConversionConfig val = new FermenterConversionConfig();
((ConversionConfig)val).FromItem = "item_meadbasebeer";
((ConversionConfig)val).ToItem = "item_carbon_beer";
ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)(object)val));
}
private void AddItemsWithConfigs()
{
}
private void AddClonedItems()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Expected O, but got Unknown
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
AssetBundle val = AssetUtils.LoadAssetBundleFromResources("brew");
if ((Object)(object)val == (Object)null)
{
MonoBehaviour.print((object)"Error loading assetbundle brew");
return;
}
try
{
CharacterDrop component = PrefabManager.Instance.GetPrefab("Troll").GetComponent<CharacterDrop>();
Drop val2 = new Drop();
val2.m_prefab = PrefabManager.Instance.GetPrefab("item_hops");
val2.m_amountMin = 1;
val2.m_amountMax = 2;
val2.m_chance = 0.5f;
component.m_drops.Add(val2);
PrefabManager.Instance.GetPrefab("Boar").GetComponent<MonsterAI>().m_consumeItems.Add(PrefabManager.Instance.GetPrefab("item_hops").GetComponent<ItemDrop>());
PrefabManager.Instance.GetPrefab("Lox").GetComponent<MonsterAI>().m_consumeItems.Add(PrefabManager.Instance.GetPrefab("item_hops").GetComponent<ItemDrop>());
GameObject val3 = val.LoadAsset<GameObject>("beertmp");
GameObject obj = PrefabManager.Instance.CreateClonedPrefab("item_carbon_beer", "MeadTasty");
Material[] sharedMaterials = ((Renderer)obj.GetComponentInChildren<MeshRenderer>()).sharedMaterials;
if (sharedMaterials.Length != 0)
{
Material val4 = new Material(sharedMaterials[0]);
((Object)val4).name = "beer_material";
val4.mainTexture = ((Renderer)val3.GetComponentInChildren<MeshRenderer>()).sharedMaterial.mainTexture;
sharedMaterials[0] = val4;
}
((Renderer)obj.GetComponentInChildren<MeshRenderer>()).sharedMaterials = sharedMaterials;
CustomItem val5 = new CustomItem(obj, true);
((Object)val5.ItemDrop).name = "item_carbon_beer";
val5.ItemDrop.m_itemData = val3.GetComponent<ItemDrop>().m_itemData;
ItemManager.Instance.AddItem(val5);
MonoBehaviour.print((object)"carbonated beer item added");
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught in AddClonedItems: {arg}");
}
finally
{
val.Unload(false);
}
PrefabManager.OnVanillaPrefabsAvailable -= AddClonedItems;
}
private void AddItems(AssetBundle brewAssetBundle)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Expected O, but got Unknown
CustomItem val = new CustomItem(brewAssetBundle.LoadAsset<GameObject>("hops"), true);
((Object)val.ItemDrop).name = "item_hops";
ItemManager.Instance.AddItem(val);
MonoBehaviour.print((object)"hops item added");
CustomItem val2 = new CustomItem(brewAssetBundle.LoadAsset<GameObject>("MeadBaseBeer"), true);
((Object)val2.ItemDrop).name = "item_meadbasebeer";
ItemManager.Instance.AddItem(val2);
MonoBehaviour.print((object)"beer item added");
RecipeConfig val3 = new RecipeConfig();
val3.Item = "item_meadbasebeer";
val3.AddRequirement(new RequirementConfig("item_hops", 10, 0, false));
val3.AddRequirement(new RequirementConfig("Honey", 5, 0, false));
val3.AddRequirement(new RequirementConfig("Barley", 10, 0, false));
val3.CraftingStation = "piece_MeadCauldron";
ItemManager.Instance.AddRecipe(new CustomRecipe(val3));
}
private void AddCreatures(AssetBundle brewAssetBundle)
{
}
private void AddPieces(AssetBundle brewAssetBundle)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
GameObject val = brewAssetBundle.LoadAsset<GameObject>("hops_plant");
val.AddComponent<SpawnPicked>();
PieceManager instance = PieceManager.Instance;
PieceConfig val2 = new PieceConfig();
val2.PieceTable = "Cultivator";
val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
{
new RequirementConfig
{
Item = "Wood",
Recover = true,
Amount = 3
},
new RequirementConfig
{
Item = "item_hops",
Recover = false,
Amount = 5
}
};
val2.CraftingStation = "piece_workbench";
instance.AddPiece(new CustomPiece(val, true, val2));
}
private void AddRecipes()
{
}
public static void debug(string text, Vector3 pos)
{
}
}