// automatically generated by the FlatBuffers compiler, do not modify


// @generated

use core::mem;
use core::cmp::Ordering;

extern crate flatbuffers;
use self::flatbuffers::{EndianScalar, Follow};

// struct RewardConfig, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct RewardConfig(pub [u8; 12]);
impl Default for RewardConfig { 
  fn default() -> Self { 
    Self([0; 12])
  }
}
impl core::fmt::Debug for RewardConfig {
  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
    f.debug_struct("RewardConfig")
      .field("item_id", &self.item_id())
      .field("amount", &self.amount())
      .field("unk_1", &self.unk_1())
      .finish()
  }
}

impl flatbuffers::SimpleToVerifyInSlice for RewardConfig {}
impl<'a> flatbuffers::Follow<'a> for RewardConfig {
  type Inner = &'a RewardConfig;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    <&'a RewardConfig>::follow(buf, loc)
  }
}
impl<'a> flatbuffers::Follow<'a> for &'a RewardConfig {
  type Inner = &'a RewardConfig;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    flatbuffers::follow_cast_ref::<RewardConfig>(buf, loc)
  }
}
impl<'b> flatbuffers::Push for RewardConfig {
    type Output = RewardConfig;
    #[inline]
    unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
        let src = ::core::slice::from_raw_parts(self as *const RewardConfig as *const u8, <Self as flatbuffers::Push>::size());
        dst.copy_from_slice(src);
    }
    #[inline]
    fn alignment() -> flatbuffers::PushAlignment {
        flatbuffers::PushAlignment::new(4)
    }
}

impl<'a> flatbuffers::Verifiable for RewardConfig {
  #[inline]
  fn run_verifier(
    v: &mut flatbuffers::Verifier, pos: usize
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    use self::flatbuffers::Verifiable;
    v.in_buffer::<Self>(pos)
  }
}

impl<'a> RewardConfig {
  #[allow(clippy::too_many_arguments)]
  pub fn new(
    item_id: u32,
    amount: u32,
    unk_1: i32,
  ) -> Self {
    let mut s = Self([0; 12]);
    s.set_item_id(item_id);
    s.set_amount(amount);
    s.set_unk_1(unk_1);
    s
  }

  pub fn item_id(&self) -> u32 {
    let mut mem = core::mem::MaybeUninit::<<u32 as EndianScalar>::Scalar>::uninit();
    // Safety:
    // Created from a valid Table for this object
    // Which contains a valid value in this slot
    EndianScalar::from_little_endian(unsafe {
      core::ptr::copy_nonoverlapping(
        self.0[0..].as_ptr(),
        mem.as_mut_ptr() as *mut u8,
        core::mem::size_of::<<u32 as EndianScalar>::Scalar>(),
      );
      mem.assume_init()
    })
  }

  pub fn set_item_id(&mut self, x: u32) {
    let x_le = x.to_little_endian();
    // Safety:
    // Created from a valid Table for this object
    // Which contains a valid value in this slot
    unsafe {
      core::ptr::copy_nonoverlapping(
        &x_le as *const _ as *const u8,
        self.0[0..].as_mut_ptr(),
        core::mem::size_of::<<u32 as EndianScalar>::Scalar>(),
      );
    }
  }

  pub fn amount(&self) -> u32 {
    let mut mem = core::mem::MaybeUninit::<<u32 as EndianScalar>::Scalar>::uninit();
    // Safety:
    // Created from a valid Table for this object
    // Which contains a valid value in this slot
    EndianScalar::from_little_endian(unsafe {
      core::ptr::copy_nonoverlapping(
        self.0[4..].as_ptr(),
        mem.as_mut_ptr() as *mut u8,
        core::mem::size_of::<<u32 as EndianScalar>::Scalar>(),
      );
      mem.assume_init()
    })
  }

  pub fn set_amount(&mut self, x: u32) {
    let x_le = x.to_little_endian();
    // Safety:
    // Created from a valid Table for this object
    // Which contains a valid value in this slot
    unsafe {
      core::ptr::copy_nonoverlapping(
        &x_le as *const _ as *const u8,
        self.0[4..].as_mut_ptr(),
        core::mem::size_of::<<u32 as EndianScalar>::Scalar>(),
      );
    }
  }

  pub fn unk_1(&self) -> i32 {
    let mut mem = core::mem::MaybeUninit::<<i32 as EndianScalar>::Scalar>::uninit();
    // Safety:
    // Created from a valid Table for this object
    // Which contains a valid value in this slot
    EndianScalar::from_little_endian(unsafe {
      core::ptr::copy_nonoverlapping(
        self.0[8..].as_ptr(),
        mem.as_mut_ptr() as *mut u8,
        core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
      );
      mem.assume_init()
    })
  }

  pub fn set_unk_1(&mut self, x: i32) {
    let x_le = x.to_little_endian();
    // Safety:
    // Created from a valid Table for this object
    // Which contains a valid value in this slot
    unsafe {
      core::ptr::copy_nonoverlapping(
        &x_le as *const _ as *const u8,
        self.0[8..].as_mut_ptr(),
        core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
      );
    }
  }

}

pub enum OnceRewardTemplateOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct OnceRewardTemplate<'a> {
  pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for OnceRewardTemplate<'a> {
  type Inner = OnceRewardTemplate<'a>;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    Self { _tab: flatbuffers::Table::new(buf, loc) }
  }
}

impl<'a> OnceRewardTemplate<'a> {
  pub const VT_REWARD_ID: flatbuffers::VOffsetT = 4;
  pub const VT_UNK_1: flatbuffers::VOffsetT = 6;
  pub const VT_UNK_2: flatbuffers::VOffsetT = 8;
  pub const VT_UNK_3: flatbuffers::VOffsetT = 10;
  pub const VT_UNK_4: flatbuffers::VOffsetT = 12;
  pub const VT_REWARD_LIST: flatbuffers::VOffsetT = 14;

  #[inline]
  pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
    OnceRewardTemplate { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
    args: &'args OnceRewardTemplateArgs<'args>
  ) -> flatbuffers::WIPOffset<OnceRewardTemplate<'bldr>> {
    let mut builder = OnceRewardTemplateBuilder::new(_fbb);
    if let Some(x) = args.reward_list { builder.add_reward_list(x); }
    if let Some(x) = args.unk_4 { builder.add_unk_4(x); }
    if let Some(x) = args.unk_3 { builder.add_unk_3(x); }
    builder.add_unk_2(args.unk_2);
    builder.add_unk_1(args.unk_1);
    builder.add_reward_id(args.reward_id);
    builder.finish()
  }


  #[inline]
  pub fn reward_id(&self) -> u32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<u32>(OnceRewardTemplate::VT_REWARD_ID, Some(0)).unwrap()}
  }
  #[inline]
  pub fn unk_1(&self) -> i32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<i32>(OnceRewardTemplate::VT_UNK_1, Some(0)).unwrap()}
  }
  #[inline]
  pub fn unk_2(&self) -> i32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<i32>(OnceRewardTemplate::VT_UNK_2, Some(0)).unwrap()}
  }
  #[inline]
  pub fn unk_3(&self) -> Option<flatbuffers::Vector<'a, i32>> {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i32>>>(OnceRewardTemplate::VT_UNK_3, None)}
  }
  #[inline]
  pub fn unk_4(&self) -> Option<flatbuffers::Vector<'a, i32>> {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i32>>>(OnceRewardTemplate::VT_UNK_4, None)}
  }
  #[inline]
  pub fn reward_list(&self) -> Option<flatbuffers::Vector<'a, RewardConfig>> {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, RewardConfig>>>(OnceRewardTemplate::VT_REWARD_LIST, None)}
  }
}

impl flatbuffers::Verifiable for OnceRewardTemplate<'_> {
  #[inline]
  fn run_verifier(
    v: &mut flatbuffers::Verifier, pos: usize
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    use self::flatbuffers::Verifiable;
    v.visit_table(pos)?
     .visit_field::<u32>("reward_id", Self::VT_REWARD_ID, false)?
     .visit_field::<i32>("unk_1", Self::VT_UNK_1, false)?
     .visit_field::<i32>("unk_2", Self::VT_UNK_2, false)?
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i32>>>("unk_3", Self::VT_UNK_3, false)?
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i32>>>("unk_4", Self::VT_UNK_4, false)?
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, RewardConfig>>>("reward_list", Self::VT_REWARD_LIST, false)?
     .finish();
    Ok(())
  }
}
pub struct OnceRewardTemplateArgs<'a> {
    pub reward_id: u32,
    pub unk_1: i32,
    pub unk_2: i32,
    pub unk_3: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i32>>>,
    pub unk_4: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i32>>>,
    pub reward_list: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, RewardConfig>>>,
}
impl<'a> Default for OnceRewardTemplateArgs<'a> {
  #[inline]
  fn default() -> Self {
    OnceRewardTemplateArgs {
      reward_id: 0,
      unk_1: 0,
      unk_2: 0,
      unk_3: None,
      unk_4: None,
      reward_list: None,
    }
  }
}

pub struct OnceRewardTemplateBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> OnceRewardTemplateBuilder<'a, 'b, A> {
  #[inline]
  pub fn add_reward_id(&mut self, reward_id: u32) {
    self.fbb_.push_slot::<u32>(OnceRewardTemplate::VT_REWARD_ID, reward_id, 0);
  }
  #[inline]
  pub fn add_unk_1(&mut self, unk_1: i32) {
    self.fbb_.push_slot::<i32>(OnceRewardTemplate::VT_UNK_1, unk_1, 0);
  }
  #[inline]
  pub fn add_unk_2(&mut self, unk_2: i32) {
    self.fbb_.push_slot::<i32>(OnceRewardTemplate::VT_UNK_2, unk_2, 0);
  }
  #[inline]
  pub fn add_unk_3(&mut self, unk_3: flatbuffers::WIPOffset<flatbuffers::Vector<'b , i32>>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(OnceRewardTemplate::VT_UNK_3, unk_3);
  }
  #[inline]
  pub fn add_unk_4(&mut self, unk_4: flatbuffers::WIPOffset<flatbuffers::Vector<'b , i32>>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(OnceRewardTemplate::VT_UNK_4, unk_4);
  }
  #[inline]
  pub fn add_reward_list(&mut self, reward_list: flatbuffers::WIPOffset<flatbuffers::Vector<'b , RewardConfig>>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(OnceRewardTemplate::VT_REWARD_LIST, reward_list);
  }
  #[inline]
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> OnceRewardTemplateBuilder<'a, 'b, A> {
    let start = _fbb.start_table();
    OnceRewardTemplateBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> flatbuffers::WIPOffset<OnceRewardTemplate<'a>> {
    let o = self.fbb_.end_table(self.start_);
    flatbuffers::WIPOffset::new(o.value())
  }
}

impl core::fmt::Debug for OnceRewardTemplate<'_> {
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    let mut ds = f.debug_struct("OnceRewardTemplate");
      ds.field("reward_id", &self.reward_id());
      ds.field("unk_1", &self.unk_1());
      ds.field("unk_2", &self.unk_2());
      ds.field("unk_3", &self.unk_3());
      ds.field("unk_4", &self.unk_4());
      ds.field("reward_list", &self.reward_list());
      ds.finish()
  }
}
pub enum OnceRewardTemplateTbOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct OnceRewardTemplateTb<'a> {
  pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for OnceRewardTemplateTb<'a> {
  type Inner = OnceRewardTemplateTb<'a>;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    Self { _tab: flatbuffers::Table::new(buf, loc) }
  }
}

impl<'a> OnceRewardTemplateTb<'a> {
  pub const VT_DATA: flatbuffers::VOffsetT = 4;

  #[inline]
  pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
    OnceRewardTemplateTb { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
    args: &'args OnceRewardTemplateTbArgs<'args>
  ) -> flatbuffers::WIPOffset<OnceRewardTemplateTb<'bldr>> {
    let mut builder = OnceRewardTemplateTbBuilder::new(_fbb);
    if let Some(x) = args.data { builder.add_data(x); }
    builder.finish()
  }


  #[inline]
  pub fn data(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<OnceRewardTemplate<'a>>>> {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<OnceRewardTemplate>>>>(OnceRewardTemplateTb::VT_DATA, None)}
  }
}

impl flatbuffers::Verifiable for OnceRewardTemplateTb<'_> {
  #[inline]
  fn run_verifier(
    v: &mut flatbuffers::Verifier, pos: usize
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    use self::flatbuffers::Verifiable;
    v.visit_table(pos)?
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<OnceRewardTemplate>>>>("data", Self::VT_DATA, false)?
     .finish();
    Ok(())
  }
}
pub struct OnceRewardTemplateTbArgs<'a> {
    pub data: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<OnceRewardTemplate<'a>>>>>,
}
impl<'a> Default for OnceRewardTemplateTbArgs<'a> {
  #[inline]
  fn default() -> Self {
    OnceRewardTemplateTbArgs {
      data: None,
    }
  }
}

pub struct OnceRewardTemplateTbBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> OnceRewardTemplateTbBuilder<'a, 'b, A> {
  #[inline]
  pub fn add_data(&mut self, data: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<OnceRewardTemplate<'b >>>>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(OnceRewardTemplateTb::VT_DATA, data);
  }
  #[inline]
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> OnceRewardTemplateTbBuilder<'a, 'b, A> {
    let start = _fbb.start_table();
    OnceRewardTemplateTbBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> flatbuffers::WIPOffset<OnceRewardTemplateTb<'a>> {
    let o = self.fbb_.end_table(self.start_);
    flatbuffers::WIPOffset::new(o.value())
  }
}

impl core::fmt::Debug for OnceRewardTemplateTb<'_> {
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    let mut ds = f.debug_struct("OnceRewardTemplateTb");
      ds.field("data", &self.data());
      ds.finish()
  }
}
