You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
683 B
29 lines
683 B
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Godot;
|
|
|
|
namespace Babushka.scripts.CSharp.Common.Camera;
|
|
|
|
public partial class CameraTarget : Node2D
|
|
{
|
|
private static readonly List<CameraTarget> AllTargets = new();
|
|
|
|
public static CameraTarget GetActiveTarget() // Called every frame. Maybe needs performance optimization in the future
|
|
{
|
|
return AllTargets
|
|
.OrderByDescending(t => t.Priority)
|
|
.First();
|
|
}
|
|
|
|
[Export] public float Priority { get; set; }
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
AllTargets.Add(this);
|
|
}
|
|
|
|
public override void _ExitTree()
|
|
{
|
|
AllTargets.Remove(this);
|
|
}
|
|
} |