diff --git a/assets/maps/map1.map b/assets/maps/map1.map index 81a1e4b..2639408 100644 --- a/assets/maps/map1.map +++ b/assets/maps/map1.map @@ -627,7 +627,8 @@ { "classname" "enemy_spawn" "origin" "648 -680 -248" -"angles" "0 -75 0" +"angles" "0 -90 0" +"head" "field medic" } // entity 3 { @@ -638,6 +639,8 @@ { "classname" "enemy_spawn" "origin" "3256 248 -248" +"head" "field medic" +"angles" "0 0 0" } // entity 5 { diff --git a/assets/models/heads/field medic.glb b/assets/models/heads/field medic.glb index 944af50..53d69c3 100644 Binary files a/assets/models/heads/field medic.glb and b/assets/models/heads/field medic.glb differ diff --git a/src/tb_entities.rs b/src/tb_entities.rs index 8c213cf..1053408 100644 --- a/src/tb_entities.rs +++ b/src/tb_entities.rs @@ -83,7 +83,9 @@ pub struct MoveTarget { #[require(Transform)] #[component(on_add = Self::on_add)] #[model({ "path": "models/alien_naked.glb" })] -pub struct EnemySpawn {} +pub struct EnemySpawn { + pub head: String, +} impl EnemySpawn { fn on_add(mut world: DeferredWorld, entity: Entity, _id: ComponentId) { @@ -91,8 +93,13 @@ impl EnemySpawn { return; }; + let this = world.get_entity(entity).unwrap().get::().unwrap(); + let mesh = asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/alien_naked.glb")); + let head_mesh = asset_server + .load(GltfAssetLabel::Scene(0).from_asset(format!("models/heads/{}.glb", this.head))); + world .commands() .entity(entity) @@ -106,6 +113,10 @@ impl EnemySpawn { LockedAxes::new().lock_rotation_z().lock_rotation_x(), Transform::from_translation(Vec3::new(0., 1.0, 0.)), )) + .with_child(( + Transform::from_translation(Vec3::new(0., 1., 0.)), + SceneRoot(head_mesh), + )) .with_child(( Visibility::default(), Transform::from_translation(Vec3::new(0., -1.4, 0.)) diff --git a/trenchbroom/hedz/hedz.fgd b/trenchbroom/hedz/hedz.fgd index d38e994..98f82c4 100644 --- a/trenchbroom/hedz/hedz.fgd +++ b/trenchbroom/hedz/hedz.fgd @@ -66,6 +66,7 @@ @PointClass base(transform) model({ "path": "models/alien_naked.glb" }) = enemy_spawn [ + head(string) : "head" : "" : "" ] @SolidClass base(transform, target) = movable