require "Insurgent/InsurgentTraitDefinitions"

RunNGunTrait = CreateInsurgentTrait()
RunNGunTrait.name = "RunNGun"
RunNGunTrait.insurgentExclusive = true

function RunNGunTrait.Create()
    return TraitFactory.addTrait("RunNGun", getText("UI_trait_RunNGun"), 6, getText("UI_trait_RunNGunDesc"), false, false);
end

function RunNGunTrait.OnPlayerUpdate(player)
    if not player:HasTrait("RunNGun") then
        return
    end

    if player:IsAiming() and player:isPlayerMoving() then
        local weapon = player:getPrimaryHandItem()
        if weapon and weapon:IsWeapon() then
            if weapon:getSubCategory() == "Firearm" then
                player:setBeenMovingFor(0);
            end
        end
    end
end

function RunNGunTrait.RegisterEvents()
    Events.OnPlayerUpdate.Add(RunNGunTrait.OnPlayerUpdate)
end