cirnogodot/Scripts/Activables/BlackCover.cs
2025-02-24 10:24:12 +01:00

52 lines
No EOL
1.1 KiB
C#

using System;
using Godot;
namespace Cirno.Scripts.Activables;
public partial class BlackCover : Sprite2D, IActivable
{
[Export]
public bool StartActive { get; private set; } = true;
private bool _activated;
public override void _Ready()
{
_activated = StartActive;
UpdateSprite();
}
public void Activate(ActivationType activationType = ActivationType.Toggle)
{
switch (activationType)
{
case ActivationType.Use:
case ActivationType.Toggle:
_activated = !_activated;
break;
case ActivationType.Close:
case ActivationType.Enable:
_activated = true;
break;
case ActivationType.Open:
case ActivationType.Disable:
_activated = false;
break;
case ActivationType.Destroy:
break;
}
UpdateSprite();
}
private void UpdateSprite()
{
if (_activated)
{
this.Show();
}
else
{
this.Hide();
}
}
}