using Godot; namespace Cirno.Scripts.Actors; public partial class Prism : Area2D { [Export] public float ReflectionAngle { get; private set; } = 90f; [Export] public float RotationAngle { get; set; } private Sprite2D _sprite; public override void _Ready() { this.AreaEntered += OnCollision; _sprite = this.GetNode("Sprite2D"); SetReflectionAngle(ReflectionAngle); } public void SetReflectionAngle(float angle) { ReflectionAngle = angle; var frames = _sprite.Hframes; var frame = (int)(frames * angle / 360); _sprite.Frame = frame - 1; } private void OnCollision(Area2D other) { if (other is not Bullet bullet) return; bullet.RotateBullet(ReflectionAngle); } }