Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified Collections to Enable Notifications on Change #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/SO Architecture/Collections/BaseCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace ScriptableObjectArchitecture
{
public abstract class BaseCollection : SOArchitectureBaseObject, IEnumerable
public abstract class BaseCollection : GameEventBase, IEnumerable
{
public object this[int index]
{
Expand Down
20 changes: 18 additions & 2 deletions Assets/SO Architecture/Collections/Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,28 @@ public override Type Type
public void Add(T obj)
{
_list.Add(obj);
Raise();
}

public void AddRange(IList<T> obj)
{
_list.AddRange(obj);
Raise();
}

public void Remove(T obj)
{
if (_list.Contains(obj))
{
_list.Remove(obj);
Raise();
}

}
public void Clear()
{
_list.Clear();
Raise();
}
public bool Contains(T value)
{
Expand All @@ -61,10 +74,12 @@ public int IndexOf(T value)
public void RemoveAt(int index)
{
_list.RemoveAt(index);
Raise();
}
public void Insert(int index, T value)
{
_list.Insert(index, value);
Raise();
}
IEnumerator IEnumerable.GetEnumerator()
{
Expand All @@ -78,8 +93,9 @@ public override string ToString()
{
return "Collection<" + typeof(T) + ">(" + Count + ")";
}
public T[] ToArray() {
public T[] ToArray()
{
return _list.ToArray();
}
}
}
}