예제 #1
0
파일: CodePiece.cs 프로젝트: helvm/BefunGen
        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);
        }
예제 #2
0
파일: CodePiece.cs 프로젝트: helvm/BefunGen
        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);
            }
        }
예제 #3
0
파일: CodePiece.cs 프로젝트: helvm/BefunGen
        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);
            }
        }
예제 #4
0
 public bool EqualsTagLess(BefungeCommand c)
 {
     return(!HasTag() && !c.HasTag() && this.Type == c.Type && this.Param == c.Param);
 }