Table of Contents

Class CharacterPortalService

Namespace
FishMMO.Database.Npgsql.Services
Assembly
FishMMO-DB.dll

Persists the portals a character has activated for themselves, as per-scene bitmask pages.

public sealed class CharacterPortalService : BaseService<CharacterPortalEntity>, ICharacterPortalService, IFetchCollectionByKeyAction<long, CharacterPortalData>, IDeleteByKeyAction<long>
Inheritance
CharacterPortalService
Implements
Inherited Members

Remarks

A copy of CharacterWaypointService over its own table rather than a shared table with a "kind" column: the two index spaces are authored separately (a waypoint and a portal may both be index 0 in a scene), and keeping them apart keeps the waypoint row's key and every query over it unchanged. The mask is ulong in the game and bigint here; the two's-complement reinterpretation is done in this class only.

Constructors

CharacterPortalService(INpgsqlDbContextFactory)

public CharacterPortalService(INpgsqlDbContextFactory dbContextFactory)

Parameters

dbContextFactory INpgsqlDbContextFactory

Methods

DeleteAsync(long, CancellationToken)

Deletes the entity identified by the given key.

public Task<DatabaseResult> DeleteAsync(long characterId, CancellationToken cancellationToken = default)

Parameters

characterId long
cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

Remarks

Hard-deletes every page the character has. The foreign key cascades too; this exists for an explicit purge.

FetchAsync(long, CancellationToken)

Fetches a collection of items for the given key.

public Task<DatabaseResult<IReadOnlyList<CharacterPortalData>>> FetchAsync(long characterId, CancellationToken cancellationToken = default)

Parameters

characterId long
cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult<IReadOnlyList<CharacterPortalData>>>

MergeAsync(IEnumerable<CharacterPortalData>, CancellationToken)

OR-merges pages into the stored masks, creating rows that do not exist yet.

public Task<DatabaseResult> MergeAsync(IEnumerable<CharacterPortalData> pages, CancellationToken cancellationToken = default)

Parameters

pages IEnumerable<CharacterPortalData>

The pages to merge. Bits already stored are retained.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

Success, or the failure that stopped the whole batch.