Access.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace OpenVIII.Fields
  6. {
  7. public partial class WalkMesh
  8. {
  9. public class Access : ICloneable, IList<short>
  10. {
  11. private List<short> items;
  12. public Access() => this.items = new List<short>(3);
  13. public short this[int index] { get => ((IList<short>)items)[index]; set => ((IList<short>)items)[index] = value; }
  14. public int Count => ((IList<short>)items).Count;
  15. public bool IsReadOnly => ((IList<short>)items).IsReadOnly;
  16. public void Add(short item) => ((IList<short>)items).Add(item);
  17. public void Clear() => ((IList<short>)items).Clear();
  18. public bool Contains(short item) => ((IList<short>)items).Contains(item);
  19. public void CopyTo(short[] array, int arrayIndex) => ((IList<short>)items).CopyTo(array, arrayIndex);
  20. public IEnumerator<short> GetEnumerator() => ((IList<short>)items).GetEnumerator();
  21. public int IndexOf(short item) => ((IList<short>)items).IndexOf(item);
  22. public void Insert(int index, short item) => ((IList<short>)items).Insert(index, item);
  23. public bool Remove(short item) => ((IList<short>)items).Remove(item);
  24. public void RemoveAt(int index) => ((IList<short>)items).RemoveAt(index);
  25. /// <summary>
  26. /// Goal to label unpassable locations. Deling labeled as -1 unsure if it's -1 or lessthanequal
  27. /// </summary>
  28. /// <param name="index">Which side of triangle in clockwise order</param>
  29. /// <returns></returns>
  30. /// <see cref="https://github.com/myst6re/deling/blob/master/WalkmeshGLWidget.cpp"/>
  31. public bool IsWall(int index) => items[index] <= -1;
  32. IEnumerator IEnumerable.GetEnumerator() => ((IList<short>)items).GetEnumerator();
  33. public object Clone() => new Access { items = items.ToList()};
  34. }
  35. }
  36. }