public uint ChooseToRemoveFromKnownSet() { // if the buffer is full we need to choose a vitim. while (KnownCreatures.Count == KnownCreatureLimit) { foreach (var candidate in KnownCreatures.OrderBy(kvp => kvp.Value).ToList()) // .ToList() prevents modifiying an enumerating collection in the rare case we hit an exception down there. { try { if (KnownCreatures.Remove(candidate.Key)) { return(candidate.Key); } } catch { // happens when 2 try to remove time, which we don't care too much. } } } return(uint.MinValue); // 0 }
public bool KnowsCreatureWithId(uint creatureId) { return(KnownCreatures.ContainsKey(creatureId)); }