public bool SetBondCountWithSpecialUnknownHandling(PotentialBond potentialBond, BondCount bondCount) { if (!atoms.ContainsKey(potentialBond.coords) || !atoms.ContainsKey(potentialBond.getCoordsOfOtherBonder())) { return(false); } if (bondCount > (BondCount)GetBondCountAsInt(potentialBond)) { Atom sourceAtom = atoms[potentialBond.coords]; if (sourceAtom.element != Element.Unknown && (GetTotalBondsAt(potentialBond.coords) - GetBondCountAsInt(potentialBond) + bondCount > (BondCount)sourceAtom.GetMaxBonds())) { // source atom would be over max. bonds return(false); } Atom targetAtom = atoms[potentialBond.getCoordsOfOtherBonder()]; if (targetAtom.element != Element.Unknown && (GetTotalBondsAt(potentialBond.getCoordsOfOtherBonder()) - GetBondCountAsInt(potentialBond) + bondCount > (BondCount)targetAtom.GetMaxBonds())) { // target atom would be over max. bonds return(false); } } SetBondCount(potentialBond, new BondCount?(bondCount)); return(true); }
public bool SetBondCountWithoutMaxBondsCheck(PotentialBond potentialBond, BondCount bondCount) { if (!atoms.ContainsKey(potentialBond.coords) || !atoms.ContainsKey(potentialBond.getCoordsOfOtherBonder())) { return(false); } SetBondCount(potentialBond, new BondCount?(bondCount)); return(true); }