refactor: unify runtime sets, update naming of event channels (#17)
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>
This commit is contained in:
2023-08-12 22:26:36 -05:00
committed by madxmike
parent 7b48612c4b
commit ad725ee518
21 changed files with 104 additions and 80 deletions

View File

@@ -0,0 +1,10 @@
using DefaultNamespace;
using UnityEngine;
namespace RuntimeSet
{
[CreateAssetMenu(fileName = "EnemyRuntimeSet",menuName = "Runtime Set/Enemy")]
public class EnemyRuntimeSetSO : RuntimeSetSO<Enemy>
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5f1e329a7f6343f88553db21ffb55693
timeCreated: 1690858329

View File

@@ -0,0 +1,9 @@
using UnityEngine;
namespace RuntimeSet
{
[CreateAssetMenu(fileName = "EnemyRuntimeSet",menuName = "Runtime Set/Hero Unit")]
public class HeroUnitRuntimeSetSO : RuntimeSetSO<HeroUnit>
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0ec1a0df7a5949a2959596c722680f76
timeCreated: 1691632762

View File

@@ -0,0 +1,41 @@
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();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 942f0916a83b433891dd4c6a9bbb50fd
timeCreated: 1690858304