Code/Vehicle/Wheel/WheelCollider.Visual.cs
using System;
using Sandbox;
namespace Meteor.VehicleTool.Vehicle.Wheel;
public partial class WheelCollider
{
[Property]
[FeatureEnabled( "Visual", Icon = "videocam" )]
public bool UseVisual { get; set; } = true;
[Feature( "Visual" )]
[Property] public GameObject RendererObject { get; set; }
void UpdateVisual()
{
if ( !RendererObject.IsValid() )
return;
RendererObject.WorldPosition = GetCenter();
}
[Feature( "Visual" )]
[Button]
public void SetBoundsToVisual()
{
var bounds = RendererObject.GetLocalBounds().Size / 2;
using ( Scene.Editor.UndoScope( "Set Bounds To Visual" ).WithComponentChanges( this ).Push() )
{
Width = Math.Max( 0.5f, bounds.y * 2 - 1 );
Radius = Math.Max( 0.5f, bounds.x - 1 );
}
}
}