internal async void Check(FFXIVMemory mem) { if (!hubConnection.Connected) { await Connect(); } if (!hubConnection.Connected) { return; } if (lastJoined != mem.GetWorldId() && Joined && !Joining || !Joined) { await LeaveGroup(); await JoinServerGroup(); } ServerTimeUtc = mem.GetServerUtcTime(); ushort thisZone = mem.GetZoneId(); if (thisZone != lastZone && Settings.Default.OncePerHunt && Settings.Default.ForgetOnZoneChange) { HuntsPutInChat.Clear(); } if (Array.IndexOf(DCZones, thisZone) > -1 && Array.IndexOf(DCZones, lastZone) == -1 && Joined) { LastShoutChatSync = await JoinDCZone(thisZone); } else if (Array.IndexOf(DCZones, lastZone) > -1 && Array.IndexOf(DCZones, thisZone) == -1) { await LeaveDCZone(); } lastZone = thisZone; foreach (Monster c in mem.Combatants.OfType <Monster>().Where(c => Hunts.Exists(h => h.Id == c.BNpcNameID && GetZoneId(c.BNpcNameID) == thisZone))) { _ = ReportHunt(c); } if (Array.IndexOf(DCZones, thisZone) > -1 && LastShoutChatSync != null) { await ReportDCShoutChat(mem.ReadChatLogBackwards(filter : x => x.Channel == ChatChannel.Shout, stopOn : x => x.Timestamp <= LastShoutChatSync).OrderByDescending(x => x.Timestamp).Take(10)); } foreach (FATE f in mem.GetFateList().Where(f => f.ZoneID == thisZone)) { _ = ReportFate(f); if (f.IsDataCenterShared() && PutInChat(new FATEReport(f) { WorldId = mem.GetWorldId() }) && Settings.Default.FlashTaskbarIconOnHuntAndFATEs) { NativeMethods.FlashTaskbarIcon(mem.Process); } } }
public override void Update() { RadarOverlay.< > c__DisplayClass30_0 CS$ < > 8__locals1 = new RadarOverlay.< > c__DisplayClass30_0(); this._tickEngine.Pulse(); if (base.OverlayWindow == null || !base.OverlayWindow.IsVisible) { return; } if (!this.MouseDown) { this.FollowTargetWindow(); } RadarOverlay.< > c__DisplayClass30_0 CS$ < > 8__locals2 = CS$ < > 8__locals1; FFXIVMemory mem = Program.mem; CS$ < > 8__locals2.self = ((mem != null) ? mem.GetSelfCombatant() : null); FFXIVMemory mem2 = Program.mem; List <Entity> clist = (mem2 != null) ? mem2.GetCombatantList() : null; if (CS$ < > 8__locals1.self != null && clist != null) { clist.RemoveAll((Entity c) => c.OwnerID == CS$ < > 8__locals1.self.ID); using (List <uint> .Enumerator enumerator = (from x in clist.OfType <PC>() select x.ID).ToList <uint>().GetEnumerator()) { while (enumerator.MoveNext()) { uint ID = enumerator.Current; clist.RemoveAll((Entity c) => c.OwnerID == ID); } } this.RemoveUnvantedCombatants(CS$ < > 8__locals1.self, clist); double centerY = base.OverlayWindow.Height / 2.0; double centerX = base.OverlayWindow.Width / 2.0; foreach (Entity c2 in clist) { if (c2.ID == 3758096384u && !this.miscDrawMap.ContainsKey(c2.PosX + c2.PosY)) { this.miscDrawMap.Add(c2.PosX + c2.PosY, new EntityOverlayControl(c2, false)); base.OverlayWindow.Add(this.miscDrawMap[c2.PosX + c2.PosY]); } else if (!this.drawMap.ContainsKey(c2.ID)) { this.drawMap.Add(c2.ID, new EntityOverlayControl(c2, c2.ID == CS$ < > 8__locals1.self.ID)); base.OverlayWindow.Add(this.drawMap[c2.ID]); } double Top = (double)(c2.PosY - CS$ < > 8__locals1.self.PosY); double Left = (double)(c2.PosX - CS$ < > 8__locals1.self.PosX); Top += centerY + Top * base.OverlayWindow.Height * 0.003 * (double)Settings.Default.RadarZoom; Left += centerX + Left * base.OverlayWindow.Width * 0.003 * (double)Settings.Default.RadarZoom; if (this.drawMap.ContainsKey(c2.ID)) { this.drawMap[c2.ID].Update(c2); Top -= this.drawMap[c2.ID].ActualHeight / 2.0; Left -= this.drawMap[c2.ID].ActualWidth / 2.0; if (Top < 0.0) { Canvas.SetTop(this.drawMap[c2.ID], 0.0); } else if (Top > base.OverlayWindow.Height - this.drawMap[c2.ID].ActualHeight) { Canvas.SetTop(this.drawMap[c2.ID], base.OverlayWindow.Height - this.drawMap[c2.ID].ActualHeight); } else { Canvas.SetTop(this.drawMap[c2.ID], Top); } if (Left < 0.0) { Canvas.SetLeft(this.drawMap[c2.ID], 0.0); } else if (Left > base.OverlayWindow.Width - this.drawMap[c2.ID].ActualWidth) { Canvas.SetLeft(this.drawMap[c2.ID], base.OverlayWindow.Width - this.drawMap[c2.ID].ActualWidth); } else { Canvas.SetLeft(this.drawMap[c2.ID], Left); } } else if (this.miscDrawMap.ContainsKey(c2.PosX + c2.PosY)) { this.miscDrawMap[c2.PosX + c2.PosY].Update(c2); Top -= this.miscDrawMap[c2.ID].ActualHeight / 2.0; Left -= this.miscDrawMap[c2.ID].ActualWidth / 2.0; Canvas.SetTop(this.miscDrawMap[c2.PosX + c2.PosY], Top); Canvas.SetLeft(this.miscDrawMap[c2.PosX + c2.PosY], Left); } } } KeyValuePair <uint, EntityOverlayControl>[] array = this.drawMap.ToArray <KeyValuePair <uint, EntityOverlayControl> >(); int i = 0; while (i < array.Length) { KeyValuePair <uint, EntityOverlayControl> entry = array[i]; if (!entry.Value.GetEntityName().Equals("Hoard!", StringComparison.Ordinal) || clist == null) { goto IL_626; } if (!clist.OfType <EObject>().Any((EObject c) => c.SubType == EObjType.Banded)) { goto IL_626; } entry.Value.Visibility = Visibility.Collapsed; if (!this.hoardsDiscovered.Contains(entry.Key)) { this.hoardsDiscovered.Add(entry.Key); } IL_668: i++; continue; IL_626: if (clist == null || !clist.Exists((Entity c) => c.ID == entry.Key)) { entry.Value.Visibility = Visibility.Collapsed; this.drawMap.Remove(entry.Key); goto IL_668; } goto IL_668; } KeyValuePair <float, EntityOverlayControl>[] array2 = this.miscDrawMap.ToArray <KeyValuePair <float, EntityOverlayControl> >(); for (i = 0; i < array2.Length; i++) { KeyValuePair <float, EntityOverlayControl> entry = array2[i]; if (clist == null || !clist.Exists((Entity c) => c.PosX + c.PosY == entry.Key)) { entry.Value.Visibility = Visibility.Collapsed; this.miscDrawMap.Remove(entry.Key); } } }
internal void ProcessChatCommand(object sender, CommandEventArgs e) { LogHost.Default.Info($"[{nameof(ProcessChatCommand)}] New command: {e?.ToString()}"); FFXIVMemory mem = sender is FFXIVMemory ? sender as FFXIVMemory : Program.mem; if (mem == null) { return; } if (e.Command == Command.Hunt && hunts != null) { if (GameResources.TryGetDailyHuntInfo(e.Parameter, out Tuple <ushort, ushort, float, float> hi)) { _ = mem.WriteChatMessage(ChatMessage.MakePosChatMessage(string.Format(Properties.Resources.LKICanBeFoundAt, GameResources.GetEnemyName(hi.Item1, true)), hi.Item2, hi.Item3, hi.Item4)); return; } else if (hunts.hunts.Exists(x => x.Name.Equals(e.Parameter, StringComparison.OrdinalIgnoreCase))) { _ = hunts.LastKnownInfoForHunt(hunts.hunts.First(x => x.Name.Equals(e.Parameter, StringComparison.OrdinalIgnoreCase)).Id); return; } else if (GameResources.GetEnemyId(e.Parameter, out ushort bnpcid)) { _ = hunts.RandomPositionForBNpc(bnpcid); return; } ushort fid = GameResources.GetFateId(e.Parameter, true); if (fid > 0) { _ = hunts.LastKnownInfoForFATE(fid); if (Settings.Default.TrackFATEAfterQuery) { vm.FATEEntries.SingleOrDefault(x => x.ID == fid).Announce = true; } } else if (Enum.TryParse(e.Parameter.Split(' ').Last(), out HuntRank hr) && hr != HuntRank.FATE && GameResources.TryGetZoneID(e.Parameter.Substring(0, e.Parameter.Length - 2).Trim(), out ushort ZoneID) && FFXIVHunts.MapHunts.ContainsKey(ZoneID)) { foreach (ushort hid in FFXIVHunts.MapHunts[ZoneID].Where(x => hunts.HuntRankFor(x) == hr)) { _ = hunts.LastKnownInfoForHunt(hid); } } else if (!string.IsNullOrWhiteSpace(e.Parameter)) { string[] pwords = e.Parameter.Split(' '); bool hqprefer = pwords.Last().Equals("HQ", StringComparison.OrdinalIgnoreCase); Task.Factory.StartNew(async() => { Item item = await hunts.QueryItem(hqprefer ? string.Join(" ", pwords.Take(pwords.Length - 1)) : e.Parameter); if (item != null) { await mem.WriteChatMessage(ChatMessage.MakeItemChatMessage(item, HQ: hqprefer)); } }); } } else if (e.Command == Command.Perform) { if (!Directory.Exists(Settings.Default.PerformDirectory)) { LogHost.Default.Error(Properties.Resources.PerformDirectoryNotExists); _ = mem.WriteChatMessage(new ChatMessage { MessageString = Properties.Resources.PerformDirectoryNotExists }); return; } string nametxt = e.Parameter; if (!nametxt.EndsWith(".txt")) { nametxt += ".txt"; } string namemml = e.Parameter; if (!namemml.EndsWith(".mml")) { namemml += ".mml"; } string pathnametxt = Path.Combine(Settings.Default.PerformDirectory, nametxt); string pathnamemml = Path.Combine(Settings.Default.PerformDirectory, namemml); if (File.Exists(pathnametxt)) { StopPerformance(); var p = new Performance(string.Join(",", File.ReadAllLines(pathnametxt))); if (p.Sheet.Count > 0) { _ = mem.PlayPerformance(p, cts.Token); } else { TryMML(pathnametxt); } } else if (File.Exists(pathnamemml)) { StopPerformance(); TryMML(pathnamemml); } else { LogHost.Default.Error("Neither of these files were found:" + Environment.NewLine + pathnametxt + Environment.NewLine + pathnamemml); } } else if (e.Command == Command.PerformStop && cts != null) { cts.Cancel(); } else if (e.Command == Command.Flag) { string[] coords = e.Parameter.Split(','); if (coords.Length > 1 && float.TryParse(coords[0], out float xR) && float.TryParse(coords[1], out float yR)) { ushort zid = Program.mem.GetZoneId(); ushort mid = Program.mem.GetMapId(); float x = Entity.GetCoordFromReadable(xR, zid, mid); float y = Entity.GetCoordFromReadable(yR, zid, mid); var cm = ChatMessage.MakePosChatMessage(string.Empty, zid, x, y, string.Empty, mid); _ = mem.WriteChatMessage(cm); } } }
internal async void Check(FFXIVMemory mem) { FFXIVHunts.< > c__DisplayClass44_0 CS$ < > 8__locals1 = new FFXIVHunts.< > c__DisplayClass44_0(); if (!FFXIVHunts.hubConnection.Connected) { await this.Connect(); } if (FFXIVHunts.hubConnection.Connected) { ushort currentWorldID = mem.GetCurrentWorldId(); if ((FFXIVHunts.LastJoinedWorldID != currentWorldID && FFXIVHunts.Joined && !FFXIVHunts.Joining) || !FFXIVHunts.Joined) { await this.LeaveGroup(); await this.JoinServerGroup(); } FFXIVHunts.ServerTimeUtc = mem.GetServerUtcTime(); CS$ < > 8__locals1.thisZone = mem.GetZoneId(); if (CS$ < > 8__locals1.thisZone != FFXIVHunts.lastZone && Settings.Default.OncePerHunt && Settings.Default.ForgetOnZoneChange) { FFXIVHunts.HuntsPutInChat.Clear(); } if (Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)CS$ < > 8__locals1.thisZone) > -1 && Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)FFXIVHunts.lastZone) == -1 && FFXIVHunts.Joined) { TaskAwaiter <DateTime> taskAwaiter = this.JoinDCZone(CS$ < > 8__locals1.thisZone).GetAwaiter(); if (!taskAwaiter.IsCompleted) { await taskAwaiter; TaskAwaiter <DateTime> taskAwaiter2; taskAwaiter = taskAwaiter2; taskAwaiter2 = default(TaskAwaiter <DateTime>); } FFXIVHunts.LastShoutChatSync = taskAwaiter.GetResult(); } else if (Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)FFXIVHunts.lastZone) > -1 && Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)CS$ < > 8__locals1.thisZone) == -1) { await this.LeaveDCZone(); } FFXIVHunts.lastZone = CS$ < > 8__locals1.thisZone; IEnumerable <Monster> source = mem.Combatants.OfType <Monster>(); Func <Monster, bool> predicate; if ((predicate = CS$ < > 8__locals1.< > 9__3) == null) { FFXIVHunts.< > c__DisplayClass44_0 CS$ < > 8__locals2 = CS$ < > 8__locals1; Func <Monster, bool> func = (Monster c) => FFXIVHunts.CurrentWorld.Hunts.Exists((Hunt h) => h.Id == c.BNpcNameID && FFXIVHunts.GetZoneId(c.BNpcNameID) == CS$ < > 8__locals1.thisZone); CS$ < > 8__locals2.< > 9__3 = func; predicate = func; } foreach (Monster c2 in source.Where(predicate)) { this.ReportHunt(c2); } if (Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)CS$ < > 8__locals1.thisZone) > -1) { DateTime lastShoutChatSync = FFXIVHunts.LastShoutChatSync; await this.ReportDCShoutChat((from x in mem.ReadChatLogBackwards(1000, (ChatMessage x) => x.Channel == ChatChannel.Shout && !string.IsNullOrWhiteSpace(x.Sender.Name), (ChatMessage x) => x.Timestamp <= FFXIVHunts.LastShoutChatSync) orderby x.Timestamp descending select x).Take(10)); } IEnumerable <FATE> fateList = mem.GetFateList(); Func <FATE, bool> predicate2; if ((predicate2 = CS$ < > 8__locals1.< > 9__5) == null) { FFXIVHunts.< > c__DisplayClass44_0 CS$ < > 8__locals3 = CS$ < > 8__locals1; Func <FATE, bool> func2 = (FATE f) => f.ZoneID == CS$ < > 8__locals1.thisZone; CS$ < > 8__locals3.< > 9__5 = func2; predicate2 = func2; } foreach (FATE f2 in fateList.Where(predicate2)) { this.ReportFate(f2); if (f2.IsDataCenterShared() && this.PutInChat(new FATEReport(f2) { WorldId = mem.GetHomeWorldId() }) && Settings.Default.FlashTaskbarIconOnHuntAndFATEs) { NativeMethods.FlashTaskbarIcon(mem.Process); } } }