~starkingdoms/starkingdoms

7ee6868a2a9338ac4b67c4cdc44dfdae6f2f0a1f — TerraMaster85 5 months ago b708feb
fix: planet indicator direction
1 files changed, 11 insertions(+), 3 deletions(-)

M crates/unified/src/client/planet/indicators.rs
M crates/unified/src/client/planet/indicators.rs => crates/unified/src/client/planet/indicators.rs +11 -3
@@ 80,12 80,20 @@ fn update_indicators_position(
    for (planet_position, indicator_id) in &planets_w_indicator {
        let mut offset = planet_position.translation - player_position.translation;

        let sprite_size = 25.0 * camera.scale.z;
        let sprite_size = 32.0 * camera.scale.z;

        let half_window_height = window.height() * camera.scale.z / 2.0 - (sprite_size / 2.0);
        let half_window_width = window.width() * camera.scale.z / 2.0 - (sprite_size / 2.0);
        offset.x = offset.x.clamp(-half_window_width, half_window_width);
        offset.y = offset.y.clamp(-half_window_height, half_window_height);

        // scale both parts to fit x, then same for y
        if offset.x.abs() > half_window_width {
            let scale_factor = offset.x.clamp(-half_window_width, half_window_width) / offset.x;
            offset = offset * scale_factor;
        }
        if offset.y.abs() > half_window_height {
            let scale_factor = offset.y.clamp(-half_window_height, half_window_height) / offset.y;
            offset = offset * scale_factor;
        }

        let Ok((mut this_indicator, mut this_sprite)) = indicators.get_mut(indicator_id.0) else {
            continue;