refactor(simulation): apply rustfmt formatting

Formatting-only changes across server source and test files.
No logic changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-18 01:39:44 +01:00
co-authored by Claude Opus 4.6
parent 1da81a21ea
commit d5a1f6dadb
16 changed files with 169 additions and 105 deletions
+42 -20
View File
@@ -19,7 +19,9 @@ use bevy_ecs::prelude::*;
use rand::Rng;
use crate::bridge::types::{DialogueResponseEvent, RelationshipState};
use crate::content::line_pool::{AccessTier, IndexedDialogueLine, Mood, Situation, Topic, TrustTier};
use crate::content::line_pool::{
AccessTier, IndexedDialogueLine, Mood, Situation, Topic, TrustTier,
};
use crate::content::LinePoolIndexResource;
use crate::knowledge::{EntityRegistry, KnowledgeGraph};
use crate::simulation::movement::PlayerCharacter;
@@ -219,7 +221,11 @@ pub fn derive_situations(
/// - Topic match: +2 per matching topic
///
/// Returns 0 only for lines on cooldown (caller handles).
pub fn score_line(line: &IndexedDialogueLine, npc_mood: Option<Mood>, active_topics: &[Topic]) -> u32 {
pub fn score_line(
line: &IndexedDialogueLine,
npc_mood: Option<Mood>,
active_topics: &[Topic],
) -> u32 {
let mut score: u32 = 1; // Base score — no line is excluded by Layer 4
// Mood match
@@ -318,8 +324,14 @@ pub fn process_talk_interaction(
return;
};
let Ok((player_entity, observer_kg, talk_request, mut response_buffer, mut cooldown, active_dialogue_opt)) =
player_query.single_mut()
let Ok((
player_entity,
observer_kg,
talk_request,
mut response_buffer,
mut cooldown,
active_dialogue_opt,
)) = player_query.single_mut()
else {
return;
};
@@ -784,9 +796,14 @@ mod tests {
let mut match_count = 0;
for seed in 0..100 {
let mut rng = rand_chacha::ChaCha20Rng::seed_from_u64(seed);
if let Some(line) =
select_dialogue_line(&candidates, Some(Mood::Worried), &[], &cooldown, 0, &mut rng)
{
if let Some(line) = select_dialogue_line(
&candidates,
Some(Mood::Worried),
&[],
&cooldown,
0,
&mut rng,
) {
if line.id == "matched" {
match_count += 1;
}
@@ -869,9 +886,10 @@ mod tests {
role: "dock-worker".to_string(),
lines,
};
index
.dialogue
.insert(("the-terminal".to_string(), "dock-worker".to_string()), pool);
index.dialogue.insert(
("the-terminal".to_string(), "dock-worker".to_string()),
pool,
);
index
}
@@ -1009,10 +1027,11 @@ mod tests {
let mut seen_ids: Vec<String> = Vec::new();
for seed in 0..20 {
// Reset for each iteration
world.get_mut::<DialogueResponseBuffer>(player).unwrap().response = None;
world
.entity_mut(player)
.insert(TalkRequest { target: npc });
.get_mut::<DialogueResponseBuffer>(player)
.unwrap()
.response = None;
world.entity_mut(player).insert(TalkRequest { target: npc });
world.insert_resource(SimRng::new(seed));
let mut schedule = bevy_ecs::schedule::Schedule::default();
@@ -1020,7 +1039,11 @@ mod tests {
schedule.run(&mut world);
world.flush();
if let Some(resp) = &world.get::<DialogueResponseBuffer>(player).unwrap().response {
if let Some(resp) = &world
.get::<DialogueResponseBuffer>(player)
.unwrap()
.response
{
if !seen_ids.contains(&resp.line_id) {
seen_ids.push(resp.line_id.clone());
}
@@ -1046,9 +1069,7 @@ mod tests {
world.insert_resource(LinePoolIndexResource(index));
// NPC without DialogueProfile
let npc = world
.spawn((Npc, TilePosition::new(5, 5, 0)))
.id();
let npc = world.spawn((Npc, TilePosition::new(5, 5, 0))).id();
world.resource_mut::<EntityRegistry>().register(npc);
let player = world
@@ -1142,10 +1163,11 @@ mod tests {
);
// Second talk — same tick, line on cooldown
world.get_mut::<DialogueResponseBuffer>(player).unwrap().response = None;
world
.entity_mut(player)
.insert(TalkRequest { target: npc });
.get_mut::<DialogueResponseBuffer>(player)
.unwrap()
.response = None;
world.entity_mut(player).insert(TalkRequest { target: npc });
let mut schedule2 = bevy_ecs::schedule::Schedule::default();
schedule2.add_systems(process_talk_interaction);