using System; namespace PKHeX.Core; /// /// Stores two reverse values instead of having a backing array. /// public struct EvolutionNode { /// First reverse evolution in the node. public EvolutionLink First; /// Second reverse evolution in the node. Often empty. public EvolutionLink Second; /// /// Registers an evolution link into the next empty slot in the node. /// /// Link to register /// is thrown if the node is full. public void Add(EvolutionLink link) { if (First.IsEmpty) First = link; else if (Second.IsEmpty) Second = link; else throw new InvalidOperationException($"{nameof(EvolutionNode)} already has two links."); } /// /// Registers a function that disallows the reverse evolution link from being valid if the is not satisfied. /// /// Function that checks if the link should be allowed as an evolution path. public void Ban(Func func) { ref var first = ref First; if (first.IsEmpty) return; first.Ban(func); ref var second = ref Second; if (second.IsEmpty) return; second.Ban(func); } }