public static async Task <(bool result, Thing?who, Thing?what)> Controls(this Dbref whoDbref, Dbref whatDbref, CancellationToken cancellationToken) { var what = await whatDbref.Get(cancellationToken); var(result, who) = await what.IsControlledBy(whoDbref, cancellationToken); return(result, who, what); }
public static async Task <(string, Thing?)> UnparseObject(this Dbref dbref, Dbref player, CancellationToken cancellationToken) { var thing = await dbref.Get(cancellationToken); if (thing == null) { return("*INVALID*", null); } return(await thing.UnparseObject(player, cancellationToken), thing); }
public static async Task <Thing?> Get(this Dbref dbref, CancellationToken cancellationToken) { var result = await ThingRepository.Instance.GetAsync <Thing>(dbref, cancellationToken); if (!result.isSuccess || result.value == null) { return(null); } return(result.value); }
public static async Task <Dbref> GetOwner(this Dbref dbref, CancellationToken cancellationToken) { if (!dbref.IsValid()) { return(Dbref.NOT_FOUND); } var thing = await ThingRepository.Instance.GetAsync <Thing>(dbref, cancellationToken); if (!thing.isSuccess || thing.value == null) { return(Dbref.NOT_FOUND); } return(thing.value.Owner); }
public Property(string name, Dbref value) { if (string.IsNullOrWhiteSpace(name)) { throw new System.ArgumentNullException(nameof(name)); } if (default(Dbref).Equals(value)) { throw new System.ArgumentNullException(nameof(value)); } this.Name = name; this.directory = null; this.value = value; this.Type = PropertyType.DbRef; }
public static async Task <(bool result, Thing?who)> IsControlledBy(this Thing?what, Dbref whoDbref, CancellationToken cancellationToken) { var who = await whoDbref.Get(cancellationToken); return(what.IsControlledBy(who), who); }
public static async Task <(bool result, Thing?who)> Controls(this Dbref whoDbref, Thing what, CancellationToken cancellationToken) => await what.IsControlledBy(whoDbref, cancellationToken);
public static async Task <(bool result, Thing?who, Thing?where)> CanTeleportTo(this Dbref whoDbref, Dbref whereDbref, CancellationToken cancellationToken) { var(controls, who, where) = await Controls(whoDbref, whereDbref, cancellationToken); if (who == null || where == null) { return(false, null, null); } var result = who.CanTeleportTo(where, controls); return(result, who, where); }