/// <summary> /// /// </summary> /// <param name="insignia"></param> /// <returns>Returns the argument <paramref name="insignia"/></returns> /// <exception cref="ArgumentException">Thrown when the insignia is already in use</exception> public PlayerInsignia MarkUsed(PlayerInsignia insignia) { if (!freeIndicies.Remove(insignia.Index)) { throw new ArgumentException("Insignia was already in use"); } return(insignia); }
public InsigniaGetter() { PlayerInsignia.InitInsignias(MHUrhoApp.Instance.PackageManager); freeIndicies = new List <int>(); for (int i = 0; i < PlayerInsignia.InsigniaCount; i++) { freeIndicies.Add(i); } }
public PlayerInsignia GetUnusedInsignia(int index) { PlayerInsignia insignia = PlayerInsignia.GetInsignia(index); if (!freeIndicies.Remove(index)) { throw new ArgumentException("Index was already in use"); } return(insignia); }
public PlayerInsignia GetNextUnusedInsignia() { PlayerInsignia insignia = null; for (int i = 0; i < freeIndicies.Count; i++) { int index = freeIndicies[i]; if (index != NeutralPlayerIndex) { freeIndicies.RemoveAt(i); insignia = PlayerInsignia.GetInsignia(index); break; } } return(insignia); }