public void AddLeafIdx(int idx) { Assert.IsFalse(leaves.Contains(idx), $"leaf idx {idx} already added"); leaves.Add(idx); Display(Type.Leaf, leaves.Count); if (GetThreshold(Type.Leaf) > 0 && IsSatisfied(Type.Leaf)) { OnLeafFilled?.Invoke(false); } }
// this class really should not throw these events, but such is life public void LimitLeaf(int threshold) { bool prevSatisfied = IsSatisfied(Type.Leaf); Constrain(Type.Leaf, threshold); bool nowSatisfied = IsSatisfied(Type.Leaf); if (!prevSatisfied && nowSatisfied) { OnLeafFilled?.Invoke(false); } else if (prevSatisfied && !nowSatisfied) { OnLeafFilled?.Invoke(true); } }
public void RemoveIdx(int idx) { if (leaves.Contains(idx)) { leaves.Remove(idx); if (GetThreshold(Type.Leaf) > 0 && IsSatisfied(Type.Leaf)) { OnLeafFilled?.Invoke(true); } Display(Type.Leaf, leaves.Count); } else { paws.Remove(idx); if (GetThreshold(Type.Paw) > 0 && IsSatisfied(Type.Paw)) { OnPawFilled?.Invoke(true); } Display(Type.Paw, paws.Count); } }