Esempio n. 1
0
        public int GetOperationArgument(JsmCommand command, int offset)
        {
            JsmOperation operation = GetOperation(command, offset);

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

            if (operation.Command != command)
            {
                throw new ArgumentException("offset");
            }
            return(operation);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
 }
Esempio n. 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();
        }
Esempio n. 7
0
 protected AsmCommand(JsmCommand command, AsmEvent script, int offset)
 {
     Script          = script;
     Offset          = offset;
     NativeOperation = Script.GetOperation(command, offset);
 }