You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
835 B
37 lines
835 B
using Godot;
|
|
|
|
namespace Babushka.scripts.CSharp.Common;
|
|
|
|
/// <summary>
|
|
/// Switches between two available Sprite Options.
|
|
/// </summary>
|
|
public partial class SpriteSwitcher2D : Node2D
|
|
{
|
|
[Export] private Sprite2D _activeSprite;
|
|
[Export] private Sprite2D _inactiveSprite;
|
|
[Export] private bool _active = false;
|
|
|
|
|
|
public override void _Ready()
|
|
{
|
|
SetSprites();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Switches the State of the Sprites to the opposite.
|
|
/// Emits Switch Signal.
|
|
/// </summary>
|
|
public void SwitchState(bool state)
|
|
{
|
|
_active = state;
|
|
SetSprites();
|
|
}
|
|
|
|
private void SetSprites()
|
|
{
|
|
if(_activeSprite != null)
|
|
_activeSprite.Visible = _active;
|
|
if(_inactiveSprite != null)
|
|
_inactiveSprite.Visible = !_active;
|
|
}
|
|
} |