GitLab Commit is coming up on August 3-4. Learn how to innovate together using GitLab, the DevOps platform. Register for free: gitlabcommitvirtual2021.com

Commit 14625b4a authored by Eric Lathrop's avatar Eric Lathrop
Browse files

Add c# events for when items get added/removed from sets

parent a33eba95
......@@ -5,10 +5,15 @@ namespace TwoScoopGames.ScriptableObjects.Sets {
public abstract class RuntimeSet<T> : ScriptableObject {
public List<T> items = new List<T>();
public delegate void RuntimeSetMembershipEventHandler(T sender);
public event RuntimeSetMembershipEventHandler onAdd;
public event RuntimeSetMembershipEventHandler onRemove;
public void Add(T item) {
if (!items.Contains(item)) {
items.Add(item);
ItemAdded(item);
onAdd?.Invoke(item);
}
}
......@@ -18,6 +23,7 @@ namespace TwoScoopGames.ScriptableObjects.Sets {
if (items.Contains(item)) {
items.Remove(item);
ItemRemoved(item);
onRemove?.Invoke(item);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment