public ComponentLinkCommand(SpeciesReference speciesReference, ComponentBase component, int linkNumber, ComponentLinkType linkType, bool adding) { this.speciesReference = speciesReference; this.component = component; this.linkNumber = linkNumber; this.linkType = linkType; this.adding = adding; }
public void setSpeciesReference(int linkNumber, ComponentLinkType linkType, SpeciesReference reference) { switch (linkType) { case ComponentLinkType.Input: reactants[linkNumber] = reference; break; case ComponentLinkType.Output: products[linkNumber] = reference; break; } }
public ComponentLink(ComponentBase parent, ComponentLinkType type, int linkNumber, float xOffset, float yOffset) { this.parent = parent; this.linkType = type; this.linkNumber = linkNumber; this.xOffset = xOffset; this.yOffset = yOffset; }
public SpeciesReference getSpeciesReference(int linkNumber, ComponentLinkType linkType) { switch (linkType) { case ComponentLinkType.Input: return reactants[linkNumber]; case ComponentLinkType.Output: return products[linkNumber]; } return null; }
public float getLinkPointRadius(int linkNumber, ComponentLinkType linkType) { return 4f; }
public Vector2 getLinkPointOffset(int linkNumber, ComponentLinkType linkType) { Vector2 offset = new Vector2(); float angle = (float)Math.PI * -0.5f; float angleSpacePerLink; if (linkType == ComponentLinkType.Input) { //the angle given to each link around the circle angleSpacePerLink = -(float)Math.PI / (reactants.Length+1f); } else { angleSpacePerLink = (float)Math.PI / (products.Length+1f); } angle += angleSpacePerLink * (1+linkNumber); offset.x = (float)Math.Cos(angle) * ((this.getWidth()*0.5f)+getLinkPointRadius(linkNumber,linkType)*0.5f); offset.y = (float)Math.Sin(angle) * ((this.getHeight() * 0.5f) + getLinkPointRadius(linkNumber, linkType)*0.5f); return offset; }
public String getLinkPointName(int linkNumber, ComponentLinkType linkType) { switch (linkType) { case ComponentLinkType.Input: return getReactantNames()[linkNumber]; case ComponentLinkType.Output: return getProductNames()[linkNumber]; } return "Unknown"; }
public ComponentLink getLinkPoint(int linkNumber, ComponentLinkType linkType) { if (linkComponents == null) { generateLinkComponents(); } int address=linkNumber; if (linkType == ComponentLinkType.Output) { address += reactants.Length; } ComponentLink link=linkComponents[address]; return link; }