// <auto-generated>
//  automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>

using global::System;
using global::System.Collections.Generic;
using global::Google.FlatBuffers;

public struct RobotModule : IFlatbufferObject
{
  private Table __p;
  public ByteBuffer ByteBuffer { get { return __p.bb; } }
  public static void ValidateVersion() { }
  public static RobotModule GetRootAsRobotModule(ByteBuffer _bb) { return GetRootAsRobotModule(_bb, new RobotModule()); }
  public static RobotModule GetRootAsRobotModule(ByteBuffer _bb, RobotModule obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
  public static bool VerifyRobotModule(ByteBuffer _bb) {Google.FlatBuffers.Verifier verifier = new Google.FlatBuffers.Verifier(_bb); return verifier.VerifyBuffer("", false, RobotModuleVerify.Verify); }
  public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
  public RobotModule __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }

  public byte Id { get { int o = __p.__offset(4); return o != 0 ? __p.bb.Get(o + __p.bb_pos) : (byte)0; } }
  public ModuleType ModuleType { get { int o = __p.__offset(6); return o != 0 ? (ModuleType)__p.bb.GetSbyte(o + __p.bb_pos) : ModuleType.SPLITTER; } }
  public ModuleState ConfigurationType { get { int o = __p.__offset(8); return o != 0 ? (ModuleState)__p.bb.Get(o + __p.bb_pos) : ModuleState.NONE; } }
  public TTable? Configuration<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(10); return o != 0 ? (TTable?)__p.__union<TTable>(o + __p.bb_pos) : null; }
  public MotorState ConfigurationAsMotorState() { return Configuration<MotorState>().Value; }

  public static Offset<RobotModule> CreateRobotModule(FlatBufferBuilder builder,
      byte id = 0,
      ModuleType module_type = ModuleType.SPLITTER,
      ModuleState configuration_type = ModuleState.NONE,
      int configurationOffset = 0) {
    builder.StartTable(4);
    RobotModule.AddConfiguration(builder, configurationOffset);
    RobotModule.AddConfigurationType(builder, configuration_type);
    RobotModule.AddModuleType(builder, module_type);
    RobotModule.AddId(builder, id);
    return RobotModule.EndRobotModule(builder);
  }

  public static void StartRobotModule(FlatBufferBuilder builder) { builder.StartTable(4); }
  public static void AddId(FlatBufferBuilder builder, byte id) { builder.AddByte(0, id, 0); }
  public static void AddModuleType(FlatBufferBuilder builder, ModuleType moduleType) { builder.AddSbyte(1, (sbyte)moduleType, 0); }
  public static void AddConfigurationType(FlatBufferBuilder builder, ModuleState configurationType) { builder.AddByte(2, (byte)configurationType, 0); }
  public static void AddConfiguration(FlatBufferBuilder builder, int configurationOffset) { builder.AddOffset(3, configurationOffset, 0); }
  public static Offset<RobotModule> EndRobotModule(FlatBufferBuilder builder) {
    int o = builder.EndTable();
    return new Offset<RobotModule>(o);
  }
  public static void FinishRobotModuleBuffer(FlatBufferBuilder builder, Offset<RobotModule> offset) { builder.Finish(offset.Value); }
  public static void FinishSizePrefixedRobotModuleBuffer(FlatBufferBuilder builder, Offset<RobotModule> offset) { builder.FinishSizePrefixed(offset.Value); }
}


static public class RobotModuleVerify
{
  static public bool Verify(Google.FlatBuffers.Verifier verifier, uint tablePos)
  {
    return verifier.VerifyTableStart(tablePos)
      && verifier.VerifyField(tablePos, 4 /*Id*/, 1 /*byte*/, 1, false)
      && verifier.VerifyField(tablePos, 6 /*ModuleType*/, 1 /*ModuleType*/, 1, false)
      && verifier.VerifyField(tablePos, 8 /*ConfigurationType*/, 1 /*ModuleState*/, 1, false)
      && verifier.VerifyUnion(tablePos, 8, 10 /*Configuration*/, ModuleStateVerify.Verify, false)
      && verifier.VerifyTableEnd(tablePos);
  }
}
