Add new components: CannotStompComponent, SkillUnlockedComponent, SpaceshipEnterComponent, SpaceshipExitComponent, SpinComponent, StompDamageComponent, StraightMotionComponent, TerrainHitFx, TooltipComponent, TrailComponent, and UnlockOnRequirementComponent
This commit is contained in:
22
scripts/components/TrailComponent.cs
Normal file
22
scripts/components/TrailComponent.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
public partial class TrailComponent : Line2D
|
||||
{
|
||||
[Export] public int MaxPoints { get; set; } = 100;
|
||||
|
||||
private readonly Queue<Vector2> _queue = new();
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Owner is Node2D root) _queue.Enqueue(root.GlobalPosition);
|
||||
|
||||
if (_queue.Count > MaxPoints) _queue.Dequeue();
|
||||
|
||||
ClearPoints();
|
||||
|
||||
foreach (var point in _queue) AddPoint(point);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user