-- This file is generated by tools/json2lua.js

local ffxiv_ipc_object_spawn = Proto("ffxiv_ipc_object_spawn", "FFXIV-IPC Object Spawn")

local object_spawn_fields = {
  spawn_index     = ProtoField.uint8("ffxiv_ipc_object_spawn.spawn_index", "spawnIndex", base.DEC),
  obj_kind        = ProtoField.uint8("ffxiv_ipc_object_spawn.obj_kind", "objKind", base.DEC),
  state           = ProtoField.uint8("ffxiv_ipc_object_spawn.state", "state", base.DEC),
  unknown3        = ProtoField.uint8("ffxiv_ipc_object_spawn.unknown3", "unknown3", base.DEC),
  obj_id          = ProtoField.uint32("ffxiv_ipc_object_spawn.obj_id", "objId", base.DEC),
  actor_id        = ProtoField.uint32("ffxiv_ipc_object_spawn.actor_id", "actorId", base.DEC),
  level_id        = ProtoField.uint32("ffxiv_ipc_object_spawn.level_id", "levelId", base.DEC),
  unknown10       = ProtoField.uint32("ffxiv_ipc_object_spawn.unknown10", "unknown10", base.DEC),
  some_actor_id14 = ProtoField.uint32("ffxiv_ipc_object_spawn.some_actor_id14", "someActorId14", base.DEC),
  gimmick_id      = ProtoField.uint32("ffxiv_ipc_object_spawn.gimmick_id", "gimmickId", base.DEC),
  scale           = ProtoField.float("ffxiv_ipc_object_spawn.scale", "scale", base.DEC),
  unknown20a      = ProtoField.int16("ffxiv_ipc_object_spawn.unknown20a", "unknown20a", base.DEC),
  rotation        = ProtoField.uint16("ffxiv_ipc_object_spawn.rotation", "rotation", base.DEC),
  unknown24a      = ProtoField.int16("ffxiv_ipc_object_spawn.unknown24a", "unknown24a", base.DEC),
  unknown24b      = ProtoField.int16("ffxiv_ipc_object_spawn.unknown24b", "unknown24b", base.DEC),
  unknown28a      = ProtoField.uint16("ffxiv_ipc_object_spawn.unknown28a", "unknown28a", base.DEC),
  unknown28c      = ProtoField.int16("ffxiv_ipc_object_spawn.unknown28c", "unknown28c", base.DEC),
  housing_link    = ProtoField.uint32("ffxiv_ipc_object_spawn.housing_link", "housingLink", base.DEC),
  unknown3_c      = ProtoField.int16("ffxiv_ipc_object_spawn.unknown3_c", "unknown3C", base.DEC),
  unknown3_e      = ProtoField.int16("ffxiv_ipc_object_spawn.unknown3_e", "unknown3E", base.DEC),
}

ffxiv_ipc_object_spawn.fields = object_spawn_fields

function ffxiv_ipc_object_spawn.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_object_spawn, tvbuf)
  pktinfo.cols.info:set("Object Spawn")

  local len = tvbuf:len()

  -- dissect the spawn_index field
  local spawn_index_tvbr = tvbuf:range(0, 1)
  local spawn_index_val  = spawn_index_tvbr:le_uint()
  tree:add_le(object_spawn_fields.spawn_index, spawn_index_tvbr, spawn_index_val)

  -- dissect the obj_kind field
  local obj_kind_tvbr = tvbuf:range(1, 1)
  local obj_kind_val  = obj_kind_tvbr:le_uint()
  tree:add_le(object_spawn_fields.obj_kind, obj_kind_tvbr, obj_kind_val)

  -- dissect the state field
  local state_tvbr = tvbuf:range(2, 1)
  local state_val  = state_tvbr:le_uint()
  tree:add_le(object_spawn_fields.state, state_tvbr, state_val)

  -- dissect the unknown3 field
  local unknown3_tvbr = tvbuf:range(3, 1)
  local unknown3_val  = unknown3_tvbr:le_uint()
  tree:add_le(object_spawn_fields.unknown3, unknown3_tvbr, unknown3_val)

  -- dissect the obj_id field
  local obj_id_tvbr = tvbuf:range(4, 4)
  local obj_id_val  = obj_id_tvbr:le_uint()
  tree:add_le(object_spawn_fields.obj_id, obj_id_tvbr, obj_id_val)

  local obj_id_display = ", objId: " .. obj_id_val
  pktinfo.cols.info:append(obj_id_display)
  tree:append_text(obj_id_display)

  -- dissect the actor_id field
  local actor_id_tvbr = tvbuf:range(8, 4)
  local actor_id_val  = actor_id_tvbr:le_uint()
  tree:add_le(object_spawn_fields.actor_id, actor_id_tvbr, actor_id_val)

  -- dissect the level_id field
  local level_id_tvbr = tvbuf:range(12, 4)
  local level_id_val  = level_id_tvbr:le_uint()
  tree:add_le(object_spawn_fields.level_id, level_id_tvbr, level_id_val)

  -- dissect the unknown10 field
  local unknown10_tvbr = tvbuf:range(16, 4)
  local unknown10_val  = unknown10_tvbr:le_uint()
  tree:add_le(object_spawn_fields.unknown10, unknown10_tvbr, unknown10_val)

  -- dissect the some_actor_id14 field
  local some_actor_id14_tvbr = tvbuf:range(20, 4)
  local some_actor_id14_val  = some_actor_id14_tvbr:le_uint()
  tree:add_le(object_spawn_fields.some_actor_id14, some_actor_id14_tvbr, some_actor_id14_val)

  -- dissect the gimmick_id field
  local gimmick_id_tvbr = tvbuf:range(24, 4)
  local gimmick_id_val  = gimmick_id_tvbr:le_uint()
  tree:add_le(object_spawn_fields.gimmick_id, gimmick_id_tvbr, gimmick_id_val)

  -- dissect the scale field
  local scale_tvbr = tvbuf:range(28, 4)
  local scale_val  = scale_tvbr:le_float()
  tree:add_le(object_spawn_fields.scale, scale_tvbr, scale_val)

  -- dissect the unknown20a field
  local unknown20a_tvbr = tvbuf:range(32, 2)
  local unknown20a_val  = unknown20a_tvbr:le_int()
  tree:add_le(object_spawn_fields.unknown20a, unknown20a_tvbr, unknown20a_val)

  -- dissect the rotation field
  local rotation_tvbr = tvbuf:range(34, 2)
  local rotation_val  = rotation_tvbr:le_uint()
  tree:add_le(object_spawn_fields.rotation, rotation_tvbr, rotation_val)

  -- dissect the unknown24a field
  local unknown24a_tvbr = tvbuf:range(36, 2)
  local unknown24a_val  = unknown24a_tvbr:le_int()
  tree:add_le(object_spawn_fields.unknown24a, unknown24a_tvbr, unknown24a_val)

  -- dissect the unknown24b field
  local unknown24b_tvbr = tvbuf:range(38, 2)
  local unknown24b_val  = unknown24b_tvbr:le_int()
  tree:add_le(object_spawn_fields.unknown24b, unknown24b_tvbr, unknown24b_val)

  -- dissect the unknown28a field
  local unknown28a_tvbr = tvbuf:range(40, 2)
  local unknown28a_val  = unknown28a_tvbr:le_uint()
  tree:add_le(object_spawn_fields.unknown28a, unknown28a_tvbr, unknown28a_val)

  -- dissect the unknown28c field
  local unknown28c_tvbr = tvbuf:range(42, 2)
  local unknown28c_val  = unknown28c_tvbr:le_int()
  tree:add_le(object_spawn_fields.unknown28c, unknown28c_tvbr, unknown28c_val)

  -- dissect the housing_link field
  local housing_link_tvbr = tvbuf:range(44, 4)
  local housing_link_val  = housing_link_tvbr:le_uint()
  tree:add_le(object_spawn_fields.housing_link, housing_link_tvbr, housing_link_val)

  -- dissect position3
  local position3_dissector = Dissector.get('ffxiv_ipc_position3')
  local position3_pos = 48
  local position3_len = 12
  local position3_count = 1

  while position3_pos + position3_len <= len do
    local position3_tvbr = tvbuf:range(position3_pos, 12)
    position3_dissector:call(position3_tvbr:tvb(), pktinfo, root)
    position3_pos = position3_pos + position3_len
    position3_count = position3_count - 1
    if position3_count <= 0 then
      break
    end
  end

  -- dissect the unknown3_c field
  local unknown3_c_tvbr = tvbuf:range(60, 2)
  local unknown3_c_val  = unknown3_c_tvbr:le_int()
  tree:add_le(object_spawn_fields.unknown3_c, unknown3_c_tvbr, unknown3_c_val)

  -- dissect the unknown3_e field
  local unknown3_e_tvbr = tvbuf:range(62, 2)
  local unknown3_e_val  = unknown3_e_tvbr:le_int()
  tree:add_le(object_spawn_fields.unknown3_e, unknown3_e_tvbr, unknown3_e_val)

  return len
end