예제 #1
0
        private void EmoteNpc(string command, string[] args)
        {
            if (!Context.IsMainPlayer && !Config.AllowNonHostEmoteNpcCommand)
            {
                this.Monitor.Log(I18n.Command_PermissionsDenied(), LogLevel.Info);
                return;
            }

            if (args.Length < 2)
            {
                this.Monitor.Log($"{I18n.Command_MissingParameters()}\n\n{I18n.Command_PlayEmoteNpc_Usage()}", LogLevel.Info);
                return;
            }

            NPC npc = Game1.getCharacterFromName(args[0], mustBeVillager: false);

            if (npc == null)
            {
                this.Monitor.Log($"Could not find any NPC with the name \"{args[0]}\".", LogLevel.Info);
                return;
            }

            if (!int.TryParse(args[1], out int id))
            {
                this.Monitor.Log("The emote id must be a integer.", LogLevel.Info);
                return;
            }

            if (id <= 0)
            {
                this.Monitor.Log("The emote id value must be greater than 0.", LogLevel.Info);
                return;
            }

            npc.doEmote(id * 4);

#if DEBUG
            this.Monitor.Log($"[id: {npc.id}, name: \"{npc.Name}\"] Playing emote: {id}", LogLevel.Info);
#else
            this.Monitor.Log($"[\"{npc.Name}\"] Playing emote: {id}", LogLevel.Info);
#endif
        }