~starkingdoms/starkingdoms

33e867eb07895ba9770a0f9c882855c84ac81aa5 — ghostly_zsh 17 days ago bb44598
feat: hearty in starguide
M crates/unified/src/client/mod.rs => crates/unified/src/client/mod.rs +1 -1
@@ 82,7 82,7 @@ fn find_me(
        info!("^^^^^^^^^^^ IGNORE THESE WARNINGS ^^^^^^^^^^^^^^");
        info!("they are normal! and are from the world state being replicated as it is sent over the network");
        info!(?msg, "finding me: got hello from server");
        commands.entity(msg.you_are).insert(Me).insert(STARGUIDE_LAYER);
        commands.entity(msg.you_are).insert(Me);

        /*let mut heart_sprite =
            Sprite::from_image(asset_server.load("sprites/hearty_heart.png"));

M crates/unified/src/client/starguide/init.rs => crates/unified/src/client/starguide/init.rs +28 -2
@@ 2,17 2,21 @@ use bevy::anti_alias::fxaa::Fxaa;
use bevy::core_pipeline::tonemapping::DebandDither;
use bevy::post_process::bloom::Bloom;
use crate::prelude::*;
use crate::ecs::{StarguideCamera, STARGUIDE_LAYER};
use crate::ecs::{Me, Part, STARGUIDE_LAYER, StarguideCamera, StarguideMe};
use crate::config::planet::SpecialSpriteProperties;
use crate::config::planet::Planet;

pub fn starguide_init_plugin(app: &mut App) {
    app.add_systems(Startup, init_starguide);
    app
        .add_systems(Startup, init_starguide)
        .add_systems(Update, player_init)
        .add_systems(Update, player_position_update);
}

pub fn init_starguide(mut commands: Commands) {
    commands.spawn((Camera2d::default(), Camera {
        is_active: false,
        clear_color: ClearColorConfig::Custom(Color::linear_rgba(0.0, 0.0, 0.0, 0.0)),
        ..default()
    }))
    .insert(Bloom::default())


@@ 21,3 25,25 @@ pub fn init_starguide(mut commands: Commands) {
    .insert(STARGUIDE_LAYER)
    .insert(StarguideCamera);
}

pub fn player_init(
    me: Single<(Entity, &Sprite, &Part), Added<Me>>,
    mut commands: Commands,
    asset_server: Res<AssetServer>,
) {
    let mut sprite = Sprite::from_image(asset_server.load(&me.2.strong_config.part.sprite_connected));
    sprite.custom_size = Some(Vec2::new(
        me.2.strong_config.physics.width,
        me.2.strong_config.physics.height,
    ));
    commands.spawn((sprite, StarguideMe, STARGUIDE_LAYER,
            Transform::from_scale(Vec3::splat(10.0))));
}

fn player_position_update(
    me: Single<&Transform, (Changed<Transform>, With<Me>)>,
    mut starguide_me: Single<&mut Transform, (With<StarguideMe>, Without<Me>)>,
) {
    starguide_me.translation = me.translation;
    starguide_me.rotation = me.rotation;
}

M crates/unified/src/ecs.rs => crates/unified/src/ecs.rs +2 -0
@@ 89,6 89,8 @@ pub struct PlayerStorage {

#[derive(Component)]
pub struct Me;
#[derive(Component)]
pub struct StarguideMe;

#[derive(Message, Serialize, Deserialize, Debug, MapEntities)]
pub struct Hi {