Files
hotdesking/Gameplay/ActorPanel.cs
2025-07-21 03:17:09 -04:00

51 lines
1.4 KiB
C#

using Godot;
using System;
public partial class ActorPanel : Panel
{
public bool _hovered = false;
public Actor _actor;
public static ActorPanel _Create(Actor ACTOR)
{
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/actor_panel.tscn");
ActorPanel newActorPanel = scene.Instantiate<ActorPanel>();
newActorPanel._actor = ACTOR;
newActorPanel.SetSprite(newActorPanel._actor.GetNode<Sprite2D>("Sprite").Texture);
newActorPanel.SetMax(newActorPanel._actor._healthMax);
newActorPanel.SetValue(newActorPanel._actor._health);
newActorPanel.SetPosition(new Vector2(50, 50));
return newActorPanel;
}
public void SetPosition(Vector2 POSITION)
{
Position = POSITION;
}
public void SetSprite(Texture2D TEXTURE)
{
GetNode<Sprite2D>("Image").Texture = TEXTURE;
}
public void SetValue(int VALUE)
{
GetNode<Control>("Health").GetNode<RichTextLabel>("Value").Text = VALUE.ToString();
GetNode<Control>("Health").GetNode<ProgressBar>("Bar").Value = VALUE;
}
public void SetMax(int MAX)
{
GetNode<Control>("Health").GetNode<RichTextLabel>("Max").Text = MAX.ToString();
GetNode<Control>("Health").GetNode<ProgressBar>("Bar").MaxValue = MAX;
}
private void OnMouseEntered()
{
_hovered = true;
}
private void OnMouseExited()
{
_hovered = false;
}
}