< 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
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 90
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
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(...)100%22100%
GetHashCode()100%11100%
RecordData(...)100%11100%

File(s)

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

#LineLine coverage
 1//=======================================================================
 2// PlatformSnapshot.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9using System.Text.Json.Serialization;
 10using Chronicler;
 11using FixedMathSharp;
 12
 13namespace Trailblazer.Navigation.Motor;
 14
 15/// <summary>
 16/// Represents a host-provided snapshot of a contacted surface's stable identity and transform for the current frame.
 17/// </summary>
 18public struct PlatformSnapshot : IEquatable<PlatformSnapshot>, IRecordable
 19{
 20    /// <summary>
 21    /// Stable identifier used to determine whether two surface snapshots refer to the same platform.
 22    /// </summary>
 23    private int _id;
 24
 25    /// <inheritdoc cref="_id"/>
 631126    public readonly int Id => _id;
 27
 28    /// <summary>
 29    /// World-space transform sampled from the host for this frame.
 30    /// </summary>
 31    public Fixed4x4 Transform;
 32
 33    /// <summary>
 34    /// Indicates that the sampled surface should not act as a kinematic carrier for platform locomotion.
 35    /// </summary>
 36    public bool Inert;
 37
 38    /// <summary>
 39    /// Whether this snapshot represents an active platform sample.
 40    /// </summary>
 534041    public readonly bool Active => Id != 0;
 42
 43    /// <summary>
 44    /// Whether this sampled surface should participate in moving-platform attachment and motion transfer logic.
 45    /// </summary>
 406746    public readonly bool SupportsKinematicMotion => Active && !Inert;
 47
 48    /// <summary>
 49    /// Initializes a new instance of the PlatformSnapshot class with the specified identifier, transform, and inert sta
 50    /// </summary>
 51    /// <param name="id">The unique identifier for the platform snapshot.</param>
 52    /// <param name="transform">The transformation matrix representing the platform's position and orientation.</param>
 53    /// <param name="inert">true if the platform is inert and does not interact with other objects; otherwise, false.</p
 54    [JsonConstructor]
 55    public PlatformSnapshot(int id, Fixed4x4 transform, bool inert = false)
 56    {
 25757        _id = id;
 25758        Transform = transform;
 25759        Inert = inert;
 25760    }
 61
 62    /// <summary>
 63    /// Determines whether two PlatformSnapshot instances are equal.
 64    /// </summary>
 43265    public static bool operator ==(PlatformSnapshot left, PlatformSnapshot right) => left.Equals(right);
 66
 67    /// <summary>
 68    /// Determines whether two PlatformSnapshot instances are not equal.
 69    /// </summary>
 43170    public static bool operator !=(PlatformSnapshot left, PlatformSnapshot right) => !(left == right);
 71
 72    /// <summary>
 73    /// Two snapshots are considered the same platform when they share the same stable id.
 74    /// </summary>
 44475    public readonly bool Equals(PlatformSnapshot other) => Id == other.Id;
 76
 77    /// <inheritdoc/>
 1478    public override readonly bool Equals(object? obj) => obj is PlatformSnapshot h && Equals(h);
 79
 80    /// <inheritdoc/>
 281    public override readonly int GetHashCode() => Id;
 82
 83    /// <inheritdoc/>
 84    public void RecordData(IChronicler chronicler)
 85    {
 30586        chronicler.LookValue(ref _id, "Id", 0);
 30587        chronicler.LookValue(ref Transform, "Transform", default);
 30588        chronicler.LookValue(ref Inert, "Inert", false);
 30589    }
 90}