public bool ReadRecord(out DrawTextCommand record) { record = default; unsafe { fixed(byte *pByte = this.buffer) { // This pointer points to the current read point in the // instruction stream. byte *pCur = pByte; // This points to the first byte past the end of the // instruction stream (i.e. when to stop) byte *pEndOfInstructions = pByte + this.currentReadOffset; if ((pCur >= pEndOfInstructions)) //reach end { return(false); } RecordHeader *pCurRecord = (RecordHeader *)pCur; if (pCurRecord->Type != RecordType.DrawText) { return(false); } DrawTextCommand *data = (DrawTextCommand *)(pCur + sizeof(RecordHeader)); record = *data; this.currentReadOffset += pCurRecord->Size; return(true); } } }
private static void DrawText(DrawTextCommand cmd) { using (var text = new PinnedString(cmd.text.Substring(0, Math.Min(99, cmd.text.Length)))) { Call(SET_TEXT_FONT, cmd.font); Call(SET_TEXT_SCALE, cmd.scale, cmd.scale); Call(SET_TEXT_COLOUR, cmd.color); Call(BEGIN_TEXT_COMMAND_DISPLAY_TEXT, PinnedString.CELL_EMAIL_BCON); Call(ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, text); Call(END_TEXT_COMMAND_DISPLAY_TEXT, cmd.x, cmd.y); } }