private ILocValue FuncGender(LocArgs args)
        {
            if (args.Args.Count < 1)
            {
                return(new LocValueString(nameof(Gender.Neuter)));
            }

            ILocValue entity0 = args.Args[0];

            if (entity0.Value != null)
            {
                EntityUid entity = (EntityUid)entity0.Value;

                if (_entMan.TryGetComponent <GrammarComponent?>(entity, out var grammar) && grammar.Gender.HasValue)
                {
                    return(new LocValueString(grammar.Gender.Value.ToString().ToLowerInvariant()));
                }

                if (TryGetEntityLocAttrib(entity, "gender", out var gender))
                {
                    return(new LocValueString(gender));
                }
            }

            return(new LocValueString(nameof(Gender.Neuter)));
        }
        private ILocValue FuncProper(LocArgs args)
        {
            if (args.Args.Count < 1)
            {
                return(new LocValueString("false"));
            }

            ILocValue entity0 = args.Args[0];

            if (entity0.Value != null)
            {
                EntityUid entity = (EntityUid)entity0.Value;

                if (_entMan.TryGetComponent <GrammarComponent?>(entity, out var grammar) && grammar.ProperNoun.HasValue)
                {
                    return(new LocValueString(grammar.ProperNoun.Value.ToString().ToLowerInvariant()));
                }

                if (TryGetEntityLocAttrib(entity, "proper", out var proper))
                {
                    return(new LocValueString(proper));
                }
            }

            return(new LocValueString("false"));
        }
        private ILocValue FuncCapitalize(LocArgs args)
        {
            var input = args.Args[0].Format(new LocContext());

            if (!String.IsNullOrEmpty(input))
            {
                return(new LocValueString(input[0].ToString().ToUpper() + input.Substring(1)));
            }
            else
            {
                return(new LocValueString(""));
            }
        }
        private IFluentType CallFunction(LocFunction function,
                                         IList <IFluentType> positionalArgs, IDictionary <string, IFluentType> namedArgs)
        {
            var args = new ILocValue[positionalArgs.Count];

            for (var i = 0; i < args.Length; i++)
            {
                args[i] = positionalArgs[i].ToLocValue();
            }

            var options = new Dictionary <string, ILocValue>(namedArgs.Count);

            foreach (var(k, v) in namedArgs)
            {
                options.Add(k, v.ToLocValue());
            }

            var argStruct = new LocArgs(args, options);

            return(function.Invoke(argStruct).FluentFromVal());
        }
        private ILocValue FuncAttrib(MessageContext context, LocArgs args)
        {
            if (args.Args.Count < 2)
            {
                return(new LocValueString("other"));
            }

            ILocValue entity0 = args.Args[0];

            if (entity0.Value != null)
            {
                IEntity   entity  = (IEntity)entity0.Value;
                ILocValue attrib0 = args.Args[1];
                if (TryGetEntityLocAttrib(entity, attrib0.Format(new LocContext(context)), out var attrib))
                {
                    return(new LocValueString(attrib));
                }
            }

            return(new LocValueString("other"));
        }
        private ILocValue FuncAttrib(FluentBundle bundle, LocArgs args)
        {
            if (args.Args.Count < 2)
            {
                return(new LocValueString("other"));
            }

            ILocValue entity0 = args.Args[0];

            if (entity0.Value != null)
            {
                EntityUid entity  = (EntityUid)entity0.Value;
                ILocValue attrib0 = args.Args[1];
                if (TryGetEntityLocAttrib(entity, attrib0.Format(new LocContext(bundle)), out var attrib))
                {
                    return(new LocValueString(attrib));
                }
            }

            return(new LocValueString("other"));
        }
        private FluentType CallFunction(
            LocFunction function,
            IList <object> fluentArgs, IDictionary <string, object> fluentOptions)
        {
            var args = new ILocValue[fluentArgs.Count];

            for (var i = 0; i < args.Length; i++)
            {
                args[i] = ValFromFluent(fluentArgs[i]);
            }

            var options = new Dictionary <string, ILocValue>(fluentOptions.Count);

            foreach (var(k, v) in fluentOptions)
            {
                options.Add(k, ValFromFluent(v));
            }

            var argStruct = new LocArgs(args, options);

            var ret = function(argStruct);

            return(ValToFluent(ret));
        }
 private ILocValue FuncSubject(LocArgs args)
 {
     return(new LocValueString(GetString("zzzz-subject-pronoun", ("ent", args.Args[0]))));
 }
 private ILocValue FuncThe(LocArgs args)
 {
     return(new LocValueString(GetString("zzzz-the", ("ent", args.Args[0]))));
 }
 private ILocValue FuncConjugateHave(LocArgs args)
 {
     return(new LocValueString(GetString("zzzz-conjugate-have", ("ent", args.Args[0]))));
 }
 private ILocValue FuncReflexive(LocArgs args)
 {
     return(new LocValueString(GetString("zzzz-reflexive-pronoun", ("ent", args.Args[0]))));
 }
 private ILocValue FuncPossPronoun(LocArgs args)
 {
     return(new LocValueString(GetString("zzzz-possessive-pronoun", ("ent", args.Args[0]))));
 }
 private ILocValue FuncPossAdj(LocArgs args)
 {
     return(new LocValueString(GetString("zzzz-possessive-adjective", ("ent", args.Args[0]))));
 }