2025-10-22 19:30:33 +02:00
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-24 15:13:35 +02:00
|
|
|
/// Moves the Detector to the position in accordance with the player view to limit the player's range of actions to the ones in front of them.
|
2025-10-22 19:30:33 +02:00
|
|
|
/// </summary>
|
|
|
|
|
public partial class DetectionCross : Node2D
|
|
|
|
|
{
|
2025-10-24 15:13:35 +02:00
|
|
|
[Export] private Detector _detector;
|
|
|
|
|
[Export] private float _xOffset;
|
|
|
|
|
[Export] private float _yOffset;
|
2025-10-22 19:30:33 +02:00
|
|
|
|
2025-10-24 15:13:35 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the current look direction of the player and moves the detection shape with it.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="direction"></param>
|
|
|
|
|
public void SetDirection(Vector2 direction)
|
2025-10-22 19:30:33 +02:00
|
|
|
{
|
2025-10-24 15:13:35 +02:00
|
|
|
_detector.Position = new Vector2(direction.X * _xOffset, direction.Y * _yOffset);
|
2025-10-22 19:30:33 +02:00
|
|
|
}
|
|
|
|
|
}
|