public void SetTag(int x, int y, CodeTag tag, bool force = false) { BefungeCommand cmd = this[x, y]; if (cmd.HasTag() && !force) { throw new InvalidCodeManipulationException("Tryed to remove existing Tag: " + cmd.Tag + " with: " + tag); } BefungeCommand newcmd = new BefungeCommand(cmd.Type, cmd.Param, tag); ForceSet(x, y, newcmd); }
private void ForceSet(int x, int y, BefungeCommand value) // Suppresses CodeModificationException { if (!IsIncluded(x, y)) { Expand(x, y); } BefungeCommand prev = commandArr[x - MinX][y - MinY]; if (prev.HasTag()) { tagCache.Remove(prev.Tag); } commandArr[x - MinX][y - MinY] = value; if (value.HasTag()) { tagCache.Add(value.Tag); } }
private void Set(int x, int y, BefungeCommand value) { if (!IsIncluded(x, y)) { Expand(x, y); } if (commandArr[x - MinX][y - MinY].Type != BefungeCommandType.NOP) { throw new InvalidCodeManipulationException("Modification of CodePiece : " + x + "|" + y); } if (HasTag(value.Tag)) { throw new InvalidCodeManipulationException(string.Format("Duplicate Tag in CodePiece : [{0},{1}] = '{2}' = [{3},{4}])", x, y, value.Tag.ToString(), FindTag(value.Tag).X, FindTag(value.Tag).Y)); } commandArr[x - MinX][y - MinY] = value; if (value.HasTag()) { tagCache.Add(value.Tag); } }
public bool EqualsTagLess(BefungeCommand c) { return(!HasTag() && !c.HasTag() && this.Type == c.Type && this.Param == c.Param); }