mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 00:35:53 +00:00
Shrouds
This commit is contained in:
parent
36c050f112
commit
8d1c0beadc
6 changed files with 116 additions and 3 deletions
51
Scripts/Activables/BlackCover.cs
Normal file
51
Scripts/Activables/BlackCover.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue