Files
sbox-public/engine/Sandbox.Engine/Game/Navigation/NavMesh/NavMesh.Serialize.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

49 lines
1.6 KiB
C#

using System.Text.Json.Nodes;
namespace Sandbox.Navigation;
public sealed partial class NavMesh
{
/// <summary>
/// Data saved in a Scene file
/// </summary>
internal JsonObject Serialize()
{
JsonObject jso = new JsonObject();
jso["Enabled"] = IsEnabled;
jso["IncludeStaticBodies"] = IncludeStaticBodies;
jso["IncludeKeyframedBodies"] = IncludeKeyframedBodies;
jso["EditorAutoUpdate"] = EditorAutoUpdate;
jso["AgentHeight"] = AgentHeight;
jso["AgentRadius"] = AgentRadius;
jso["AgentStepSize"] = AgentStepSize;
jso["AgentMaxSlope"] = AgentMaxSlope;
jso["ExcludedBodies"] = Json.ToNode( ExcludedBodies, typeof( TagSet ) );
jso["IncludedBodies"] = Json.ToNode( IncludedBodies, typeof( TagSet ) );
return jso;
}
/// <summary>
/// Data loaded from a Scene file
/// </summary>
internal void Deserialize( JsonObject jso )
{
if ( jso is null )
return;
IsEnabled = (bool)(jso["Enabled"] ?? IsEnabled);
IncludeStaticBodies = (bool)(jso["IncludeStaticBodies"] ?? IncludeStaticBodies);
IncludeKeyframedBodies = (bool)(jso["IncludeKeyframedBodies"] ?? IncludeKeyframedBodies);
EditorAutoUpdate = (bool)(jso["EditorAutoUpdate"] ?? EditorAutoUpdate);
AgentHeight = (float)(jso["AgentHeight"] ?? AgentHeight);
AgentRadius = (float)(jso["AgentRadius"] ?? AgentRadius);
AgentStepSize = (float)(jso["AgentStepSize"] ?? AgentStepSize);
AgentMaxSlope = (float)(jso["AgentMaxSlope"] ?? AgentMaxSlope);
ExcludedBodies = Json.FromNode( jso["ExcludedBodies"], typeof( TagSet ) ) as TagSet ?? ExcludedBodies;
IncludedBodies = Json.FromNode( jso["IncludedBodies"], typeof( TagSet ) ) as TagSet ?? IncludedBodies;
}
}