상속: ObservableObject, IDisposable
예제 #1
0
        public MacroState(Player client)
        {
            if (client == null)
            throw new ArgumentNullException("client");

              this.client = client;
        }
예제 #2
0
        public PlayerMacroState GetMacroState(Player player)
        {
            if (isLockedDown)
            throw new InvalidOperationException("Macro virtual machine is currently locked down.");

              if (clientMacros.ContainsKey(player.Process.ProcessId))
            return clientMacros[player.Process.ProcessId];

              var state = new PlayerMacroState(player);
              clientMacros[player.Process.ProcessId] = state;

              return state;
        }
예제 #3
0
        public void AddNewClient(ClientProcess process, ClientVersion version = null)
        {
            var player = new Player(process) { Version = version };
              player.PropertyChanged += Player_PropertyChanged;

              if (player.Version == null)
              {
            player.Version = ClientVersionManager.Instance.Versions.First(v => v.Key != "Auto-Detect");
              }

              AddPlayer(player);
              player.Update();
        }
예제 #4
0
        public void AddPlayer(Player player)
        {
            if (player == null)
            throw new ArgumentNullException("player");

              var alreadyExists = players.ContainsKey(player.Process.ProcessId);

              players[player.Process.ProcessId] = player;

              if (alreadyExists)
            OnPlayerUpdated(player);
              else
            OnPlayerAdded(player);
        }
예제 #5
0
 public MapLocation(Player owner)
 {
     this.owner = owner;
 }
예제 #6
0
        void OnPlayerLoggedOut(Player player)
        {
            if (player == null || string.IsNullOrWhiteSpace(player.Name))
            return;

              var shouldSaveMacroStates = UserSettingsManager.Instance.Settings.SaveMacroStates;
              var macro = MacroManager.Instance.GetMacroState(player);

              try
              {
            if (shouldSaveMacroStates && macro != null)
              SaveMacroState(macro);

              }
              catch (Exception ex)
              {
            this.Dispatcher.Invoke((Action)delegate
            {
              this.ShowMessageBox("Save State Error",
                 string.Format("There was an error saving the macro state:\n{0}", ex.Message),
                 string.Format("{0}'s macro state may not be preserved upon next login.", player.Name),
                 MessageBoxButton.OK, 460, 260);

            }, DispatcherPriority.Normal, null);
              }
              finally
              {
            this.Dispatcher.InvokeIfRequired(() =>
            {
              if (player.HasHotkey)
            HotkeyManager.Instance.UnregisterHotkey(windowSource.Handle, player.Hotkey);

              player.Hotkey = null;
            });
              }

              if (macro != null)
              {
            macro.ClearSpellQueue();
            macro.ClearFlowerQueue();
              }
        }
예제 #7
0
        void OnPlayerLoggedIn(Player player)
        {
            if (player == null || string.IsNullOrWhiteSpace(player.Name))
            return;

              var shouldSaveMacroStates = UserSettingsManager.Instance.Settings.SaveMacroStates;
              var macro = MacroManager.Instance.GetMacroState(player);

              try
              {
            if (shouldSaveMacroStates && macro != null)
            {
              LoadMacroState(player);
            }
              }
              catch (Exception ex)
              {
            this.Dispatcher.Invoke((Action)delegate
            {
              this.ShowMessageBox("Load State Error",
                 string.Format("There was an error loading the macro state:\n{0}", ex.Message),
                 string.Format("{0}'s macro state was not preserved.", player.Name),
                 MessageBoxButton.OK, 460, 260);

            }, DispatcherPriority.Normal, null);
              }
        }
예제 #8
0
        void LoadMacroState(Player player)
        {
            if (player == null)
            throw new ArgumentNullException("player");

              if (!Directory.Exists("saves"))
            return;

              var filename = Path.Combine("saves", string.Format("{0}.xml", player.Name));

              if (!File.Exists(filename))
            return;

              var macroState = SavedMacroState.LoadFromFile(filename);

              if (macroState == null)
            return;

              MacroManager.Instance.ImportMacroState(player, macroState);

              if (File.Exists(filename))
            File.Delete(filename);
        }
예제 #9
0
 public PlayerModifiers(Player owner)
 {
     this.owner = owner;
 }
예제 #10
0
 public PlayerEventArgs(Player player)
 {
     this.player = player;
 }
예제 #11
0
 public ClientState(Player owner)
 {
     this.owner = owner;
 }
예제 #12
0
        public void ImportMacroState(Player player, SavedMacroState state)
        {
            if (player == null)
            throw new ArgumentNullException("player");

              if (state == null)
            throw new ArgumentNullException("state");

              var macro = GetMacroState(player);
              if (macro == null)
            return;

              macro.Stop();

              var process = Process.GetCurrentProcess();

              if (player.HasHotkey)
              {
            HotkeyManager.Instance.UnregisterHotkey(process.MainWindowHandle, player.Hotkey);
            player.Hotkey = null;
              }

              player.Skillbook.ClearActiveSkills();
              macro.ClearSpellQueue();
              macro.ClearFlowerQueue();

              player.Update(PlayerFieldFlags.Spellbook);
              macro.UseLyliacVineyard = player.HasLyliacVineyard && state.UseLyliacVineyard;
              macro.FlowerAlternateCharacters = player.HasLyliacPlant && state.FlowerAlternateCharacters;

              player.Update(PlayerFieldFlags.Skillbook);
              foreach (var skill in state.Skills)
              {
            if (!player.Skillbook.ContainSkill(skill.SkillName))
              continue;

            player.Skillbook.ToggleActive(skill.SkillName, true);
              }

              foreach (var spell in state.Spells)
              {
            if (!player.Spellbook.ContainSpell(spell.SpellName))
              continue;

            var spellInfo = player.Spellbook.GetSpell(spell.SpellName);
            if (spellInfo == null)
              continue;

            var queueItem = new SpellQueueItem(spellInfo, spell);
            macro.AddToSpellQueue(queueItem);
              }

              if (player.HasLyliacPlant)
            foreach (var flower in state.Flowers)
            {
              if (flower.TargetMode == TargetCoordinateUnits.None)
            continue;

              var queueItem = new FlowerQueueItem(flower);
              macro.AddToFlowerQueue(queueItem);
            }

              var windowHandle = Process.GetCurrentProcess().MainWindowHandle;

              if (state.HotkeyKey != Key.None && (state.HotkeyModifiers != ModifierKeys.None || Hotkey.IsFunctionKey(state.HotkeyKey)))
              {
            var hotkey = new Hotkey(state.HotkeyModifiers, state.HotkeyKey);

            if (HotkeyManager.Instance.RegisterHotkey(windowHandle, hotkey))
              player.Hotkey = hotkey;
              }
        }
예제 #13
0
        void OnPlayerUpdated(Player player)
        {
            player.PropertyChanged += Player_PropertyChanged;

              var handler = this.PlayerUpdated;

              if (handler != null)
            handler(this, new PlayerEventArgs(player));
        }
예제 #14
0
        void OnPlayerPropertyChanged(Player player, string propertyName)
        {
            var handler = this.PlayerPropertyChanged;

              if (handler != null)
            handler(player, new PropertyChangedEventArgs(propertyName));
        }
예제 #15
0
 public PlayerStats(Player owner)
 {
     this.owner = owner;
 }