Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Celeste.Library.CoreObjects
  7. {
  8.     public class WoWLogin
  9.     {
  10.         private WoWCore Core;
  11.         public WoWLogin(WoWCore Core)
  12.         {
  13.             this.Core = Core;
  14.         }
  15.  
  16.         public bool RealmFrameVisible { get { return Core.Lua.GetReturnVal<bool>("RealmList:IsShown()", 0); } }
  17.         public bool CharSelectVisible { get { return Core.Lua.GetReturnVal<bool>("CharacterSelectUI:IsShown()", 0); } }
  18.  
  19.         public void Login(string account, string password)
  20.         {
  21.             Core.Lua.DoString(string.Format("DefaultServerLogin('{0}', '{1}');", account, password));
  22.         }
  23.  
  24.         public void SelectGameAccount(string account)
  25.         {
  26.             Core.Lua.DoString(
  27.                 string.Format(
  28.                     "for i = 0, GetNumGameAccounts(), 1 do local name = GetGameAccountInfo(i); " +
  29.                     "if (name == '{0}') then SetGameAccount(i); end end",
  30.                     account));
  31.         }
  32.  
  33.         public void SelectRealm(string realm)
  34.         {
  35.             if (RealmFrameVisible)
  36.             {
  37.                 Core.Lua.DoString(
  38.                     string.Format(
  39.                         "for i = 1, select('#', GetRealmCategories()), 1 do local numRealms = GetNumRealms(i);" +
  40.                         "for j = 1, numRealms, 1 do local name, numCharacters = GetRealmInfo(i, j);" +
  41.                         "if (name ~= nil and name == '{0}') ChangeRealm(i,j); end end end",
  42.                         realm));
  43.             }
  44.         }
  45.  
  46.         public void SelectCharacter(string character)
  47.         {
  48.             if (CharSelectVisible)
  49.             {
  50.                 Core.Lua.DoString(
  51.                     string.Format(
  52.                         "for i=0,GetNumCharacters(),1 do local name = GetCharacterInfo(i);" +
  53.                         "if (name ~= nil and name == '{0}') then CharacterSelect_SelectCharacter(i); end end",
  54.                         character));
  55.             }
  56.         }
  57.  
  58.         public void EnterWorld()
  59.         {
  60.             Core.Lua.DoString("EnterWorld();");
  61.         }
  62.  
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement