Updated the PlayerData constructors.

Added a new constructor with a parameter that is responsible for installing TShock items into inventory.

The `TSPlayer` parameter was not used, so I labeled the constructor obsolete.
This commit is contained in:
AkjaHAsLk1IALk0MasH 2023-05-14 10:30:52 +07:00
parent c67d5cf152
commit 2e8823434c

View file

@ -23,6 +23,7 @@ using Terraria.Localization;
using Terraria.GameContent.NetModules;
using Terraria.Net;
using Terraria.ID;
using System;
namespace TShockAPI
{
@ -63,18 +64,27 @@ namespace TShockAPI
public int unlockedSuperCart;
public int enabledSuperCart;
public PlayerData(TSPlayer player)
/// <summary>
/// Sets the default values for the inventory.
/// </summary>
[Obsolete("The player argument is not used.")]
public PlayerData(TSPlayer player) : this(true) { }
/// <summary>
/// Sets the default values for the inventory.
/// </summary>
/// <param name="includingStarterInventory">Is it necessary to load items from TShock's config</param>
public PlayerData(bool includingStarterInventory = true)
{
for (int i = 0; i < NetItem.MaxInventory; i++)
{
this.inventory[i] = new NetItem();
}
for (int i = 0; i < TShock.ServerSideCharacterConfig.Settings.StartingInventory.Count; i++)
{
var item = TShock.ServerSideCharacterConfig.Settings.StartingInventory[i];
StoreSlot(i, item.NetId, item.PrefixId, item.Stack);
}
if (includingStarterInventory)
for (int i = 0; i < TShock.ServerSideCharacterConfig.Settings.StartingInventory.Count; i++)
{
var item = TShock.ServerSideCharacterConfig.Settings.StartingInventory[i];
StoreSlot(i, item.NetId, item.PrefixId, item.Stack);
}
}
/// <summary>