Grahpics overhaul and predicting bullets

This commit is contained in:
MaddoScientisto 2025-05-04 22:01:59 +02:00
commit 946e7df71e
14 changed files with 144 additions and 26 deletions

View file

@ -4,6 +4,7 @@ using System.Linq;
using Cirno.Scripts.Actors;
using Cirno.Scripts.Components;
using Cirno.Scripts.Resources;
using Cirno.Scripts.Utils;
using Godot;
using Godot.Collections;
using Array = System.Array;
@ -36,6 +37,7 @@ public partial class SpiralPattern : AttackPattern
// [ExportGroup("Modifiers")] [Export] private BulletCreationModifier _modifier;
// [ExportGroup("Modifiers")] [Export] private Array<TimeModifier> _timeModifiers;
[ExportCategory("Other")] [Export] public bool _targetPlayer = false;
[ExportCategory("Other")] [Export] public bool _predictPlayer = false;
[ExportCategory("Overrides")]
[Export] public bool OverrideOwner { get; private set; } = false;
@ -224,7 +226,20 @@ public partial class SpiralPattern : AttackPattern
if (pattern._targetPlayer && GameManager.Instance.PlayerPosition.HasValue)
{
direction = (GameManager.Instance.PlayerPosition.Value - Parent.GlobalPosition).Normalized();
if (pattern._predictPlayer && GameManager.Instance.PlayerVelocity.HasValue)
{
var predictedDirection = MathFunctions.PredictInterceptPosition(Parent.GlobalPosition,
GameManager.Instance.PlayerPosition.Value, GameManager.Instance.PlayerVelocity.Value,
pattern.BulletResource.BulletSpeed);
if (predictedDirection.HasValue)
{
direction = (predictedDirection.Value - Parent.GlobalPosition).Normalized();
}
}
else
{
direction = (GameManager.Instance.PlayerPosition.Value - Parent.GlobalPosition).Normalized();
}
}
var bullet = pattern.MakeBullet(Parent.GlobalPosition, pattern.bulletCount,