Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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;
        }
Exemple #6
0
        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);
        }
Exemple #7
0
 public static async Task <(bool result, Thing?who)> Controls(this Dbref whoDbref, Thing what, CancellationToken cancellationToken) => await what.IsControlledBy(whoDbref, cancellationToken);
Exemple #8
0
        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);
        }