This commit is contained in:
Marco 2025-02-24 09:10:20 +01:00
commit 8d1c0beadc
6 changed files with 116 additions and 3 deletions

View file

@ -0,0 +1,51 @@
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;
}
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();
}
}
}