using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Decal.Adapter.Support;
using Decal.Interop.Filters;

namespace Decal.Adapter.Wrappers;

public class CharacterFilter : GenericDisposableWrapper<CharacterStats>, IIndexedProvider<CharFilterIndex>
{
	private EventHandler<SpellCastEventArgs> mSpellCast;

	private EventHandler<StatusMessageEventArgs> mStatusMessage;

	private EventHandler<SpellbookEventArgs> mSpellbookChange;

	private EventHandler<ChangePortalModeEventArgs> mChangePortalMode;

	private EventHandler<ChangePlayerEventArgs> mChangePlayer;

	private EventHandler<ChangeFellowshipEventArgs> mChangeFellowship;

	private EventHandler<ChangeEnchantmentsEventArgs> mChangeEnchantments;

	private EventHandler<ChangeExperienceEventArgs> mChangeExperience;

	private EventHandler<ChangeVitalEventArgs> mChangeVital;

	private EventHandler<ChangeSpellbarEventArgs> mChangeSpellbar;

	private EventHandler<ChangeShortcutEventArgs> mChangeShortcut;

	private EventHandler<LoginEventArgs> mLogin;

	private EventHandler<LogoffEventArgs> mLogoff;

	private EventHandler<DeathEventArgs> mDeath;

	private EventHandler<SettingsEventArgs> mChangeSettings;

	private EventHandler mActionComplete;

	private EventHandler mLoginComplete;

	private EventHandler<ChangeSettingsFlagsEventArgs> mChangeSettingsFlags;

	private EventHandler<ChangeOptionEventArgs> mChangeOption;

	private Collection<int> mySpellBook;

	private ReadOnlyCollection<int> myAugmentations;

	private Dictionary<int, ReadOnlyCollection<int>> mySpellBars;

	private Dictionary<string, AllegianceInfoWrapper> allegianceData;

	private Dictionary<string, EnchantmentWrapper> enchantmentData;

	private Dictionary<string, SkillInfoWrapper> vitalSkillData;

	private Dictionary<string, AttributeInfoWrapper> attributeData;

	public string AccountName
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.AccountName;
		}
	}

	public int Age
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Age;
		}
	}

	public DateTime Birth
	{
		get
		{
			EnforceDisposedOnce();
			return new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(base.Wrapped.Birth);
		}
	}

	public int Burden
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Burden;
		}
	}

	public int BurdenUnits
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.BurdenUnits;
		}
	}

	public string Name
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Name;
		}
	}

	public int Id
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Character;
		}
	}

	public int CharacterOptions
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.CharacterOptions;
		}
	}

	public int CharacterOptionFlags => base.Wrapped.CharacterOptionFlags;

	public string ClassTemplate
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.ClassTemplate;
		}
	}

	public int Deaths
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Deaths;
		}
	}

	public string Gender
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Gender;
		}
	}

	public int Health
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Health;
		}
	}

	public int Stamina
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Stamina;
		}
	}

	public int Mana
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Mana;
		}
	}

	public int Level
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Level;
		}
	}

	public int LoginStatus
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.LoginStatus;
		}
	}

	public string Race
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Race;
		}
	}

	public int Rank
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Rank;
		}
	}

	public string Server
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Server;
		}
	}

	public int ServerPopulation
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.ServerPopulation;
		}
	}

	public long TotalXP
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.TotalXP_64;
		}
	}

	[CLSCompliant(false)]
	public IndexedCollection<CharFilterIndex, int, AllegianceInfoWrapper> Vassals
	{
		get
		{
			EnforceDisposedOnce();
			return new IndexedCollection<CharFilterIndex, int, AllegianceInfoWrapper>(this, CharFilterIndex.Vassals);
		}
	}

	[CLSCompliant(false)]
	public IndexedCollection<CharFilterIndex, int, AccountCharInfo> Characters
	{
		get
		{
			EnforceDisposedOnce();
			return new IndexedCollection<CharFilterIndex, int, AccountCharInfo>(this, CharFilterIndex.Characters);
		}
	}

	[CLSCompliant(false)]
	public IndexedCollection<CharFilterIndex, int, EnchantmentWrapper> Enchantments
	{
		get
		{
			EnforceDisposedOnce();
			return new IndexedCollection<CharFilterIndex, int, EnchantmentWrapper>(this, CharFilterIndex.Enchantments);
		}
	}

	[CLSCompliant(false)]
	public IndexedCollection<CharFilterIndex, CharFilterVitalType, SkillInfoWrapper> Vitals
	{
		get
		{
			EnforceDisposedOnce();
			return new IndexedCollection<CharFilterIndex, CharFilterVitalType, SkillInfoWrapper>(this, CharFilterIndex.Vitals);
		}
	}

	[CLSCompliant(false)]
	public IndexedCollection<CharFilterIndex, CharFilterAttributeType, AttributeInfoWrapper> Attributes
	{
		get
		{
			EnforceDisposedOnce();
			return new IndexedCollection<CharFilterIndex, CharFilterAttributeType, AttributeInfoWrapper>(this, CharFilterIndex.Attributes);
		}
	}

	[CLSCompliant(false)]
	public IndexedCollection<CharFilterIndex, CharFilterSkillType, SkillInfoWrapper> Skills
	{
		get
		{
			EnforceDisposedOnce();
			return new IndexedCollection<CharFilterIndex, CharFilterSkillType, SkillInfoWrapper>(this, CharFilterIndex.Skills);
		}
	}

	public long UnassignedXP
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.UnassignedXP_64;
		}
	}

	public int Vitae
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Vitae;
		}
	}

	public AllegianceInfoWrapper Monarch
	{
		get
		{
			EnforceDisposedOnce();
			string key = "Monarch";
			AllegianceInfo monarch = base.Wrapped.Monarch;
			AllegianceInfoWrapper value = null;
			if (allegianceData.TryGetValue(key, out value) && value.Id != monarch.GUID)
			{
				allegianceData.Remove(key);
				value.Dispose();
				value = null;
			}
			if (value == null)
			{
				value = new AllegianceInfoWrapper(monarch);
				allegianceData.Add(key, value);
			}
			return value;
		}
	}

	public AllegianceInfoWrapper Patron
	{
		get
		{
			EnforceDisposedOnce();
			string key = "Patron";
			AllegianceInfo patron = base.Wrapped.Patron;
			AllegianceInfoWrapper value = null;
			if (allegianceData.TryGetValue(key, out value) && value.Id != patron.GUID)
			{
				allegianceData.Remove(key);
				value.Dispose();
				value = null;
			}
			if (value == null)
			{
				value = new AllegianceInfoWrapper(patron);
				allegianceData.Add(key, value);
			}
			return value;
		}
	}

	public AllegianceInfoWrapper Allegiance
	{
		get
		{
			EnforceDisposedOnce();
			string key = "MyAllegiance";
			AllegianceInfoWrapper value = null;
			if (allegianceData.TryGetValue(key, out value))
			{
				allegianceData.Remove(key);
				value.Dispose();
			}
			value = new AllegianceInfoWrapper(base.Wrapped.MyAllegiance);
			allegianceData.Add(key, value);
			return value;
		}
	}

	public int Followers
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.Followers;
		}
	}

	public int MonarchFollowers
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.MonarchFollowers;
		}
	}

	public int SkillPoints
	{
		get
		{
			EnforceDisposedOnce();
			return base.Wrapped.SkillPoints;
		}
	}

	public long XPToNextLevel => base.Wrapped.XPToNextLevel;

	public ReadOnlyCollection<int> SpellBook
	{
		get
		{
			EnforceDisposedOnce();
			if (mySpellBook == null)
			{
				mySpellBook = new Collection<int>(base.Wrapped.SpellbookArray);
			}
			return new ReadOnlyCollection<int>(mySpellBook);
		}
	}

	public ReadOnlyCollection<int> Augmentations
	{
		get
		{
			EnforceDisposedOnce();
			if (myAugmentations == null)
			{
				myAugmentations = new ReadOnlyCollection<int>(base.Wrapped.AugmentationArray);
			}
			return myAugmentations;
		}
	}

	[CLSCompliant(false)]
	public IndexedCollection<CharFilterIndex, CharFilterAttributeType, int> EffectiveAttribute => new IndexedCollection<CharFilterIndex, CharFilterAttributeType, int>(this, CharFilterIndex.EffectiveAttributes);

	[CLSCompliant(false)]
	public IndexedCollection<CharFilterIndex, CharFilterSkillType, int> EffectiveSkill => new IndexedCollection<CharFilterIndex, CharFilterSkillType, int>(this, CharFilterIndex.EffectiveSkills);

	[CLSCompliant(false)]
	public IndexedCollection<CharFilterIndex, CharFilterVitalType, int> EffectiveVital => new IndexedCollection<CharFilterIndex, CharFilterVitalType, int>(this, CharFilterIndex.EffectiveVitals);

	public event EventHandler ActionComplete
	{
		add
		{
			mActionComplete = (EventHandler)Delegate.Combine(mActionComplete, value);
		}
		remove
		{
			mActionComplete = (EventHandler)Delegate.Remove(mActionComplete, value);
		}
	}

	public event EventHandler LoginComplete
	{
		add
		{
			mLoginComplete = (EventHandler)Delegate.Combine(mLoginComplete, value);
		}
		remove
		{
			mLoginComplete = (EventHandler)Delegate.Remove(mLoginComplete, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<SpellbookEventArgs> SpellbookChange
	{
		add
		{
			mSpellbookChange = (EventHandler<SpellbookEventArgs>)Delegate.Combine(mSpellbookChange, value);
		}
		remove
		{
			mSpellbookChange = (EventHandler<SpellbookEventArgs>)Delegate.Remove(mSpellbookChange, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<DeathEventArgs> Death
	{
		add
		{
			mDeath = (EventHandler<DeathEventArgs>)Delegate.Combine(mDeath, value);
		}
		remove
		{
			mDeath = (EventHandler<DeathEventArgs>)Delegate.Remove(mDeath, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<ChangePortalModeEventArgs> ChangePortalMode
	{
		add
		{
			mChangePortalMode = (EventHandler<ChangePortalModeEventArgs>)Delegate.Combine(mChangePortalMode, value);
		}
		remove
		{
			mChangePortalMode = (EventHandler<ChangePortalModeEventArgs>)Delegate.Remove(mChangePortalMode, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<ChangePlayerEventArgs> ChangePlayer
	{
		add
		{
			mChangePlayer = (EventHandler<ChangePlayerEventArgs>)Delegate.Combine(mChangePlayer, value);
		}
		remove
		{
			mChangePlayer = (EventHandler<ChangePlayerEventArgs>)Delegate.Remove(mChangePlayer, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<ChangeFellowshipEventArgs> ChangeFellowship
	{
		add
		{
			mChangeFellowship = (EventHandler<ChangeFellowshipEventArgs>)Delegate.Combine(mChangeFellowship, value);
		}
		remove
		{
			mChangeFellowship = (EventHandler<ChangeFellowshipEventArgs>)Delegate.Remove(mChangeFellowship, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<ChangeEnchantmentsEventArgs> ChangeEnchantments
	{
		add
		{
			mChangeEnchantments = (EventHandler<ChangeEnchantmentsEventArgs>)Delegate.Combine(mChangeEnchantments, value);
		}
		remove
		{
			mChangeEnchantments = (EventHandler<ChangeEnchantmentsEventArgs>)Delegate.Remove(mChangeEnchantments, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<ChangeExperienceEventArgs> ChangeExperience
	{
		add
		{
			mChangeExperience = (EventHandler<ChangeExperienceEventArgs>)Delegate.Combine(mChangeExperience, value);
		}
		remove
		{
			mChangeExperience = (EventHandler<ChangeExperienceEventArgs>)Delegate.Remove(mChangeExperience, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<ChangeVitalEventArgs> ChangeVital
	{
		add
		{
			mChangeVital = (EventHandler<ChangeVitalEventArgs>)Delegate.Combine(mChangeVital, value);
		}
		remove
		{
			mChangeVital = (EventHandler<ChangeVitalEventArgs>)Delegate.Remove(mChangeVital, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<ChangeSpellbarEventArgs> ChangeSpellbar
	{
		add
		{
			mChangeSpellbar = (EventHandler<ChangeSpellbarEventArgs>)Delegate.Combine(mChangeSpellbar, value);
		}
		remove
		{
			mChangeSpellbar = (EventHandler<ChangeSpellbarEventArgs>)Delegate.Remove(mChangeSpellbar, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<ChangeShortcutEventArgs> ChangeShortcut
	{
		add
		{
			mChangeShortcut = (EventHandler<ChangeShortcutEventArgs>)Delegate.Combine(mChangeShortcut, value);
		}
		remove
		{
			mChangeShortcut = (EventHandler<ChangeShortcutEventArgs>)Delegate.Remove(mChangeShortcut, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<LoginEventArgs> Login
	{
		add
		{
			mLogin = (EventHandler<LoginEventArgs>)Delegate.Combine(mLogin, value);
		}
		remove
		{
			mLogin = (EventHandler<LoginEventArgs>)Delegate.Remove(mLogin, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<SettingsEventArgs> ChangeSettings
	{
		add
		{
			mChangeSettings = (EventHandler<SettingsEventArgs>)Delegate.Combine(mChangeSettings, value);
		}
		remove
		{
			mChangeSettings = (EventHandler<SettingsEventArgs>)Delegate.Remove(mChangeSettings, value);
		}
	}

	public event EventHandler<ChangeSettingsFlagsEventArgs> ChangeSettingsFlags
	{
		add
		{
			mChangeSettingsFlags = (EventHandler<ChangeSettingsFlagsEventArgs>)Delegate.Combine(mChangeSettingsFlags, value);
		}
		remove
		{
			mChangeSettingsFlags = (EventHandler<ChangeSettingsFlagsEventArgs>)Delegate.Remove(mChangeSettingsFlags, value);
		}
	}

	public event EventHandler<ChangeOptionEventArgs> ChangeOption
	{
		add
		{
			mChangeOption = (EventHandler<ChangeOptionEventArgs>)Delegate.Combine(mChangeOption, value);
		}
		remove
		{
			mChangeOption = (EventHandler<ChangeOptionEventArgs>)Delegate.Remove(mChangeOption, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<LogoffEventArgs> Logoff
	{
		add
		{
			mLogoff = (EventHandler<LogoffEventArgs>)Delegate.Combine(mLogoff, value);
		}
		remove
		{
			mLogoff = (EventHandler<LogoffEventArgs>)Delegate.Remove(mLogoff, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<SpellCastEventArgs> SpellCast
	{
		add
		{
			mSpellCast = (EventHandler<SpellCastEventArgs>)Delegate.Combine(mSpellCast, value);
		}
		remove
		{
			mSpellCast = (EventHandler<SpellCastEventArgs>)Delegate.Remove(mSpellCast, value);
		}
	}

	[CLSCompliant(false)]
	public event EventHandler<StatusMessageEventArgs> StatusMessage
	{
		add
		{
			mStatusMessage = (EventHandler<StatusMessageEventArgs>)Delegate.Combine(mStatusMessage, value);
		}
		remove
		{
			mStatusMessage = (EventHandler<StatusMessageEventArgs>)Delegate.Remove(mStatusMessage, value);
		}
	}

	public CharacterFilter(CharacterStats obj)
		: base(obj)
	{
		base.Wrapped.CastSpell += myCS_CastSpell;
		base.Wrapped.ChangeEnchantments += myCS_ChangeEnchantments;
		base.Wrapped.ChangeFellowship += myCS_ChangeFellowship;
		base.Wrapped.ChangePlayer += myCS_ChangePlayer;
		base.Wrapped.ChangePortalMode += myCS_ChangePortalMode;
		base.Wrapped.ChangeSettings += myCS_ChangeSettings;
		base.Wrapped.ChangeShortcut += myCS_ChangeShortcut;
		base.Wrapped.ChangeSpellbar += myCS_ChangeSpellbar;
		base.Wrapped.ChangeVital += myCS_ChangeVital;
		base.Wrapped.ChangeXPS += myCS_ChangeXPS;
		base.Wrapped.Death += myCS_Death;
		base.Wrapped.ActionComplete += myCS_ActionComplete;
		base.Wrapped.Login += myCS_Login;
		base.Wrapped.LoginComplete += myCS_LoginComplete;
		base.Wrapped.Logoff += myCS_Logoff;
		base.Wrapped.Spellbook_Add += myCS_Spellbook_Add;
		base.Wrapped.Spellbook_Delete += myCS_Spellbook_Delete;
		base.Wrapped.StatusMessage += myCS_StatusMessage;
		base.Wrapped.ChangeSettingFlags += myCS_ChangeSettingFlags;
		base.Wrapped.ChangeOption += myCS_ChangeOption;
		Reset(createNew: true);
	}

	protected override void Dispose(bool userCalled)
	{
		if (userCalled)
		{
			if (base.Wrapped != null)
			{
				base.Wrapped.CastSpell -= myCS_CastSpell;
				base.Wrapped.ChangeEnchantments -= myCS_ChangeEnchantments;
				base.Wrapped.ChangeFellowship -= myCS_ChangeFellowship;
				base.Wrapped.ChangePlayer -= myCS_ChangePlayer;
				base.Wrapped.ChangePortalMode -= myCS_ChangePortalMode;
				base.Wrapped.ChangeSettings -= myCS_ChangeSettings;
				base.Wrapped.ChangeShortcut -= myCS_ChangeShortcut;
				base.Wrapped.ChangeSpellbar -= myCS_ChangeSpellbar;
				base.Wrapped.ChangeVital -= myCS_ChangeVital;
				base.Wrapped.ChangeXPS -= myCS_ChangeXPS;
				base.Wrapped.Death -= myCS_Death;
				base.Wrapped.ActionComplete -= myCS_ActionComplete;
				base.Wrapped.Login -= myCS_Login;
				base.Wrapped.LoginComplete -= myCS_LoginComplete;
				base.Wrapped.Logoff -= myCS_Logoff;
				base.Wrapped.Spellbook_Add -= myCS_Spellbook_Add;
				base.Wrapped.Spellbook_Delete -= myCS_Spellbook_Delete;
				base.Wrapped.StatusMessage -= myCS_StatusMessage;
			}
			Reset(createNew: false);
		}
		base.Dispose(userCalled);
	}

	object IIndexedProvider<CharFilterIndex>.GetIndexedObject(CharFilterIndex objectIndex, int index)
	{
		EnforceDisposedOnce();
		object result = null;
		switch (objectIndex)
		{
		case CharFilterIndex.Vassals:
		{
			if (index >= base.Wrapped.VassalCount)
			{
				throw new IndexOutOfRangeException("Requested Vassal " + index + " doesn't exist");
			}
			string key = "Vassal" + index;
			AllegianceInfoWrapper value3 = null;
			if (allegianceData.TryGetValue(key, out value3))
			{
				allegianceData.Remove(key);
				value3?.Dispose();
			}
			value3 = new AllegianceInfoWrapper(((ICharacterStats)base.Wrapped).get_Vassal(index));
			allegianceData.Add(key, value3);
			return value3;
		}
		case CharFilterIndex.Enchantments:
		{
			if (index >= base.Wrapped.EnchantmentCount)
			{
				throw new IndexOutOfRangeException("Requested Enchantment " + index + " doesn't exist");
			}
			string key = "Enchant-" + index;
			EnchantmentWrapper value4 = null;
			if (enchantmentData.TryGetValue(key, out value4))
			{
				enchantmentData.Remove(key);
				value4?.Dispose();
			}
			value4 = new EnchantmentWrapper(((ICharacterStats)base.Wrapped).get_Enchantment(index));
			enchantmentData.Add(key, value4);
			return value4;
		}
		case CharFilterIndex.Characters:
			if (index >= base.Wrapped.AccountCharCount)
			{
				throw new IndexOutOfRangeException("Requested Character " + index + " doesn't exist");
			}
			return new AccountCharInfo(this, index);
		case CharFilterIndex.Vitals:
		{
			if (!Enum.IsDefined(typeof(eVitalID), index))
			{
				throw new IndexOutOfRangeException("Requested Vital " + index + " doesn't exist");
			}
			string key = "Vital-" + index;
			SkillInfoWrapper value5 = null;
			if (vitalSkillData.TryGetValue(key, out value5))
			{
				vitalSkillData.Remove(key);
				value5?.Dispose();
			}
			value5 = new SkillInfoWrapper(((ICharacterStats)base.Wrapped).get_Vital((eVitalID)index));
			vitalSkillData.Add(key, value5);
			return value5;
		}
		case CharFilterIndex.Attributes:
		{
			if (!Enum.IsDefined(typeof(eAttributeID), index))
			{
				throw new IndexOutOfRangeException("Requested Attribute " + index + " doesn't exist");
			}
			string key = "Attribute-" + index;
			AttributeInfoWrapper value2 = null;
			if (attributeData.TryGetValue(key, out value2))
			{
				attributeData.Remove(key);
				value2?.Dispose();
			}
			value2 = new AttributeInfoWrapper(((ICharacterStats)base.Wrapped).get_Attribute((eAttributeID)index));
			attributeData.Add(key, value2);
			return value2;
		}
		case CharFilterIndex.Skills:
		{
			if (!Enum.IsDefined(typeof(CharFilterSkillType), index))
			{
				throw new IndexOutOfRangeException("Requested Skill " + index + " doesn't exist");
			}
			string key = "Skill-" + index;
			SkillInfoWrapper value = null;
			if (vitalSkillData.TryGetValue(key, out value))
			{
				vitalSkillData.Remove(key);
				value?.Dispose();
			}
			value = new SkillInfoWrapper(((ICharacterStats)base.Wrapped).get_Skill((eSkillID)index));
			vitalSkillData.Add(key, value);
			return value;
		}
		case CharFilterIndex.EffectiveAttributes:
			return ((ICharacterStats)base.Wrapped).get_EffectiveAttribute((eAttributeID)index);
		case CharFilterIndex.EffectiveSkills:
			return ((ICharacterStats)base.Wrapped).get_EffectiveSkill((eSkillID)index);
		case CharFilterIndex.EffectiveVitals:
			return ((ICharacterStats)base.Wrapped).get_EffectiveVital((eVitalID)index);
		default:
			return result;
		}
	}

	IEnumerator IIndexedProvider<CharFilterIndex>.GetEnumerator(CharFilterIndex objectIndex)
	{
		EnforceDisposedOnce();
		return objectIndex switch
		{
			CharFilterIndex.Vassals => VassalEnum(), 
			CharFilterIndex.Enchantments => EnchantmentEnum(), 
			CharFilterIndex.Vitals => VitalEnum(), 
			CharFilterIndex.Attributes => AttributeEnum(), 
			CharFilterIndex.Skills => SkillEnum(), 
			_ => null, 
		};
	}

	private IEnumerator<AllegianceInfoWrapper> VassalEnum()
	{
		int vassalCount = base.Wrapped.VassalCount;
		for (int x = 0; x < vassalCount; x++)
		{
			yield return Vassals[x];
		}
	}

	private IEnumerator<EnchantmentWrapper> EnchantmentEnum()
	{
		int enchantCount = base.Wrapped.EnchantmentCount;
		for (int x = 0; x < enchantCount; x++)
		{
			yield return Enchantments[x];
		}
	}

	private IEnumerator<SkillInfoWrapper> VitalEnum()
	{
		for (int x = 2; x <= 6; x += 2)
		{
			yield return Vitals[(CharFilterVitalType)x];
		}
	}

	private IEnumerator<AttributeInfoWrapper> AttributeEnum()
	{
		int AttributeCount = base.Wrapped.AttributeCount;
		int x = 1;
		while (x <= AttributeCount)
		{
			yield return Attributes[(CharFilterAttributeType)x];
			int num = x + 1;
			x = num;
		}
	}

	private IEnumerator<SkillInfoWrapper> SkillEnum()
	{
		_ = base.Wrapped.SkillCount;
		foreach (int value in Enum.GetValues(typeof(CharFilterSkillType)))
		{
			yield return Skills[(CharFilterSkillType)value];
		}
	}

	int IIndexedProvider<CharFilterIndex>.Count(CharFilterIndex objectIndex)
	{
		EnforceDisposedOnce();
		return objectIndex switch
		{
			CharFilterIndex.Vassals => base.Wrapped.VassalCount, 
			CharFilterIndex.Enchantments => base.Wrapped.EnchantmentCount, 
			CharFilterIndex.Vitals => 3, 
			CharFilterIndex.Attributes => base.Wrapped.AttributeCount, 
			CharFilterIndex.Skills => base.Wrapped.SkillCount, 
			CharFilterIndex.Characters => base.Wrapped.AccountCharCount, 
			CharFilterIndex.Spells => base.Wrapped.TotalSpells, 
			CharFilterIndex.Augmentations => base.Wrapped.AugmentationCount(), 
			CharFilterIndex.EffectiveAttributes => base.Wrapped.AttributeCount, 
			CharFilterIndex.EffectiveSkills => base.Wrapped.SkillCount, 
			CharFilterIndex.EffectiveVitals => 3, 
			_ => 0, 
		};
	}

	private void myCS_StatusMessage(int type, string text)
	{
		Util.SafeFireEvent(this, mStatusMessage, new StatusMessageEventArgs(type, text));
	}

	private void myCS_Spellbook_Delete(int spellDeleted)
	{
		if (mySpellBook != null)
		{
			mySpellBook.Remove(spellDeleted);
		}
		Util.SafeFireEvent(this, mSpellbookChange, new SpellbookEventArgs(AddRemoveEventType.Delete, spellDeleted));
	}

	private void myCS_Spellbook_Add(int spellAdded)
	{
		if (mySpellBook != null)
		{
			mySpellBook.Add(spellAdded);
		}
		Util.SafeFireEvent(this, mSpellbookChange, new SpellbookEventArgs(AddRemoveEventType.Add, spellAdded));
	}

	private void myCS_Logoff(PlayerLogoffType type)
	{
		Util.SafeFireEvent(this, mLogoff, new LogoffEventArgs((LogoffEventType)type));
		Reset(createNew: true);
	}

	private void myCS_LoginComplete()
	{
		Util.SafeFireEvent(this, mLoginComplete, new EventArgs());
	}

	private void myCS_Login(int character)
	{
		Util.SafeFireEvent(this, mLogin, new LoginEventArgs(character));
	}

	private void myCS_Death(string text)
	{
		Util.SafeFireEvent(this, mDeath, new DeathEventArgs(text));
	}

	private void myCS_ChangeXPS(PlayerXPType change, int amount)
	{
		Util.SafeFireEvent(this, mChangeExperience, new ChangeExperienceEventArgs((PlayerXPEventType)change, amount));
	}

	private void myCS_ChangeVital(PlayerVitalType change, int amount)
	{
		Util.SafeFireEvent(this, mChangeVital, new ChangeVitalEventArgs((CharFilterVitalType)change, amount));
	}

	private void myCS_ChangeSpellbar(PlayerAddRemoveType Change, int Tab, int Slot, int SpellID)
	{
		if (mySpellBars != null && mySpellBars.ContainsKey(Tab))
		{
			mySpellBars.Remove(Tab);
		}
		Util.SafeFireEvent(this, mChangeSpellbar, new ChangeSpellbarEventArgs((AddRemoveEventType)Change, Tab, Slot, SpellID));
	}

	private void myCS_ChangeShortcut(PlayerAddRemoveType Change, int Slot, int ObjectID)
	{
		Util.SafeFireEvent(this, mChangeShortcut, new ChangeShortcutEventArgs((AddRemoveEventType)Change, Slot, ObjectID));
	}

	private void myCS_ChangeSettings(int Settings)
	{
		Util.SafeFireEvent(this, mChangeSettings, new SettingsEventArgs(Settings));
	}

	private void myCS_ChangePortalMode(PlayerPortalType Change)
	{
		Util.SafeFireEvent(this, mChangePortalMode, new ChangePortalModeEventArgs((PortalEventType)Change));
	}

	private void myCS_ChangePlayer(PlayerModifyType Change, int StatID)
	{
		if (Change == PlayerModifyType.pevtAugmentation && myAugmentations != null)
		{
			myAugmentations = null;
		}
		Util.SafeFireEvent(this, mChangePlayer, new ChangePlayerEventArgs((PlayerModifyEventType)Change, StatID));
	}

	private void myCS_ChangeFellowship(PlayerFellowshipType Change, int Character)
	{
		Util.SafeFireEvent(this, mChangeFellowship, new ChangeFellowshipEventArgs((FellowshipEventType)Change, Character));
	}

	private void myCS_ChangeEnchantments(PlayerAddRemoveType Change, Enchantment Enchantment)
	{
		using EnchantmentWrapper enchantment = new EnchantmentWrapper(Enchantment);
		Util.SafeFireEvent(this, mChangeEnchantments, new ChangeEnchantmentsEventArgs((AddRemoveEventType)Change, enchantment));
	}

	private void myCS_ActionComplete()
	{
		Util.SafeFireEvent(this, mActionComplete, new EventArgs());
	}

	private void myCS_CastSpell(PlayerCastType Type, int SpellID, int TargetID)
	{
		Util.SafeFireEvent(this, mSpellCast, new SpellCastEventArgs((CastEventType)Type, SpellID, TargetID));
	}

	private void myCS_ChangeOption(int key, int value)
	{
		Util.SafeFireEvent(this, mChangeOption, new ChangeOptionEventArgs(key, value));
	}

	private void myCS_ChangeSettingFlags(int Settings)
	{
		Util.SafeFireEvent(this, mChangeSettingsFlags, new ChangeSettingsFlagsEventArgs(Settings));
	}

	private void Reset(bool createNew)
	{
		if (allegianceData != null)
		{
			foreach (KeyValuePair<string, AllegianceInfoWrapper> allegianceDatum in allegianceData)
			{
				if (allegianceDatum.Value != null)
				{
					allegianceDatum.Value.Dispose();
				}
			}
		}
		if (enchantmentData != null)
		{
			foreach (KeyValuePair<string, EnchantmentWrapper> enchantmentDatum in enchantmentData)
			{
				if (enchantmentDatum.Value != null)
				{
					enchantmentDatum.Value.Dispose();
				}
			}
		}
		if (vitalSkillData != null)
		{
			foreach (KeyValuePair<string, SkillInfoWrapper> vitalSkillDatum in vitalSkillData)
			{
				if (vitalSkillDatum.Value != null)
				{
					vitalSkillDatum.Value.Dispose();
				}
			}
		}
		if (attributeData != null)
		{
			foreach (KeyValuePair<string, AttributeInfoWrapper> attributeDatum in attributeData)
			{
				if (attributeDatum.Value != null)
				{
					attributeDatum.Value.Dispose();
				}
			}
		}
		mySpellBook = null;
		if (createNew)
		{
			mySpellBars = new Dictionary<int, ReadOnlyCollection<int>>();
			allegianceData = new Dictionary<string, AllegianceInfoWrapper>();
			enchantmentData = new Dictionary<string, EnchantmentWrapper>();
			vitalSkillData = new Dictionary<string, SkillInfoWrapper>();
			attributeData = new Dictionary<string, AttributeInfoWrapper>();
		}
	}

	internal int get_AccountCharID(int index)
	{
		EnforceDisposedOnce();
		return ((ICharacterStats)base.Wrapped).get_AccountCharID(index);
	}

	internal string get_AccountCharName(int index)
	{
		EnforceDisposedOnce();
		return ((ICharacterStats)base.Wrapped).get_AccountCharName(index);
	}

	public int Shortcut(int slot)
	{
		return ((ICharacterStats)base.Wrapped).get_Quickslots(slot);
	}

	public bool IsSpellKnown(int spellId)
	{
		if (((ICharacterStats)base.Wrapped).get_SpellLearned(spellId) != 0)
		{
			return true;
		}
		return false;
	}

	public int GetCharProperty(int key)
	{
		int pValue = 0;
		if (base.Wrapped.AugmentationExists((eAugmentations)key, out pValue))
		{
			return pValue;
		}
		return 0;
	}

	public ReadOnlyCollection<int> SpellBar(int barNumber)
	{
		EnforceDisposedOnce();
		if (barNumber < 0 || barNumber > 6)
		{
			throw new ArgumentOutOfRangeException("barNumber", barNumber, "barNumber must be between 0 and 6 inclusive");
		}
		if (mySpellBars == null)
		{
			mySpellBars = new Dictionary<int, ReadOnlyCollection<int>>();
		}
		if (!mySpellBars.ContainsKey(barNumber))
		{
			mySpellBars.Add(barNumber, new ReadOnlyCollection<int>(base.Wrapped.SpellBarArray(barNumber)));
		}
		return mySpellBars[barNumber];
	}
}
