Struct PlotOwner
Who owns a plot: a character, a guild, or nobody.
public readonly struct PlotOwner : IEquatable<PlotOwner>
- Implements
- Inherited Members
Remarks
A plot row stores ownership as two columns, an owning character and an owning guild, and exactly one of them may be set. Nothing in the schema enforces that — the codebase has no check constraints, and neither column can carry a foreign key because both use zero to mean "none" — so the invariant is held here instead, in a type that cannot represent a plot owned by a character and a guild at once.
Rows are read back through TryFromColumns(long, long, out PlotOwner) rather than a constructor, so a row that does somehow hold both is refused at the boundary instead of being resolved by whichever column the reader happened to check first. Two readers guessing differently about the same plot is how one owner ends up able to build on it and another ends up able to sell it.
Fields
None
An unclaimed plot.
public static readonly PlotOwner None
Field Value
Properties
CharacterID
The owning character, or zero when the plot is unowned or guild-owned.
public long CharacterID { get; }
Property Value
Remarks
Written straight into the plot row's owner column, which is why it reports zero rather than the guild's identifier for a guild-owned plot.
GuildID
The owning guild, or zero when the plot is unowned or character-owned.
public long GuildID { get; }
Property Value
ID
The owner's identifier, interpreted according to Type. Zero when unowned.
public long ID { get; }
Property Value
IsOwned
True when somebody owns the plot.
public bool IsOwned { get; }
Property Value
Type
What kind of holder owns the plot.
public PlotOwnerType Type { get; }
Property Value
Methods
Equals(PlotOwner)
public bool Equals(PlotOwner other)
Parameters
otherPlotOwner
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
objobject
Returns
ForCharacter(long)
Ownership by an individual character.
public static PlotOwner ForCharacter(long characterID)
Parameters
characterIDlongThe owning character. Must be greater than zero.
Returns
Remarks
Throws rather than returning None, because an identifier of zero here is a caller that has lost track of who it is acting for. Quietly folding that into "unowned" would answer a claim by releasing the plot to everyone.
Exceptions
- ArgumentOutOfRangeException
Thrown when
characterIDis not greater than zero.
ForGuild(long)
Ownership by a guild.
public static PlotOwner ForGuild(long guildID)
Parameters
guildIDlongThe owning guild. Must be greater than zero.
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown when
guildIDis not greater than zero.
GetHashCode()
public override int GetHashCode()
Returns
IsAllowedBy(HousingOwnershipMode)
True when this kind of ownership is permitted by the server's housing configuration.
public bool IsAllowedBy(HousingOwnershipMode mode)
Parameters
modeHousingOwnershipMode
Returns
Remarks
The gate that HousingOwnershipMode exists to provide, asked in the one place that knows what kind of owner is being proposed. None is permitted under every mode including Neither: releasing a plot has to keep working on a server that has since turned housing off, or plots claimed while it was on could never be given back.
ToString()
public override string ToString()
Returns
TryFromColumns(long, long, out PlotOwner)
Reads ownership back from a plot row's two owner columns.
public static bool TryFromColumns(long ownerCharacterID, long ownerGuildID, out PlotOwner owner)
Parameters
ownerCharacterIDlongThe row's owning character, zero for none.
ownerGuildIDlongThe row's owning guild, zero for none.
ownerPlotOwnerThe ownership the columns describe, or None on failure.
Returns
- bool
False when the columns contradict each other or hold a negative identifier.
Remarks
Both columns set is not a state any writer here produces, so encountering it means the row was written by something else or corrupted. Refusing it keeps that damage contained to the one plot rather than letting each reader invent its own answer.
Operators
operator ==(PlotOwner, PlotOwner)
public static bool operator ==(PlotOwner left, PlotOwner right)
Parameters
Returns
operator !=(PlotOwner, PlotOwner)
public static bool operator !=(PlotOwner left, PlotOwner right)