mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Shooting and big tank fix
This commit is contained in:
parent
cc00c8eaf0
commit
0a6e89faed
26 changed files with 797 additions and 9 deletions
97
Scripts/Actors/ScriptableBulletsEmitter3D.cs
Normal file
97
Scripts/Actors/ScriptableBulletsEmitter3D.cs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
using Cirno.Scripts.AttackPatterns;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Resources.BulletScripts;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
public partial class ScriptableBulletsEmitter3D : Node3D, IActivable, IScriptHost3D
|
||||
{
|
||||
public Node3D ParentObject => this;
|
||||
|
||||
[Export]
|
||||
public BulletScript3D Script { get; 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 BulletScript3D.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)
|
||||
{
|
||||
switch (activationType)
|
||||
{
|
||||
case ActivationType.Use:
|
||||
case ActivationType.Toggle:
|
||||
_isActive = !_isActive;
|
||||
break;
|
||||
case ActivationType.Open:
|
||||
case ActivationType.Enable:
|
||||
_isActive = !InvertSignal;
|
||||
break;
|
||||
case ActivationType.Close:
|
||||
case ActivationType.Disable:
|
||||
_isActive = InvertSignal;
|
||||
break;
|
||||
case ActivationType.Destroy:
|
||||
_isActive = InvertSignal;
|
||||
// TODO: Explode
|
||||
break;
|
||||
}
|
||||
|
||||
if (_isActive)
|
||||
{
|
||||
ScriptMachine.Start();
|
||||
}
|
||||
|
||||
EmitSignal(SignalName.StateChanged, _isActive);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Toggle()
|
||||
{
|
||||
this.Activate();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (!_isActive) return;
|
||||
|
||||
ScriptMachine.UpdatePhase(delta);
|
||||
}
|
||||
|
||||
private Vector3 _homePosition;
|
||||
public Vector3 HomePosition => _homePosition;
|
||||
|
||||
public void ChangeSpriteDirection(Vector2 direction)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue