Stash work on refactor of trajecotry

This commit is contained in:
Michal Pikulski
2025-12-04 16:23:53 +01:00
committed by Michal Pikulski
parent e9d528d837
commit a4363fecb3
7 changed files with 644 additions and 65 deletions

View File

@@ -115,6 +115,12 @@ namespace Common.Input
{
launchAnchor = transform;
}
// Auto-find trajectory preview if not assigned
if (trajectoryPreview == null)
{
trajectoryPreview = GetComponent<Common.Visual.TrajectoryPreview>();
}
}
#endregion
@@ -283,21 +289,6 @@ namespace Common.Input
#region Abstract Methods - Subclass Implementation
/// <summary>
/// Update visual feedback during drag (trajectory preview, rubber band, etc.)
/// </summary>
protected abstract void UpdateVisuals(Vector2 currentPosition, Vector2 direction, float force, float dragDistance, float mass);
/// <summary>
/// Show preview visuals when controller is enabled
/// </summary>
protected abstract void ShowPreview();
/// <summary>
/// Hide preview visuals when controller is disabled
/// </summary>
protected abstract void HidePreview();
/// <summary>
/// Perform the actual launch (spawn projectile/airplane, apply force, etc.)
/// </summary>
@@ -305,6 +296,47 @@ namespace Common.Input
#endregion
#region Virtual Methods - Visual Feedback (Override if needed)
/// <summary>
/// Update visual feedback during drag (trajectory preview, rubber band, etc.)
/// Default: Updates trajectory preview using prefab's physics properties.
/// Override for custom visuals.
/// </summary>
protected virtual void UpdateVisuals(Vector2 currentPosition, Vector2 direction, float force, float dragDistance, float mass)
{
if (trajectoryPreview != null && dragDistance > 0.1f)
{
GameObject prefab = GetProjectilePrefab();
if (prefab != null)
{
trajectoryPreview.UpdateTrajectory(launchAnchor.position, direction, force, prefab);
}
}
}
/// <summary>
/// Show preview visuals when controller is enabled.
/// Default: Shows trajectory preview.
/// Override for custom visuals.
/// </summary>
protected virtual void ShowPreview()
{
trajectoryPreview?.Show();
}
/// <summary>
/// Hide preview visuals when controller is disabled.
/// Default: Hides trajectory preview.
/// Override for custom visuals.
/// </summary>
protected virtual void HidePreview()
{
trajectoryPreview?.Hide();
}
#endregion
#region Virtual Methods - Optional Override
/// <summary>