mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 09:45:33 +00:00
46 lines
No EOL
1.3 KiB
C#
46 lines
No EOL
1.3 KiB
C#
using System;
|
|
using Cirno.Scripts.Enums;
|
|
using Godot;
|
|
|
|
namespace Cirno.Scripts.Interactables.Modules;
|
|
|
|
public partial class SwitchSpriteChanger : AnimatedSprite2D
|
|
{
|
|
[Export]
|
|
public StateSwitch Switch { get; private set; }
|
|
|
|
[Export] public StringName OnAnimationName { get; private set; } = "On";
|
|
[Export] public StringName OffAnimationName { get; private set; } = "Off";
|
|
[Export] public StringName DestroyedAnimationName { get; private set; } = "Destroyed";
|
|
[Export] public StringName DisabledAnimationName { get; private set; } = "Disabled";
|
|
|
|
public override void _Ready()
|
|
{
|
|
Switch.OnActivated += SwitchOnActivated;
|
|
UpdateSprite();
|
|
}
|
|
|
|
private void SwitchOnActivated(ActivationType activationType)
|
|
{
|
|
UpdateSprite();
|
|
}
|
|
|
|
private void UpdateSprite()
|
|
{
|
|
switch (Switch.CurrentState)
|
|
{
|
|
case SwitchState.On:
|
|
this.Play(OnAnimationName);
|
|
break;
|
|
case SwitchState.Off:
|
|
this.Play(OffAnimationName);
|
|
break;
|
|
case SwitchState.Destroyed:
|
|
this.Play(DestroyedAnimationName);
|
|
break;
|
|
case SwitchState.Disabled:
|
|
this.Play(DisabledAnimationName);
|
|
break;
|
|
}
|
|
}
|
|
} |