dofile_once( "mods/spellbound_bundle/files/scripts/utils.lua");
local entity = GetUpdatedEntityID();
local projectile = EntityGetFirstComponentIncludingDisabled( entity, "ProjectileComponent" );
if projectile ~= nil then
    local keep = false;
    local shooter = ComponentGetValue2( projectile, "mWhoShot" ) or 0;
    local active_wand = getCurrentlyEquippedWandId( shooter );
    if active_wand ~= nil then
        local aim_angle = 0;
        local controls = EntityGetFirstComponentIncludingDisabled( entity, "ControlsComponent" );
        if controls then
            local ax, ay = ComponentGetValue2( component, "mAimingVector" );
            aim_angle = math.atan2( ay, ax );
        end
        local velocity = EntityGetFirstComponentIncludingDisabled( entity, "VelocityComponent" );
        local magnitude = 0;
        if velocity ~= nil then
            local vx, vy = ComponentGetValue2( velocity, "mVelocity" );
            magnitude = math.sqrt( vx * vx + vy * vy ) / 60;
        end
        local x, y, angle = EntityGetTransform( entity );
        angle = aim_angle - angle;
        local wx, wy = EntityGetTransform( active_wand );
        EntitySetVariable( entity, "gkbrkn_magic_hand_angle", "float", angle );
    end
end