using System.Collections.Generic;
using Decal.Interop.Filters;

namespace Decal.Adapter.Wrappers;

public class WorldObject : GenericDisposableWrapper<Decal.Interop.Filters.WorldObject>
{
	public int ActiveSpellCount => Values(LongValueKey.ActiveSpellCount);

	public int SpellCount => Values(LongValueKey.SpellCount);

	public int Behavior => base.Wrapped.Behavior;

	public int Category => base.Wrapped.Category;

	public int Container => base.Wrapped.Container;

	public int GameDataFlags1 => base.Wrapped.GameDataFlags1;

	public int Id => base.Wrapped.GUID;

	public bool HasIdData => base.Wrapped.HasIdData;

	public int Icon => base.Wrapped.Icon;

	public int LastIdTime => base.Wrapped.LastIdTime;

	public string Name => base.Wrapped.Name;

	public ObjectClass ObjectClass => (ObjectClass)base.Wrapped.ObjectClass;

	public int PhysicsDataFlags => base.Wrapped.PhysicsDataFlags;

	public int Type => base.Wrapped.Type;

	public List<int> BoolKeys
	{
		get
		{
			List<int> list = new List<int>();
			int num = 0;
			for (int num2 = base.Wrapped.EnumBoolKey(0); num2 != -1; num2 = base.Wrapped.EnumBoolKey(num))
			{
				list.Add(num2);
				num++;
			}
			if (base.Wrapped.Bools((Decal.Interop.Filters.BoolValueKey)(-1)))
			{
				list.Add(-1);
			}
			return list;
		}
	}

	public List<int> LongKeys
	{
		get
		{
			List<int> list = new List<int>();
			int num = 0;
			for (int num2 = base.Wrapped.EnumLongKey(0); num2 != -1; num2 = base.Wrapped.EnumLongKey(num))
			{
				list.Add(num2);
				num++;
			}
			if (base.Wrapped.Longs((Decal.Interop.Filters.LongValueKey)(-1), -1) != -1)
			{
				list.Add(-1);
			}
			return list;
		}
	}

	public List<int> DoubleKeys
	{
		get
		{
			List<int> list = new List<int>();
			int num = 0;
			for (int num2 = base.Wrapped.EnumDoubleKey(0); num2 != -1; num2 = base.Wrapped.EnumDoubleKey(num))
			{
				list.Add(num2);
				num++;
			}
			if (base.Wrapped.Doubles((Decal.Interop.Filters.DoubleValueKey)(-1), -1.0) != -1.0)
			{
				list.Add(-1);
			}
			return list;
		}
	}

	public List<int> StringKeys
	{
		get
		{
			List<int> list = new List<int>();
			int num = 0;
			for (int num2 = base.Wrapped.EnumStringKey(0); num2 != -1; num2 = base.Wrapped.EnumStringKey(num))
			{
				list.Add(num2);
				num++;
			}
			if (!base.Wrapped.Strings((Decal.Interop.Filters.StringValueKey)(-1), "-1").Equals("-1"))
			{
				list.Add(-1);
			}
			return list;
		}
	}

	public WorldObject(Decal.Interop.Filters.WorldObject obj)
		: base(obj)
	{
	}

	public int ActiveSpell(int index)
	{
		return base.Wrapped.ActiveSpell(index);
	}

	public bool Exists(BoolValueKey index)
	{
		bool pValue;
		return base.Wrapped.BoolExists((Decal.Interop.Filters.BoolValueKey)index, out pValue);
	}

	public bool Exists(DoubleValueKey index)
	{
		double pValue;
		return base.Wrapped.DoubleExists((Decal.Interop.Filters.DoubleValueKey)index, out pValue);
	}

	public bool Exists(LongValueKey index)
	{
		int pValue;
		return base.Wrapped.LongExists((Decal.Interop.Filters.LongValueKey)index, out pValue);
	}

	public bool Exists(StringValueKey index)
	{
		string pValue;
		return base.Wrapped.StringExists((Decal.Interop.Filters.StringValueKey)index, out pValue);
	}

	public bool Exists(BoolValueKey index, out bool pValue)
	{
		return base.Wrapped.BoolExists((Decal.Interop.Filters.BoolValueKey)index, out pValue);
	}

	public bool Exists(DoubleValueKey index, out double pValue)
	{
		return base.Wrapped.DoubleExists((Decal.Interop.Filters.DoubleValueKey)index, out pValue);
	}

	public bool Exists(LongValueKey index, out int pValue)
	{
		return base.Wrapped.LongExists((Decal.Interop.Filters.LongValueKey)index, out pValue);
	}

	public bool Exists(StringValueKey index, out string pValue)
	{
		return base.Wrapped.StringExists((Decal.Interop.Filters.StringValueKey)index, out pValue);
	}

	public bool Values(BoolValueKey index)
	{
		return Values(index, defaultValue: false);
	}

	public double Values(DoubleValueKey index)
	{
		return Values(index, 0.0);
	}

	public int Values(LongValueKey index)
	{
		return index switch
		{
			LongValueKey.Slot => Values(index, -1), 
			LongValueKey.SlotLegacy => Values(index, 0), 
			_ => Values(index, 0), 
		};
	}

	public string Values(StringValueKey index)
	{
		return Values(index, string.Empty);
	}

	public bool Values(BoolValueKey index, bool defaultValue)
	{
		return base.Wrapped.Bools((Decal.Interop.Filters.BoolValueKey)index, defaultValue);
	}

	public double Values(DoubleValueKey index, double defaultValue)
	{
		return base.Wrapped.Doubles((Decal.Interop.Filters.DoubleValueKey)index, defaultValue);
	}

	public int Values(LongValueKey index, int defaultValue)
	{
		return base.Wrapped.Longs((Decal.Interop.Filters.LongValueKey)index, defaultValue);
	}

	public string Values(StringValueKey index, string defaultValue)
	{
		return base.Wrapped.Strings((Decal.Interop.Filters.StringValueKey)index, defaultValue);
	}

	public CoordsObject Coordinates()
	{
		double NorthSouth = 0.0;
		double EastWest = 0.0;
		if (base.Wrapped.Coordinates(ref NorthSouth, ref EastWest))
		{
			return new CoordsObject(NorthSouth, EastWest);
		}
		return null;
	}

	public Vector3Object Offset()
	{
		double x = 0.0;
		double y = 0.0;
		double z = 0.0;
		if (base.Wrapped.Offset(out x, out y, out z))
		{
			return new Vector3Object(x, y, z);
		}
		return null;
	}

	public Vector4Object Orientation()
	{
		double w = 0.0;
		double x = 0.0;
		double y = 0.0;
		double z = 0.0;
		if (base.Wrapped.Orientation(out w, out x, out y, out z))
		{
			return new Vector4Object(w, x, y, z);
		}
		return null;
	}

	public Vector3Object RawCoordinates()
	{
		double pX = 0.0;
		double pY = 0.0;
		double pZ = 0.0;
		if (base.Wrapped.RawCoordinates(ref pX, ref pY, ref pZ))
		{
			return new Vector3Object(pX, pY, pZ);
		}
		return null;
	}

	public int Spell(int index)
	{
		return base.Wrapped.Spell(index);
	}
}
