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