Skip to content

fix: Use float extension methods in Multiplayer sample #713

@tyevco

Description

@tyevco

Summary

The Multiplayer sample uses direct float comparison instead of the recommended FloatExtensions methods, violating CLAUDE.md guidelines and teaching anti-patterns.

Source: Code Review #682 (SAMPLE-1)

Location

samples/KeenEyes.Sample.Multiplayer/Components.cs:36-46

// CURRENT (lines 36-46):
public readonly uint GetDirtyMask(in Position baseline)
{
    uint mask = 0;
    if (MathF.Abs(X - baseline.X) > 0.001f)  // ❌ Direct float comparison
    {
        mask |= 1;
    }
    // ...
}

// SHOULD BE:
using KeenEyes.Common;

public readonly uint GetDirtyMask(in Position baseline)
{
    uint mask = 0;
    if (!X.ApproximatelyEquals(baseline.X))
    {
        mask |= 1;
    }
    // ...
}

Impact

  • CLAUDE.md explicitly states "Never use == to compare floats"
  • Sample code teaches anti-patterns that users will copy
  • Inconsistent with other samples that use the extension methods

Priority

HIGH - Sample code quality affects all users learning from the codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions