add: Item Manager
This commit is contained in:
43
src/SkinManagers/SkinPacker.cs
Normal file
43
src/SkinManagers/SkinPacker.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Godot;
|
||||
|
||||
namespace Polonium.SkinManagers;
|
||||
|
||||
public abstract partial class SkinPacker : Node2D
|
||||
{
|
||||
public Node2D SkinCollector { get; set; }
|
||||
protected Skin[] CollectedSkins => SkinCollector
|
||||
.GetChildren()
|
||||
.OfType<Skin>()
|
||||
.ToArray();
|
||||
|
||||
private Vector2I BackingFrameCoords { get; set; }
|
||||
|
||||
[Export]
|
||||
protected Vector2I FrameCoords
|
||||
{
|
||||
get => BackingFrameCoords;
|
||||
set
|
||||
{
|
||||
BackingFrameCoords = value;
|
||||
UpdateSkins();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSkins()
|
||||
{
|
||||
if (SkinCollector is not null)
|
||||
foreach(Skin skin in CollectedSkins)
|
||||
skin.FrameCoords = FrameCoords;
|
||||
}
|
||||
|
||||
public AnimationPlayer SyncPlayer { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
SyncPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
||||
SkinCollector = GetNode<Node2D>("SkinCollector");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user