basic Party Manager
This commit is contained in:
parent
c141e6a169
commit
6f1d5ea681
10 changed files with 158 additions and 8 deletions
38
scripts/core/PartyManager.cs
Normal file
38
scripts/core/PartyManager.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
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)}");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue