For AI agents: the complete documentation index is available at /AchEngine/zh/llms.txt, the full documentation bundle is available at /AchEngine/zh/llms-full.txt, and this page is available as Markdown at /AchEngine/zh/usage/managers/player-data.md.
  • 简体中文
  • PlayerManager 与玩家数据

    PlayerManager 按类型保存 PlayerDataContainerBase<TKey, TValue> 容器。

    public class InventoryContainer : PlayerDataContainerBase<int, ItemData>
    {
        public InventoryContainer()
        {
            DataKey = nameof(InventoryContainer);
            _dataDic = new Dictionary<int, ItemData>();
        }
    }
    
    var player = ServiceLocator.Resolve<PlayerManager>();
    player.AddContainer(new InventoryContainer());
    var inventory = player.GetContainer<InventoryContainer>();
    inventory.Add(101, new ItemData { Id = 101, Name = "Sword" });

    保存和加载由 SaveManager 负责。