< Summary

Information
Class: Trailblazer.Navigation.NavigationAgentProfileRecord
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/Serialization/NavigationAgentProfileRecord.cs
Line coverage
100%
Covered lines: 33
Uncovered lines: 0
Coverable lines: 33
Total lines: 83
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
.ctor(...)100%11100%
Capture(...)100%11100%
TryCreate(...)100%11100%
RecordData(...)100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/Serialization/NavigationAgentProfileRecord.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationAgentProfileRecord.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 Chronicler;
 10using FixedMathSharp;
 11using Trailblazer.Pathing;
 12
 13namespace Trailblazer.Navigation;
 14
 15/// <summary>Records one exact immutable navigation-agent profile.</summary>
 16internal sealed class NavigationAgentProfileRecord : IRecordable
 17{
 12218    public NavigationAgentProfileRecord()
 19    {
 12220    }
 21
 15422    public NavigationAgentProfileRecord(NavigationAgentProfile profile) => Capture(profile);
 23
 24    public Fixed64 Radius;
 25
 26    public Fixed64 Height;
 27
 28    public Fixed64 RootToFootOffsetY;
 29
 30    public Fixed64 MaxStepUp;
 31
 32    public Fixed64 MaxDropDown;
 33
 34    public Fixed64 ArrivalRadius;
 35
 36    public TraversalMedia AllowedMedia;
 37
 38    public TraversalCapability Capabilities;
 39
 40    public void Capture(NavigationAgentProfile profile)
 41    {
 13942        Radius = profile.Shape.Radius;
 13943        Height = profile.Shape.Height;
 13944        RootToFootOffsetY = profile.Shape.RootToFootOffsetY;
 13945        MaxStepUp = profile.MaxStepUp;
 13946        MaxDropDown = profile.MaxDropDown;
 13947        ArrivalRadius = profile.ArrivalRadius;
 13948        AllowedMedia = profile.AllowedMedia;
 13949        Capabilities = profile.Capabilities;
 13950    }
 51
 52    public bool TryCreate(out NavigationAgentProfile profile)
 53    {
 7854        profile = default;
 55        try
 56        {
 7857            profile = new NavigationAgentProfile(
 7858                new KinematicBodyShape(Radius, Height, RootToFootOffsetY),
 7859                MaxStepUp,
 7860                MaxDropDown,
 7861                ArrivalRadius,
 7862                AllowedMedia,
 7863                Capabilities);
 7464            return true;
 65        }
 466        catch (ArgumentException)
 67        {
 468            return false;
 69        }
 7870    }
 71
 72    public void RecordData(IChronicler chronicler)
 73    {
 19774        RecordValues.Look(chronicler, ref Radius, "Radius", Fixed64.Zero);
 19775        RecordValues.Look(chronicler, ref Height, "Height", Fixed64.Zero);
 19776        RecordValues.Look(chronicler, ref RootToFootOffsetY, "RootToFootOffsetY", Fixed64.Zero);
 19777        RecordValues.Look(chronicler, ref MaxStepUp, "MaxStepUp", Fixed64.Zero);
 19778        RecordValues.Look(chronicler, ref MaxDropDown, "MaxDropDown", Fixed64.Zero);
 19779        RecordValues.Look(chronicler, ref ArrivalRadius, "ArrivalRadius", Fixed64.Zero);
 19780        RecordValues.Look(chronicler, ref AllowedMedia, "AllowedMedia", TraversalMedia.None);
 19781        RecordValues.Look(chronicler, ref Capabilities, "Capabilities", TraversalCapability.None);
 19782    }
 83}