Thraka / SadConsole

A .NET ascii/ansi console engine written in C# for MonoGame and XNA. Create your own text roguelike (or other) games!
MIT License
1.22k stars 120 forks source link

Redesign collection types based on framework guidelines #313

Closed Thraka closed 1 year ago

Thraka commented 1 year ago

Framework guide says that collection types should conform to one of the base classes or interfaces, such as IList<T>.

With how many of the new types are being implemented in SadConsole, I think IList<T> is the way to go. The ControlsHost is close to it. Because the ControlsConsole implements the host as .Controls you don't want ControlsHost.Controls for the collection, because then you end up with ControlsConsole.Controls.Controls to get to the collection of the controls. ControlsHost should implement IList<T> (and practically does) but other collections should also follow this pattern:

Also, the EffectSet uses linked list when it probably doesn't need to. It could be cleaned up.

Chris3606 commented 1 year ago

FocusedConsoles (this uses a stack-based system, so is there a framework interface/base for that?)

@Thraka ICollection<T> and IReadOnlyCollection<T> is the closest you can probably get to this. That's all C#'s built-in Stack implements: https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.stack-1?view=net-7.0

Thraka commented 1 year ago

Closing this. I did quite a bit of work in some areas, but I feel like it's good enough and I want to move on from it.