コード例 #1
0
        public ReadResults Parse(IStringReader reader, DispatcherResources resources, out GameType result)
        {
            result = default;
            int         start       = reader.GetCursor();
            ReadResults readResults = reader.ReadUnquotedString(out string gamemode);

            if (!readResults.Successful)
            {
                return(readResults);
            }
            if (!resources.Gamemodes.TryGet(gamemode, out result))
            {
                reader.SetCursor(start);
                return(ReadResults.Failure(CommandError.UnknownGamemode(gamemode).WithContext(reader)));
            }

            return(ReadResults.Success());
        }
コード例 #2
0
        private static ReadResults ReadGamemode(EntitySelectorParser parser, IStringReader reader, DispatcherResources resources)
        {
            int         start       = reader.GetCursor();
            ReadResults readResults = reader.ReadUnquotedString(out string gamemode);

            if (!readResults.Successful)
            {
                return(readResults);
            }

            if (resources.Gamemodes.TryGet(gamemode, out _))
            {
                parser.AddArgument(new ParsedArgument <Literal>(new Literal(gamemode), false));
                return(ReadResults.Success());
            }
            else
            {
                reader.SetCursor(start);
                return(ReadResults.Failure(CommandError.UnknownGamemode(gamemode).WithContext(reader)));
            }
        }