Table of Contents

Class PlotStructureService

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

Reads and writes the structures built on plots.

public sealed class PlotStructureService : BaseService<PlotStructureEntity>, IPlotStructureService
Inheritance
PlotStructureService
Implements
Inherited Members

Constructors

PlotStructureService(INpgsqlDbContextFactory)

public PlotStructureService(INpgsqlDbContextFactory dbContextFactory)

Parameters

dbContextFactory INpgsqlDbContextFactory

Methods

DemolishAllAsync(long, CancellationToken)

Removes everything built on a plot.

public Task<DatabaseResult<int>> DemolishAllAsync(long plotID, CancellationToken cancellationToken = default)

Parameters

plotID long
cancellationToken CancellationToken

Returns

Task<DatabaseResult<int>>

The number of structures removed.

Remarks

Used when a plot is released or reclaimed: land handed to somebody else must not come with the previous owner's house still standing on it.

DemolishAsync(long, long, CancellationToken)

Removes a structure, if it stands on the expected plot.

public Task<DatabaseResult<int>> DemolishAsync(long structureID, long plotID, CancellationToken cancellationToken = default)

Parameters

structureID long

The structure to remove.

plotID long

The plot it is expected to stand on.

cancellationToken CancellationToken

Returns

Task<DatabaseResult<int>>

1 when removed, 0 when it does not exist or is on another plot.

Remarks

Pinned to the plot so a demolition request can only ever affect the plot the caller was judged against. Without it, a permission check that passed for one plot would authorise deleting a structure on somebody else's.

FetchByPlotAsync(long, CancellationToken)

Fetches everything built on a plot.

public Task<DatabaseResult<List<PlotStructureData>>> FetchByPlotAsync(long plotID, CancellationToken cancellationToken = default)

Parameters

plotID long
cancellationToken CancellationToken

Returns

Task<DatabaseResult<List<PlotStructureData>>>

FetchByPlotsAsync(List<long>, CancellationToken)

Fetches everything built on any of the given plots.

public Task<DatabaseResult<List<PlotStructureData>>> FetchByPlotsAsync(List<long> plotIDs, CancellationToken cancellationToken = default)

Parameters

plotIDs List<long>
cancellationToken CancellationToken

Returns

Task<DatabaseResult<List<PlotStructureData>>>

Remarks

One query for a whole scene's worth of plots. Fetching per plot would be one round trip per foundation on every scene load, which is the cost this exists to avoid.

PlaceAsync(long, int, float, float, float, float, CancellationToken)

Records a newly built structure.

public Task<DatabaseResult<long>> PlaceAsync(long plotID, int templateID, float localX, float localY, float localZ, float yaw, CancellationToken cancellationToken = default)

Parameters

plotID long
templateID int
localX float
localY float
localZ float
yaw float
cancellationToken CancellationToken

Returns

Task<DatabaseResult<long>>

The new structure's identity, or zero on failure.