using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Navalheim")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Navalheim")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("17516a32-190f-4873-8df2-3ba09afa9180")]
[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 Cannons;
public class Cannon : MonoBehaviour, Interactable, Hoverable
{
public string m_name = "Cañón";
public GameObject barrel;
private Collider barrelCollider;
public float maxPushForce = 100f;
public float pushMultiplier = 1f;
public Transform playerAttach;
public Projectile projectile;
public GameObject projectilePrefab;
public Transform projectileSpawnPoint;
public float projectileSpeed = 40f;
public float projectileLifeTime = 15f;
private bool reloading = false;
private float fireTimer = 0f;
private Quaternion originalBarrelRotation;
private Player player;
private bool loadedProjectile;
private GameObject currentProjectile;
private static ItemData arbalestItem;
private static ItemData blackmetalBolt;
private void Awake()
{
}
private void Start()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
playerAttach = barrel.transform.parent.parent.Find("attach");
barrelCollider = barrel.GetComponentInChildren<Collider>();
originalBarrelRotation = barrel.transform.rotation;
arbalestItem = PrefabManager.Instance.GetPrefab("DvergerArbalest").GetComponent<ItemDrop>().m_itemData;
blackmetalBolt = PrefabManager.Instance.GetPrefab("BoltBlackmetal").GetComponent<ItemDrop>().m_itemData;
}
private void Update()
{
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)player != (Object)null && Cannons.usingCannon)
{
if (!((Character)player).IsAttached())
{
SetActive(value: false);
}
if (fireTimer >= 1f)
{
reloading = false;
}
if (reloading)
{
fireTimer += Time.deltaTime;
}
if ((Object)(object)barrel != (Object)null && (Object)(object)Cannons.cameraTransform != (Object)null)
{
barrel.transform.LookAt(Cannons.cameraTransform.position + Cannons.cameraTransform.forward * 100f);
}
if (Input.GetKeyDown((KeyCode)102) && loadedProjectile && !reloading)
{
ShootProjectile();
}
}
}
public string GetHoverText()
{
if (!Cannons.usingCannon)
{
if (!loadedProjectile)
{
return Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] Cargar munición ");
}
return Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] Usar " + m_name);
}
return "";
}
public string GetHoverName()
{
return m_name;
}
public bool Interact(Humanoid _player, bool hold, bool alt)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
if (loadedProjectile)
{
SetActive(value: true);
player = Player.m_localPlayer;
((Character)player).AttachStart(playerAttach, (GameObject)null, true, false, true, "crouching", new Vector3(0f, 0.5f, 0f), (Transform)null);
if (((Character)player).IsAttached())
{
Logger.LogInfo((object)(player.GetPlayerName() + " is using the cannon"));
}
((Collider)((Character)player).GetCollider()).enabled = false;
barrelCollider.enabled = false;
return true;
}
LoadProjectile();
return true;
}
public bool UseItem(Humanoid player, ItemData item)
{
return false;
}
private void SetActive(bool value)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
Cannons.usingCannon = value;
Cannons.aiming = value;
if (!value)
{
((Collider)((Character)player).GetCollider()).enabled = true;
if (((Character)player).IsAttached())
{
((Character)player).AttachStop();
}
barrel.transform.rotation = originalBarrelRotation;
barrelCollider.enabled = true;
player = null;
}
}
public void LoadProjectile()
{
//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)
if (!loadedProjectile)
{
string name = PrefabManager.Instance.GetPrefab("Cannonball").GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
if (!((Humanoid)Player.m_localPlayer).GetInventory().HaveItem(name, true))
{
((Character)Player.m_localPlayer).Message((MessageType)2, "No tienes " + name, 0, (Sprite)null);
return;
}
((Humanoid)Player.m_localPlayer).GetInventory().RemoveItem(name, 1, -1, true);
Object.Instantiate<GameObject>(Cannons.cannonLoadSfx, ((Component)this).transform.position, ((Component)this).transform.rotation);
loadedProjectile = true;
}
}
public void ShootProjectile()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
currentProjectile = Object.Instantiate<GameObject>(projectilePrefab, projectileSpawnPoint.position + projectileSpawnPoint.forward * 0.5f, projectileSpawnPoint.rotation);
projectile = currentProjectile.GetComponent<Projectile>();
projectile.m_damage = new DamageTypes
{
m_blunt = Cannons.CannonballProjectileBluntDamage.Value,
m_chop = Cannons.CannonballProjectileChopDamage.Value
};
projectile.m_spawnOnHit = Cannons.cannonballHitAoe;
projectile.m_spawnOnHit.GetComponent<Aoe>().m_damage = new DamageTypes
{
m_blunt = 100f
};
projectile.m_canHitWater = false;
currentProjectile.SetActive(false);
HitData val = new HitData();
val.m_pushForce = projectileSpeed;
val.m_backstabBonus = 4f;
val.m_staggerMultiplier = 10f;
val.m_blockable = false;
val.m_dodgeable = true;
val.SetAttacker((Character)(object)player);
currentProjectile.SetActive(true);
Object.Instantiate<GameObject>(Cannons.cannonFireSfx, projectileSpawnPoint.position, projectileSpawnPoint.rotation);
IProjectile component = currentProjectile.GetComponent<IProjectile>();
if (component != null)
{
component.Setup((Character)(object)player, currentProjectile.transform.forward * projectileSpeed, 50f, val, arbalestItem, blackmetalBolt);
}
Object.Destroy((Object)(object)currentProjectile, projectileLifeTime);
arbalestItem.m_lastProjectile = currentProjectile;
reloading = true;
fireTimer = 0f;
loadedProjectile = false;
currentProjectile = null;
}
public void OnDestroy()
{
if ((Object)(object)player != (Object)null && Cannons.usingCannon)
{
SetActive(value: false);
}
}
}
internal class Cannonball : MonoBehaviour
{
public Collider collider = (Collider)new SphereCollider
{
isTrigger = true,
radius = 0.45f
};
private bool didHit = false;
private void Start()
{
}
private void FixedUpdate()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
if (didHit)
{
GameObject val = Object.Instantiate<GameObject>(PrefabManager.Instance.GetPrefab("sledge_aoe"));
val.transform.rotation = new Quaternion
{
x = 0f,
y = 0f,
z = 90f
};
Object.DestroyImmediate((Object)(object)((Component)this).gameObject);
didHit = false;
}
}
private void OnTriggerEnter(Collider other)
{
Logger.LogInfo((object)("Cannonball hit: " + ((Object)((Component)other).gameObject).name));
if (!((Object)((Component)other).gameObject).name.Contains("WaterVolume"))
{
didHit = true;
}
}
}
[BepInPlugin("com.valkyrie.cannons", "Cannons!", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class Cannons : BaseUnityPlugin
{
public class ShowCoordsCommand : ConsoleCommand
{
public override string Name => "coords";
public override string Help => "Toggles showing coordinates con top left corner";
public override void Run(string[] args)
{
if (!showCoords)
{
if (GUIManager.Instance == null)
{
Logger.LogError((object)"GUIManager instance is null");
}
else if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront))
{
Logger.LogError((object)"GUIManager CustomGUI is null");
}
else
{
showCoords = true;
}
}
else
{
showCoords = false;
}
}
}
[HarmonyPatch]
public static class GameCameraPatch
{
[HarmonyPatch(typeof(GameCamera), "GetCameraPosition")]
[HarmonyPriority(100)]
[HarmonyPostfix]
private static void GetCameraPosition_Postfix(GameCamera __instance, float dt, Vector3 pos, Quaternion rot)
{
if ((Object)(object)__instance != (Object)null && originalFov == 0f)
{
originalFov = __instance.m_fov;
}
}
[HarmonyPriority(0)]
[HarmonyPrefix]
[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
public static void UpdateCamera_Prefix(GameCamera __instance)
{
if (usingCannon)
{
cameraTransform = ((Component)__instance).transform;
if (Input.GetKey((KeyCode)304))
{
__instance.m_fov = zoomFov;
}
if (Input.GetKeyUp((KeyCode)304))
{
__instance.m_fov = originalFov;
}
}
}
}
public static class PlayerPatches
{
[HarmonyPatch(typeof(Player), "Update")]
private static class PlayerUpdatePatch
{
private static void Postfix()
{
//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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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)
if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && showCoords && !Object.op_Implicit((Object)(object)coordsText))
{
playerPosition = ((Component)Player.m_localPlayer).transform.position;
Object.DestroyImmediate((Object)(object)coordsText);
coordsText = GUIManager.Instance.CreateText(GetPositionString(), GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -50f), GUIManager.Instance.AveriaSerifBold, 18, Color.white, false, Color.white, 350f, 40f, false);
}
else
{
coordsText = null;
}
}
}
[HarmonyPatch(typeof(Player), "PlayerAttackInput")]
private static class PlayerAttackInputPatch
{
private static bool Prefix()
{
if (usingCannon)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Character), "Damage")]
private static class CharacterDamagePatch
{
private static bool Prefix()
{
if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.HasBadConnection() && Mathf.Sin(Time.time * 10f) > 0f)
{
return false;
}
return true;
}
}
}
private static readonly Cannons instance;
public const string PluginGUID = "com.valkyrie.cannons";
public const string PluginName = "Cannons!";
public const string PluginVersion = "0.0.1";
public static AssetBundle bundle;
private static readonly string pluginPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private static readonly string configPath = Paths.ConfigPath;
private static Harmony harm = new Harmony("ValkyrieCannons");
private static AudioSource sfxGroup;
public static bool usingCannon = false;
public static bool aiming = false;
public static CustomPiece cannonDrakkar;
public static float originalFov;
public static float zoomFov = 30f;
public static Vector3 playerHitPoint;
public static Transform cameraTransform;
public static GameObject salitre;
public static GameObject cannonPrefab;
public static GameObject cannonballPrefab;
public static GameObject cannonFireSfx;
public static GameObject cannonLoadSfx;
public static GameObject cannonballHitSfx;
public static GameObject cannonballProjectile;
public static GameObject cannonballHitAoe;
public static GameObject coordsText;
public static bool showCoords;
public static Vector3 playerPosition;
private static string ConfigFileName = "com.valkyrie.cannons.cfg";
private static string ConfigFileFullPath;
public static ConfigEntry<int> CannonShipIronCost;
public static ConfigEntry<int> CannonShipFinewoodCost;
public static ConfigEntry<int> CannonShipAncientBarkCost;
public static ConfigEntry<int> CannonballSalitreCost;
public static ConfigEntry<float> CannonballWeight;
public static ConfigEntry<float> CannonballProjectileBluntDamage;
public static ConfigEntry<float> CannonballProjectileChopDamage;
public static ConfigEntry<float> CannonballSplashDamage;
public static ConfigEntry<int> CannonballIronCost;
public static ConfigEntry<int> CannonballCoalCost;
public static ConfigEntry<int> SalitreMinYield;
public static ConfigEntry<int> SalitreMaxYield;
private static bool IsServer => (int)SystemInfo.graphicsDeviceType == 4;
private void Awake()
{
bundle = AssetUtils.LoadAssetBundleFromResources("cannons");
CreateConfigValues();
SetupWatcher();
LoadAssets();
CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ShowCoordsCommand());
PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable;
harm.PatchAll();
}
private static string GetPositionString()
{
return "Coords: " + playerPosition.x.ToString("F1") + "/" + playerPosition.y.ToString("F1") + "/" + playerPosition.z.ToString("F1");
}
private static void setPosition(GameObject extensions, GameObject ship, bool rotate = false)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
extensions.transform.position = ship.transform.position;
extensions.transform.parent = ship.transform;
extensions.transform.localPosition = new Vector3(2f, 1f, 0f);
extensions.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
}
private void LoadAssets()
{
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
salitre = bundle.LoadAsset<GameObject>("Salitre");
cannonPrefab = bundle.LoadAsset<GameObject>("Cannon");
cannonballPrefab = bundle.LoadAsset<GameObject>("Cannonball");
cannonballHitAoe = bundle.LoadAsset<GameObject>("cannonball_aoe");
cannonFireSfx = bundle.LoadAsset<GameObject>("sfx_cannon_fire");
cannonLoadSfx = bundle.LoadAsset<GameObject>("sfx_cannon_load");
cannonballHitSfx = bundle.LoadAsset<GameObject>("sfx_cannonball_hit");
cannonballProjectile = bundle.LoadAsset<GameObject>("cannonball_projectile");
PrefabManager.Instance.AddPrefab(cannonballProjectile);
PrefabManager.Instance.AddPrefab(cannonFireSfx);
PrefabManager.Instance.AddPrefab(cannonLoadSfx);
PrefabManager.Instance.AddPrefab(cannonballHitSfx);
cannonballHitAoe.GetComponent<Aoe>().m_damage = new DamageTypes
{
m_blunt = CannonballSplashDamage.Value
};
ZNetView val = cannonPrefab.GetComponent<ZNetView>();
if ((Object)(object)val == (Object)null)
{
val = cannonPrefab.AddComponent<ZNetView>();
}
val.m_persistent = true;
cannonPrefab.AddComponent<ZSyncTransform>();
Cannon cannon = cannonPrefab.AddComponent<Cannon>();
Transform val2 = cannonPrefab.transform.Find("cannon");
cannon.barrel = ((Component)val2.Find("barrel")).gameObject;
cannon.playerAttach = val2.Find("attach");
cannon.projectilePrefab = cannonballProjectile;
cannon.projectileSpawnPoint = cannon.barrel.transform.Find("BarrelTip");
}
private void OnVanillaPrefabsAvailable()
{
SetupSFX();
AddSalitre();
AddCannonball();
AddCannonDrakkar();
SetupDrops();
}
private void AddSalitre()
{
//IL_000b: 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_0022: Expected O, but got Unknown
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
Sprite val = RenderManager.Instance.Render(salitre, RenderManager.IsometricRotation);
GameObject obj = salitre;
ItemConfig val2 = new ItemConfig();
val2.Enabled = false;
val2.Name = "Salitre";
val2.Description = "Uno de los ingredientes de la pólvora. Sirve para crear bolas de cañón.";
val2.Icons = (Sprite[])(object)new Sprite[1] { val };
CustomItem val3 = new CustomItem(obj, false, val2);
ItemManager.Instance.AddItem(val3);
}
private void SetupDrops()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
GameObject prefab = Cache.GetPrefab<GameObject>("Leviathan");
MineRock component = prefab.GetComponent<MineRock>();
DropData item = default(DropData);
item.m_item = PrefabManager.Instance.GetPrefab("Salitre");
item.m_stackMax = 1;
item.m_stackMin = 1;
item.m_weight = 1f;
item.m_dontScale = false;
component.m_dropItems.m_drops.Add(item);
}
private void SetupSFX()
{
sfxGroup = Cache.GetPrefab<AudioSource>("sfx_arrow_hit");
cannonFireSfx.GetComponentInChildren<AudioSource>().outputAudioMixerGroup = sfxGroup.outputAudioMixerGroup;
cannonLoadSfx.GetComponentInChildren<AudioSource>().outputAudioMixerGroup = sfxGroup.outputAudioMixerGroup;
cannonballHitSfx.GetComponentInChildren<AudioSource>().outputAudioMixerGroup = sfxGroup.outputAudioMixerGroup;
}
private void AddCannonball()
{
//IL_000b: 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_0022: Expected O, but got Unknown
//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_0084: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected O, but got Unknown
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Expected O, but got Unknown
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Expected O, but got Unknown
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Expected O, but got Unknown
Sprite val = RenderManager.Instance.Render(cannonballPrefab, RenderManager.IsometricRotation);
GameObject obj = cannonballPrefab;
ItemConfig val2 = new ItemConfig();
val2.CraftingStation = "forge";
val2.Icons = (Sprite[])(object)new Sprite[1] { val };
val2.Weight = CannonballWeight.Value;
val2.StackSize = 20;
val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
{
new RequirementConfig
{
Item = "Salitre",
Amount = CannonballSalitreCost.Value
},
new RequirementConfig
{
Item = "Coal",
Amount = CannonballCoalCost.Value
},
new RequirementConfig
{
Item = "Iron",
Amount = CannonballIronCost.Value
}
};
CustomItem val3 = new CustomItem(obj, false, val2);
RecipeConfig val4 = new RecipeConfig();
val4.Item = "Cannonball";
val4.Name = "Cannonballx5";
val4.Amount = 5;
val4.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
{
new RequirementConfig
{
Item = "Salitre",
Amount = CannonballSalitreCost.Value * 5
},
new RequirementConfig
{
Item = "Coal",
Amount = CannonballCoalCost.Value * 5
},
new RequirementConfig
{
Item = "Iron",
Amount = CannonballIronCost.Value * 5
}
};
CustomRecipe val5 = new CustomRecipe(val4);
ItemManager.Instance.AddRecipe(val5);
ItemManager.Instance.AddItem(val3);
}
private static void AddCannonPiece()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_0060: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
Sprite icon = RenderManager.Instance.Render(cannonPrefab, RenderManager.IsometricRotation);
GameObject val = cannonPrefab;
val.AddComponent<Piece>();
PieceConfig val2 = new PieceConfig();
val2.Name = "Cañón";
val2.PieceTable = "Hammer";
val2.Category = "Misc";
val2.Icon = icon;
val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
{
new RequirementConfig
{
Item = "Wood",
Amount = 2,
Recover = true
}
};
CustomPiece val3 = new CustomPiece(val, false, val2);
((Object)val3.PiecePrefab).name = "piece_cannon";
PieceManager.Instance.AddPiece(val3);
}
private static void AddCannonDrakkar()
{
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Expected O, but got Unknown
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Expected O, but got Unknown
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Expected O, but got Unknown
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_035b: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: Expected O, but got Unknown
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_0388: Unknown result type (might be due to invalid IL or missing references)
//IL_0399: Unknown result type (might be due to invalid IL or missing references)
//IL_03a2: Expected O, but got Unknown
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
//IL_03cf: Expected O, but got Unknown
//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
//IL_03e1: Expected O, but got Unknown
GameObject prefab = Cache.GetPrefab<GameObject>("VikingShip");
GameObject val = bundle.LoadAsset<GameObject>("CannonShip");
Transform val2 = val.transform.Find("ship").Find("visual").Find("watermask");
Transform val3 = prefab.transform.Find("ship").Find("visual").Find("watermask");
Transform val4 = val.transform.Find("watereffects");
Transform val5 = prefab.transform.Find("watereffects");
Transform val6 = val4.Find("splash_effects");
Transform val7 = val5.Find("splash_effects");
Transform val8 = val4.Find("SpeedWake");
Transform val9 = val5.Find("SpeedWake");
ParticleSystemRenderer[] componentsInChildren = ((Component)val8).GetComponentsInChildren<ParticleSystemRenderer>();
foreach (ParticleSystemRenderer val10 in componentsInChildren)
{
if (((Object)((Component)val10).transform).name == "Trail")
{
((Renderer)val10).material = ((Renderer)((Component)val9.Find("Trail")).GetComponentInChildren<ParticleSystemRenderer>()).material;
}
else
{
((Renderer)val10).material = ((Renderer)((Component)val9.Find("rudder")).GetComponentInChildren<ParticleSystemRenderer>()).material;
}
}
WaterTrigger[] componentsInChildren2 = ((Component)val6).GetComponentsInChildren<WaterTrigger>();
foreach (WaterTrigger val11 in componentsInChildren2)
{
val11.m_effects.m_effectPrefabs = ((Component)val7).GetComponentInChildren<WaterTrigger>().m_effects.m_effectPrefabs;
}
((Renderer)((Component)val4.Find("WaterSurface")).GetComponentInChildren<ParticleSystemRenderer>()).material = ((Renderer)((Component)val5.Find("WaterSurface")).GetComponentInChildren<ParticleSystemRenderer>()).material;
prefab.transform.Find("watereffects").localPosition = new Vector3(0f, -0.7999992f, 0f);
((Renderer)((Component)val2).GetComponent<MeshRenderer>()).materials = ((Renderer)((Component)val3).GetComponent<MeshRenderer>()).materials;
Transform val12 = val.transform.Find("interactive");
Transform val13 = val12.Find("cannons");
for (int k = 0; k < val13.childCount; k++)
{
Transform child = val13.GetChild(k);
Cannon cannon = ((Component)child).gameObject.AddComponent<Cannon>();
Transform val14 = child.Find("cannon");
cannon.barrel = ((Component)val14.Find("barrel")).gameObject;
cannon.playerAttach = child.Find("attach");
cannon.projectilePrefab = cannonballProjectile;
cannon.projectileSpawnPoint = cannon.barrel.transform.Find("BarrelTip");
}
PieceConfig val15 = new PieceConfig();
val15.Name = "Drakkar de Cañón";
val15.Icon = val.GetComponent<Piece>().m_icon;
val15.Category = "Misc";
val15.PieceTable = "Hammer";
val15.Requirements = (RequirementConfig[])(object)new RequirementConfig[5]
{
new RequirementConfig
{
Item = "IronNails",
Amount = 100,
Recover = true
},
new RequirementConfig
{
Item = "DeerHide",
Amount = 10,
Recover = true
},
new RequirementConfig
{
Item = "FineWood",
Amount = CannonShipFinewoodCost.Value,
Recover = true
},
new RequirementConfig
{
Item = "ElderBark",
Amount = CannonShipAncientBarkCost.Value,
Recover = true
},
new RequirementConfig
{
Item = "Iron",
Amount = CannonShipIronCost.Value,
Recover = true
}
};
cannonDrakkar = new CustomPiece(val, true, val15);
PieceManager.Instance.AddPiece(cannonDrakkar);
}
private void SetupWatcher()
{
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
fileSystemWatcher.Changed += ReadConfigValues;
fileSystemWatcher.Created += ReadConfigValues;
fileSystemWatcher.Renamed += ReadConfigValues;
fileSystemWatcher.IncludeSubdirectories = true;
fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
fileSystemWatcher.EnableRaisingEvents = true;
}
private void ReadConfigValues(object sender, FileSystemEventArgs e)
{
if (!File.Exists(ConfigFileFullPath))
{
return;
}
try
{
Logger.LogDebug((object)"Attempting to reload configuration...");
((BaseUnityPlugin)this).Config.Reload();
}
catch
{
Logger.LogError((object)("There was an issue loading " + ConfigFileName));
}
}
private void CreateConfigValues()
{
//IL_000e: 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_001c: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Expected O, but got Unknown
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Expected O, but got Unknown
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Expected O, but got Unknown
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Expected O, but got Unknown
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Expected O, but got Unknown
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Expected O, but got Unknown
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_0394: Expected O, but got Unknown
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
{
IsAdminOnly = true
};
AcceptableValueRange<float> val2 = new AcceptableValueRange<float>(0f, 1000f);
CannonballWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Cannonball", "Item Weight", 10f, new ConfigDescription("Weight of the cannonball item.", (AcceptableValueBase)(object)val2, new object[1] { val }));
CannonballWeight.SettingChanged += delegate
{
ItemManager.Instance.GetItem("Cannonball").ItemDrop.m_itemData.m_shared.m_weight = CannonballWeight.Value;
};
CannonballProjectileBluntDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Cannonball", "Projectile Blunt Damage", 130f, new ConfigDescription("Blunt damage for the cannonball projectile impact.", (AcceptableValueBase)(object)val2, new object[1] { val }));
CannonballProjectileBluntDamage.SettingChanged += delegate
{
ItemManager.Instance.GetItem("Cannonball").ItemDrop.m_itemData.m_shared.m_damages.m_blunt = CannonballProjectileBluntDamage.Value;
};
CannonballProjectileChopDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Cannonball", "Projectile Chop Damage", 40f, new ConfigDescription("Chop damage for the cannonball projectile impact.", (AcceptableValueBase)(object)val2, new object[1] { val }));
CannonballProjectileChopDamage.SettingChanged += delegate
{
ItemManager.Instance.GetItem("Cannonball").ItemDrop.m_itemData.m_shared.m_damages.m_chop = CannonballProjectileChopDamage.Value;
};
CannonballSplashDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Cannonball", "Splash Blunt Damage", 70f, new ConfigDescription("Blunt damage for the cannonball splash damage.", (AcceptableValueBase)(object)val2, new object[1] { val }));
CannonballSplashDamage.SettingChanged += delegate
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
cannonballHitAoe.GetComponent<Aoe>().m_damage = new DamageTypes
{
m_blunt = CannonballSplashDamage.Value
};
};
CannonShipIronCost = ((BaseUnityPlugin)this).Config.Bind<int>("Cannon Drakkar", "Iron Cost", 40, new ConfigDescription("Iron cost for the Cannon Drakkar.", (AcceptableValueBase)null, new object[1] { val }));
CannonShipIronCost.SettingChanged += delegate
{
Requirement[] resources9 = PieceManager.Instance.GetPiece("CannonShip").Piece.m_resources;
foreach (Requirement val11 in resources9)
{
if (!(((Object)((Component)val11.m_resItem).gameObject).name != "Iron"))
{
val11.m_amount = CannonShipIronCost.Value;
}
}
};
CannonShipFinewoodCost = ((BaseUnityPlugin)this).Config.Bind<int>("Cannon Drakkar", "Finewood Cost", 50, new ConfigDescription("Finewood cost for the Cannon Drakkar.", (AcceptableValueBase)null, new object[1] { val }));
CannonShipFinewoodCost.SettingChanged += delegate
{
Requirement[] resources8 = PieceManager.Instance.GetPiece("CannonShip").Piece.m_resources;
foreach (Requirement val10 in resources8)
{
if (!(((Object)((Component)val10.m_resItem).gameObject).name != "FineWood"))
{
val10.m_amount = CannonShipFinewoodCost.Value;
}
}
};
CannonShipAncientBarkCost = ((BaseUnityPlugin)this).Config.Bind<int>("Cannon Drakkar", "Ancient Bark Cost", 50, new ConfigDescription("Ancient Bark cost for the Cannon Drakkar.", (AcceptableValueBase)null, new object[1] { val }));
CannonShipAncientBarkCost.SettingChanged += delegate
{
Requirement[] resources7 = PieceManager.Instance.GetPiece("CannonShip").Piece.m_resources;
foreach (Requirement val9 in resources7)
{
if (!(((Object)((Component)val9.m_resItem).gameObject).name != "ElderBark"))
{
val9.m_amount = CannonShipAncientBarkCost.Value;
}
}
};
CannonballSalitreCost = ((BaseUnityPlugin)this).Config.Bind<int>("Cannonball", "Salitre Cost", 1, new ConfigDescription("Salitre cost for the cannonball item.", (AcceptableValueBase)null, new object[1] { val }));
CannonballSalitreCost.SettingChanged += delegate
{
Requirement[] resources5 = ItemManager.Instance.GetRecipe("Cannonball").Recipe.m_resources;
foreach (Requirement val7 in resources5)
{
if (!(((Object)((Component)val7.m_resItem).gameObject).name != "Salitre"))
{
val7.m_amount = CannonballSalitreCost.Value;
}
}
Requirement[] resources6 = ItemManager.Instance.GetRecipe("Cannonballx5").Recipe.m_resources;
foreach (Requirement val8 in resources6)
{
if (!(((Object)((Component)val8.m_resItem).gameObject).name != "Salitre"))
{
val8.m_amount = CannonballSalitreCost.Value * 5;
}
}
};
CannonballIronCost = ((BaseUnityPlugin)this).Config.Bind<int>("Cannonball", "Iron Cost", 1, new ConfigDescription("Iron cost for the cannonball item.", (AcceptableValueBase)null, new object[1] { val }));
CannonballIronCost.SettingChanged += delegate
{
Requirement[] resources3 = ItemManager.Instance.GetRecipe("Cannonball").Recipe.m_resources;
foreach (Requirement val5 in resources3)
{
if (!(((Object)((Component)val5.m_resItem).gameObject).name != "Iron"))
{
val5.m_amount = CannonballIronCost.Value;
}
}
Requirement[] resources4 = ItemManager.Instance.GetRecipe("Cannonballx5").Recipe.m_resources;
foreach (Requirement val6 in resources4)
{
if (!(((Object)((Component)val6.m_resItem).gameObject).name != "Iron"))
{
val6.m_amount = CannonballIronCost.Value * 5;
}
}
};
CannonballCoalCost = ((BaseUnityPlugin)this).Config.Bind<int>("Cannonball", "Coal Cost", 1, new ConfigDescription("Coal cost for the cannonball item.", (AcceptableValueBase)null, new object[1] { val }));
CannonballCoalCost.SettingChanged += delegate
{
Requirement[] resources = ItemManager.Instance.GetRecipe("Cannonball").Recipe.m_resources;
foreach (Requirement val3 in resources)
{
if (!(((Object)((Component)val3.m_resItem).gameObject).name != "Coal"))
{
val3.m_amount = CannonballCoalCost.Value;
}
}
Requirement[] resources2 = ItemManager.Instance.GetRecipe("Cannonballx5").Recipe.m_resources;
foreach (Requirement val4 in resources2)
{
if (!(((Object)((Component)val4.m_resItem).gameObject).name != "Coal"))
{
val4.m_amount = CannonballCoalCost.Value * 5;
}
}
};
SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr)
{
if (attr.InitialSynchronization)
{
((BaseUnityPlugin)this).Logger.LogMessage((object)"Initial Config sync event received for Cannons");
}
else
{
((BaseUnityPlugin)this).Logger.LogMessage((object)"Config sync event received for Cannons");
}
};
}
static Cannons()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
string text = Paths.ConfigPath;
char directorySeparatorChar = Path.DirectorySeparatorChar;
ConfigFileFullPath = text + directorySeparatorChar + ConfigFileName;
}
}