mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Adds a generic IModdedOptionList definition for easier typed iteration
This commit is contained in:
1 parent
8fa87c0b7d
commit
1ab662bcf1
2 files changed
+25
-7
No files matched your search
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.PluginLoading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.GameOptions;
|
||||
@@ -122,3 +122,16 @@ public interface IModdedOption
|
||||
public interface IModdedOptionList : IReadOnlyList<IModdedOption>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for list of <typeparamref name="T"/> options.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of <see cref="IModdedOption"/>.</typeparam>
|
||||
public interface IModdedOptionList<out T> : IModdedOptionList where T : IModdedOption
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
new T this[int index] { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
new IEnumerator<T> GetEnumerator();
|
||||
}
|
||||
@@ -9,7 +9,7 @@ namespace MiraAPI.GameOptions.OptionTypes;
|
||||
/// Represents a modded option list.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of options.</typeparam>
|
||||
public class ModdedOptionList<T> : IModdedOptionList where T : IModdedOption
|
||||
public class ModdedOptionList<T> : IModdedOptionList<T> where T : IModdedOption
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public int Count { get; }
|
||||
@@ -40,10 +40,10 @@ public class ModdedOptionList<T> : IModdedOptionList where T : IModdedOption
|
||||
Options = options.ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerator<IModdedOption> GetEnumerator()
|
||||
/// <inheritdoc cref="IEnumerable{T}.GetEnumerator"/>
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return ((IEnumerable<IModdedOption>)Options).GetEnumerator();
|
||||
return Options.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
@@ -51,6 +51,11 @@ public class ModdedOptionList<T> : IModdedOptionList where T : IModdedOption
|
||||
return Options.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator<IModdedOption> IEnumerable<IModdedOption>.GetEnumerator()
|
||||
{
|
||||
return ((IEnumerable<IModdedOption>)Options).GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indexes the option of type <typeparamref name="T"/>.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user