public int GetOperationArgument(JsmCommand command, int offset) { JsmOperation operation = GetOperation(command, offset); if (!operation.HasArgument) { throw new ArgumentException("command"); } return(operation.Argument); }
public JsmOperation GetOperation(JsmCommand command, int offset) { JsmOperation operation = this[offset]; if (operation.Command != command) { throw new ArgumentException("offset"); } return(operation); }
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); }
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); }
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); }
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(); }
protected AsmCommand(JsmCommand command, AsmEvent script, int offset) { Script = script; Offset = offset; NativeOperation = Script.GetOperation(command, offset); }