Skip to main content

IProjectVGameplayDataPolicy interface

Helpers for the mission scene: the scene reports what happens (enemies spawned and killed, the outcome, the final health) and the SDK works out which drops count and what to send. Every call fails once the presenter is unbound.

Namespace: SilverTiger.ProjectV.Unity.Presentation.Gameplay

public interface IProjectVGameplayDataPolicy : IProjectVGameplayDataPresenter

Methodsโ€‹

ValidateSkillCatalog(IReadOnlyList<ProjectVGameplaySkillId> skillIds)โ€‹

Checks that your skill assets match the run's skill tree. Call it before gameplay starts.

ProjectVGameplayDataResult ValidateSkillCatalog(IReadOnlyList<ProjectVGameplaySkillId> skillIds);

Parameters

NameTypeDescription
skillIdsIReadOnlyList<ProjectVGameplaySkillId>The skill IDs read from your skill assets; each must appear once and be in ProjectVGameplayStartingDataView.SkillCatalogIds.

Returns

ProjectVGameplayDataResult: Success when they match. A failure when the list is empty, has a duplicate or unknown ID, or the run is missing an active skill; then do not start.

Exceptions

ExceptionWhen
ArgumentNullExceptionskillIds is null.

ValidateCastMapping(ProjectVGameplayDataSkillSlot slot, int level, ProjectVGameplaySkillId skillId)โ€‹

Checks that the skill asset you picked for a slot matches the run. Call it for both slots before gameplay starts.

ProjectVGameplayDataResult ValidateCastMapping(ProjectVGameplayDataSkillSlot slot, int level, ProjectVGameplaySkillId skillId);

Parameters

NameTypeDescription
slotProjectVGameplayDataSkillSlotThe slot.
levelintThe level of the asset you picked.
skillIdProjectVGameplaySkillIdThe skill ID of the asset you picked.

Returns

ProjectVGameplayDataResult: Success when the slot's skill in ProjectVGameplayStartingDataView.CastSkills has exactly this level and ID; otherwise a failure, and do not start.

RegisterDropOwner(object owner, string slotId, long activationLease, ProjectVGameplayDropRegistration registration)โ€‹

Registers a reward enemy when it becomes active. Call it again with a new activationLease each time a pooled enemy is reused.

ProjectVGameplayDataResult RegisterDropOwner(object owner, string slotId, long activationLease, out ProjectVGameplayDropRegistration registration);

Parameters

NameTypeDescription
ownerobjectThe enemy object, such as its component; the same object each time.
slotIdstringThe slot ID placed on the enemy; must be one of ProjectVGameplayStartingDataView.Drops.
activationLeaselongA number that changes on every activation of this enemy, such as a spawn counter.
registrationProjectVGameplayDropRegistrationSet on success; keep it for RecordDropDefeated and UnregisterDropOwner. Default on failure.

Returns

ProjectVGameplayDataResult: Success when registered. A failure when the slot ID is unknown, the result is already sent, or two enemies share a slot (or one enemy uses two slots); those slots then never count.

Exceptions

ExceptionWhen
ArgumentNullExceptionowner is null.

RecordDropDefeated(ProjectVGameplayDropRegistration registration)โ€‹

Reports that a registered reward enemy died.

ProjectVGameplayDataResult RecordDropDefeated(ProjectVGameplayDropRegistration registration);

Parameters

NameTypeDescription
registrationProjectVGameplayDropRegistrationThe registration from RegisterDropOwner for the current activation.

Returns

ProjectVGameplayDataResult: Success when recorded. A failure when the registration is from an older activation, the slot is shared, the death is already recorded, or the result is already sent.

UnregisterDropOwner(ProjectVGameplayDropRegistration registration)โ€‹

Reports that a reward enemy was deactivated, for example returned to its pool. A recorded death still counts.

ProjectVGameplayDataResult UnregisterDropOwner(ProjectVGameplayDropRegistration registration);

Parameters

NameTypeDescription
registrationProjectVGameplayDropRegistrationThe registration from RegisterDropOwner.

Returns

ProjectVGameplayDataResult: Success when the registration is still current; a failure when it is from an older activation.

ObserveOutcome(ProjectVGameplayDataOutcome outcome, long? enemiesDefeated)โ€‹

Reports how the run ended and the kill count, before CompleteObservedAsync. After this, skill uses and IProjectVGameplayDataPresenter.CancelRunAsync are refused.

ProjectVGameplayDataResult ObserveOutcome(ProjectVGameplayDataOutcome outcome, long? enemiesDefeated);

Parameters

NameTypeDescription
outcomeProjectVGameplayDataOutcomeHow the run ended.
enemiesDefeatedlong?How many enemies were defeated, from 0 to 1024; null when not counted.

Returns

ProjectVGameplayDataResult: Success when recorded. A failure when a value is invalid, or the result is already sent with a different outcome (the same outcome again succeeds).

SetClientRewards(IReadOnlyList<ProjectVGameplayClientRewardView> rewards)โ€‹

Sets the picked-up rewards to send when trust client rewards is on. Call it before CompleteObservedAsync; a later call replaces the list. The list is copied.

ProjectVGameplayDataResult SetClientRewards(IReadOnlyList<ProjectVGameplayClientRewardView> rewards);

Parameters

NameTypeDescription
rewardsIReadOnlyList<ProjectVGameplayClientRewardView>The picked-up rewards. An empty list means no rewards.

Returns

ProjectVGameplayDataResult: Success when stored; a failure when the result is already sent.

Exceptions

ExceptionWhen
ArgumentNullExceptionrewards is null.
ArgumentExceptionrewards contains a null entry.

CompleteObservedAsync(float currentHealth, int currentArmor, long rawSessionExperience, CancellationToken cancellationToken)โ€‹

Sends the run result built from what the scene reported and waits for the server. The first call fixes the result; a retry after a failure resends it and ignores new values.

Task<ProjectVGameplayDataResult> CompleteObservedAsync(float currentHealth, int currentArmor, long rawSessionExperience, CancellationToken cancellationToken);

Parameters

NameTypeDescription
currentHealthfloatHealth at the end; rounded and kept between 0 and the starting maximum. Must be a finite number.
currentArmorintArmor at the end; kept between 0 and the starting maximum.
rawSessionExperiencelongExperience earned in the run before any bonus; 0 or more.
cancellationTokenCancellationTokenStops waiting for the server.

Returns

Task<ProjectVGameplayDataResult>: On success, show only ProjectVGameplayDataResult.Rewards and ProjectVGameplayDataResult.Stars. A failure when no outcome was reported, a value is invalid, or the server call failed; keep the result screen open with Retry.

TryGetHealthPercent(float currentHealth, float healthPercent)โ€‹

Works out health as a percentage of the starting maximum, for the result preview.

bool TryGetHealthPercent(float currentHealth, out float healthPercent);

Parameters

NameTypeDescription
currentHealthfloatThe current health.
healthPercentfloatFrom 0 to 100; 0 when the method returns false.

Returns

bool: False when currentHealth is not a finite number or the presenter is unbound.