Decompiled source of SeaShardArsenal v1.11.0

SeaShardArsenal.dll

Decompiled 26 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using PassiveTree;
using PassiveTree.Gear;
using PassiveTree.Loot;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SeaShardArsenal")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.11.0.0")]
[assembly: AssemblyInformationalVersion("1.11.0")]
[assembly: AssemblyProduct("SeaShardArsenal")]
[assembly: AssemblyTitle("SeaShardArsenal")]
[assembly: AssemblyVersion("1.11.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 SeaShardArsenal
{
	[BepInPlugin("groshyr.seashardarsenal", "SeaShardArsenal", "1.11.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		private enum FxMode
		{
			Core,
			Trail,
			Launch,
			Hit,
			Spiral
		}

		private sealed class FxLayer
		{
			public string Name;

			public ConfigEntry<FxPart> Part;

			public ConfigEntry<Color> Colour;

			public ConfigEntry<float> Opacity;

			public ConfigEntry<float> Size;

			public ConfigEntry<float> Amount;

			public ConfigEntry<float> Life;

			public ConfigEntry<float> Speed;
		}

		private enum PreviewKind
		{
			None,
			Shot,
			Launch,
			Hit,
			Whirlpool
		}

		private sealed class Skin
		{
			public string Albedo;

			public string Emission;

			public Color EmissionColor = Color.black;

			public string MaterialFrom;
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		private static class NeckHits
		{
			private static void Prefix(HitData hit)
			{
				Character val = ((hit != null) ? hit.GetAttacker() : null);
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<NeckBond>() != (Object)null && MinionLife.IsActive(val))
				{
					((DamageTypes)(ref hit.m_damage)).Modify(1.8f);
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "BlockAttack")]
		private static class ShieldBlockPatch
		{
			private static void Postfix(Humanoid __instance, Character attacker, HitData hit, bool __result)
			{
				if (!__result || (Object)(object)attacker == (Object)null || hit == null || (Object)(object)Instance == (Object)null)
				{
					return;
				}
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer)
				{
					return;
				}
				ItemData val2 = CurrentBlocker((Humanoid)(object)val);
				if ((Object)(object)val2?.m_dropPrefab == (Object)null)
				{
					return;
				}
				string name = ((Object)val2.m_dropPrefab).name;
				if (name == "SeaShardStaff_RtD")
				{
					if (PerfectParry((Humanoid)(object)val, val2))
					{
						Instance.StaffParry(val, attacker, hit);
					}
				}
				else if (name == "SeaScaleShield_RtD" && !hit.m_ranged && _waveFrame != Time.frameCount)
				{
					Instance.BlockSplash(val, attacker);
				}
			}
		}

		[HarmonyPatch(typeof(Aoe), "Setup")]
		private static class AoeSetupPatch
		{
			private static void Postfix(Aoe __instance, Character owner, Vector3 velocity, float hitNoise, HitData hitData, ItemData item, ItemData ammo)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				Instance?.OnAoeSetup(__instance, owner, velocity, hitNoise, hitData, item, ammo);
			}
		}

		[HarmonyPatch(typeof(Attack), "GetAttackEitr", new Type[]
		{
			typeof(Character),
			typeof(ItemData)
		})]
		private static class SpinEitrPatch
		{
			private static void Postfix(Attack __instance, ItemData weapon, ref float __result)
			{
				if (!((Object)(object)__instance.m_spawnOnTrigger == (Object)null) && ((Object)__instance.m_spawnOnTrigger).name.StartsWith("SeaPoisonStaff_whirlpool") && weapon != null && !(weapon.m_shared.m_attack.m_attackEitr <= 0f))
				{
					__result *= __instance.m_attackEitr / weapon.m_shared.m_attack.m_attackEitr;
				}
			}
		}

		private const float NordMargin = 1.15f;

		private const decimal NordMarginExact = 1.15m;

		private const float NordSpearDamage = 170f;

		private const float NordSpearBlock = 66f;

		private const float NordSpearParry = 2f;

		private const float NordSpearDeflection = 20f;

		private const float NordShieldBlock = 132f;

		private const float NordShieldParry = 1.5f;

		private const float NordShieldDeflection = 50f;

		private const float StrikeStaffDamage = 300f;

		private const float StrikeStaffEitr = 40f;

		private const float StrikeStaffBlock = 48f;

		private const float StrikeStaffParry = 2f;

		private const float StrikeStaffDeflection = 20f;

		private const float NordCapeArmor = 12f;

		private const float NordCapeArmorPerLevel = 2f;

		private static readonly DamageTypes StaffMix = new DamageTypes
		{
			m_frost = 1f
		};

		private const string BeltName = "OceanBelt_RtD";

		private const int BeltFoodSlots = 3;

		internal const string DepthsName = "SeaShardDepths";

		internal const string WhirlFeedName = "SeaShardDepthsWhirl";

		internal const string ShoalFeedName = "SeaShardDepthsShoal";

		internal const string PuddleFeedName = "SeaShardDepthsPuddle";

		internal const string ParryFeedName = "SeaShardDepthsParry";

		internal const int DepthsStacks = 5;

		internal const float DepthsSlowPerStack = -0.06f;

		internal const float DepthsLife = 6f;

		internal const float DepthsImmunity = 3f;

		internal const float GeyserRadius = 3f;

		internal const float GeyserFrost = 56f;

		private const float FeedSlowLife = 1.5f;

		private const float ShoalFeedInterval = 2f;

		private const string GeyserName = "SeaShard_geyser";

		private const string GeyserSound = "sfx_watercastImpact_RtD_new";

		private SE_SeaDepths _depths;

		private readonly List<SE_DepthsFeed> _feeds = new List<SE_DepthsFeed>();

		private GameObject _geyser;

		private bool _resistLogged;

		private readonly Dictionary<string, GameObject> _heavyDrips = new Dictionary<string, GameObject>();

		private const float LabRebuildDelay = 0.3f;

		private static readonly Dictionary<FxPart, (string prefab, string child)> PartSources = new Dictionary<FxPart, (string, string)>
		{
			{
				FxPart.FoamMist,
				("fx_iceshard_launch", "smoke")
			},
			{
				FxPart.IceSmoke,
				("DvergerStaffIce_projectile", "smoke")
			},
			{
				FxPart.Glints,
				("StaffIceShards", null)
			},
			{
				FxPart.Glow,
				("StaffIceShards", "flare")
			},
			{
				FxPart.Halo,
				("StaffIceShards", "Particle System")
			},
			{
				FxPart.WaterPatches,
				("fx_float_hitwater", "vfx_water_surface")
			},
			{
				FxPart.WaterRing,
				("fx_float_hitwater", "ring")
			},
			{
				FxPart.WaterDust,
				("fx_float_hitwater", null)
			},
			{
				FxPart.WaterBurst,
				("WaterExplosionWandSOL_RtD", "WaterExplosionSmall")
			},
			{
				FxPart.WaterSpray,
				("WaterExplosionWandSOL_RtD", "WaterDroplets")
			},
			{
				FxPart.SpinningWater,
				("WaterAOESOL_RtD", "AuraSpinningWater")
			},
			{
				FxPart.WaveCircles,
				("WaterAOESOL_RtD", "WaveCircles")
			}
		};

		private static readonly HashSet<FxPart> SolidParts = new HashSet<FxPart> { FxPart.SerpentOrb };

		private const string LabSection = "Effect lab";

		private const int LabPreset = 3;

		private ConfigEntry<float> _fxIntensity;

		private readonly List<FxLayer> _layers = new List<FxLayer>();

		private readonly List<FxLayer> _shotLayers = new List<FxLayer>();

		private readonly List<FxLayer> _trailLayers = new List<FxLayer>();

		private readonly List<FxLayer> _launchLayers = new List<FxLayer>();

		private readonly List<FxLayer> _hitLayers = new List<FxLayer>();

		private readonly List<FxLayer> _whirlLayers = new List<FxLayer>();

		private ConfigEntry<float> _launchLight;

		private ConfigEntry<float> _hitLight;

		private ConfigEntry<float> _spiralTurn;

		private ConfigEntry<SpiralDirection> _spiralDirection;

		private readonly List<ConfigEntryBase> _labEntries = new List<ConfigEntryBase>();

		private ConfigEntry<LabLayer> _editLayer;

		private ConfigEntry<FxPart> _editPart;

		private ConfigEntry<Color> _editColour;

		private ConfigEntry<float> _editOpacity;

		private ConfigEntry<float> _editSize;

		private ConfigEntry<float> _editAmount;

		private ConfigEntry<float> _editLife;

		private ConfigEntry<float> _editSpeed;

		private ConfigEntry<bool> _previewOnChange;

		private ConfigEntry<KeyboardShortcut> _previewKey;

		private bool _syncing;

		private int _order = 1000;

		private Transform _shotVisual;

		private GameObject _orbBody;

		private Vector3 _orbScale = Vector3.one;

		private bool _shotDirty;

		private bool _releaseDirty;

		private bool _hitDirty;

		private bool _vortexDirty;

		private PreviewKind _changedKind;

		private PreviewKind _previewKind;

		private float _labChanged = -1f;

		private float _previewAt;

		private static readonly HashSet<string> EditorKeys = new HashSet<string> { "Part", "Colour", "Opacity", "Size", "Amount", "Life", "Speed" };

		private const string HarpoonName = "SeaShardSpear_RtD";

		private static readonly DamageTypes HarpoonMix = new DamageTypes
		{
			m_pierce = 160f,
			m_poison = 70f
		};

		private const float HarpoonPokeStamina = 16f;

		private const float HarpoonThrowStamina = 18f;

		private const float HarpoonDropChance = 0.05f;

		private const string BossName = "Belzor_RtD";

		private static readonly string[] HarpoonCarriers = new string[4] { "CatFish_RtD", "Reptile_RtD", "MirLizard_RtD", "MirRake_RtD" };

		private const float PreviewRange = 40f;

		private const float PreviewMissDistance = 25f;

		private const float PreviewFallbackSpeed = 30f;

		private static int _previewMask = -1;

		private static readonly Skin HarpoonSkin = new Skin
		{
			Albedo = "spear_albedo"
		};

		private static readonly Skin ShieldSkin = new Skin
		{
			Albedo = "shield_albedo"
		};

		private static readonly Skin CapeSkin = new Skin
		{
			Albedo = "cape_albedo",
			MaterialFrom = "CapeAsksvin"
		};

		private static readonly Skin BeltSkin = new Skin
		{
			Albedo = "belt_albedo"
		};

		private static readonly Skin NeckSkin = new Skin
		{
			Albedo = "neck_albedo",
			Emission = "neck_emission",
			EmissionColor = Color.white
		};

		private const string CapeName = "SeaFareCape_RtD";

		private const string NeckBody = "Visual/Body";

		private const string NeckPads = "Visual/Lillies";

		private readonly HashSet<Material> _painted = new HashSet<Material>();

		private static readonly string[] DescribedRelics = new string[5] { "SeaShardStaff_RtD", "SeaScaleShield_RtD", "SeaShardSpear_RtD", "SeaFareCape_RtD", "OceanBelt_RtD" };

		private const string NameColour = "<#20B2AA>";

		private const string NeckName = "NeckSummon_RtD";

		private const float NeckReserve = 60f;

		private const float NeckLife = 46f;

		private const int NeckQuality = 1;

		private const float NeckPower = 1.8f;

		private const float NeckLeash = 60f;

		private const float RecallReach = 60f;

		private const float RecallCone = 6f;

		private const float ClaimWindow = 15f;

		private const float BatchRadius = 2f;

		private const float NeckCommandLock = 0.6f;

		private const string MsgNoEitr = "$seashard_neck_no_eitr";

		private const string MsgDismissed = "$seashard_neck_dismissed";

		private static float _neckLockUntil;

		private static int _pendingNecks;

		private static float _pendingUntil;

		private static bool _batchSpawned;

		private const string ArriveName = "SeaShard_neckarrive";

		private const string ArriveSoundName = "SeaShard_neckarrive_sfx";

		private const string ArriveSoundSource = "sfx_serpent_idle";

		private const string RingSource = "fx_float_hitwater";

		private const float ArriveScale = 0.7f;

		private static readonly Color SeaTeal = new Color(0.11f, 0.73f, 0.69f);

		private static readonly Color SeaFoam = new Color(0.47f, 0.88f, 0.82f);

		private GameObject _arrive;

		private GameObject _arriveSound;

		private GameObject _dismissFx;

		public const string Guid = "groshyr.seashardarsenal";

		public const string ModName = "SeaShardArsenal";

		public const string Version = "1.11.0";

		private const string PovGuid = "treextr.pathofvalheiman";

		private const string OldConfigFile = "groshyr.seapoisonstafffx.cfg";

		internal static Plugin Instance;

		private const string StaffName = "SeaShardStaff_RtD";

		private const string SourceProjectile = "projectile_serpent_green_RtD";

		private const string CloneName = "SeaPoisonStaff_projectile";

		private const string CastPuffSource = "fx_float_hitwater";

		private const string CastPuffName = "SeaPoisonStaff_castpuff";

		private const string ReleaseSource = "fx_iceshard_launch";

		private const string ReleaseName = "SeaPoisonStaff_release";

		private const string WaterSplashEffect = "fx_float_hitwater";

		private const string FlightSoundSource = "staff_OrbofAhri_projectile";

		private const string FlightSoundChild = "sfx_stafforbofahri_projectile_loop";

		private const string HeadFxSource = "StaffIceShards";

		private const string StaffMeshPath = "attach/default";

		private static readonly Vector3 StaffHeadPosition = new Vector3(0f, 1.66f, 0f);

		private const float HeadLightIntensity = 0.9f;

		private const float HeadLightRange = 2.5f;

		private const float HeadFlareAlpha = 0.45f;

		private const string HeadMistSource = "fx_float_hitwater";

		private const float HeadMistRate = 1.5f;

		private static readonly Color HeadSparkColour = new Color(0.47f, 0.88f, 0.82f);

		private const float HitCloudScale = 0.3f;

		private static readonly Dictionary<GlowPreset, string> GlowSources = new Dictionary<GlowPreset, string>
		{
			{
				GlowPreset.Morkhalla,
				"BlobMork"
			},
			{
				GlowPreset.SeaSerpent,
				"projectile_serpent_green_RtD"
			},
			{
				GlowPreset.SeaCrystal,
				"SeaCrystal_RtD"
			},
			{
				GlowPreset.Guck,
				"GuckSack"
			},
			{
				GlowPreset.Wisp,
				"Wisp"
			}
		};

		private static readonly FieldRef<ZNetScene, Dictionary<int, GameObject>> NamedPrefabs = AccessTools.FieldRefAccess<ZNetScene, Dictionary<int, GameObject>>("m_namedPrefabs");

		private ConfigEntry<string> _castSounds;

		private ConfigEntry<string> _hitSounds;

		private ConfigEntry<bool> _flightSound;

		private ConfigEntry<float> _flightVolume;

		private ConfigEntry<GlowPreset> _glow;

		private ConfigEntry<bool> _headGlow;

		private GameObject _holder;

		private GameObject _clone;

		private GameObject _castPuff;

		private GameObject _release;

		private GameObject _hitVisual;

		private Light _glowSource;

		private bool _staffPatched;

		private readonly HashSet<string> _warned = new HashSet<string>();

		private const Biome RelicLand = (Biome)32;

		private static readonly HashSet<string> Relics = new HashSet<string> { "SeaShardStaff_RtD", "SeaShardWand_RtD", "SeaShardSpear_RtD", "SeaScaleShield_RtD", "SeaFareCape_RtD", "OceanBelt_RtD" };

		private const string PuddleSource = "WaterAOESOL_RtD";

		private const string PuddleName = "SeaPoisonStaff_puddle";

		private const int PuddleCount = 2;

		private const float PuddleRadius = 2f;

		private const float PuddleLifetime = 6f;

		private const float PuddleSpreadMin = 0.8f;

		private const float PuddleSpreadMax = 2.5f;

		private const float PuddleWaterAlpha = 0.4f;

		private const float PrimaryEitr = 13f;

		private const float PrimaryStamina = 22f;

		private const float SlowLightSpeed = -0.3f;

		private GameObject _puddle;

		private const string ShieldName = "SeaScaleShield_RtD";

		private const float ShieldMove = -0.05f;

		private const string ParryWaveName = "SeaShard_parrywave";

		private const string ParryEffectName = "SeaShardParryWave";

		private const string ParrySlowName = "SeaShardParrySlowed";

		private const float ParryRadius = 3f;

		private const float ParryPoison = 30f;

		private const float ParrySlowLifetime = 2f;

		private const float ParryCooldown = 5f;

		private const float ParryWaveLife = 1.2f;

		private const float ParryPush = 80f;

		private const string ParrySplashSource = "WaterExplosionWandSOL_RtD";

		private const string BlockSplashName = "SeaShard_blocksplash";

		private const float BlockSplashScale = 0.6f;

		private const float BlockSplashCooldown = 1f;

		private const float BlockSplashReach = 5f;

		private static readonly Func<Humanoid, ItemData> CurrentBlocker = AccessTools.MethodDelegate<Func<Humanoid, ItemData>>(AccessTools.Method(typeof(Humanoid), "GetCurrentBlocker", (Type[])null, (Type[])null), (object)null, true);

		private GameObject _blockSplash;

		private float _lastBlockSplash = -100f;

		private static int _waveFrame = -1;

		private GameObject _parryWave;

		private ParryWaveEffect _parryEffect;

		private SE_Stats _parrySlow;

		private static float _lastParryWave = -100f;

		private const string SphereName = "SeaShardWand_RtD";

		private const string SphereSource = "StaffFrostOrbs";

		internal const string SphereStatusName = "SeaShard_TideSphere";

		private const string SphereCastName = "SeaShard_tidesphere_cast";

		private const string SphereWaveName = "SeaShard_tidesphere_wave";

		private const string SphereVisualName = "SeaShard_tidesphere_visual";

		internal const float SphereLifetime = 69f;

		internal const float SphereMinDamage = 0f;

		internal const int SphereMaxCharges = 5;

		internal const float SphereChargeDecay = 4f;

		private const float SphereWaveRadius = 5f;

		private const float SphereWaveDamage = 88.549995f;

		private bool _spherePatched;

		private Aoe _sphereCast;

		private GameObject _sphereWave;

		private GameObject _sphereVisual;

		private TideSphereEffect _sphereStatus;

		private bool _sphereModelBuilt;

		private static readonly Color TideColour = new Color(0.16f, 0.48f, 0.39f, 0.24f);

		private static readonly Color CrystalColour = new Color(0.72f, 0.95f, 0.95f);

		private const float StaffParryPush = 60f;

		private const float StaffParryReach = 5f;

		private const float StaffParryCooldown = 1f;

		private static readonly Vector3 GuardOffset = new Vector3(0f, 1.05f, 0.8f);

		private static readonly FieldRef<Humanoid, float> BlockTimer = AccessTools.FieldRefAccess<Humanoid, float>("m_blockTimer");

		private GameObject _waterGuard;

		private float _lastStaffParry = -100f;

		private const int RenderSize = 512;

		private const int IconSize = 128;

		private const float IconTilt = 8f;

		private const float IconEmissionFactor = 0.35f;

		private const float IconDesaturate = 0.35f;

		private const float IconDarken = 0.85f;

		private const float CropShare = 0.5f;

		private const float CropTopMargin = 0.06f;

		private const float HeadBand = 0.3f;

		private const float HaloRadius = 0.5f;

		private const float HaloAlpha = 0.9f;

		private const float HaloWhiten = 0.2f;

		private const int Sparkles = 18;

		private const int SparkleSeed = 7;

		private ConfigEntry<bool> _customIcon;

		private const string StaffModelSource = "StaffGreenRoots";

		private const string StaffMaterial = "TentacleStaff_mat";

		private const string StaffGlowMaterial = "TentacleStaff_Glow_Mat";

		private static readonly Color HelmGlow = new Color(0.11f, 0.73f, 0.69f, 0.75f);

		private static readonly Dictionary<string, Texture2D> LoadedTextures = new Dictionary<string, Texture2D>();

		private const string WhirlpoolSource = "WaterAOESOL_RtD";

		private const string WhirlpoolName = "SeaPoisonStaff_whirlpool";

		private const string ShoalName = "SeaPoisonStaff_shoal";

		private const string FlatAuraPart = "FlatColor";

		private const string WaveCirclesPart = "WaveCircles";

		private const string TrailSource = "AtgeirIron";

		private const float TrailLifetime = 0.35f;

		private const float TrailAlpha = 0.35f;

		private const float WaterAlpha = 0.35f;

		private const float ShoalAlpha = 0.25f;

		private const float RingAlpha = 0.4f;

		private const float RingWidth = 0.08f;

		private const string WhirlOpenSound = "sfx_watercastAOE_RtD_new";

		private const string WhirlCloseSound = "sfx_watercastImpact_RtD_new";

		private const float SpinScale = 1.5f;

		private const float SpinEitr = 30f;

		private const float SpinStamina = 33f;

		private const float ShoalLifetime = 8f;

		internal const float WhirlRange = 25f;

		internal const float EbbRadius = 3f;

		internal const float PullStep = 1.5f;

		internal const float PullHold = 1f;

		private const string SlowSource = "Slimed";

		private const string SlowBossName = "SeaPoisonSlowedBoss";

		private const float SlowSpeed = -0.5f;

		private const float SlowBossSpeed = -0.2f;

		private const float SlowLifetime = 1.5f;

		private static readonly Vector3 TrailBase = new Vector3(0f, 1.3f, 0f);

		private static readonly Vector3 TrailTip = new Vector3(0f, 2f, 0f);

		private static readonly Color FallbackGlow = new Color(0.11f, 0.73f, 0.69f);

		private static readonly Color FallbackPoison = new Color(0.52f, 1f, 0.19f);

		private static readonly HashSet<string> WaterParts = new HashSet<string> { "AuraSpinningWater", "WaterSplash" };

		private static readonly FieldRef<MeleeWeaponTrail, Material> TrailMaterial = AccessTools.FieldRefAccess<MeleeWeaponTrail, Material>("_material");

		private static readonly FieldRef<MeleeWeaponTrail, Color[]> TrailColours = AccessTools.FieldRefAccess<MeleeWeaponTrail, Color[]>("_colors");

		private static readonly FieldRef<MeleeWeaponTrail, float> TrailLife = AccessTools.FieldRefAccess<MeleeWeaponTrail, float>("_lifeTime");

		private static readonly FieldRef<MeleeWeaponTrail, Transform> TrailBaseRef = AccessTools.FieldRefAccess<MeleeWeaponTrail, Transform>("_base");

		private static readonly FieldRef<MeleeWeaponTrail, Transform> TrailTipRef = AccessTools.FieldRefAccess<MeleeWeaponTrail, Transform>("_tip");

		private ConfigEntry<string> _spinSounds;

		private ConfigEntry<string> _spinImpactSounds;

		private ConfigEntry<bool> _spinTrail;

		private ConfigEntry<bool> _spinRing;

		private ConfigEntry<float> _brightness;

		private GameObject _whirlpool;

		private GameObject _shoal;

		private GameObject _spinBurst;

		private GameObject _ebb;

		private readonly List<Character> _spinTargets = new List<Character>();

		private SE_Stats _slowBoss;

		private static int _aimMask = -1;

		private float Fx => Mathf.Clamp(_fxIntensity.Value, 0.5f, 2f);

		private FxLayer EditedLayer => _layers[Mathf.Clamp((int)_editLayer.Value, 0, _layers.Count - 1)];

		private static int PreviewMask
		{
			get
			{
				if (_previewMask == -1)
				{
					return _previewMask = LayerMask.GetMask(new string[11]
					{
						"Default", "static_solid", "Default_small", "piece", "terrain", "vehicle", "character", "character_net", "character_ghost", "character_noenv",
						"hitbox"
					});
				}
				return _previewMask;
			}
		}

		private static float ShieldBlock => Above(132f);

		private static float ShieldParry => AboveFine(1.5f);

		private static float ShieldDeflection => Above(50f);

		private float Brightness => Mathf.Clamp(_brightness.Value, 0f, 2f);

		private static int AimMask
		{
			get
			{
				if (_aimMask == -1)
				{
					return _aimMask = LayerMask.GetMask(new string[11]
					{
						"Default", "static_solid", "Default_small", "piece", "terrain", "vehicle", "character", "character_net", "character_ghost", "character_noenv",
						"hitbox"
					});
				}
				return _aimMask;
			}
		}

		private static float Above(float nord)
		{
			return (float)Math.Round((decimal)nord * 1.15m, 0, MidpointRounding.AwayFromZero);
		}

		private static float AboveFine(float nord)
		{
			return (float)Math.Round((decimal)nord * 1.15m, 2, MidpointRounding.AwayFromZero);
		}

		private static DamageTypes Split(float total, DamageTypes mix)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			float scale = total / ((DamageTypes)(ref mix)).GetTotalDamage();
			return new DamageTypes
			{
				m_blunt = Part(mix.m_blunt),
				m_pierce = Part(mix.m_pierce),
				m_lightning = Part(mix.m_lightning),
				m_frost = Part(mix.m_frost),
				m_poison = Part(mix.m_poison)
			};
			float Part(float share)
			{
				return Mathf.Floor(share * scale + 0.5f);
			}
		}

		private static string Describe(DamageTypes d)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			return $"{((DamageTypes)(ref d)).GetTotalDamage():0} (blunt {d.m_blunt:0}, pierce {d.m_pierce:0}, lightning {d.m_lightning:0}, frost {d.m_frost:0}, poison {d.m_poison:0})";
		}

		private void ApplyStaffAndCapeBalance(ObjectDB db)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			GameObject itemPrefab = db.GetItemPrefab("SeaShardStaff_RtD");
			SharedData val = ((itemPrefab == null) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData.m_shared);
			if (val != null)
			{
				val.m_damages = StaffMix;
				((DamageTypes)(ref val.m_damages)).Modify(Mathf.Round(112.125f));
				val.m_damagesPerLevel = default(DamageTypes);
				val.m_blockPower = Above(48f);
				val.m_timedBlockBonus = AboveFine(2f);
				val.m_deflectionForce = Above(20f);
			}
			GameObject itemPrefab2 = db.GetItemPrefab("SeaFareCape_RtD");
			SharedData val2 = ((itemPrefab2 == null) ? null : itemPrefab2.GetComponent<ItemDrop>()?.m_itemData.m_shared);
			if (val2 != null)
			{
				val2.m_armor = Above(12f);
				val2.m_armorPerLevel = AboveFine(2f);
			}
		}

		private void RegisterBelt()
		{
			try
			{
				EquipmentApi.RegisterBelt("OceanBelt_RtD", 3);
				((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0}: {1} food slots in the Path of Valheiman belt", "OceanBelt_RtD", 3));
			}
			catch (Exception ex)
			{
				WarnOnce("OceanBelt_RtD", "belt food slots not registered: " + ex.Message);
			}
		}

		private void EnsureGeyser(ZNetScene scene)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_geyser != (Object)null) && !((Object)(object)_blockSplash == (Object)null))
			{
				_geyser = Object.Instantiate<GameObject>(_blockSplash, Holder().transform, false);
				((Object)_geyser).name = "SeaShard_geyser";
				ScaleEffect(_geyser, 1.6666666f);
				ParticleSystem[] componentsInChildren = _geyser.GetComponentsInChildren<ParticleSystem>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					MainModule main = componentsInChildren[i].main;
					((MainModule)(ref main)).startSpeedMultiplier = ((MainModule)(ref main)).startSpeedMultiplier * 1.6f;
				}
				string text = AddSound(scene, _geyser, "sfx_watercastImpact_RtD_new");
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Created SeaShard_geyser: RtD water burst at native size, sound " + text));
			}
		}

		private string AddSound(ZNetScene scene, GameObject parent, string name)
		{
			GameObject val = Find(scene, name);
			if ((Object)(object)val == (Object)null)
			{
				WarnOnce(name, "sound not found, skipped");
				return "missing";
			}
			foreach (Component item in (from c in CopyChild(val, parent.transform).GetComponentsInChildren<Component>(true)
				where c is ZNetView || c is ZSyncTransform
				select c).ToList())
			{
				Object.DestroyImmediate((Object)(object)item);
			}
			return name;
		}

		private void EnsureDepthEffects(ObjectDB db)
		{
			if ((Object)(object)_depths == (Object)null)
			{
				_depths = ScriptableObject.CreateInstance<SE_SeaDepths>();
				((Object)_depths).name = "SeaShardDepths";
				((StatusEffect)_depths).m_name = "$seashard_depths";
				((StatusEffect)_depths).m_ttl = 6f;
				((Object)_depths).hideFlags = (HideFlags)32;
				string text = DressDepths(db, _depths);
				_feeds.Add(MakeFeed("SeaShardDepthsWhirl", -0.5f, -0.2f, 1, 0f));
				_feeds.Add(MakeFeed("SeaShardDepthsShoal", -0.5f, -0.2f, 1, 2f));
				_feeds.Add(MakeFeed("SeaShardDepthsPuddle", -0.3f, -0.2f, 1, 0f));
				_feeds.Add(MakeFeed("SeaShardDepthsParry", 0f, 0f, 2, 0f));
				((BaseUnityPlugin)this).Logger.LogInfo((object)(string.Format("Status {0}: up to {1} stacks, {2:P0} speed each, {3} s after the last hit; ", "SeaShardDepths", 5, -0.06f, 6f) + $"at {5}: geyser {56f} frost x Elemental Magic within {3f} m + stagger, then {3f} s " + "without stacks; drips: " + text + "; feeders: " + string.Join(", ", _feeds.Select((SE_DepthsFeed f) => $"{((Object)f).name} ({((SE_Stats)f).m_speedModifier:P0}, +{f.m_count}" + ((f.m_interval > 0f) ? $" per {f.m_interval} s)" : ")")))));
			}
			foreach (StatusEffect item in new List<StatusEffect> { (StatusEffect)(object)_depths }.Concat((IEnumerable<StatusEffect>)_feeds))
			{
				if ((Object)(object)db.GetStatusEffect(StringExtensionMethods.GetStableHashCode(((Object)item).name)) == (Object)null)
				{
					db.m_StatusEffects.Add(item);
				}
			}
		}

		private static SE_DepthsFeed MakeFeed(string name, float slow, float bossSlow, int count, float interval)
		{
			SE_DepthsFeed sE_DepthsFeed = ScriptableObject.CreateInstance<SE_DepthsFeed>();
			((Object)sE_DepthsFeed).name = name;
			((StatusEffect)sE_DepthsFeed).m_ttl = 1.5f;
			((SE_Stats)sE_DepthsFeed).m_speedModifier = slow;
			sE_DepthsFeed.m_bossSlow = bossSlow;
			sE_DepthsFeed.m_count = count;
			sE_DepthsFeed.m_interval = interval;
			((Object)sE_DepthsFeed).hideFlags = (HideFlags)32;
			return sE_DepthsFeed;
		}

		private string DressDepths(ObjectDB db, SE_SeaDepths depths)
		{
			StatusEffect statusEffect = db.GetStatusEffect(SEMan.s_statusEffectWet);
			EffectData[] array = (((Object)(object)statusEffect != (Object)null) ? statusEffect.m_startEffects.m_effectPrefabs.Where((EffectData e) => (Object)(object)e?.m_prefab != (Object)null).ToArray() : null);
			if (array == null || array.Length == 0)
			{
				WarnOnce("wet", "Wet status effects not found, the stacks show no drips");
				return "none";
			}
			depths.m_light = array.Select((EffectData e) => CopyEffect(e, e.m_prefab)).ToArray();
			depths.m_heavy = array.Select((EffectData e) => CopyEffect(e, HeavyDrips(e.m_prefab))).ToArray();
			return string.Join(", ", array.Select((EffectData e) => ((Object)e.m_prefab).name)) + " (x2.5 from 3 stacks)";
		}

		private static EffectData CopyEffect(EffectData e, GameObject prefab)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			return new EffectData
			{
				m_prefab = prefab,
				m_enabled = true,
				m_variant = -1,
				m_attach = e.m_attach,
				m_follow = e.m_follow,
				m_inheritParentRotation = e.m_inheritParentRotation,
				m_inheritParentScale = e.m_inheritParentScale,
				m_multiplyParentVisualScale = e.m_multiplyParentVisualScale,
				m_randomRotation = e.m_randomRotation,
				m_scale = e.m_scale,
				m_childTransform = e.m_childTransform
			};
		}

		private GameObject HeavyDrips(GameObject source)
		{
			//IL_005f: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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)
			if (_heavyDrips.TryGetValue(((Object)source).name, out var value))
			{
				return value;
			}
			value = Object.Instantiate<GameObject>(source, Holder().transform, false);
			((Object)value).name = ((Object)source).name + "_SeaShardHeavy";
			ParticleSystem[] componentsInChildren = value.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem obj in componentsInChildren)
			{
				TintSea(obj, new Color(0.35f, 0.62f, 0.82f), 1.3f);
				EmissionModule emission = obj.emission;
				((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((EmissionModule)(ref emission)).rateOverTimeMultiplier * 2.5f;
				MainModule main = obj.main;
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt((float)((MainModule)(ref main)).maxParticles * 2.5f);
			}
			_heavyDrips[((Object)source).name] = value;
			if ((Object)(object)ZNetScene.instance != (Object)null && (Object)(object)value.GetComponent<ZNetView>() != (Object)null)
			{
				Register(ZNetScene.instance, value);
			}
			return value;
		}

		internal static void Geyser(Character target, Character caster, float skillLevel)
		{
			//IL_001f: 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_006d: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			Plugin instance = Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)target == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)target).transform.position;
			if ((Object)(object)instance._geyser != (Object)null)
			{
				Object.Instantiate<GameObject>(instance._geyser, position, Quaternion.identity);
			}
			float frost = 56f * Mathf.Lerp(0.4f, 1f, Mathf.Clamp01(skillLevel / 100f));
			List<Character> list = new List<Character>();
			Character.GetCharactersInRange(position, 3f, list);
			foreach (Character item in list)
			{
				if ((Object)(object)item == (Object)null || item.IsDead() || (Object)(object)item == (Object)(object)caster)
				{
					continue;
				}
				bool num;
				if (!((Object)(object)caster != (Object)null))
				{
					if (item.IsPlayer())
					{
						continue;
					}
					num = item.IsTamed();
				}
				else
				{
					num = !BaseAI.IsEnemy(caster, item);
				}
				if (!num)
				{
					Vector3 val = ((Component)item).transform.position - position;
					val.y = 0f;
					HitData val2 = new HitData
					{
						m_point = item.GetCenterPoint(),
						m_dir = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.up),
						m_skill = (SkillType)9,
						m_skillLevel = skillLevel,
						m_hitType = (HitType)((!(caster is Player)) ? 1 : 2),
						m_blockable = false,
						m_dodgeable = false,
						m_ranged = true
					};
					val2.m_damage.m_frost = frost;
					if ((Object)(object)caster != (Object)null)
					{
						val2.SetAttacker(caster);
					}
					item.Damage(val2);
					if (!item.IsBoss())
					{
						item.Stagger(val2.m_dir);
					}
				}
			}
		}

		private void LogFrostResistance(ZNetScene scene)
		{
			//IL_0056: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (_resistLogged)
			{
				return;
			}
			_resistLogged = true;
			SortedDictionary<DamageModifier, List<string>> sortedDictionary = new SortedDictionary<DamageModifier, List<string>>();
			foreach (GameObject prefab in scene.m_prefabs)
			{
				Character val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Character>() : null);
				if ((Object)(object)val == (Object)null || val is Player)
				{
					continue;
				}
				DamageModifier frost = val.m_damageModifiers.m_frost;
				if ((int)frost != 0)
				{
					if (!sortedDictionary.TryGetValue(frost, out var value))
					{
						value = (sortedDictionary[frost] = new List<string>());
					}
					value.Add(((Object)prefab).name);
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Frost resistance of creatures (others take normal frost damage): " + string.Join("; ", sortedDictionary.Select((KeyValuePair<DamageModifier, List<string>> g) => string.Format("{0} ({1}): {2}", g.Key, g.Value.Count, string.Join(", ", g.Value.OrderBy((string n) => n)))))));
		}

		private void BindFxConfig()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Expected O, but got Unknown
			_fxIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "Effects intensity", 1f, new ConfigDescription("Density and opacity of the block curtain, the whirlpool's water column and its foam ring: 0.5 = subtle, 2 = twice as strong. The shot, trail, launch, impact and whirlpool are set in the Effect lab section. Read at game start.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
			_shotLayers.Add(BindLayer("Shot", 1, FxPart.SerpentOrb, "6FC6E0FF", 1f, 0f, 0f, 0f, 0f));
			_shotLayers.Add(BindLayer("Shot", 2, FxPart.FoamMist, "A0EADFFF", 1.2f, 0.35f, 25f, 0.3f, 0.1f));
			_shotLayers.Add(BindLayer("Shot", 3, FxPart.WaterSpray, "B8E6F2FF", 1f, 0.12f, 20f, 0.35f, 0.6f));
			_shotLayers.Add(BindLayer("Shot", 4, FxPart.Glints, "D6F4FAFF", 0.7f, 0.1f, 10f, 0.3f, 0.2f));
			_trailLayers.Add(BindLayer("Trail", 1, FxPart.FoamMist, "78E0D1FF", 2.5f, 0.5f, 60f, 0.25f, 0.15f));
			_trailLayers.Add(BindLayer("Trail", 2, FxPart.WaterSpray, "B8E6F2FF", 1f, 0.08f, 30f, 0.5f, 0.3f));
			_launchLayers.Add(BindLayer("Launch", 1, FxPart.FoamMist, "78E0D1FF", 3f, 0.6f, 4f, 0.35f, 1.4f));
			_launchLayers.Add(BindLayer("Launch", 2, FxPart.WaterSpray, "B8E6F2FF", 0.9f, 0.12f, 14f, 0.35f, 5f));
			_launchLayers.Add(BindLayer("Launch", 3, FxPart.WaterRing, "78E0D1FF", 0.6f, 1.2f, 1f, 0.5f, 0f));
			_hitLayers.Add(BindLayer("Hit", 1, FxPart.WaterBurst, "9FDCEBFF", 1f, 0f, 0f, 0f, 0f));
			_hitLayers.Add(BindLayer("Hit", 2, FxPart.WaterRing, "78E0D1FF", 0.6f, 1.6f, 1f, 0.4f, 0f));
			_hitLayers.Add(BindLayer("Hit", 3, FxPart.WaterSpray, "B8E6F2FF", 1f, 0.12f, 18f, 0.5f, 5f));
			_whirlLayers.Add(BindLayer("Whirlpool", 1, FxPart.FoamMist, "A0EADFFF", 2.3f, 1.2f, 80f, 1.7f, 3.2f));
			_whirlLayers.Add(BindLayer("Whirlpool", 2, FxPart.SpinningWater, "78C8E0FF", 0.8f, 0f, 30f, 1.5f, 2.5f));
			_whirlLayers.Add(BindLayer("Whirlpool", 3, FxPart.WaterPatches, "78E0D1FF", 0.6f, 2.2f, 14f, 1.5f, 1.2f));
			_layers.AddRange(_shotLayers.Concat(_trailLayers).Concat(_launchLayers).Concat(_hitLayers)
				.Concat(_whirlLayers));
			_editLayer = ((BaseUnityPlugin)this).Config.Bind<LabLayer>("Effect lab", "Layer", LabLayer.Shot1, Visible("Which layer the fields below show and change: Shot 1-4 fly with the shot, Trail 1-2 stay behind it, Launch 1-3 at the staff head, Hit 1-3 where it hits, Whirlpool 1-3 in the whirlpool. Picking a layer plays its effect.", null));
			_editPart = ((BaseUnityPlugin)this).Config.Bind<FxPart>("Effect lab", "Part", FxPart.None, Field("What the layer shows (None = nothing). The solid SerpentOrb (the water orb) only works on the shot.", null));
			_editColour = ((BaseUnityPlugin)this).Config.Bind<Color>("Effect lab", "Colour", Color.white, Field("Colour of the part.", null));
			_editOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Effect lab", "Opacity", 1f, Field("Multiplies the part's own opacity (1 = original, 2 = twice as opaque). For solid models: glow strength.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 6f)));
			_editSize = ((BaseUnityPlugin)this).Config.Bind<float>("Effect lab", "Size", 0f, Field("Particle size in metres; for solid models, their scale. 0 = as in the original part.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 8f)));
			_editAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Effect lab", "Amount", 0f, Field("Particles per second on the shot, trail and whirlpool; per burst on the launch and impact. 0 = as in the original part.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f)));
			_editLife = ((BaseUnityPlugin)this).Config.Bind<float>("Effect lab", "Life", 0f, Field("How long each particle lives, in seconds. 0 = as in the original part.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 6f)));
			_editSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Effect lab", "Speed", 0f, Field("Particle speed in m/s: how far a burst flies; on the whirlpool, how fast it runs out or in. 0 = as in the original part.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f)));
			_launchLight = ((BaseUnityPlugin)this).Config.Bind<float>("Effect lab", "Launch light", 1.6f, Visible("Brightness of the short teal light at the staff head (0 = none).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f)));
			_hitLight = ((BaseUnityPlugin)this).Config.Bind<float>("Effect lab", "Hit light", 1.4f, Visible("Brightness of the short teal light where the shot hits (0 = none).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f)));
			_spiralDirection = ((BaseUnityPlugin)this).Config.Bind<SpiralDirection>("Effect lab", "Whirlpool spiral", SpiralDirection.Inward, Visible("Inward = the whirlpool layers are born at its edge and drawn to its centre; Outward = born at the centre and carried to the edge; Still = spread over the whole whirlpool, only turning.", null));
			_spiralTurn = ((BaseUnityPlugin)this).Config.Bind<float>("Effect lab", "Whirlpool turn speed", 2.4f, Visible("How fast the whirlpool layers circle its centre, in radians per second (6.3 = one turn a second).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 8f)));
			_previewOnChange = ((BaseUnityPlugin)this).Config.Bind<bool>("Effect lab", "Preview on change", true, Visible("Play the edited effect in front of you after every change: the shot flies where you look (no damage, no eitr), the whirlpool opens where you aim.", null));
			_previewKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Effect lab", "Preview key", new KeyboardShortcut((KeyCode)292, Array.Empty<KeyCode>()), Visible("Plays the effect of the selected layer again.", null));
			_labEntries.AddRange((IEnumerable<ConfigEntryBase>)(object)new ConfigEntryBase[4]
			{
				(ConfigEntryBase)_launchLight,
				(ConfigEntryBase)_hitLight,
				(ConfigEntryBase)_spiralDirection,
				(ConfigEntryBase)_spiralTurn
			});
			ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("Lab", "Preset", 0, new ConfigDescription("Set by the mod: the effect set your lab values come from. A newer set from the mod replaces them once.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = false
				}
			}));
			if (val.Value < 3)
			{
				foreach (ConfigEntryBase labEntry in _labEntries)
				{
					labEntry.BoxedValue = labEntry.DefaultValue;
				}
				val.Value = 3;
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Effect lab: set {3} from the mod applied");
			}
			LoadEditor();
			_editLayer.SettingChanged += delegate
			{
				LoadEditor();
				RequestPreview(KindOf(_editLayer.Value));
			};
			_launchLight.SettingChanged += delegate
			{
				MarkLab(PreviewKind.Launch);
			};
			_hitLight.SettingChanged += delegate
			{
				MarkLab(PreviewKind.Hit);
			};
			_spiralDirection.SettingChanged += delegate
			{
				MarkLab(PreviewKind.Whirlpool);
			};
			_spiralTurn.SettingChanged += delegate
			{
				MarkLab(PreviewKind.Whirlpool);
			};
			((BaseUnityPlugin)this).Config.SettingChanged += delegate(object _, SettingChangedEventArgs args)
			{
				ConfigDefinition definition = args.ChangedSetting.Definition;
				string section = definition.Section;
				if (section == "Effect lab")
				{
					if (EditorKeys.Contains(definition.Key))
					{
						StoreEditor();
					}
				}
				else if (section.StartsWith("Lab Shot") || section.StartsWith("Lab Trail"))
				{
					MarkLab(PreviewKind.Shot);
				}
				else if (section.StartsWith("Lab Launch"))
				{
					MarkLab(PreviewKind.Launch);
				}
				else if (section.StartsWith("Lab Hit"))
				{
					MarkLab(PreviewKind.Hit);
				}
				else if (section.StartsWith("Lab Whirlpool"))
				{
					MarkLab(PreviewKind.Whirlpool);
				}
			};
		}

		private ConfigDescription Visible(string description, AcceptableValueBase range)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			return new ConfigDescription(description, range, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = _order--
				}
			});
		}

		private ConfigDescription Field(string description, AcceptableValueBase range)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			return new ConfigDescription(description + " Changes the layer picked in Layer.", range, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = _order--,
					HideDefaultButton = true
				}
			});
		}

		private FxLayer BindLayer(string slot, int index, FxPart part, string rgba, float opacity, float size, float amount, float life, float speed)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			string text = $"Lab {slot} {index}";
			FxLayer fxLayer = new FxLayer
			{
				Name = $"{slot} {index}",
				Part = ((BaseUnityPlugin)this).Config.Bind<FxPart>(text, "Part", part, Hidden()),
				Colour = ((BaseUnityPlugin)this).Config.Bind<Color>(text, "Colour", Hex(rgba), Hidden()),
				Opacity = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Opacity", opacity, Hidden()),
				Size = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Size", size, Hidden()),
				Amount = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Amount", amount, Hidden()),
				Life = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Life", life, Hidden()),
				Speed = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Speed", speed, Hidden())
			};
			_labEntries.AddRange((IEnumerable<ConfigEntryBase>)(object)new ConfigEntryBase[7]
			{
				(ConfigEntryBase)fxLayer.Part,
				(ConfigEntryBase)fxLayer.Colour,
				(ConfigEntryBase)fxLayer.Opacity,
				(ConfigEntryBase)fxLayer.Size,
				(ConfigEntryBase)fxLayer.Amount,
				(ConfigEntryBase)fxLayer.Life,
				(ConfigEntryBase)fxLayer.Speed
			});
			return fxLayer;
			static ConfigDescription Hidden()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Expected O, but got Unknown
				return new ConfigDescription("Stored lab layer; edit it in the Effect lab section.", (AcceptableValueBase)null, new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Browsable = false
					}
				});
			}
		}

		private static Color Hex(string rgba)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			ColorUtility.TryParseHtmlString("#" + rgba, ref result);
			return result;
		}

		private static PreviewKind KindOf(LabLayer layer)
		{
			if (layer > LabLayer.Trail2)
			{
				if (layer > LabLayer.Launch3)
				{
					if (layer > LabLayer.Hit3)
					{
						return PreviewKind.Whirlpool;
					}
					return PreviewKind.Hit;
				}
				return PreviewKind.Launch;
			}
			return PreviewKind.Shot;
		}

		private void LoadEditor()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			FxLayer editedLayer = EditedLayer;
			_syncing = true;
			try
			{
				_editPart.Value = editedLayer.Part.Value;
				_editColour.Value = editedLayer.Colour.Value;
				_editOpacity.Value = editedLayer.Opacity.Value;
				_editSize.Value = editedLayer.Size.Value;
				_editAmount.Value = editedLayer.Amount.Value;
				_editLife.Value = editedLayer.Life.Value;
				_editSpeed.Value = editedLayer.Speed.Value;
			}
			finally
			{
				_syncing = false;
			}
		}

		private void StoreEditor()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!_syncing)
			{
				FxLayer editedLayer = EditedLayer;
				editedLayer.Part.Value = _editPart.Value;
				editedLayer.Colour.Value = _editColour.Value;
				editedLayer.Opacity.Value = _editOpacity.Value;
				editedLayer.Size.Value = _editSize.Value;
				editedLayer.Amount.Value = _editAmount.Value;
				editedLayer.Life.Value = _editLife.Value;
				editedLayer.Speed.Value = _editSpeed.Value;
			}
		}

		private void MarkLab(PreviewKind kind)
		{
			_shotDirty |= kind == PreviewKind.Shot;
			_releaseDirty |= kind == PreviewKind.Launch;
			_hitDirty |= kind == PreviewKind.Hit;
			_vortexDirty |= kind == PreviewKind.Whirlpool;
			_changedKind = kind;
			_labChanged = Time.unscaledTime;
		}

		private void RequestPreview(PreviewKind kind)
		{
			_previewKind = kind;
			_previewAt = Time.unscaledTime + 0.3f;
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = _previewKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				RequestPreview(KindOf(_editLayer.Value));
			}
			if (_labChanged >= 0f && Time.unscaledTime - _labChanged >= 0.3f)
			{
				_labChanged = -1f;
				RebuildLab();
			}
			if (_previewKind != PreviewKind.None && _labChanged < 0f && Time.unscaledTime >= _previewAt)
			{
				PreviewKind previewKind = _previewKind;
				_previewKind = PreviewKind.None;
				Preview(previewKind);
			}
			if (!_resistLogged && (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)ZNetScene.instance != (Object)null)
			{
				LogFrostResistance(ZNetScene.instance);
			}
		}

		private void RebuildLab()
		{
			ZNetScene instance = ZNetScene.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				List<string> list = new List<string>();
				if (_shotDirty)
				{
					list.Add("shot: " + BuildShotLook(instance));
				}
				if (_releaseDirty)
				{
					list.Add("launch: " + BuildReleaseLook(instance));
				}
				if (_hitDirty)
				{
					list.Add("hit: " + BuildHitLook(instance));
				}
				if (_vortexDirty)
				{
					list.Add("whirlpool: " + BuildVortex(instance));
				}
				_shotDirty = (_releaseDirty = (_hitDirty = (_vortexDirty = false)));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Effect lab rebuilt - " + string.Join("; ", list)));
				if (_previewOnChange.Value)
				{
					RequestPreview(_changedKind);
					_previewAt = Time.unscaledTime;
				}
			}
		}

		private static Transform FreshContainer(Transform parent, string name)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(name);
			if ((Object)(object)val != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
			}
			GameObject val2 = new GameObject(name);
			val2.transform.SetParent(parent, false);
			return val2.transform;
		}

		private void PrepareShotVisual(Projectile projectile)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_005a: 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)
			GameObject val = new GameObject("sea_visual");
			val.transform.SetParent(((Component)projectile).transform, false);
			if ((Object)(object)projectile.m_visual != (Object)null)
			{
				_orbBody = projectile.m_visual;
				_orbBody.transform.SetParent(val.transform, true);
				_orbScale = _orbBody.transform.localScale;
			}
			projectile.m_visual = val;
			_shotVisual = val.transform;
		}

		private string BuildShotLook(ZNetScene scene)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_shotVisual == (Object)null)
			{
				return "no projectile";
			}
			if ((Object)(object)_orbBody != (Object)null)
			{
				FxLayer fxLayer = _shotLayers.FirstOrDefault((FxLayer l) => l.Part.Value == FxPart.SerpentOrb);
				_orbBody.SetActive(fxLayer != null);
				if (fxLayer != null)
				{
					PaintSolid(_orbBody, fxLayer.Colour.Value, fxLayer.Opacity.Value);
					_orbBody.transform.localScale = _orbScale * ((fxLayer.Size.Value > 0f) ? fxLayer.Size.Value : 1f);
				}
			}
			Transform look = FreshContainer(_shotVisual, "look");
			Transform trail = FreshContainer(_shotVisual, "trail");
			return Describe(_shotLayers.Select((FxLayer l) => BuildLayer(scene, l, look, FxMode.Core, 0f)).Concat(_trailLayers.Select((FxLayer l) => BuildLayer(scene, l, trail, FxMode.Trail, 0f))));
		}

		private string BuildReleaseLook(ZNetScene scene)
		{
			if ((Object)(object)_release == (Object)null)
			{
				return "no launch effect";
			}
			Transform look = FreshContainer(_release.transform, "look");
			List<string> list = _launchLayers.Select((FxLayer l) => BuildLayer(scene, l, look, FxMode.Launch, 0f)).ToList();
			if (_launchLight.Value > 0f)
			{
				AddFlash(scene, look, _launchLight.Value, 4f);
				list.Add($"light {_launchLight.Value:0.#}");
			}
			return Describe((IEnumerable<string>)list);
		}

		private string BuildHitLook(ZNetScene scene)
		{
			if ((Object)(object)_hitVisual == (Object)null)
			{
				return "no impact effect";
			}
			Transform look = FreshContainer(_hitVisual.transform, "look");
			List<string> list = _hitLayers.Select((FxLayer l) => BuildLayer(scene, l, look, FxMode.Hit, 0f)).ToList();
			if (_hitLight.Value > 0f)
			{
				AddFlash(scene, look, _hitLight.Value, 3.5f);
				list.Add($"light {_hitLight.Value:0.#}");
			}
			return Describe((IEnumerable<string>)list);
		}

		private string BuildVortex(ZNetScene scene)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			Aoe aoe = (((Object)(object)_whirlpool != (Object)null) ? _whirlpool.GetComponent<Aoe>() : null);
			if ((Object)(object)aoe == (Object)null)
			{
				return "no whirlpool";
			}
			Transform vortex = FreshContainer(_whirlpool.transform, "vortex");
			vortex.localPosition = new Vector3(0f, 0.15f, 0f);
			List<string> list = _whirlLayers.Select((FxLayer l) => BuildLayer(scene, l, vortex, FxMode.Spiral, aoe.m_radius)).ToList();
			list.Add($"{_spiralDirection.Value}, {_spiralTurn.Value:0.#} rad/s");
			return Describe((IEnumerable<string>)list);
		}

		private static string Describe(IEnumerable<string> parts)
		{
			string text = string.Join(" + ", parts.Where((string p) => !string.IsNullOrEmpty(p)));
			if (text.Length != 0)
			{
				return text;
			}
			return "empty";
		}

		private string BuildLayer(ZNetScene scene, FxLayer layer, Transform parent, FxMode mode, float radius)
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			FxPart value = layer.Part.Value;
			if (value == FxPart.None)
			{
				return null;
			}
			if (SolidParts.Contains(value))
			{
				if (mode != FxMode.Core)
				{
					return $"{layer.Name}: {value} only works on the shot";
				}
				return "SerpentOrb";
			}
			if (!PartSources.TryGetValue(value, out (string, string) value2))
			{
				return null;
			}
			GameObject val = Find(scene, value2.Item1);
			Transform val2 = ((value2.Item2 != null) ? FindChild(val, value2.Item2) : (((Object)(object)val != (Object)null) ? val.transform : null));
			if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).GetComponent<ParticleSystem>() == (Object)null)
			{
				WarnOnce("lab-" + value, $"{value2.Item1}/{value2.Item2} not found, the {value} part is unavailable");
				return $"{value} missing";
			}
			GameObject val3 = CopyParticles(((Component)val2).gameObject, parent, layer.Name);
			if (mode == FxMode.Core)
			{
				val3.transform.localPosition = val2.localPosition;
				val3.transform.localRotation = val2.localRotation;
			}
			ParticleSystem component = val3.GetComponent<ParticleSystem>();
			WhitenMaterials(val3.GetComponent<ParticleSystemRenderer>());
			ShapeLayer(component, layer, mode, radius);
			return value.ToString();
		}

		private GameObject CopyParticles(GameObject source, Transform parent, string name)
		{
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(source, Holder().transform, false);
			foreach (Transform item in ((IEnumerable)val.transform).Cast<Transform>().ToList())
			{
				Object.DestroyImmediate((Object)(object)((Component)item).gameObject);
			}
			foreach (MonoBehaviour item2 in val.GetComponents<MonoBehaviour>().Reverse())
			{
				Object.DestroyImmediate((Object)(object)item2);
			}
			foreach (Component item3 in val.GetComponents<Component>().Reverse())
			{
				if ((Object)(object)item3 != (Object)null && !(item3 is Transform) && !(item3 is ParticleSystem) && !(item3 is ParticleSystemRenderer))
				{
					Object.DestroyImmediate((Object)(object)item3);
				}
			}
			((Object)val).name = name;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = Vector3.zero;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			return val;
		}

		private static void WhitenMaterials(ParticleSystemRenderer renderer)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)renderer == (Object)null)
			{
				return;
			}
			Material[] sharedMaterials = ((Renderer)renderer).sharedMaterials;
			for (int i = 0; i < sharedMaterials.Length; i++)
			{
				if ((Object)(object)sharedMaterials[i] == (Object)null)
				{
					continue;
				}
				sharedMaterials[i] = new Material(sharedMaterials[i]);
				string[] array = new string[2] { "_Color", "_TintColor" };
				foreach (string text in array)
				{
					if (sharedMaterials[i].HasProperty(text))
					{
						Color white = Color.white;
						white.a = sharedMaterials[i].GetColor(text).a;
						sharedMaterials[i].SetColor(text, white);
					}
				}
			}
			((Renderer)renderer).sharedMaterials = sharedMaterials;
		}

		private void ShapeLayer(ParticleSystem particles, FxLayer layer, FxMode mode, float radius)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0099: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: 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_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			MainModule main = particles.main;
			EmissionModule emission = particles.emission;
			float rateOverTimeMultiplier = ((EmissionModule)(ref emission)).rateOverTimeMultiplier;
			int num = 0;
			MinMaxCurve val;
			for (int i = 0; i < ((EmissionModule)(ref emission)).burstCount; i++)
			{
				int num2 = num;
				Burst burst = ((EmissionModule)(ref emission)).GetBurst(i);
				val = ((Burst)(ref burst)).count;
				num = num2 + Mathf.RoundToInt(((MinMaxCurve)(ref val)).constantMax);
			}
			TintSea(particles, layer.Colour.Value, layer.Opacity.Value);
			TrailModule trails = particles.trails;
			if (((TrailModule)(ref trails)).enabled)
			{
				((TrailModule)(ref trails)).inheritParticleColor = true;
				((TrailModule)(ref trails)).colorOverTrail = MinMaxGradient.op_Implicit(Color.white);
				((TrailModule)(ref trails)).colorOverLifetime = MinMaxGradient.op_Implicit(Color.white);
			}
			float value = layer.Size.Value;
			float value2 = layer.Amount.Value;
			float value3 = layer.Life.Value;
			float value4 = layer.Speed.Value;
			if (value > 0f)
			{
				((MainModule)(ref main)).startSize3D = false;
				((MainModule)(ref main)).startSize = new MinMaxCurve(value * 0.75f, value * 1.25f);
			}
			if (value3 > 0f)
			{
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(value3 * 0.75f, value3);
			}
			val = ((MainModule)(ref main)).startLifetime;
			float num3 = Mathf.Max(0.05f, ((MinMaxCurve)(ref val)).constantMax);
			((MainModule)(ref main)).startDelay = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).playOnAwake = true;
			((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0;
			((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)1;
			CollisionModule collision = particles.collision;
			((CollisionModule)(ref collision)).enabled = false;
			SubEmittersModule subEmitters = particles.subEmitters;
			((SubEmittersModule)(ref subEmitters)).enabled = false;
			LightsModule lights = particles.lights;
			((LightsModule)(ref lights)).enabled = false;
			TriggerModule trigger = particles.trigger;
			((TriggerModule)(ref trigger)).enabled = false;
			ForceOverLifetimeModule forceOverLifetime = particles.forceOverLifetime;
			((ForceOverLifetimeModule)(ref forceOverLifetime)).enabled = false;
			LimitVelocityOverLifetimeModule limitVelocityOverLifetime = particles.limitVelocityOverLifetime;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).enabled = false;
			VelocityOverLifetimeModule velocityOverLifetime = particles.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = false;
			ShapeModule shape = particles.shape;
			((EmissionModule)(ref emission)).enabled = true;
			switch (mode)
			{
			case FxMode.Core:
			case FxMode.Trail:
				((MainModule)(ref main)).loop = true;
				if (mode == FxMode.Trail)
				{
					((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
					((ShapeModule)(ref shape)).enabled = true;
					((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
					((ShapeModule)(ref shape)).radius = 0.1f;
					((ShapeModule)(ref shape)).position = Vector3.zero;
					((ShapeModule)(ref shape)).rotation = Vector3.zero;
				}
				if (value2 > 0f || (rateOverTimeMultiplier <= 0f && ((EmissionModule)(ref emission)).rateOverDistanceMultiplier <= 0f))
				{
					float num7 = ((value2 > 0f) ? value2 : Mathf.Max(20f, (float)num * 4f));
					((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[0]);
					((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(num7);
					((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(0f);
					((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(num7 * num3) + 8;
				}
				if (value4 > 0f)
				{
					((MainModule)(ref main)).startSpeed = new MinMaxCurve(0f, value4);
				}
				break;
			case FxMode.Launch:
			case FxMode.Hit:
			{
				int num6 = ((value2 > 0f) ? Mathf.RoundToInt(value2) : Mathf.Max(1, Mathf.Max(num, Mathf.RoundToInt(rateOverTimeMultiplier * 0.3f))));
				((MainModule)(ref main)).loop = false;
				((MainModule)(ref main)).duration = 1f;
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
				((MainModule)(ref main)).maxParticles = Mathf.Max(1, num6);
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
				((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(0f);
				((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
				{
					new Burst(0f, (short)Mathf.Clamp(num6, 1, 32767))
				});
				if (value4 > 0f)
				{
					((MainModule)(ref main)).startSpeed = new MinMaxCurve(value4 * 0.4f, value4);
				}
				((ShapeModule)(ref shape)).enabled = true;
				((ShapeModule)(ref shape)).position = Vector3.zero;
				((ShapeModule)(ref shape)).rotation = Vector3.zero;
				if (mode == FxMode.Launch)
				{
					((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
					((ShapeModule)(ref shape)).angle = 25f;
					((ShapeModule)(ref shape)).radius = 0.05f;
				}
				else
				{
					((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
					((ShapeModule)(ref shape)).radius = 0.2f;
				}
				break;
			}
			case FxMode.Spiral:
			{
				float num4 = ((value2 > 0f) ? value2 : Mathf.Max(10f, rateOverTimeMultiplier));
				float num5 = ((value4 > 0f) ? value4 : 2.5f);
				SpiralDirection value5 = _spiralDirection.Value;
				((MainModule)(ref main)).loop = true;
				((MainModule)(ref main)).duration = 1f;
				((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0;
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(num4 * num3) + 8;
				((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[0]);
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(num4);
				((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(0f);
				((ShapeModule)(ref shape)).enabled = true;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
				((ShapeModule)(ref shape)).position = Vector3.zero;
				((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f);
				((ShapeModule)(ref shape)).radius = ((value5 == SpiralDirection.Outward) ? 0.8f : radius);
				((ShapeModule)(ref shape)).radiusThickness = value5 switch
				{
					SpiralDirection.Still => 1f, 
					SpiralDirection.Inward => 0.15f, 
					_ => 0.5f, 
				};
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = MinMaxCurve.op_Implicit(0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = MinMaxCurve.op_Implicit(0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = MinMaxCurve.op_Implicit(0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalX = MinMaxCurve.op_Implicit(0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalY = MinMaxCurve.op_Implicit(_spiralTurn.Value);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalZ = MinMaxCurve.op_Implicit(0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).radial = MinMaxCurve.op_Implicit(value5 switch
				{
					SpiralDirection.Inward => 0f - num5, 
					SpiralDirection.Outward => num5, 
					_ => 0f, 
				});
				break;
			}
			}
		}

		private static void PaintSolid(GameObject model, Color colour, float glow)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (val is ParticleSystemRenderer)
				{
					continue;
				}
				Material[] sharedMaterials = val.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					if ((Object)(object)sharedMaterials[j] == (Object)null)
					{
						continue;
					}
					sharedMaterials[j] = new Material(sharedMaterials[j]);
					string[] array = new string[2] { "_Color", "_TintColor" };
					foreach (string text in array)
					{
						if (sharedMaterials[j].HasProperty(text))
						{
							Color val2 = colour;
							val2.a = sharedMaterials[j].GetColor(text).a;
							sharedMaterials[j].SetColor(text, val2);
						}
					}
					if (sharedMaterials[j].HasProperty("_EmissionColor"))
					{
						sharedMaterials[j].SetColor("_EmissionColor", colour * (0.6f * glow));
					}
				}
				val.sharedMaterials = sharedMaterials;
			}
		}

		private void ApplyHarpoon(ObjectDB db)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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)
			GameObject itemPrefab = db.GetItemPrefab("SeaShardSpear_RtD");
			ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
			if ((Object)(object)val == (Object)null)
			{
				WarnOnce("SeaShardSpear_RtD", "harpoon not found in ObjectDB");
				return;
			}
			SharedData shared = val.m_itemData.m_shared;
			shared.m_damages = Split(Above(170f), HarpoonMix);
			shared.m_blockPower = Above(66f);
			shared.m_timedBlockBonus = AboveFine(2f);
			shared.m_deflectionForce = Above(20f);
			shared.m_damagesPerLevel = default(DamageTypes);
			shared.m_attack.m_attackStamina = 16f;
			shared.m_secondaryAttack.m_attackStamina = 18f;
		}

		private void ApplyHarpoonDrops(ZNetScene scene)
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			GameObject harpoon = scene.GetPrefab("SeaShardSpear_RtD");
			if ((Object)(object)harpoon == (Object)null)
			{
				WarnOnce("SeaShardSpear_RtD-drop", "harpoon prefab not found, drops unchanged");
				return;
			}
			int num = 0;
			string[] harpoonCarriers = HarpoonCarriers;
			foreach (string text in harpoonCarriers)
			{
				GameObject prefab = scene.GetPrefab(text);
				CharacterDrop val = ((prefab != null) ? prefab.GetComponent<CharacterDrop>() : null);
				if ((Object)(object)val == (Object)null)
				{
					WarnOnce(text, "creature not found, its harpoon drop unchanged");
					continue;
				}
				foreach (Drop drop in val.m_drops)
				{
					if ((Object)(object)drop.m_prefab == (Object)(object)harpoon)
					{
						drop.m_chance = 0.05f;
						num++;
					}
				}
			}
			GameObject prefab2 = scene.GetPrefab("Belzor_RtD");
			CharacterDrop val2 = ((prefab2 != null) ? prefab2.GetComponent<CharacterDrop>() : null);
			if ((Object)(object)val2 == (Object)null)
			{
				WarnOnce("Belzor_RtD", "Belzor not found, he does not drop the harpoon");
			}
			else if (!val2.m_drops.Exists((Drop d) => (Object)(object)d.m_prefab == (Object)(object)harpoon))
			{
				val2.m_drops.Add(new Drop
				{
					m_prefab = harpoon,
					m_amountMin = 1,
					m_amountMax = 1,
					m_chance = 1f
				});
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0}: drop chance {1:P0} on {2} creature(s), always from {3}", "SeaShardSpear_RtD", 0.05f, num, "Belzor_RtD"));
		}

		private void Preview(PreviewKind kind)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0075: 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)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_007a: 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)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || (Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			Vector3 lookDir = ((Character)localPlayer).GetLookDir();
			Vector3 val = ((Character)localPlayer).GetEyePoint() + lookDir * 1f;
			Quaternion val2 = Quaternion.LookRotation(lookDir);
			RaycastHit val4 = default(RaycastHit);
			Vector3 val3 = (Physics.Raycast(val, lookDir, ref val4, 40f, PreviewMask, (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val4)).point : (val + lookDir * 25f));
			switch (kind)
			{
			case PreviewKind.Shot:
				PreviewShot(val, val2, val3);
				break;
			case PreviewKind.Launch:
				if ((Object)(object)_release != (Object)null)
				{
					Object.Instantiate<GameObject>(_release, val, val2);
				}
				break;
			case PreviewKind.Hit:
				if ((Object)(object)_hitVisual != (Object)null)
				{
					Object.Instantiate<GameObject>(_hitVisual, val3, Quaternion.identity);
				}
				break;
			case PreviewKind.Whirlpool:
				PreviewWhirlpool(localPlayer);
				break;
			}
		}

		private void PreviewShot(Vector3 origin, Quaternion facing, Vector3 target)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			//IL_00a5: 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_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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_release != (Object)null)
			{
				Object.Instantiate<GameObject>(_release, origin, facing);
			}
			if (!((Object)(object)_shotVisual == (Object)null))
			{
				object obj;
				if (!((Object)(object)ObjectDB.instance != (Object)null))
				{
					obj = null;
				}
				else
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("SeaShardStaff_RtD");
					obj = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				}
				ItemDrop val = (ItemDrop)obj;
				float num = (((Object)(object)val != (Object)null && val.m_itemData.m_shared.m_attack.m_projectileVel > 0f) ? val.m_itemData.m_shared.m_attack.m_projectileVel : 30f);
				GameObject obj2 = Object.Instantiate<GameObject>(((Component)_shotVisual).gameObject, origin, facing);
				((Object)obj2).name = "SeaShard_lab_preview";
				LabFlight labFlight = obj2.AddComponent<LabFlight>();
				Vector3 val2 = target - origin;
				labFlight.m_velocity = ((Vector3)(ref val2)).normalized * num;
				labFlight.m_time = Vector3.Distance(origin, target) / num;
				labFlight.m_target = target;
				labFlight.m_hit = _hitVisual;
			}
		}

		private void PreviewWhirlpool(Player player)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			Aoe val = (((Object)(object)_whirlpool != (Object)null) ? _whirlpool.GetComponent<Aoe>() : null);
			Transform val2 = (((Object)(object)_whirlpool != (Object)null) ? _whirlpool.transform.Find("vortex") : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
			{
				bool onWater;
				Vector3 val3 = GroundRing.Surface(AimPoint(player, 25f), out onWater);
				GameObject obj = Object.Instantiate<GameObject>(((Component)val2).gameObject, val3 + val2.localPosition, Quaternion.identity);
				((Object)obj).name = "SeaShard_lab_preview";
				obj.AddComponent<LabFlight>().m_time = val.m_ttl;
			}
		}

		private void ApplyLooks(ObjectDB db, ZNetScene scene)
		{
			List<string> values = new List<string>
			{
				Look(db, "SeaShardSpear_RtD", "ChitinKnife_mat", HarpoonSkin, "icon_spear"),
				Look(db, "SeaScaleShield_RtD", "SerpentScaleShield_mat", ShieldSkin, "icon_shield"),
				Look(db, "SeaFareCape_RtD", "OdinCape", CapeSkin, "icon_cape"),
				Look(db, "OceanBelt_RtD", "Belt1_Mat", BeltSkin, "icon_belt"),
				SphereLook(db),
				NeckLook(scene)
			};
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Looks: " + string.Join("; ", values)));
		}

		private string Look(ObjectDB db, string item, string material, Skin skin, string icon)
		{
			GameObject itemPrefab = db.GetItemPrefab(item);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				return item + " missing";
			}
			int num = ((skin.MaterialFrom != null) ? Borrow(db, itemPrefab, material, skin) : Repaint(itemPrefab, material, skin));
			return $"{item} {num} material(s), icon {SetIcon(itemPrefab, icon)}";
		}

		private int Borrow(ObjectDB db, GameObject prefab, string prefix, Skin skin)
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			GameObject itemPrefab = db.GetItemPrefab(skin.MaterialFrom);
			Transform obj = (((Object)(object)itemPrefab != (Object)null) ? (itemPrefab.transform.Find("attach_skin") ?? itemPrefab.transform) : null);
			Material val = ((obj != null) ? (from r in ((Component)obj).GetComponentsInChildren<Renderer>(true)
				where !(r is ParticleSystemRenderer) && (Object)(object)r.sharedMaterial != (Object)null
				select r.sharedMaterial).FirstOrDefault() : null);
			if ((Object)(object)val == (Object)null)
			{
				WarnOnce(skin.MaterialFrom, skin.MaterialFrom + " material not found, keeping RtD's");
				return Repaint(prefab, prefix, skin);
			}
			Material val2 = new Material(val)
			{
				name = ((Object)val).name + " (SeaShardArsenal)"
			};
			if (!Paint(val2, skin))
			{
				return 0;
			}
			int num = 0;
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val3 in componentsInChildren)
			{
				Material[] sharedMaterials = val3.sharedMaterials;
				for (int num3 = 0; num3 < sharedMaterials.Length; num3++)
				{
					if ((Object)(object)sharedMaterials[num3] != (Object)null && ((Object)sharedMaterials[num3]).name.StartsWith(prefix))
					{
						sharedMaterials[num3] = val2;
						num++;
					}
				}
				val3.sharedMaterials = sharedMaterials;
			}
			return num;
		}

		private string NeckLook(ZNetScene scene)
		{
			GameObject prefab = scene.GetPrefab("NeckSummon_RtD");
			object obj;
			if (!((Object)(object)prefab != (Object)null))
			{
				obj = null;
			}
			else
			{
				Transform obj2 = prefab.transform.Find("Visual/Body");
				obj = ((obj2 != null) ? ((Component)obj2).GetComponent<Renderer>() : null);
			}
			Renderer val = (Renderer)obj;
			if ((Object)(object)val == (Object)null || (Object)(object)val.sharedMaterial == (Object)null)
			{
				return "NeckSummon_RtD body missing";
			}
			int num = Repaint(((Component)val).gameObject, ((Object)val.sharedMaterial).name, NeckSkin);
			Transform obj3 = prefab.transform.Find("Visual/Lillies");
			Renderer val2 = ((obj3 != null) ? ((Component)obj3).GetComponent<Renderer>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				val2.sharedMaterial = val.sharedMaterial;
			}
			return string.Format("{0} {1} material(s){2}", "NeckSummon_RtD", num, ((Object)(object)val2 != (Object)null) ? " + back pads" : "");
		}

		private int Repaint(GameObject root, string prefix, Skin skin)
		{
			int num = 0;
			Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (val is ParticleSystemRenderer)
				{
					continue;
				}
				Material[] sharedMaterials = val.sharedMaterials;
				foreach (Material val2 in sharedMaterials)
				{
					if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name.StartsWith(prefix) && (_painted.Contains(val2) || Paint(val2, skin)))
					{
						_painted.Add(val2);
						num++;
					}
				}
			}
			return num;
		}

		private bool Paint(Material material, Skin skin)
		{
			//IL_0006: 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)
			try
			{
				material.SetColor("_Color", Color.white);
				material.SetTexture("_MainTex", (Texture)(object)LoadTexture(skin.Albedo));
				if (skin.Emission != null)
				{
					material.SetTexture("_EmissionMap", (Texture)(object)LoadTexture(skin.Emission));
					material.EnableKeyword("_EMISSION");
				}
				else
				{
					material.SetTexture("_EmissionMap", (Texture)null);
				}
				material.SetColor("_EmissionColor", skin.EmissionColor);
				string[] array = new string[3] { "_Hue", "_Saturation", "_Value" };
				foreach (string text in array)
				{
					if (material.HasProperty(text))
					{
						material.SetFloat(text, 0f);
					}
				}
				return true;
			}
			catch (Exception ex)
			{
				WarnOnce(((Object)material).name, "textures not applied: " + ex.Message);
				return false;
			}
		}

		private string SetIcon(GameObject prefab, string icon)
		{
			//IL_004b: 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)
			ItemDrop component = prefab.GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null)
			{
				return "no item";
			}
			try
			{
				Texture2D val = LoadTexture(icon, mipmaps: false);
				component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f) };
				return icon;
			}
			catch (Exception ex)
			{
				WarnOnce(icon, "icon not replaced: " + ex.Message);
				return "kept";
			}
		}

		private static string NameKey(string item)
		{
			return "seashard_name_" + item;
		}

		private static string DescKey(string item)
		{
			return "seashard_desc_" + item;
		}

		private void ApplyLore(ObjectDB db)
		{
			string[] describedRelics = DescribedRelics;
			foreach (string text in describedRelics)
			{
				GameObject itemPrefab = db.GetItemPrefab(text);
				ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val != (Object)null)
				{
					val.m_itemData.m_shared.m_name = "$" + NameKey(text);
					val.m_itemData.m_shared.m_description = "$" + DescKey(text);
				}
			}
		}

		private static Dictionary<string, string> Names(string staff, string shield, string harpoon, string cape, string belt)
		{
			return new Dictionary<string, string>
			{
				{
					NameKey("SeaShardStaff_RtD"),
					"<#20B2AA>" + staff
				},
				{
					NameKey("SeaScaleShield_RtD"),
					"<#20B2AA>" + shield
				},
				{
					NameKey("SeaShardSpear_RtD"),
					"<#20B2AA>" + harpoon
				},
				{
					NameKey("SeaFareCape_RtD"),
					"<#20B2AA>" + cape
				},
				{
					NameKey("OceanBelt_RtD"),
					"<#20B2AA>" + belt
				}
			};
		}

		private static void AddLoreTranslations()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "Ukrainian";
			localization.AddTranslation(ref text, Names("Кермо Глибин", "Хвилеріз", "Гарпун Глибин", "Просолений Плащ", "Пояс Припливу"));
			text = "Russian";
			localization.AddTranslation(ref text, Names("Штурвал Глубин", "Волнорез", "Гарпун Глубин", "Просоленный Плащ", "Пояс Прилива"));
			text = "English";
			localization.AddTranslation(ref text, Names("Helm of the Depths", "Breakwater", "Harpoon of the Deep", "Brine Cape", "Tide Belt"));
			text = "Ukrainian";
			localization.AddTranslation(ref text, new Dictionary<string, string> { { "seashard_depths", "Крижана вода" } });
			text = "Russian";
			localization.AddTranslation(ref text, new Dictionary<string, string> { { "seashard_depths", "Ледяная вода" } });
			text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string> { { "seashard_depths", "Icy Water" } });
			text = "Ukrainian";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{
					DescKey("SeaShardStaff_RtD"),
					"Кермове колесо драккара, що пішов на дно над лігвом Бельзора. Роками воно лежало в холодній темряві, аж поки ламінарія не обплела його, а глибина не вселилася в дерево й бронзу. Тепер воно править не кораблем, а морем: постріл б'є крижаною водою й лишає калюжі, що сковують холодом; оберт кермом відкриває вир там, куди дивиться стерник, і вир затягує ворогів, а біля самого стерника море відступає й відкидає тих, хто підійшов надто близько. Кого вода промочить до кісток, того забирає глибина."
				},
				{
					DescKey("SeaScaleShield_RtD"),
					"Луска морського змія на бронзовій оправі, позеленілій від солі. Хто вдарить у неї, отримає хвилю солоної води у відповідь, а вчасне парирування здіймає вал, що розкидає всіх довкола."
				},
				{
					DescKey("SeaShardSpear_RtD"),
					"Зазубрене вістря з морського уламка на держаку з плавника. Таку зброю носить рибний народ, та віддає її неохоче, а Бельзор, кажуть, ковтав її разом із човнами. Рана від неї сочиться отрутою, а кинутий гарпун не відпускає здобич."
				},
				{
					DescKey("SeaFareCape_RtD"),
					"Шкура асксвина, вимочена в солоній воді, аж поки не набула кольору морської трави. Вона не тягне на дно, а тримає на хвилі: хто її носить, пливе довше й легше за будь-кого з команди драккара."
				},
				{
					DescKey("OceanBelt_RtD"),
					"Шкіряний пояс із бронзовою пряжкою, в яку вправлено уламок морського кристала. Він б'ється в такт припливу й повертає сили: здоров'я, витривалість і ейтр відновлюються швидше. На ньому знайдеться місце для трьох наїдків у дорогу."
				}
			});
			text = "Russian";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{
					DescKey("SeaShardStaff_RtD"),
					"Штурвал драккара, ушедшего на дно над логовом Бельзора. Годами он лежал в холодной темноте, пока ламинария не оплела его, а глубина не вселилась в дерево и бронзу. Теперь он правит не кораблём, а морем: выстрел бьёт ледяной водой и оставляет лужи, сковывающие холодом; поворот штурвала открывает водоворот там, куда смотрит кормчий, и водоворот затягивает врагов, а у самого кормчего море отступает и отбрасывает тех, кто подошёл слишком близко. Кого вода промочит до костей, того забирает глубина."
				},
				{
					DescKey("SeaScaleShield_RtD"),
					"Чешуя морского змея на бронзовой оправе, позеленевшей от соли. Кто ударит в неё, получит волну солёной воды в ответ, а вовремя парированный удар поднимает вал, что раскидывает всех вокруг."
				},
				{
					DescKey("SeaShardSpear_RtD"),
					"Зазубренное остриё из морского осколка на древке из плавника. Такое оружие носит рыбий народ, но отдаёт его неохотно, а Бельзор, говорят, глотал его вместе с лодками. Рана от него сочится ядом, а брошенный гарпун не отпускает добычу."
				},
				{
					DescKey("SeaFareCape_RtD"),
					"Шкура асксвина, вымоченная в солёной воде, пока не стала цвета морской травы. Она не тянет на дно, а держит на волне: тот, кто её носит, плывёт дольше и легче любого из команды драккара."
				},
				{
					DescKey("OceanBelt_RtD"),
					"Кожаный пояс с бронзовой пряжкой, в которую вправлен осколок морского кристалла. Он бьётся в такт прилива и возвращает силы: здоровье, выносливость и эйтир восстанавл