mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-08 21:15:55 +00:00
Grazing particles and sound
This commit is contained in:
parent
66fbda2b2b
commit
847d33ad4e
14 changed files with 246 additions and 134 deletions
75
Scripts/Components/FSM/3DPlayer/PlayerGrazingModule3D.cs
Normal file
75
Scripts/Components/FSM/3DPlayer/PlayerGrazingModule3D.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Weapons;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
|
||||
public partial class PlayerGrazingModule3D : Area3D, IModule<PlayerState, CharacterBody3D>
|
||||
{
|
||||
[Export] public BulletOwner Owner { get; private set; } = BulletOwner.Player;
|
||||
|
||||
[Export] public ActorResourceProvider Shield { get; private set; }
|
||||
|
||||
private bool _enabled = false;
|
||||
|
||||
public IStateMachine<PlayerState, CharacterBody3D> StateMachine { get; private set; }
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => _enabled;
|
||||
set
|
||||
{
|
||||
if (_enabled == value) return;
|
||||
_enabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void EnterState(PlayerState state)
|
||||
{
|
||||
Enabled = true;
|
||||
this.AreaEntered += OnAreaEntered;
|
||||
}
|
||||
|
||||
private void OnAreaEntered(Area3D area)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
if (area is Bullet3D bullet)
|
||||
{
|
||||
if (!bullet.Enabled) return;
|
||||
if (bullet.IsGrazed) return;
|
||||
if (!bullet.BulletInfo.Grazeable) return;
|
||||
if (bullet.BulletOwner is BulletOwner.Player) return;
|
||||
|
||||
bullet.Graze();
|
||||
//bullet.IsGrazed = true;
|
||||
var baseGrazeValue = bullet.BulletInfo.GrazeValue;
|
||||
|
||||
float grazeShield = baseGrazeValue * GlobalState.Instance.SessionSettings.DifficultyDamageMultiplier;
|
||||
|
||||
Shield.CurrentResource += grazeShield;
|
||||
|
||||
// check if it's grazed
|
||||
// check if it's grazeable
|
||||
// restore appropriate amount of shield
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Init(IStateMachine<PlayerState, CharacterBody3D> machine)
|
||||
{
|
||||
StateMachine = machine;
|
||||
}
|
||||
|
||||
public void ExitState(PlayerState state)
|
||||
{
|
||||
Enabled = false;
|
||||
this.AreaEntered -= OnAreaEntered;
|
||||
}
|
||||
|
||||
public void Process(double delta)
|
||||
{
|
||||
}
|
||||
|
||||
public void PhysicsProcess(double delta)
|
||||
{
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue