public virtual void OnEvent(FightCloudEvent _fightCloudEvent) { if (CharacterID.Equals("Attacker") == true) { if (_fightCloudEvent.type == FightCloudEventType.StartFight) { EventManager.TriggerEvent <MovementEvent>(new MovementEvent(MovementEventType.Stop, this)); } if (_fightCloudEvent.type == FightCloudEventType.EndFight) { EventManager.TriggerEvent <MovementEvent>(new MovementEvent(MovementEventType.Move, this)); } } return; }
public bool Refresh() { if (ffxivProcess != null) { ffxivProcess.Refresh(); if (ffxivProcess.HasExited) { OnProcessLost?.Invoke(this, EventArgs.Empty); ffxivProcess = null; hasLost = true; Reset(); Console.WriteLine("Exited game"); } if (IsScanning() && !hasScanned) { Console.WriteLine("Scanning..."); while (IsScanning()) { Thread.Sleep(100); } Console.WriteLine("Finished scanning"); OnProcessReady?.Invoke(this, ffxivProcess); hasScanned = true; } } if ((ffxivProcess == null) && hasLost) { OnProcessSeek?.Invoke(this, EventArgs.Empty); hasLost = false; return(false); } if (Reader.CanGetCharacterId()) { string id = Reader.GetCharacterId(); if (!string.IsNullOrEmpty(id)) { if (string.IsNullOrEmpty(CharacterID) || (!string.IsNullOrEmpty(CharacterID) && !CharacterID.Equals(id))) { CharacterID = id; } } } if (Reader.CanGetPlayerInfo()) { CurrentPlayerResult res = Reader.GetCurrentPlayer(); if (res.CurrentPlayer.Job != currentPlayer.CurrentPlayer.Job) { if (currentPlayer.CurrentPlayer.Job == Sharlayan.Core.Enums.Actor.Job.Unknown) { // Logged in OnCurrentPlayerLogin?.Invoke(this, res); isLoggedIn = true; } else if (res.CurrentPlayer.Job == Sharlayan.Core.Enums.Actor.Job.Unknown) { // Logged out OnCurrentPlayerLogout?.Invoke(this, currentPlayer); isLoggedIn = false; Reset(); } else { OnCurrentPlayerJobChange?.Invoke(this, currentPlayer); } } currentPlayer = res; } if (!isLoggedIn) { return(false); } if (Reader.CanGetPartyMembers()) { PartyResult party2 = Reader.GetPartyMembers(); if (party2.NewPartyMembers.Count > 0 || party2.RemovedPartyMembers.Count > 0) { // Something changed party = party2; OnPartyChanged?.Invoke(this, party2); } int pcount = party.PartyMembers.Count; int pcount2 = party2.PartyMembers.Count; if (!(party is PartyResult) || (party is PartyResult && (pcount != pcount2))) { party = party2; OnPartyChanged?.Invoke(this, party2); } } if (Reader.CanGetPerformance()) { List <uint> changedIds = new List <uint>(); PerformanceResult perf = Reader.GetPerformance(); if (!perf.Performances.IsEmpty && !performance.Performances.IsEmpty) { foreach (KeyValuePair <uint, PerformanceItem> pp in perf.Performances) { if (pp.Value.Status != performance.Performances[pp.Key].Status) { changedIds.Add(pp.Key); } } } if (changedIds.Count > 0) { List <uint> actorIds = new List <uint>(); if (Reader.CanGetActors()) { foreach (ActorItem actor in Reader.GetActors().CurrentPCs.Values) { if (changedIds.Contains(actor.PerformanceID / 2)) { actorIds.Add(actor.ID); } } } if (actorIds.Count > 0) { OnPerformanceChanged?.Invoke(this, actorIds); } } //Update performance = perf; bool r = perf.Performances[0].IsReady(); if (r != performanceReady) { performanceReady = r; OnPerformanceReadyChanged?.Invoke(this, performanceReady); } } logItems.Clear(); if (Reader.CanGetChatLog()) { ChatLogResult readResult = Reader.GetChatLog(_previousArrayIndex, _previousOffset); _previousArrayIndex = readResult.PreviousArrayIndex; _previousOffset = readResult.PreviousOffset; foreach (ChatLogItem item in readResult.ChatLogItems) { logItems.Push(item); completeLog.Add(item); OnChatReceived?.Invoke(this, item); } } if (Reader.CanGetActors()) { int jobsum0 = 0; if (actors != null) { jobsum0 = actors.CurrentPCs.Sum(e => (int)e.Value.Job); } ActorResult actorRes = Reader.GetActors(); if (actors != null) { if (actorRes.CurrentPCs.Count != actors.CurrentPCs.Count) { actors = actorRes; OnPcChanged?.Invoke(this, actorRes.CurrentPCs.ToDictionary(k => k.Key, k => k.Value as ActorItemBase)); } int jobsum1 = actorRes.CurrentPCs.Sum(e => (int)e.Value.Job); if (jobsum0 != jobsum1) { actors = actorRes; OnPcChanged?.Invoke(this, actorRes.CurrentPCs.ToDictionary(k => k.Key, k => k.Value as ActorItemBase)); } } else { actors = actorRes; OnPcChanged?.Invoke(this, actorRes.CurrentPCs.ToDictionary(k => k.Key, k => k.Value as ActorItemBase)); } } return(true); }