2025-04-01 15:46:25 +02:00
|
|
|
|
using Cirno.Scripts.Components.Actors;
|
2025-04-08 19:06:39 +02:00
|
|
|
|
using Cirno.Scripts.Enums;
|
2025-04-01 15:46:25 +02:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Components.FSM.Player;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class PlayerGrazingModule : PlayerArea2DModule
|
|
|
|
|
|
{
|
|
|
|
|
|
[Export] public BulletOwner Owner { get; private set; } = BulletOwner.Player;
|
2025-04-07 16:05:48 +02:00
|
|
|
|
|
2025-04-01 15:46:25 +02:00
|
|
|
|
[Export] public ActorResourceProvider Shield { get; private set; }
|
2025-04-07 16:05:48 +02:00
|
|
|
|
|
2025-04-01 15:46:25 +02:00
|
|
|
|
private bool _enabled = false;
|
|
|
|
|
|
|
|
|
|
|
|
public bool Enabled
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _enabled;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_enabled == value) return;
|
|
|
|
|
|
_enabled = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void EnterState(PlayerState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
Enabled = true;
|
|
|
|
|
|
this.AreaEntered += OnAreaEntered;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnAreaEntered(Area2D area)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!Enabled) return;
|
|
|
|
|
|
if (area is Bullet bullet)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (bullet.IsGrazed) return;
|
|
|
|
|
|
if (!bullet.BulletInfo.Grazeable) return;
|
|
|
|
|
|
if (bullet.BulletOwner is BulletOwner.Player) return;
|
|
|
|
|
|
|
|
|
|
|
|
GD.Print("Grazed");
|
2025-04-07 16:05:48 +02:00
|
|
|
|
|
2025-04-01 16:13:54 +02:00
|
|
|
|
bullet.Graze();
|
|
|
|
|
|
//bullet.IsGrazed = true;
|
2025-04-08 19:06:39 +02:00
|
|
|
|
var baseGrazeValue = bullet.BulletInfo.GrazeValue;
|
|
|
|
|
|
|
|
|
|
|
|
float grazeShield = GlobalState.Instance.SessionSettings.Difficulty switch
|
|
|
|
|
|
{
|
|
|
|
|
|
DifficultyLevel.Easy => baseGrazeValue * 5,
|
|
|
|
|
|
DifficultyLevel.Normal => baseGrazeValue * 2,
|
|
|
|
|
|
DifficultyLevel.Hard or DifficultyLevel.Lunatic => baseGrazeValue,
|
|
|
|
|
|
_ => baseGrazeValue
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Shield.CurrentResource += grazeShield;
|
|
|
|
|
|
|
2025-04-01 15:46:25 +02:00
|
|
|
|
// check if it's grazed
|
|
|
|
|
|
// check if it's grazeable
|
|
|
|
|
|
// restore appropriate amount of shield
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExitState(PlayerState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
Enabled = false;
|
|
|
|
|
|
this.AreaEntered -= OnAreaEntered;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Process(double delta)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void PhysicsProcess(double delta)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|