Park/Paths/CursorPath.cs
using HC3.Terrain;
using System;
namespace HC3;
/// <summary>
/// The visuals for current cursor path
/// this doesn't really need to be it's own Component but I imagine we'll replace this with a nice pretty mesh at some point?
/// </summary>
class CursorPath : Component
{
PathBuilder PathBuilder => PathBuilder.Instance;
protected override void OnUpdate()
{
base.OnUpdate();
if ( !PathBuilder.Enabled || !PathBuilder.CursorPosition.HasValue )
{
DestroyGameObject();
return;
}
using var gizmo = Gizmo.Scope( "CursorPath" );
Vector3 direction = (Vector3Int)PathBuilder.Direction.GetDirection();
WorldPosition = GridManager.GridToWorldPosition( PathBuilder.CursorPosition.Value ) + GridManager.CentreOffset;
WorldRotation = Rotation.LookAt( direction );
var bbox = BBox.FromPositionAndSize( WorldPosition + Vector3.Up * 4, new Vector3( GridManager.GridSize, GridManager.GridSize, 0 ) );
Gizmo.Draw.LineThickness = 4;
Gizmo.Draw.Color = Color.White.WithAlpha( 0.2f );
//Gizmo.Draw.LineBBox( bbox );
Gizmo.Transform = WorldTransform;
var start = Vector3.Up * 4;
float offset = 18 + (MathF.Sin( RealTime.Now * 4 ) * 5);
Gizmo.Draw.Color = Color.White;
Gizmo.Draw.Model( "models/gameplay/arrow.vmdl", new Transform( start + Vector3.Forward * offset, Rotation.LookAt( Vector3.Up, Vector3.Left ) ) );
}
}