38 lines
960 B
C#
38 lines
960 B
C#
using Godot;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public partial class PartyManager : Node
|
|
{
|
|
public List<string> PartyCreatureIds { get; private set; } = new();
|
|
|
|
[Export] public NodePath SaveManagerPath { get; set; }
|
|
private SaveManager? _save;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_save = GetNodeOrNull<SaveManager>(SaveManagerPath);
|
|
if (_save == null)
|
|
{
|
|
GD.PrintErr("PartyManager: SaveManagerPath not set.");
|
|
return;
|
|
}
|
|
|
|
// v0: party is all captured creatures (later: cap to 6 and add boxes)
|
|
PartyCreatureIds = _save.State.CapturedCreatures.ToList();
|
|
GD.Print($"Party loaded: {string.Join(", ", PartyCreatureIds)}");
|
|
}
|
|
|
|
public void AddToParty(string creatureId)
|
|
{
|
|
if (_save == null) return;
|
|
|
|
_save.State.CapturedCreatures.Add(creatureId);
|
|
_save.Save();
|
|
|
|
if (!PartyCreatureIds.Contains(creatureId))
|
|
PartyCreatureIds.Add(creatureId);
|
|
|
|
GD.Print($"Party updated: {string.Join(", ", PartyCreatureIds)}");
|
|
}
|
|
}
|