mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-07 08:15:53 +00:00
Autospawner trigger
This commit is contained in:
parent
d99c773641
commit
6b3f6b5bfb
1 changed files with 48 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Components.FSM.Enemy;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Resources.Loot;
|
||||
|
|
@ -8,7 +9,7 @@ using Godot;
|
|||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
[Tool]
|
||||
public partial class RogueliteEnemySpawner : Marker2D
|
||||
public partial class RogueliteEnemySpawner : Marker2D, IActivable
|
||||
{
|
||||
private EnemyResource _enemy;
|
||||
|
||||
|
|
@ -26,7 +27,21 @@ public partial class RogueliteEnemySpawner : Marker2D
|
|||
}
|
||||
}
|
||||
|
||||
[Export] public bool AutoSpawn { get; set; } = false;
|
||||
private bool _autoSpawn = false;
|
||||
|
||||
[Export]
|
||||
public bool AutoSpawn
|
||||
{
|
||||
get => _autoSpawn;
|
||||
set
|
||||
{
|
||||
_autoSpawn = value;
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Export] public int Wave { get; private set; } = 0;
|
||||
|
||||
|
|
@ -41,8 +56,11 @@ public partial class RogueliteEnemySpawner : Marker2D
|
|||
if (!Engine.IsEditorHint()) return;
|
||||
if (Enemy is null) return;
|
||||
if (Enemy.IconSprite is null) return;
|
||||
|
||||
var modulate = AutoSpawn ? new Color(1.0f, 1.0f, 1.0f, 1.0f) : new Color(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
DrawTexture(Enemy.IconSprite, - new Vector2(_enemy.IconSprite.GetWidth() / 2f, _enemy.IconSprite.GetHeight() / 2f), modulate);
|
||||
|
||||
DrawTexture(Enemy.IconSprite, - new Vector2(_enemy.IconSprite.GetWidth() / 2f, _enemy.IconSprite.GetHeight() / 2f));
|
||||
}
|
||||
|
||||
private void Redraw()
|
||||
|
|
@ -103,4 +121,30 @@ public partial class RogueliteEnemySpawner : Marker2D
|
|||
_spawnedEnemy = null;
|
||||
Spawned = false;
|
||||
}
|
||||
|
||||
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
switch (activationType)
|
||||
{
|
||||
case ActivationType.Toggle:
|
||||
Spawn();
|
||||
break;
|
||||
case ActivationType.Enable:
|
||||
break;
|
||||
case ActivationType.Disable:
|
||||
break;
|
||||
case ActivationType.Use:
|
||||
break;
|
||||
case ActivationType.Destroy:
|
||||
break;
|
||||
case ActivationType.Open:
|
||||
break;
|
||||
case ActivationType.Close:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(activationType), activationType, null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue