refactor: unify runtime sets, update naming of event channels (#17)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
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:
10
Assets/Scripts/RuntimeSet/EnemyRuntimeSetSO.cs
Normal file
10
Assets/Scripts/RuntimeSet/EnemyRuntimeSetSO.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using DefaultNamespace;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RuntimeSet
|
||||
{
|
||||
[CreateAssetMenu(fileName = "EnemyRuntimeSet",menuName = "Runtime Set/Enemy")]
|
||||
public class EnemyRuntimeSetSO : RuntimeSetSO<Enemy>
|
||||
{
|
||||
}
|
||||
}
|
3
Assets/Scripts/RuntimeSet/EnemyRuntimeSetSO.cs.meta
generated
Normal file
3
Assets/Scripts/RuntimeSet/EnemyRuntimeSetSO.cs.meta
generated
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f1e329a7f6343f88553db21ffb55693
|
||||
timeCreated: 1690858329
|
9
Assets/Scripts/RuntimeSet/HeroUnitRuntimeSet.cs
Normal file
9
Assets/Scripts/RuntimeSet/HeroUnitRuntimeSet.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RuntimeSet
|
||||
{
|
||||
[CreateAssetMenu(fileName = "EnemyRuntimeSet",menuName = "Runtime Set/Hero Unit")]
|
||||
public class HeroUnitRuntimeSetSO : RuntimeSetSO<HeroUnit>
|
||||
{
|
||||
}
|
||||
}
|
3
Assets/Scripts/RuntimeSet/HeroUnitRuntimeSet.cs.meta
generated
Normal file
3
Assets/Scripts/RuntimeSet/HeroUnitRuntimeSet.cs.meta
generated
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ec1a0df7a5949a2959596c722680f76
|
||||
timeCreated: 1691632762
|
41
Assets/Scripts/RuntimeSet/RuntimeSetSO.cs
Normal file
41
Assets/Scripts/RuntimeSet/RuntimeSetSO.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/RuntimeSet/RuntimeSetSO.cs.meta
generated
Normal file
3
Assets/Scripts/RuntimeSet/RuntimeSetSO.cs.meta
generated
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 942f0916a83b433891dd4c6a9bbb50fd
|
||||
timeCreated: 1690858304
|
Reference in New Issue
Block a user