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

local db = require('ffxiv_db')
local enum = require('ffxiv_enum')
local ffxiv_ipc_actor_cast = Proto("ffxiv_ipc_actor_cast", "FFXIV-IPC Actor Cast")

local actor_cast_fields = {
  action     = ProtoField.uint16("ffxiv_ipc_actor_cast.action", "Action", base.DEC, db.Action),
  skill_type = ProtoField.uint8("ffxiv_ipc_actor_cast.skill_type", "skillType", base.DEC, enum.reverse.actor_cast_skill_type),
  unknown    = ProtoField.uint8("ffxiv_ipc_actor_cast.unknown", "unknown", base.DEC),
  item_id    = ProtoField.uint32("ffxiv_ipc_actor_cast.item_id", "ItemId", base.DEC, db.Item),
  cast_time  = ProtoField.float("ffxiv_ipc_actor_cast.cast_time", "cast_time", base.DEC),
  target_id  = ProtoField.uint32("ffxiv_ipc_actor_cast.target_id", "target_id", base.HEX),
  rotation   = ProtoField.float("ffxiv_ipc_actor_cast.rotation", "rotation", base.DEC),
  unknown_2  = ProtoField.uint32("ffxiv_ipc_actor_cast.unknown_2", "unknown_2", base.DEC),
  pos_x      = ProtoField.uint16("ffxiv_ipc_actor_cast.pos_x", "posX", base.DEC),
  pos_y      = ProtoField.uint16("ffxiv_ipc_actor_cast.pos_y", "posY", base.DEC),
  pos_z      = ProtoField.uint16("ffxiv_ipc_actor_cast.pos_z", "posZ", base.DEC),
  unknown_3  = ProtoField.uint16("ffxiv_ipc_actor_cast.unknown_3", "unknown_3", base.DEC),
}

ffxiv_ipc_actor_cast.fields = actor_cast_fields

function ffxiv_ipc_actor_cast.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_actor_cast, tvbuf)
  pktinfo.cols.info:set("Actor Cast")

  local len = tvbuf:len()

  -- dissect the action field
  local action_tvbr = tvbuf:range(0, 2)
  local action_val  = action_tvbr:le_uint()
  tree:add_le(actor_cast_fields.action, action_tvbr, action_val)

  -- dissect the skill_type field
  local skill_type_tvbr = tvbuf:range(2, 1)
  local skill_type_val  = skill_type_tvbr:le_uint()
  tree:add_le(actor_cast_fields.skill_type, skill_type_tvbr, skill_type_val)

  -- dissect the unknown field
  local unknown_tvbr = tvbuf:range(3, 1)
  local unknown_val  = unknown_tvbr:le_uint()
  tree:add_le(actor_cast_fields.unknown, unknown_tvbr, unknown_val)

  -- dissect the item_id field
  local item_id_tvbr = tvbuf:range(4, 4)
  local item_id_val  = item_id_tvbr:le_uint()
  tree:add_le(actor_cast_fields.item_id, item_id_tvbr, item_id_val)

  -- dissect the cast_time field
  local cast_time_tvbr = tvbuf:range(8, 4)
  local cast_time_val  = cast_time_tvbr:le_float()
  tree:add_le(actor_cast_fields.cast_time, cast_time_tvbr, cast_time_val)

  -- dissect the target_id field
  local target_id_tvbr = tvbuf:range(12, 4)
  local target_id_val  = target_id_tvbr:le_uint()
  tree:add_le(actor_cast_fields.target_id, target_id_tvbr, target_id_val)

  -- dissect the rotation field
  local rotation_tvbr = tvbuf:range(16, 4)
  local rotation_val  = rotation_tvbr:le_float()
  tree:add_le(actor_cast_fields.rotation, rotation_tvbr, rotation_val)

  -- dissect the unknown_2 field
  local unknown_2_tvbr = tvbuf:range(20, 4)
  local unknown_2_val  = unknown_2_tvbr:le_uint()
  tree:add_le(actor_cast_fields.unknown_2, unknown_2_tvbr, unknown_2_val)

  -- dissect the pos_x field
  local pos_x_tvbr = tvbuf:range(24, 2)
  local pos_x_val  = pos_x_tvbr:le_uint()
  tree:add_le(actor_cast_fields.pos_x, pos_x_tvbr, pos_x_val)

  -- dissect the pos_y field
  local pos_y_tvbr = tvbuf:range(26, 2)
  local pos_y_val  = pos_y_tvbr:le_uint()
  tree:add_le(actor_cast_fields.pos_y, pos_y_tvbr, pos_y_val)

  -- dissect the pos_z field
  local pos_z_tvbr = tvbuf:range(28, 2)
  local pos_z_val  = pos_z_tvbr:le_uint()
  tree:add_le(actor_cast_fields.pos_z, pos_z_tvbr, pos_z_val)

  -- dissect the unknown_3 field
  local unknown_3_tvbr = tvbuf:range(30, 2)
  local unknown_3_val  = unknown_3_tvbr:le_uint()
  tree:add_le(actor_cast_fields.unknown_3, unknown_3_tvbr, unknown_3_val)

  return len
end