require "Insurgent/InsurgentTraitDefinitions"

LoadoutRiflemanTrait = CreateInsurgentTrait()
LoadoutRiflemanTrait.name = "LoadoutRifleman"
LoadoutRiflemanTrait.insurgentExclusive = true
LoadoutRiflemanTrait.mutualExclusions = {"LoadoutMarksman", "LoadoutAssault", "LoadoutMachinegunner", "LoadoutRecon"}
LoadoutRiflemanTrait.description  = getText("UI_trait_LoadoutRiflemanDesc")

function LoadoutRiflemanTrait.Create()
    return TraitFactory.addTrait("LoadoutRifleman", getText("UI_trait_LoadoutRifleman"), 4, LoadoutRiflemanTrait.description, false, false)
end

function LoadoutRiflemanTrait.OnNewGame(player)
    if not player:HasTrait("LoadoutRifleman") then
        return
    end

    local weapon = InsurgentWeaponUtil.addWeapon(player, "Base.AssaultRifle", {"Base.RedDot", "Base.Laser", "Base.RecoilPad"})
    InsurgentWeaponUtil.addMags(player, "Base.556Clip", 6)
    InsurgentWeaponUtil.equipAndFullyLoadWeapon(player, weapon, "Base.556Clip")
end

function LoadoutRiflemanTrait.RegisterEvents()
    Events.OnNewGame.Add(LoadoutRiflemanTrait.OnNewGame)
end