mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-05 18:55:54 +00:00
Scriptable bullet emitter
This commit is contained in:
parent
d62538a382
commit
4261009c33
17 changed files with 251 additions and 74 deletions
64
Scripts/Actors/ScriptableBulletsEmitter.cs
Normal file
64
Scripts/Actors/ScriptableBulletsEmitter.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using Cirno.Scripts.AttackPatterns;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
public partial class ScriptableBulletsEmitter : Area2D, IActivable, IScriptHost
|
||||
{
|
||||
[Export]
|
||||
public BulletScript Script { get; private set; }
|
||||
|
||||
|
||||
private bool _isActive = false;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_homePosition = this.GlobalPosition;
|
||||
}
|
||||
|
||||
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
switch (activationType)
|
||||
{
|
||||
case ActivationType.Use:
|
||||
case ActivationType.Toggle:
|
||||
_isActive = !_isActive;
|
||||
break;
|
||||
case ActivationType.Close:
|
||||
case ActivationType.Enable:
|
||||
_isActive = true;
|
||||
break;
|
||||
case ActivationType.Open:
|
||||
case ActivationType.Disable:
|
||||
_isActive = false;
|
||||
break;
|
||||
case ActivationType.Destroy:
|
||||
_isActive = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (_isActive)
|
||||
{
|
||||
Script.Start(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (!_isActive) return;
|
||||
|
||||
Script.UpdatePhase(delta);
|
||||
}
|
||||
|
||||
private Vector2 _homePosition;
|
||||
public Vector2 HomePosition => _homePosition;
|
||||
|
||||
public void ChangeSpriteDirection(Vector2 direction)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue