private async Task ReportFate(FATE f) { int idx = FATEs.FindIndex(h => h.ID == f.ID); if (idx < 0 || (FATEs[idx].LastReported > ServerTimeUtc.AddSeconds(-5) && !(FATEs[idx].Progress != 100 && f.Progress > 99))) { return; } FATEs[idx].LastReported = ServerTimeUtc; //too pussy to use copy constructor FATEs[idx].Progress = f.Progress; FATEs[idx].PosX = f.PosX; FATEs[idx].PosZ = f.PosZ; FATEs[idx].PosY = f.PosY; FATEs[idx].ZoneID = f.ZoneID; FATEs[idx].Duration = f.Duration; FATEs[idx].StartTimeEpoch = f.StartTimeEpoch; FATEs[idx].State = f.State; FATEs[idx].ZoneID = f.ZoneID; try { if (hubConnection.Connected && Joined) { await hubConnection.Connection.InvokeAsync(nameof(ReportFate), FATEs[idx]); } } catch (Exception e) { LogHost.Default.WarnException(nameof(ReportFate), e); } }
private FATE GetFateFromByteArray(byte[] ba) { FATE f = new FATE() { ID = BitConverter.ToUInt16(ba, 0x18), StartTimeEpoch = BitConverter.ToUInt32(ba, 0x20), Duration = BitConverter.ToUInt16(ba, 0x28), ReadName = GetStringFromBytes(ba, Is64Bit ? 0xE2 : 0xAA), State = (FATEState)ba[Is64Bit ? 0x3AC : 0x2F4], Progress = ba[Is64Bit ? 0x3B3 : 0x2FB], PosX = BitConverter.ToSingle(ba, Is64Bit ? 0x400 : 0x340), PosZ = BitConverter.ToSingle(ba, Is64Bit ? 0x404 : 0x344), PosY = BitConverter.ToSingle(ba, Is64Bit ? 0x408 : 0x348), ZoneID = BitConverter.ToUInt16(ba, Is64Bit ? 0x624 : 0x4F4) }; if (f.ID == 0 || f.Progress < 0 || f.Progress > 100 || !f.PosX.IsWithin(-1024, 1024) || !f.PosY.IsWithin(-1024, 1024)) { return(null); } else { return(f); } }
internal async Task LastKnownInfoForFATE(ushort id) { if (!hubConnection.Connected || !Joined) { return; } FATE result = await hubConnection.Connection.InvokeAsync <FATEReport>("QueryFATE", id); if (result == null) { return; } TimeSpan timeSinceLastReport = ServerTimeUtc.Subtract(result.LastReported); if (timeSinceLastReport < TimeSpan.Zero) { timeSinceLastReport = TimeSpan.Zero; } ChatMessage cm = new ChatMessage(); if (timeSinceLastReport.TotalDays > 90) { cm.MessageString = string.Format(Resources.LKIHuntNotReported, result.Name()); } else if (timeSinceLastReport.TotalHours > 100) { cm.MessageString = string.Format(Resources.LKIFATEDays, result.Name(), Convert.ToUInt32(timeSinceLastReport.TotalDays)); } else { cm = ChatMessage.MakePosChatMessage(string.Format(Resources.LKIFATE, result.Name(), Math.Floor(timeSinceLastReport.TotalHours), timeSinceLastReport.Minutes), result.ZoneID, result.PosX, result.PosY); } await Program.mem.WriteChatMessage(cm); }
public FATE(FATE f)//copy constructor { ID = f.ID; ReadName = f.ReadName; Progress = f.Progress; PosX = f.PosX; PosZ = f.PosZ; PosY = f.PosY; ZoneID = f.ZoneID; State = f.State; StartTimeEpoch = f.StartTimeEpoch; Duration = f.Duration; }
public FATE(FATE fate) { if (fate == null) { throw new ArgumentNullException("fate"); } this.ID = fate.ID; this.ReadName = fate.ReadName; this.Progress = fate.Progress; this.PosX = fate.PosX; this.PosZ = fate.PosZ; this.PosY = fate.PosY; this.ZoneID = fate.ZoneID; this.State = fate.State; this.StartTimeEpoch = fate.StartTimeEpoch; this.Duration = fate.Duration; }
public override bool Equals(object obj) { FATE f = obj as FATE; return(f != null && obj != null && this.ID == f.ID); }
public FATEReport(FATE fate) : base(fate) { }