Reworked Domovoi kitchen animation and added AnimationStarter script

This commit is contained in:
2025-07-09 23:50:43 +02:00
parent 202f8809aa
commit 135ba0d198
4 changed files with 155 additions and 19 deletions
@@ -0,0 +1,24 @@
using Godot;
using System;
public partial class AnimationStarter : Node2D
{
[Export] private AnimationPlayer _animationPlayer;
[Export] private string _animationName;
[Export] private bool _repeatable = true;
private bool _played;
public void PlayAnimation()
{
if (_animationPlayer == null || string.IsNullOrEmpty(_animationName))
return;
if (!_repeatable && _played)
return;
_animationPlayer.Play(_animationName);
_played = true;
}
}
@@ -0,0 +1 @@
uid://31p67cdowuw4
@@ -13,19 +13,30 @@ public partial class InteractionArea2D : Node2D
[Signal] public delegate void InteractedToolEventHandler(int id); // TODO: remove
[Signal] public delegate void InteractedEventHandler();
public bool IsActive { get; set; } = true;
public void OnPlayerEntered(Node2D player)
{
if (!IsActive)
return;
if(_showLabel)
_label.Show();
}
public void OnPlayerExited(Node2D player)
{
if (!IsActive)
return;
_label.Hide();
}
public override void _Input(InputEvent @event)
{
if (!IsActive)
return;
if (@event.IsAction("interact") && @event.IsPressed() && _area.HasOverlappingBodies())
{
_label.Hide();
@@ -36,9 +47,18 @@ public partial class InteractionArea2D : Node2D
public void SetSpriteActiveState(bool success, int id) // TODO: remove
{
if(!IsActive)
return;
if (_id == id)
{
_sprites.SwitchState(!success);
}
}
public void ToggleActive()
{
IsActive = !IsActive;
_label.Hide();
}
}