mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 16:25:55 +00:00
Grazing for shields
This commit is contained in:
parent
c452979a3d
commit
8b28805cbd
22 changed files with 554 additions and 9 deletions
|
|
@ -28,6 +28,8 @@ public partial class Bullet : Area2D
|
|||
|
||||
private GameManager _gameManager;
|
||||
|
||||
public bool IsGrazed { get; set; } = false;
|
||||
|
||||
[Signal] public delegate void OnDestroyEventHandler();
|
||||
|
||||
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ public class BulletInfo
|
|||
public PackedScene DestructionParticlesScene { get; set; }
|
||||
public IBulletModifier Modifier { get; set; }
|
||||
public List<TimeModifier> TimeModifiers { get; set; } = new List<TimeModifier>();
|
||||
|
||||
public bool Grazeable { get; set; }
|
||||
public float GrazeValue { get; set; }
|
||||
|
||||
#region Laser
|
||||
public bool IsLaser { get; set; }
|
||||
|
|
|
|||
65
Scripts/Components/FSM/Player/PlayerGrazingModule.cs
Normal file
65
Scripts/Components/FSM/Player/PlayerGrazingModule.cs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
using Cirno.Scripts.Components.Actors;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM.Player;
|
||||
|
||||
public partial class PlayerGrazingModule : PlayerArea2DModule
|
||||
{
|
||||
[Export] public BulletOwner Owner { get; private set; } = BulletOwner.Player;
|
||||
|
||||
[Export] public ActorResourceProvider Shield { get; private set; }
|
||||
|
||||
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");
|
||||
|
||||
bullet.IsGrazed = true;
|
||||
Shield.CurrentResource += bullet.BulletInfo.GrazeValue;
|
||||
// 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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
1
Scripts/Components/FSM/Player/PlayerGrazingModule.cs.uid
Normal file
1
Scripts/Components/FSM/Player/PlayerGrazingModule.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d2r5eh3wn16bg
|
||||
|
|
@ -20,6 +20,8 @@ public partial class BulletResource : Resource
|
|||
[Export] public BulletOwner Owner = BulletOwner.None;
|
||||
[Export] public DamageType DamageType = DamageType.Neutral;
|
||||
[Export] public bool Controllable = false;
|
||||
[Export] public bool Grazeable { get; set; } = true;
|
||||
[Export] public float GrazeValue { get; set; } = 1f;
|
||||
|
||||
[Export]
|
||||
public BulletCreationModifier Modifier;
|
||||
|
|
@ -44,7 +46,9 @@ public partial class BulletResource : Resource
|
|||
DestroyOnCollision = DestroyOnCollision,
|
||||
DestructionParticlesScene = DestructionParticlesScene,
|
||||
Controllabe = Controllable,
|
||||
TimeModifiers = TimeModifiers.Select(x => x).ToList()
|
||||
TimeModifiers = TimeModifiers.Select(x => x).ToList(),
|
||||
Grazeable = Grazeable,
|
||||
GrazeValue = GrazeValue,
|
||||
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().Select(m => new ModifierWrapper()
|
||||
// {
|
||||
// TimeModifier = m,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue