Chuyển tới nội dung chính

ProjectVCharacterData class

Everything the Character screen shows, as last confirmed by the server: the roster, loadout, skill trees, inventory, wallet, equipment, backpack, skins, EXP items and cast skills. Read-only; a change arrives as a new instance.

Namespace: SilverTiger.ProjectV.Unity.Presentation.Character

public sealed class ProjectVCharacterData

Constructors​

ProjectVCharacterData(IReadOnlyList<ProjectVCharacterEntry> characters, IReadOnlyList<ProjectVCharacterLoadoutSlot> loadout, long loadoutRevision, long charactersRevision, IReadOnlyList<ProjectVCharacterSkillTree> skillTrees, IReadOnlyList<ProjectVCharacterResource> inventory, string inventoryVersion, IReadOnlyList<ProjectVCharacterResource> balances, IReadOnlyList<ProjectVCharacterEquipment> equipment, IReadOnlyList<ProjectVCharacterBackpackSlot> backpack, string equipmentVersion, IReadOnlyList<ProjectVCharacterSkin> skins, string skinVersion, IReadOnlyList<ProjectVCharacterXpItemDefinition>? xpItems)​

Creates Character data without cast skills, for example in tests.

public ProjectVCharacterData(IReadOnlyList<ProjectVCharacterEntry> characters, IReadOnlyList<ProjectVCharacterLoadoutSlot> loadout, long loadoutRevision, long charactersRevision, IReadOnlyList<ProjectVCharacterSkillTree> skillTrees, IReadOnlyList<ProjectVCharacterResource> inventory, string inventoryVersion, IReadOnlyList<ProjectVCharacterResource> balances, IReadOnlyList<ProjectVCharacterEquipment> equipment, IReadOnlyList<ProjectVCharacterBackpackSlot> backpack, string equipmentVersion, IReadOnlyList<ProjectVCharacterSkin> skins, string skinVersion, IReadOnlyList<ProjectVCharacterXpItemDefinition>? xpItems = null);

Parameters

NameTypeDescription
charactersIReadOnlyList<ProjectVCharacterEntry>The owned characters and allies.
loadoutIReadOnlyList<ProjectVCharacterLoadoutSlot>The loadout slots.
loadoutRevisionlongThe loadout's server revision; 1 or more.
charactersRevisionlongThe roster's server revision; 1 or more.
skillTreesIReadOnlyList<ProjectVCharacterSkillTree>One tree per owned character at most.
inventoryIReadOnlyList<ProjectVCharacterResource>The items the player owns.
inventoryVersionstringThe inventory's server version; not empty.
balancesIReadOnlyList<ProjectVCharacterResource>The wallet's currency balances.
equipmentIReadOnlyList<ProjectVCharacterEquipment>The equipment catalog, owned or not.
backpackIReadOnlyList<ProjectVCharacterBackpackSlot>The backpack slots.
equipmentVersionstringThe equipment's server version; not empty.
skinsIReadOnlyList<ProjectVCharacterSkin>The skin catalog, owned or not.
skinVersionstringThe skins' server version; not empty.
xpItemsIReadOnlyList<ProjectVCharacterXpItemDefinition>?The EXP items that can level characters; null for none.

Exceptions

ExceptionWhen
ArgumentNullExceptionA required list is null.
ArgumentOutOfRangeExceptionA revision is below 1.
ArgumentExceptionA version is empty, a skill tree belongs to no owned character or appears twice, or xpItems has more than 32 entries, a null entry or a duplicate item.

ProjectVCharacterData(IReadOnlyList<ProjectVCharacterEntry> characters, IReadOnlyList<ProjectVCharacterLoadoutSlot> loadout, long loadoutRevision, long charactersRevision, IReadOnlyList<ProjectVCharacterSkillTree> skillTrees, IReadOnlyList<ProjectVCharacterResource> inventory, string inventoryVersion, IReadOnlyList<ProjectVCharacterResource> balances, IReadOnlyList<ProjectVCharacterEquipment> equipment, IReadOnlyList<ProjectVCharacterBackpackSlot> backpack, string equipmentVersion, IReadOnlyList<ProjectVCharacterSkin> skins, string skinVersion, IReadOnlyList<ProjectVCharacterXpItemDefinition>? xpItems, ProjectVCharacterCastSkillsSnapshot? castSkills)​

Creates Character data, for example in tests. The SDK builds this for you from server data.

public ProjectVCharacterData(IReadOnlyList<ProjectVCharacterEntry> characters, IReadOnlyList<ProjectVCharacterLoadoutSlot> loadout, long loadoutRevision, long charactersRevision, IReadOnlyList<ProjectVCharacterSkillTree> skillTrees, IReadOnlyList<ProjectVCharacterResource> inventory, string inventoryVersion, IReadOnlyList<ProjectVCharacterResource> balances, IReadOnlyList<ProjectVCharacterEquipment> equipment, IReadOnlyList<ProjectVCharacterBackpackSlot> backpack, string equipmentVersion, IReadOnlyList<ProjectVCharacterSkin> skins, string skinVersion, IReadOnlyList<ProjectVCharacterXpItemDefinition>? xpItems, ProjectVCharacterCastSkillsSnapshot? castSkills);

Parameters

NameTypeDescription
charactersIReadOnlyList<ProjectVCharacterEntry>The owned characters and allies.
loadoutIReadOnlyList<ProjectVCharacterLoadoutSlot>The loadout slots.
loadoutRevisionlongThe loadout's server revision; 1 or more.
charactersRevisionlongThe roster's server revision; 1 or more.
skillTreesIReadOnlyList<ProjectVCharacterSkillTree>One tree per owned character at most.
inventoryIReadOnlyList<ProjectVCharacterResource>The items the player owns.
inventoryVersionstringThe inventory's server version; not empty.
balancesIReadOnlyList<ProjectVCharacterResource>The wallet's currency balances.
equipmentIReadOnlyList<ProjectVCharacterEquipment>The equipment catalog, owned or not.
backpackIReadOnlyList<ProjectVCharacterBackpackSlot>The backpack slots.
equipmentVersionstringThe equipment's server version; not empty.
skinsIReadOnlyList<ProjectVCharacterSkin>The skin catalog, owned or not.
skinVersionstringThe skins' server version; not empty.
xpItemsIReadOnlyList<ProjectVCharacterXpItemDefinition>?The EXP items that can level characters; null for none.
castSkillsProjectVCharacterCastSkillsSnapshot?The cast skills of owned characters; null when not loaded.

Exceptions

ExceptionWhen
ArgumentNullExceptionA required list is null.
ArgumentOutOfRangeExceptionA revision is below 1.
ArgumentExceptionA version is empty, a skill tree or cast skill set belongs to no owned character, a skill tree appears twice, or xpItems has more than 32 entries, a null entry or a duplicate item.

Properties​

PropertyTypeDescription
CharactersIReadOnlyList<ProjectVCharacterEntry>The owned characters and allies.
LoadoutIReadOnlyList<ProjectVCharacterLoadoutSlot>The loadout slots and the character in each.
LoadoutRevisionlongThe loadout's server revision. Not needed in UI.
CharactersRevisionlongThe roster's server revision. Not needed in UI.
SkillTreesIReadOnlyList<ProjectVCharacterSkillTree>One skill tree per character that has one; use GetSkills to look one up.
InventoryIReadOnlyList<ProjectVCharacterResource>The items the player owns, such as EXP items.
InventoryVersionstringThe inventory's server version. Not needed in UI.
BalancesIReadOnlyList<ProjectVCharacterResource>The wallet's currency balances.
EquipmentIReadOnlyList<ProjectVCharacterEquipment>The whole equipment catalog; check ProjectVCharacterEquipment.Owned for what the player has.
BackpackIReadOnlyList<ProjectVCharacterBackpackSlot>The backpack slots and the item in each.
EquipmentVersionstringThe equipment's server version. Not needed in UI.
SkinsIReadOnlyList<ProjectVCharacterSkin>The whole skin catalog; check ProjectVCharacterSkin.Owned for what the player has.
SkinVersionstringThe skins' server version. Not needed in UI.
XpItemsIReadOnlyList<ProjectVCharacterXpItemDefinition>The EXP items that can level characters or allies, and how much EXP each gives.
CastSkillsProjectVCharacterCastSkillsSnapshot?The cast skills of every owned character; null when they are not loaded.
CastSkillsRevisionlongThe cast skills' server revision, or 0 when not loaded. Not needed in UI.
CastSkillsCatalogRevisionstringThe cast skill catalog's server revision, or empty when not loaded. Not needed in UI.
IsEmptyboolTrue when the player owns no characters; show an empty state.

Methods​

GetCastSkills(ProjectVCharacterId characterId)​

Gets a character's cast skills (weapon and character slot).

public IReadOnlyList<ProjectVCharacterCastSkill> GetCastSkills(ProjectVCharacterId characterId);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character to look up.

Returns

IReadOnlyList<ProjectVCharacterCastSkill>: The character's cast skills; empty when it has none or cast skills are not loaded.

GetCastSkillUpgradeDetails(ProjectVCharacterId characterId, ProjectVCharacterCastSkillSlot slot)​

Works out whether a cast skill can be upgraded now, what it costs and what the player has.

public ProjectVCharacterCastSkillUpgradeDetails GetCastSkillUpgradeDetails(ProjectVCharacterId characterId, ProjectVCharacterCastSkillSlot slot);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character that owns the cast skill.
slotProjectVCharacterCastSkillSlotThe cast skill slot.

Returns

ProjectVCharacterCastSkillUpgradeDetails: The upgrade details; never null. ProjectVCharacterCastSkillUpgradeDetails.IsMapped is false when the skill is not found.

GetSkills(ProjectVCharacterId characterId)​

Gets a character's skill tree.

public IReadOnlyList<ProjectVCharacterSkill> GetSkills(ProjectVCharacterId characterId);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character to look up.

Returns

IReadOnlyList<ProjectVCharacterSkill>: The character's skills; empty when it has no skill tree.

GetSkill(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId)​

Finds one skill of a character.

public ProjectVCharacterSkill? GetSkill(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character that owns the skill.
skillIdProjectVCharacterSkillIdThe skill to find.

Returns

ProjectVCharacterSkill?: The skill, or null when the character has no such skill.

GetSkillUpgradeDetails(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId)​

Works out whether a skill can rank up now, what it costs and what still blocks it.

public ProjectVCharacterSkillUpgradeDetails GetSkillUpgradeDetails(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character that owns the skill.
skillIdProjectVCharacterSkillIdThe skill to check.

Returns

ProjectVCharacterSkillUpgradeDetails: The upgrade details; never null. ProjectVCharacterSkillUpgradeDetails.IsMapped is false when the skill is not found.

GetResourceAmount(ProjectVResourceId resourceId)​

Gets how much of a currency or item the player owns, looking in the wallet first, then the inventory.

public long GetResourceAmount(ProjectVResourceId resourceId);

Parameters

NameTypeDescription
resourceIdProjectVResourceIdThe currency or item ID, such as core_dust.

Returns

long: The amount owned; 0 when the player has none.

GetSkillResourceAmount(ProjectVCharacterId characterId, ProjectVResourceId resourceId)​

What a skill rank of this character can spend: its own level points plus the wallet's.

public long GetSkillResourceAmount(ProjectVCharacterId characterId, ProjectVResourceId resourceId);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character whose skill rank is being bought.
resourceIdProjectVResourceIdThe cost's resource ID.

Returns

long: For skill_point, the wallet's skill points plus the character's own ProjectVCharacterSkillTree.LevelSkillPoints; for any other resource, the same as GetResourceAmount.

CanAfford(IReadOnlyList<ProjectVCharacterCost> costs)​

Checks whether the player owns enough of every cost line, using GetResourceAmount. For a skill rank, use GetSkillUpgradeDetails instead: it also counts the character's own skill points.

public bool CanAfford(IReadOnlyList<ProjectVCharacterCost> costs);

Parameters

NameTypeDescription
costsIReadOnlyList<ProjectVCharacterCost>The price lines to check; an empty list is always affordable.

Returns

bool: True when every cost line is covered.

Exceptions

ExceptionWhen
ArgumentNullExceptioncosts is null.