示例#1
0
        public int GetOperationArgument(JsmCommand command, int offset)
        {
            JsmOperation operation = GetOperation(command, offset);

            if (!operation.HasArgument)
            {
                throw new ArgumentException("command");
            }
            return(operation.Argument);
        }
示例#2
0
        public JsmOperation GetOperation(JsmCommand command, int offset)
        {
            JsmOperation operation = this[offset];

            if (operation.Command != command)
            {
                throw new ArgumentException("offset");
            }
            return(operation);
        }
示例#3
0
        public T TryCreate <T>(int offset, JsmCommand command) where T : AsmCommand
        {
            Action <AsmCommand> handler;
            T result = InternalTryCreate <T>(offset, command);

            if (result != null && _createdHandlers.TryGetValue(result.GetType(), out handler))
            {
                handler(result);
            }
            return(result);
        }
示例#4
0
        protected AsmCommandOld(JsmCommand command, int offset, AsmEvent script)
        {
            if (offset < 0 || offset >= script.Count)
            {
                throw new ArgumentOutOfRangeException("offset");
            }

            Script = Exceptions.CheckArgumentNull(script, "script");
            Offset = offset;

            Operation = Script.GetOperation(command, offset);
        }
示例#5
0
 public T TryFind <T>(JsmCommand command) where T : AsmCommand
 {
     for (int i = 0; i < _length; i++)
     {
         T result = TryCreate <T>(i, command);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
示例#6
0
        private T InternalTryCreate <T>(int offset, JsmCommand command) where T : AsmCommand
        {
            offset += _offset;

            if (_event[offset].Command != command)
            {
                return(null);
            }

            switch (command)
            {
            case JsmCommand.SETPC:
                return((T)(AsmCommand) new AsmSetCharacterCommand(_event, offset));

            case JsmCommand.SETPLACE:
                return((T)(AsmCommand) new AsmSetPlaceCommand(_event, offset));

            case JsmCommand.ASK:
                return((T)(AsmCommand) new AsmAskCommand(_event, offset));

            case JsmCommand.AASK:
                return((T)(AsmCommand) new AsmAppearAskCommand(_event, offset));

            case JsmCommand.MES:
                return((T)(AsmCommand) new AsmMessageCommand(_event, offset));

            case JsmCommand.AMES:
                return((T)(AsmCommand) new AsmAppearMessageCommand(_event, offset));

            case JsmCommand.AMESW:
                return((T)(AsmCommand) new AsmAppearMessageAndWaitCommand(_event, offset));

            case JsmCommand.RAMESW:
                return((T)(AsmCommand) new AsmResumeScriptAppearMessageAndWaitCommand(_event, offset));
            }

            throw new NotImplementedException();
        }
示例#7
0
 protected AsmCommand(JsmCommand command, AsmEvent script, int offset)
 {
     Script          = script;
     Offset          = offset;
     NativeOperation = Script.GetOperation(command, offset);
 }