Michael
ad725ee518
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Some general refactors: Turns HeroPartySO into a runtime set class. Make runtime set an IEnumerable Simplify name of events Reviewed-on: #17 Reviewed-by: zephyr <zephyr@noreply.localhost> Co-authored-by: Michael <mep053@gmail.com> Co-committed-by: Michael <mep053@gmail.com>
41 lines
952 B
C#
41 lines
952 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace RuntimeSet
|
|
{
|
|
public abstract class RuntimeSetSO<T> : ScriptableObject, IEnumerable<T>
|
|
{
|
|
[HideInInspector] [SerializeField] private List<T> items = new();
|
|
|
|
protected IReadOnlyCollection<T> Items => items;
|
|
public bool IsEmpty => items.Count == 0;
|
|
public int Count => items.Count;
|
|
|
|
public void Add(T item)
|
|
{
|
|
if (!items.Contains(item))
|
|
{
|
|
items.Add(item);
|
|
}
|
|
}
|
|
|
|
public void Remove(T item)
|
|
{
|
|
if (items.Contains(item))
|
|
{
|
|
items.Remove(item);
|
|
}
|
|
}
|
|
|
|
public IEnumerator<T> GetEnumerator()
|
|
{
|
|
return items.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return GetEnumerator();
|
|
}
|
|
}
|
|
} |