refactor(server): fix clippy warnings from Rust 1.93
- Use #[derive(Default)] + #[default] instead of manual Default impls for FacingDirection, KnowledgeState, RelationshipState, EntityVisibility - Replace manual modulo check with .is_multiple_of() - Collapse nested if in shadowcast symmetry check Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -47,8 +47,9 @@ pub struct GameTime {
|
||||
|
||||
/// 8-directional facing direction, matching movement system.
|
||||
/// Used for vision cone computation (D-015) and snapshot wire format.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
|
||||
pub enum FacingDirection {
|
||||
#[default]
|
||||
North,
|
||||
Northeast,
|
||||
East,
|
||||
@@ -59,12 +60,6 @@ pub enum FacingDirection {
|
||||
Northwest,
|
||||
}
|
||||
|
||||
impl Default for FacingDirection {
|
||||
fn default() -> Self {
|
||||
FacingDirection::North
|
||||
}
|
||||
}
|
||||
|
||||
/// A tile visible to the observer with its visibility quality
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct VisibleTile {
|
||||
|
||||
@@ -100,7 +100,7 @@ pub fn decay_knowledge(
|
||||
mut knowledge_query: Query<&mut KnowledgeGraph>,
|
||||
) {
|
||||
// Decay runs every 10 ticks (1 game-minute per D-031)
|
||||
if time.tick % 10 != 0 {
|
||||
if !time.tick.is_multiple_of(10) {
|
||||
return;
|
||||
}
|
||||
for mut kg in knowledge_query.iter_mut() {
|
||||
|
||||
@@ -70,9 +70,10 @@ impl KnowledgeConfidence {
|
||||
|
||||
/// Temporal/logical state of a knowledge entry.
|
||||
/// Orthogonal to confidence: a KnowsDetails entry can be Active or Contradicted.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
|
||||
pub enum KnowledgeState {
|
||||
/// Currently believed true. Default state.
|
||||
#[default]
|
||||
Active,
|
||||
/// Conflicting information exists. Both conflicting entries receive this state.
|
||||
/// Triggers monologue event when set. THE FRIEND arc detector.
|
||||
@@ -82,12 +83,6 @@ pub enum KnowledgeState {
|
||||
Stale,
|
||||
}
|
||||
|
||||
impl Default for KnowledgeState {
|
||||
fn default() -> Self {
|
||||
Self::Active
|
||||
}
|
||||
}
|
||||
|
||||
// --- Knowledge Source ---
|
||||
|
||||
/// How knowledge was acquired. Tracked per-entry for provenance.
|
||||
@@ -119,9 +114,10 @@ pub enum SoundRange {
|
||||
/// Relationship state drives D-033 entity color rendering.
|
||||
/// Derived from knowledge + NPC relationship axes (D-024).
|
||||
/// Client maps this to color palette defined in D-033.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
|
||||
pub enum RelationshipState {
|
||||
/// No prior knowledge. Teal #4a9ebb.
|
||||
#[default]
|
||||
Unknown,
|
||||
/// Recognized, neutral-to-positive. Soft green #6bc9a6.
|
||||
Known,
|
||||
@@ -133,12 +129,6 @@ pub enum RelationshipState {
|
||||
Hostile,
|
||||
}
|
||||
|
||||
impl Default for RelationshipState {
|
||||
fn default() -> Self {
|
||||
Self::Unknown
|
||||
}
|
||||
}
|
||||
|
||||
// --- Entity Knowledge ---
|
||||
|
||||
/// What entity A knows about entity B.
|
||||
@@ -205,9 +195,10 @@ impl Default for DecayThresholds {
|
||||
|
||||
/// How an entity appears in the observer snapshot.
|
||||
/// Extends VisibleEntity for knowledge-based rendering.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
pub enum EntityVisibility {
|
||||
/// Currently in line of sight.
|
||||
#[default]
|
||||
Visible,
|
||||
/// Not in LOS but remembered from knowledge graph.
|
||||
Remembered {
|
||||
@@ -215,9 +206,3 @@ pub enum EntityVisibility {
|
||||
age_ticks: u64,
|
||||
},
|
||||
}
|
||||
|
||||
impl Default for EntityVisibility {
|
||||
fn default() -> Self {
|
||||
Self::Visible
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,11 +286,9 @@ fn has_line_of_sight(
|
||||
|
||||
loop {
|
||||
// Check if we hit a blocking tile BEFORE reaching target
|
||||
if (x != x0 || y != y0) && (x != x1 || y != y1) {
|
||||
if is_opaque(x, y) {
|
||||
// Hit an obstacle before reaching target - blocked
|
||||
return false;
|
||||
}
|
||||
if (x != x0 || y != y0) && (x != x1 || y != y1) && is_opaque(x, y) {
|
||||
// Hit an obstacle before reaching target - blocked
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we reach the target, we can see it
|
||||
|
||||
Reference in New Issue
Block a user