mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-03 18:35:53 +00:00
Remade resource script system
This commit is contained in:
parent
4261009c33
commit
029128c8b8
17 changed files with 576 additions and 386 deletions
|
|
@ -5,17 +5,40 @@ using Godot;
|
|||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
public partial class ScriptableBulletsEmitter : Area2D, IActivable, IScriptHost
|
||||
public partial class ScriptableBulletsEmitter : Node2D, IActivable, IScriptHost
|
||||
{
|
||||
[Export]
|
||||
public BulletScript Script { get; private set; }
|
||||
|
||||
[Export]
|
||||
public bool InvertSignal { get; private set; } = false;
|
||||
|
||||
[Export]
|
||||
public bool EmitOnStart { get; set; } = false;
|
||||
|
||||
[Signal]
|
||||
public delegate void StateChangedEventHandler(bool isEmitting);
|
||||
|
||||
private bool _isActive = false;
|
||||
|
||||
//private BulletScript _scriptInstance;
|
||||
|
||||
protected BulletScript.BulletScriptMachine ScriptMachine;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
//_scriptInstance = Script.Duplicate(true) as BulletScript;
|
||||
|
||||
ScriptMachine = Script.Make(this);
|
||||
|
||||
_homePosition = this.GlobalPosition;
|
||||
|
||||
if (EmitOnStart)
|
||||
{
|
||||
_isActive = true;
|
||||
ScriptMachine.Start();
|
||||
}
|
||||
EmitSignal(SignalName.StateChanged, _isActive);
|
||||
}
|
||||
|
||||
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
|
|
@ -26,23 +49,26 @@ public partial class ScriptableBulletsEmitter : Area2D, IActivable, IScriptHost
|
|||
case ActivationType.Toggle:
|
||||
_isActive = !_isActive;
|
||||
break;
|
||||
case ActivationType.Close:
|
||||
case ActivationType.Enable:
|
||||
_isActive = true;
|
||||
break;
|
||||
case ActivationType.Open:
|
||||
case ActivationType.Enable:
|
||||
_isActive = !InvertSignal;
|
||||
break;
|
||||
case ActivationType.Close:
|
||||
case ActivationType.Disable:
|
||||
_isActive = false;
|
||||
_isActive = InvertSignal;
|
||||
break;
|
||||
case ActivationType.Destroy:
|
||||
_isActive = false;
|
||||
_isActive = InvertSignal;
|
||||
// TODO: Explode
|
||||
break;
|
||||
}
|
||||
|
||||
if (_isActive)
|
||||
{
|
||||
Script.Start(this);
|
||||
ScriptMachine.Start();
|
||||
}
|
||||
|
||||
EmitSignal(SignalName.StateChanged, _isActive);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -51,7 +77,7 @@ public partial class ScriptableBulletsEmitter : Area2D, IActivable, IScriptHost
|
|||
{
|
||||
if (!_isActive) return;
|
||||
|
||||
Script.UpdatePhase(delta);
|
||||
ScriptMachine.UpdatePhase(delta);
|
||||
}
|
||||
|
||||
private Vector2 _homePosition;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue