Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #7
0
 public static async Task <(bool result, Thing?who)> Controls(this Dbref whoDbref, Thing what, CancellationToken cancellationToken) => await what.IsControlledBy(whoDbref, cancellationToken);
Beispiel #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);
        }