407 lines
12 KiB
C#
407 lines
12 KiB
C#
using System.Collections.Generic;
|
|
using Decal.Interop.Filters;
|
|
|
|
namespace Decal.Adapter.Wrappers;
|
|
|
|
/// <summary>
|
|
/// Defines an object in the world
|
|
/// </summary>
|
|
public class WorldObject : GenericDisposableWrapper<Decal.Interop.Filters.WorldObject>
|
|
{
|
|
/// <summary>
|
|
/// Gets the number of active spells on this object.
|
|
/// </summary>
|
|
public int ActiveSpellCount => Values(LongValueKey.ActiveSpellCount);
|
|
|
|
/// <summary>
|
|
/// Gets the number of spells that this object casts.
|
|
/// </summary>
|
|
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)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the spell ID of one of the active spells on this object.
|
|
/// </summary>
|
|
/// <param name="index">The index in the list of active spells.</param>
|
|
/// <returns>The spell ID.</returns>
|
|
public int ActiveSpell(int index)
|
|
{
|
|
return base.Wrapped.ActiveSpell(index);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines whether this object has the specified property.
|
|
/// </summary>
|
|
/// <param name="index">The property to check.</param>
|
|
/// <returns><c>true</c> if this object has the specified property.</returns>
|
|
public bool Exists(BoolValueKey index)
|
|
{
|
|
bool pValue;
|
|
return base.Wrapped.BoolExists((Decal.Interop.Filters.BoolValueKey)index, out pValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines whether this object has the specified property.
|
|
/// </summary>
|
|
/// <param name="index">The property to check.</param>
|
|
/// <returns><c>true</c> if this object has the specified property.</returns>
|
|
public bool Exists(DoubleValueKey index)
|
|
{
|
|
double pValue;
|
|
return base.Wrapped.DoubleExists((Decal.Interop.Filters.DoubleValueKey)index, out pValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines whether this object has the specified property.
|
|
/// </summary>
|
|
/// <param name="index">The property to check.</param>
|
|
/// <returns><c>true</c> if this object has the specified property.</returns>
|
|
public bool Exists(LongValueKey index)
|
|
{
|
|
int pValue;
|
|
return base.Wrapped.LongExists((Decal.Interop.Filters.LongValueKey)index, out pValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines whether this object has the specified property.
|
|
/// </summary>
|
|
/// <param name="index">The property to check.</param>
|
|
/// <returns><c>true</c> if this object has the specified property.</returns>
|
|
public bool Exists(StringValueKey index)
|
|
{
|
|
string pValue;
|
|
return base.Wrapped.StringExists((Decal.Interop.Filters.StringValueKey)index, out pValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, if it exists.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <param name="pValue">Set to the value of the property, if it exists.</param>
|
|
/// <returns><c>true</c> if this object has the specified property.</returns>
|
|
public bool Exists(BoolValueKey index, out bool pValue)
|
|
{
|
|
return base.Wrapped.BoolExists((Decal.Interop.Filters.BoolValueKey)index, out pValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, if it exists.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <param name="pValue">Set to the value of the property, if it exists.</param>
|
|
/// <returns><c>true</c> if this object has the specified property.</returns>
|
|
public bool Exists(DoubleValueKey index, out double pValue)
|
|
{
|
|
return base.Wrapped.DoubleExists((Decal.Interop.Filters.DoubleValueKey)index, out pValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, if it exists.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <param name="pValue">Set to the value of the property, if it exists.</param>
|
|
/// <returns><c>true</c> if this object has the specified property.</returns>
|
|
public bool Exists(LongValueKey index, out int pValue)
|
|
{
|
|
return base.Wrapped.LongExists((Decal.Interop.Filters.LongValueKey)index, out pValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, if it exists.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <param name="pValue">Set to the value of the property, if it exists.</param>
|
|
/// <returns><c>true</c> if this object has the specified property.</returns>
|
|
public bool Exists(StringValueKey index, out string pValue)
|
|
{
|
|
return base.Wrapped.StringExists((Decal.Interop.Filters.StringValueKey)index, out pValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, or <c>false</c> if this
|
|
/// object doesn't have the property.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <returns>The property's value.</returns>
|
|
public bool Values(BoolValueKey index)
|
|
{
|
|
return Values(index, defaultValue: false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, or <c>0.0</c> if this
|
|
/// object doesn't have the property.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <returns>The property's value.</returns>
|
|
public double Values(DoubleValueKey index)
|
|
{
|
|
return Values(index, 0.0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, or <c>0</c> if this
|
|
/// object doesn't have the property.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <returns>The property's value.</returns>
|
|
public int Values(LongValueKey index)
|
|
{
|
|
return index switch
|
|
{
|
|
LongValueKey.Slot => Values(index, -1),
|
|
LongValueKey.SlotLegacy => Values(index, 0),
|
|
_ => Values(index, 0),
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, or <c>""</c> if this
|
|
/// object doesn't have the property.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <returns>The property's value.</returns>
|
|
public string Values(StringValueKey index)
|
|
{
|
|
return Values(index, string.Empty);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, or <c>defaultValue</c>
|
|
/// if this object doesn't have the property.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <param name="defaultValue">The value to return if this object
|
|
/// doesn't have the property.</param>
|
|
/// <returns>The property's value.</returns>
|
|
public bool Values(BoolValueKey index, bool defaultValue)
|
|
{
|
|
return base.Wrapped.Bools((Decal.Interop.Filters.BoolValueKey)index, defaultValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, or <c>defaultValue</c>
|
|
/// if this object doesn't have the property.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <param name="defaultValue">The value to return if this object
|
|
/// doesn't have the property.</param>
|
|
/// <returns>The property's value.</returns>
|
|
public double Values(DoubleValueKey index, double defaultValue)
|
|
{
|
|
return base.Wrapped.Doubles((Decal.Interop.Filters.DoubleValueKey)index, defaultValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, or <c>defaultValue</c>
|
|
/// if this object doesn't have the property.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <param name="defaultValue">The value to return if this object
|
|
/// doesn't have the property.</param>
|
|
/// <returns>The property's value.</returns>
|
|
public int Values(LongValueKey index, int defaultValue)
|
|
{
|
|
return base.Wrapped.Longs((Decal.Interop.Filters.LongValueKey)index, defaultValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of the specified property, or <c>defaultValue</c>
|
|
/// if this object doesn't have the property.
|
|
/// </summary>
|
|
/// <param name="index">The property to get.</param>
|
|
/// <param name="defaultValue">The value to return if this object
|
|
/// doesn't have the property.</param>
|
|
/// <returns>The property's value.</returns>
|
|
public string Values(StringValueKey index, string defaultValue)
|
|
{
|
|
return base.Wrapped.Strings((Decal.Interop.Filters.StringValueKey)index, defaultValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the coordinates of this object, or <c>null</c> if this
|
|
/// object doesn't have coordinates (if it's in a container, etc.)
|
|
/// </summary>
|
|
/// <returns>The coordinates of this object, or <c>null</c> if this
|
|
/// object doesn't have coordinates.</returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets this object's current offset in its landblock, or <c>null</c>
|
|
/// if this object doesn't have an offset (if it's in a container, etc.)
|
|
/// </summary>
|
|
/// <returns>The offset of this object, or <c>null</c> if this object
|
|
/// doesn't have an offset.</returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a quaternion representing the orientation of this object, or
|
|
/// <c>null</c> if this object doesn't have an orientation (if it's in
|
|
/// a container, etc.)
|
|
/// </summary>
|
|
/// <returns>The orientation of this object, or <c>null</c> if this
|
|
/// object doesn't have an orientation.</returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the raw coordinates of this object, or <c>null</c> if this
|
|
/// object doesn't have coordinates (if it's in a container, etc.)
|
|
/// </summary>
|
|
/// <returns>The raw coordinates of this object, or <c>null</c> if this
|
|
/// object doesn't have coordinates.</returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the spell ID of one of the spells that this object casts.
|
|
/// </summary>
|
|
/// <param name="index">The index in the list of spells.</param>
|
|
/// <returns>The spell ID.</returns>
|
|
public int Spell(int index)
|
|
{
|
|
return base.Wrapped.Spell(index);
|
|
}
|
|
}
|