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

IProjectVCharacterPresenter interface

The Character presenter. Pages should use IProjectVCharacterScreen instead; use the presenter only for what the screen contract does not cover, such as equipment, backpack, skins and two-step confirmations. Commands run one at a time; a command never throws for a server failure, it returns a failed ProjectVCharacterCommandResult.

Namespace: SilverTiger.ProjectV.Unity.Presentation.Character

public interface IProjectVCharacterPresenter

Properties​

PropertyTypeDescription
CurrentProjectVCharacterSnapshotThe latest snapshot; never null.
TransactionsProjectVTransactionConfirmationCoordinatorThe confirmation dialog state for PrepareSkillUpgrade and PrepareEquipmentUpgrade; bind your confirm dialog to it.
PendingProgressionProjectVCharacterProgressionPending?A level-up or level reset whose answer was lost, or null. While it is set, offer only RetryPendingProgressionAsync; new level-ups are refused until it finishes.

Methods​

GetXpUpgradePreview(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items)​

Shows what leveling a character with these EXP items would do, without sending anything.

ProjectVCharacterXpUpgradePreview GetXpUpgradePreview(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character to level.
itemsIReadOnlyList<ProjectVCharacterXpItemSelection>The EXP items and quantities to spend; may be empty to use only the EXP the character already has.

Returns

ProjectVCharacterXpUpgradePreview: The preview; never null. ProjectVCharacterXpUpgradePreview.CanSubmit says whether the level-up can be sent, and ProjectVCharacterXpUpgradePreview.Message says why not. It is false while data is loading, needs a sync, or a level-up is pending, and for invalid or null items.

UseCharacterXpItemsAsync(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items, CancellationToken cancellationToken)​

Spends EXP items on a character without taking any level.

Task<ProjectVCharacterCommandResult> UseCharacterXpItemsAsync(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items, CancellationToken cancellationToken);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character to give EXP to.
itemsIReadOnlyList<ProjectVCharacterXpItemSelection>The EXP items and quantities to spend; at most 16 lines, each item once, not empty.
cancellationTokenCancellationTokenStops waiting; it does not undo EXP the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed the EXP; otherwise Snapshot.Error.SafeMessage says why.

Exceptions

ExceptionWhen
ArgumentNullExceptionitems is null.
ArgumentExceptionitems has a null line, more than 16 lines or the same item twice.
OperationCanceledExceptioncancellationToken was already cancelled.

UpgradeCharacterWithXpItemsAsync(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items, CancellationToken cancellationToken)​

Spends EXP items on a character and takes every level the EXP and the wallet cover, in one step. Check GetXpUpgradePreview first.

Task<ProjectVCharacterCommandResult> UpgradeCharacterWithXpItemsAsync(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items, CancellationToken cancellationToken);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character to level.
itemsIReadOnlyList<ProjectVCharacterXpItemSelection>The EXP items and quantities to spend; at most 16 lines, each item once. May be empty to level with the EXP the character already has.
cancellationTokenCancellationTokenStops waiting; it does not undo a level-up the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed it, and Snapshot.Recovery.Message says how many levels were gained. On failure, Snapshot.Error.SafeMessage says why; if the answer was lost, PendingProgression is set.

Exceptions

ExceptionWhen
ArgumentNullExceptionitems is null.
ArgumentExceptionitems has a null line, more than 16 lines or the same item twice.
OperationCanceledExceptioncancellationToken was already cancelled.

RetryPendingProgressionAsync(CancellationToken cancellationToken)​

Sends PendingProgression again so the lost level-up or level reset finishes.

Task<ProjectVCharacterCommandResult> RetryPendingProgressionAsync(CancellationToken cancellationToken);

Parameters

NameTypeDescription
cancellationTokenCancellationTokenStops waiting; the pending action stays pending if no answer arrives.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed it. Fails with a message when nothing is pending.

Exceptions

ExceptionWhen
OperationCanceledExceptioncancellationToken was already cancelled.

SubscribeAsync(Action<ProjectVCharacterSnapshot> listener)​

Calls listener at once with the current snapshot, then with every change. The listener may run off the Unity main thread; IProjectVCharacterScreen.Observe renders on it for you.

Task<IDisposable> SubscribeAsync(Action<ProjectVCharacterSnapshot> listener);

Parameters

NameTypeDescription
listenerAction<ProjectVCharacterSnapshot>Called with each snapshot.

Returns

Task<IDisposable>: A subscription; dispose it when the page closes.

Exceptions

ExceptionWhen
ArgumentNullExceptionlistener is null.

RefreshAsync(CancellationToken cancellationToken)​

Loads the Character data. Saved data that is still fresh answers at once, without a request.

Task<ProjectVCharacterCommandResult> RefreshAsync(CancellationToken cancellationToken);

Parameters

NameTypeDescription
cancellationTokenCancellationTokenStops waiting; tie it to the page.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether it succeeded.

Exceptions

ExceptionWhen
OperationCanceledExceptioncancellationToken was cancelled while a pending level-up was being restored.

SynchronizeAsync(CancellationToken cancellationToken)​

Fetches current data from the server. Use it when ProjectVCharacterSnapshot.RequiresUpgradeSync is true or the player taps Sync.

Task<ProjectVCharacterCommandResult> SynchronizeAsync(CancellationToken cancellationToken);

Parameters

NameTypeDescription
cancellationTokenCancellationTokenStops waiting; tie it to the page.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is false when the server could not be reached, even if saved data is shown.

Exceptions

ExceptionWhen
OperationCanceledExceptioncancellationToken was cancelled while a pending level-up was being restored.

SelectCharacterAsync(ProjectVLoadoutSlotId slotId, ProjectVCharacterId characterId, CancellationToken cancellationToken)​

Puts a character in a loadout slot.

Task<ProjectVCharacterCommandResult> SelectCharacterAsync(ProjectVLoadoutSlotId slotId, ProjectVCharacterId characterId, CancellationToken cancellationToken);

Parameters

NameTypeDescription
slotIdProjectVLoadoutSlotIdThe loadout slot, from ProjectVCharacterData.Loadout.
characterIdProjectVCharacterIdAn owned character.
cancellationTokenCancellationTokenStops waiting; it does not undo a change the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the change.

UpgradeCharacterAsync(ProjectVCharacterId characterId, CancellationToken cancellationToken)​

Levels a character with the EXP it already has. Check ProjectVCharacterSnapshot.GetUpgradeState first. A second call while a level-up runs is refused instead of queued.

Task<ProjectVCharacterCommandResult> UpgradeCharacterAsync(ProjectVCharacterId characterId, CancellationToken cancellationToken);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character to level.
cancellationTokenCancellationTokenStops waiting; it does not undo a level-up the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed it; otherwise Snapshot.Error.SafeMessage says why, for example not enough EXP.

Exceptions

ExceptionWhen
OperationCanceledExceptioncancellationToken was already cancelled.

UpgradeSkillAsync(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId, CancellationToken cancellationToken)​

Buys the next rank of a skill straight away. To show a price confirmation first, use PrepareSkillUpgrade and ConfirmPreparedUpgradeAsync.

Task<ProjectVCharacterCommandResult> UpgradeSkillAsync(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId, CancellationToken cancellationToken);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character that owns the skill.
skillIdProjectVCharacterSkillIdThe skill to rank up.
cancellationTokenCancellationTokenStops waiting; it does not undo a rank the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the rank.

UpgradeCastSkillAsync(ProjectVCharacterId characterId, ProjectVCharacterCastSkillSlot slot, CancellationToken cancellationToken)​

Upgrades a cast skill one level. Check ProjectVCharacterData.GetCastSkillUpgradeDetails first; the command is refused when the details say it cannot be upgraded or the data needs a sync.

Task<ProjectVCharacterCommandResult> UpgradeCastSkillAsync(ProjectVCharacterId characterId, ProjectVCharacterCastSkillSlot slot, CancellationToken cancellationToken);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character that owns the cast skill.
slotProjectVCharacterCastSkillSlotThe cast skill slot; not ProjectVCharacterCastSkillSlot.Unknown.
cancellationTokenCancellationTokenStops waiting; it does not undo an upgrade the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed it; otherwise Snapshot.Error.SafeMessage says why.

ResetSkillsAsync(ProjectVCharacterId characterId, CancellationToken cancellationToken)​

Resets a character's skill tree, removing every rank. What is given back is up to the server.

Task<ProjectVCharacterCommandResult> ResetSkillsAsync(ProjectVCharacterId characterId, CancellationToken cancellationToken);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character whose skill tree to reset.
cancellationTokenCancellationTokenStops waiting; it does not undo a reset the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the reset.

EquipEquipmentAsync(ProjectVEquipmentId equipmentId, CancellationToken cancellationToken)​

Equips an owned piece of equipment in its slot.

Task<ProjectVCharacterCommandResult> EquipEquipmentAsync(ProjectVEquipmentId equipmentId, CancellationToken cancellationToken);

Parameters

NameTypeDescription
equipmentIdProjectVEquipmentIdAn owned item from ProjectVCharacterData.Equipment.
cancellationTokenCancellationTokenStops waiting; it does not undo a change the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the change.

UnequipPrimaryWeaponAsync(CancellationToken cancellationToken)​

Takes off the equipped primary weapon.

Task<ProjectVCharacterCommandResult> UnequipPrimaryWeaponAsync(CancellationToken cancellationToken);

Parameters

NameTypeDescription
cancellationTokenCancellationTokenStops waiting; it does not undo a change the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the change.

UpgradeEquipmentAsync(ProjectVEquipmentId equipmentId, CancellationToken cancellationToken)​

Upgrades a piece of equipment one level straight away. To show a price confirmation first, use PrepareEquipmentUpgrade and ConfirmPreparedUpgradeAsync.

Task<ProjectVCharacterCommandResult> UpgradeEquipmentAsync(ProjectVEquipmentId equipmentId, CancellationToken cancellationToken);

Parameters

NameTypeDescription
equipmentIdProjectVEquipmentIdAn owned item below its maximum level.
cancellationTokenCancellationTokenStops waiting; it does not undo an upgrade the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the upgrade.

SetBackpackAsync(ProjectVBackpackSlotId slotId, ProjectVItemId? itemId, CancellationToken cancellationToken)​

Puts an item in a backpack slot, or empties the slot.

Task<ProjectVCharacterCommandResult> SetBackpackAsync(ProjectVBackpackSlotId slotId, ProjectVItemId? itemId, CancellationToken cancellationToken);

Parameters

NameTypeDescription
slotIdProjectVBackpackSlotIdThe backpack slot, from ProjectVCharacterData.Backpack.
itemIdProjectVItemId?The item to put in the slot, or null to empty it.
cancellationTokenCancellationTokenStops waiting; it does not undo a change the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the change.

EquipSkinAsync(ProjectVSkinId skinId, CancellationToken cancellationToken)​

Equips an owned skin on its character.

Task<ProjectVCharacterCommandResult> EquipSkinAsync(ProjectVSkinId skinId, CancellationToken cancellationToken);

Parameters

NameTypeDescription
skinIdProjectVSkinIdAn owned skin from ProjectVCharacterData.Skins.
cancellationTokenCancellationTokenStops waiting; it does not undo a change the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the change.

UseInventoryItemAsync(ProjectVItemId itemId, long quantity, CancellationToken cancellationToken)​

Uses an inventory item, such as a consumable.

Task<ProjectVCharacterCommandResult> UseInventoryItemAsync(ProjectVItemId itemId, long quantity, CancellationToken cancellationToken);

Parameters

NameTypeDescription
itemIdProjectVItemIdAn item from ProjectVCharacterData.Inventory.
quantitylongHow many to use; 1 or more and no more than the player owns.
cancellationTokenCancellationTokenStops waiting; it does not undo a use the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the use.

PrepareSkillUpgrade(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId)​

Builds a price confirmation for the next rank of a skill and shows it through Transactions. Call ConfirmPreparedUpgradeAsync when the player confirms. Preparing again replaces the last one.

ProjectVTransactionConfirmation PrepareSkillUpgrade(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId);

Parameters

NameTypeDescription
characterIdProjectVCharacterIdThe character that owns the skill.
skillIdProjectVCharacterSkillIdThe skill to rank up.

Returns

ProjectVTransactionConfirmation: The confirmation to show: title, price and balances before and after.

Exceptions

ExceptionWhen
InvalidOperationExceptionNo data is loaded yet, the skill cannot rank up now (the message says why), or another confirmed upgrade is still running.

PrepareEquipmentUpgrade(ProjectVEquipmentId equipmentId)​

Builds a price confirmation for the next level of a piece of equipment and shows it through Transactions. Call ConfirmPreparedUpgradeAsync when the player confirms. Preparing again replaces the last one.

ProjectVTransactionConfirmation PrepareEquipmentUpgrade(ProjectVEquipmentId equipmentId);

Parameters

NameTypeDescription
equipmentIdProjectVEquipmentIdAn owned item below its maximum level.

Returns

ProjectVTransactionConfirmation: The confirmation to show: title, price and balances before and after.

Exceptions

ExceptionWhen
InvalidOperationExceptionNo data is loaded yet, the equipment is not owned or already at its maximum level, or another confirmed upgrade is still running.

ConfirmPreparedUpgradeAsync(CancellationToken cancellationToken)​

Runs the upgrade last prepared with PrepareSkillUpgrade or PrepareEquipmentUpgrade. Transactions shows the outcome.

Task<ProjectVCharacterCommandResult> ConfirmPreparedUpgradeAsync(CancellationToken cancellationToken);

Parameters

NameTypeDescription
cancellationTokenCancellationTokenStops waiting; it does not undo an upgrade the server already applied.

Returns

Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the upgrade.

Exceptions

ExceptionWhen
InvalidOperationExceptionNothing was prepared, the confirmation was cancelled or already used, or the player cannot afford it.