mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Boss patterns
This commit is contained in:
parent
5ef3e64413
commit
4541c5fbf4
7 changed files with 780 additions and 718 deletions
|
|
@ -6,10 +6,10 @@ using Godot;
|
|||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
[Tool]
|
||||
public partial class EnemyMarker3D : PreviewMarker3D
|
||||
public partial class EnemyMarker3D : PreviewMarker3D, IActivable
|
||||
{
|
||||
private EnemyResource _enemy;
|
||||
|
||||
|
||||
[Export]
|
||||
public EnemyResource Enemy
|
||||
{
|
||||
|
|
@ -25,10 +25,32 @@ public partial class EnemyMarker3D : PreviewMarker3D
|
|||
}
|
||||
}
|
||||
|
||||
[Export] public bool AutoSpawn { get; set; } = false;
|
||||
|
||||
private bool _autoSpawn = false;
|
||||
|
||||
[Export]
|
||||
public bool AutoSpawn
|
||||
{
|
||||
get => _autoSpawn;
|
||||
set
|
||||
{
|
||||
_autoSpawn = value;
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
if (_autoSpawn)
|
||||
{
|
||||
SetSpriteAlpha(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSpriteAlpha(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private EnemyProxy3D _spawnedEnemy;
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
|
@ -38,10 +60,10 @@ public partial class EnemyMarker3D : PreviewMarker3D
|
|||
Spawn(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public EnemyProxy3D Spawn(bool deleteMarker)
|
||||
{
|
||||
if (Engine.IsEditorHint()) return null ;
|
||||
if (Engine.IsEditorHint()) return null;
|
||||
if (Enemy is null) return null;
|
||||
if (_spawnedEnemy is not null) return _spawnedEnemy;
|
||||
|
||||
|
|
@ -49,21 +71,33 @@ public partial class EnemyMarker3D : PreviewMarker3D
|
|||
{
|
||||
this.QueueFree();
|
||||
}
|
||||
|
||||
|
||||
var enemyScene = GD.Load<PackedScene>(Enemy.PrefabPath);
|
||||
|
||||
|
||||
_spawnedEnemy = this.CreateSibling<EnemyProxy3D>(enemyScene);
|
||||
_spawnedEnemy.Init(Enemy);
|
||||
//Spawned = true;
|
||||
|
||||
|
||||
_spawnedEnemy.Death += SpawnedEnemyOnDeath;
|
||||
return _spawnedEnemy;
|
||||
}
|
||||
|
||||
|
||||
private void SpawnedEnemyOnDeath(EnemyProxy3D enemy)
|
||||
{
|
||||
_spawnedEnemy.Death -= SpawnedEnemyOnDeath;
|
||||
_spawnedEnemy = null;
|
||||
//Spawned = false;
|
||||
}
|
||||
|
||||
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
if (Engine.IsEditorHint()) return false;
|
||||
Spawn(false);
|
||||
return _spawnedEnemy is not null;
|
||||
}
|
||||
|
||||
public void Toggle()
|
||||
{
|
||||
Activate();
|
||||
}
|
||||
}
|
||||
|
|
@ -118,7 +118,19 @@ public partial class PreviewMarker3D : Marker3D
|
|||
_sprite.SetBillboardMode(Billboard ? BaseMaterial3D.BillboardModeEnum.Enabled : BaseMaterial3D.BillboardModeEnum.Disabled);
|
||||
_sprite.TextureFilter = BaseMaterial3D.TextureFilterEnum.Nearest;
|
||||
_sprite.PixelSize = PixelSize;
|
||||
|
||||
}
|
||||
|
||||
protected void SetSpriteAlpha(float alpha)
|
||||
{
|
||||
if (!Engine.IsEditorHint()) return;
|
||||
if (_sprite is not null)
|
||||
{
|
||||
GD.Print($"Modulating sprite to {alpha}");
|
||||
_sprite.SetModulate(new Color(_sprite.Modulate.R, _sprite.Modulate.G, _sprite.Modulate.B, alpha));
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Sprite was null");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue