< Summary

Information
Class: Trailblazer.Navigation.Motor.PlatformSnapshot
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/Motor/Surface/PlatformSnapshot.cs
Line coverage
93%
Covered lines: 15
Uncovered lines: 1
Coverable lines: 16
Total lines: 83
Line coverage: 93.7%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_Active()100%11100%
get_SupportsKinematicMotion()100%22100%
.ctor(...)100%11100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%
Equals(...)100%11100%
Equals(...)50%22100%
GetHashCode()100%210%
RecordData(...)100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/Motor/Surface/PlatformSnapshot.cs

#LineLine coverage
 1using Chronicler;
 2using FixedMathSharp;
 3using System;
 4using System.Text.Json.Serialization;
 5
 6namespace Trailblazer.Navigation.Motor;
 7
 8/// <summary>
 9/// Represents a host-provided snapshot of a contacted surface's stable identity and transform for the current frame.
 10/// </summary>
 11public struct PlatformSnapshot : IEquatable<PlatformSnapshot>, IRecordable
 12{
 13    /// <summary>
 14    /// Stable identifier used to determine whether two surface snapshots refer to the same platform.
 15    /// </summary>
 16    private int _id;
 17
 18    /// <inheritdoc cref="_id"/>
 565119    public readonly int Id => _id;
 20
 21    /// <summary>
 22    /// World-space transform sampled from the host for this frame.
 23    /// </summary>
 24    public Fixed4x4 Transform;
 25
 26    /// <summary>
 27    /// Indicates that the sampled surface should not act as a kinematic carrier for platform locomotion.
 28    /// </summary>
 29    public bool Inert;
 30
 31    /// <summary>
 32    /// Whether this snapshot represents an active platform sample.
 33    /// </summary>
 481234    public readonly bool Active => Id != 0;
 35
 36    /// <summary>
 37    /// Whether this sampled surface should participate in moving-platform attachment and motion transfer logic.
 38    /// </summary>
 385039    public readonly bool SupportsKinematicMotion => Active && !Inert;
 40
 41    /// <summary>
 42    /// Initializes a new instance of the PlatformSnapshot class with the specified identifier, transform, and inert sta
 43    /// </summary>
 44    /// <param name="id">The unique identifier for the platform snapshot.</param>
 45    /// <param name="transform">The transformation matrix representing the platform's position and orientation.</param>
 46    /// <param name="inert">true if the platform is inert and does not interact with other objects; otherwise, false.</p
 47    [JsonConstructor]
 48    public PlatformSnapshot(int id, Fixed4x4 transform, bool inert = false)
 49    {
 23250        _id = id;
 23251        Transform = transform;
 23252        Inert = inert;
 23253    }
 54
 55    /// <summary>
 56    /// Determines whether two PlatformSnapshot instances are equal.
 57    /// </summary>
 37658    public static bool operator ==(PlatformSnapshot left, PlatformSnapshot right) => left.Equals(right);
 59
 60    /// <summary>
 61    /// Determines whether two PlatformSnapshot instances are not equal.
 62    /// </summary>
 37663    public static bool operator !=(PlatformSnapshot left, PlatformSnapshot right) => !(left == right);
 64
 65    /// <summary>
 66    /// Two snapshots are considered the same platform when they share the same stable id.
 67    /// </summary>
 38868    public readonly bool Equals(PlatformSnapshot other) => Id == other.Id;
 69
 70    /// <inheritdoc/>
 1271    public override readonly bool Equals(object? obj) => obj is PlatformSnapshot h && Equals(h);
 72
 73    /// <inheritdoc/>
 074    public override readonly int GetHashCode() => Id;
 75
 76    /// <inheritdoc/>
 77    public void RecordData(IChronicler chronicler)
 78    {
 9479        chronicler.LookValue(ref _id, "Id", 0);
 9480        chronicler.LookValue(ref Transform, "Transform", default);
 9481        chronicler.LookValue(ref Inert, "Inert", false);
 9482    }
 83}