private bool onShowSuppressedAddXP(RewardEvents.ShowSuppressedAddXP evt) { if (suppressedXP.Count > 0) { RewardEvents.AddXP evt2 = (RewardEvents.AddXP)suppressedXP.Dequeue(); evt2.ShowReward = true; onAddXP(evt2); } return(false); }
private bool onAddXP(RewardEvents.AddXP evt) { if (!evt.ShowReward) { suppressedXP.Enqueue(evt); } else { switch (state) { case XPHudState.closed: currentMascotName = evt.MascotName; if (!Service.Get <ProgressionService>().IsMascotMaxLevel(currentMascotName, evt.PreviousLevel)) { Mascot mascot = Service.Get <MascotService>().GetMascot(currentMascotName); if (mascot != null) { Service.Get <EventDispatcher>().DispatchEvent(new PlayerScoreEvents.ShowPlayerScore(dataEntityCollection.LocalPlayerSessionId, $"+{evt.XPAdded}", PlayerScoreEvents.ParticleType.XP, mascot.Definition.XPTintColor)); } CoroutineRunner.Start(loadXPHudPrefab(mascotXPContentKey, evt.MascotName), this, "XPHud.loadXPHudPrefab"); currentMascotLevel = evt.PreviousLevel; targetMacotLevel = evt.CurrentLevel; state = XPHudState.opening; } break; case XPHudState.opening: case XPHudState.addingXP: if (currentMascotName == evt.MascotName) { targetMacotLevel = Math.Max(targetMacotLevel, evt.CurrentLevel); } else { pendingXP.Enqueue(evt); } break; case XPHudState.waitingToClose: if (currentMascotName == evt.MascotName) { CancelInvoke(); targetMacotLevel = Math.Max(targetMacotLevel, evt.CurrentLevel); CoroutineRunner.Start(updateXpDisplay(), this, "updateXpDisplay"); } else { pendingXP.Enqueue(evt); } break; case XPHudState.closing: pendingXP.Enqueue(evt); break; } if (ProgressionService.GetMascotLevelFromXP(targetMacotLevel) != ProgressionService.GetMascotLevelFromXP(currentMascotLevel)) { disableUI(); } } return(false); }