public static int GetParryCounter(Pawn pawn, bool increase) { // We scan the list pruning null references and increase the counter if we find the pawn in it // If the pawn isn't found we create a new entry on the list // We return the current counter foreach (MRpawntoken p in Pawntokens) { if (p.pawn == null) { Pawntokens.Remove(p); } else { if (p.pawn.Equals(pawn)) { if (increase) { p.counter++; } return(p.counter); } } } Pawntokens.Add(new MRpawntoken(pawn)); return(Pawntokens.Last().counter); }
public static void ResetParryCounter(Pawn pawn) { // We scan the list for a reference to the pawn, cleaning all null references // If we find the pawn we reset the counter foreach (MRpawntoken p in Pawntokens) { if (p.pawn == null) { Pawntokens.Remove(p); } else { if (p.pawn.Equals(pawn)) { p.counter = 0; return; } } } }
public static MRpawntoken GetPawnToken(Pawn pawn) { // We scan the list pruning null references and if we find the pawn in it we return the full token // If the pawn isn't found we create a new entry on the list with defaults foreach (MRpawntoken p in Pawntokens) { if (p.pawn == null) { Pawntokens.Remove(p); } else { if (p.pawn.Equals(pawn)) { return(p); } } } Pawntokens.Add(new MRpawntoken(pawn)); return(Pawntokens.Last()); }