public virtual WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo) { if (beatmapInfo?.BeatmapSet == null) { return(DefaultBeatmap); } lock (workingCache) { var working = workingCache.FirstOrDefault(w => beatmapInfo.Equals(w.BeatmapInfo)); if (working != null) { return(working); } beatmapInfo = beatmapInfo.Detach(); workingCache.Add(working = new BeatmapManagerWorkingBeatmap(beatmapInfo, this)); // best effort; may be higher than expected. GlobalStatistics.Get <int>("Beatmaps", $"Cached {nameof(WorkingBeatmap)}s").Value = workingCache.Count(); return(working); } }
public void OnPlayerListChangeTest() { var gs = new GlobalStatistics(); gs.Config = new ScriptConfig() { ConfigFields = new ConfigFieldList() { { "token", "Token", "Server authentication token", FieldType.Text, "0695da663534558c209f052ac2af4112", true }, }, }; var startPacket = Data.GetTestMissionEvent(Data.testLines[EventType.MissionStart]); gs.OnPlayerListChange(((MissionLogEventHeader)startPacket).Server, new List <Player>() { new Player() { NickId = Guid.NewGuid(), Country = new Country(101) { Name = "Russia" }, Ping = 100, } }); }
private void load() { Children = new[] { display = new GlobalStatisticsDisplay(), }; display.ToggleVisibility(); GlobalStatistic <double> stat = null; AddStep("Register test statistic", () => stat = GlobalStatistics.Get <double>("TestCase", "Test Statistic")); AddStep("Change value once", () => stat.Value = 10); AddStep("Change value again", () => stat.Value = 20); AddStep("Register statistics non-alphabetically", () => { GlobalStatistics.Get <int>("ZZZZZ", "BBBBB"); GlobalStatistics.Get <int>("ZZZZZ", "AAAAA"); }); AddStep("Register groups non-alphabetically", () => { GlobalStatistics.Get <int>("XXXXX", "BBBBB"); GlobalStatistics.Get <int>("TTTTT", "AAAAA"); }); }
public virtual WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo) { // if there are no files, presume the full beatmap info has not yet been fetched from the database. if (beatmapInfo?.BeatmapSet?.Files.Count == 0) { int lookupId = beatmapInfo.ID; beatmapInfo = BeatmapManager.QueryBeatmap(b => b.ID == lookupId); } if (beatmapInfo?.BeatmapSet == null) { return(DefaultBeatmap); } lock (workingCache) { var working = workingCache.FirstOrDefault(w => beatmapInfo.Equals(w.BeatmapInfo)); if (working != null) { return(working); } beatmapInfo.Metadata ??= beatmapInfo.BeatmapSet.Metadata; workingCache.Add(working = new BeatmapManagerWorkingBeatmap(beatmapInfo, this)); // best effort; may be higher than expected. GlobalStatistics.Get <int>(nameof(Beatmaps), $"Cached {nameof(WorkingBeatmap)}s").Value = workingCache.Count(); return(working); } }
private void Initialize() { CurrentState = State.Idle; _avatarCtrl = AvatarController.GetInstance(); _avatar = _avatarCtrl.Avatar; _avatar.OnSuccsefulEating += () => { Score += 1; }; _avatar.OnDeath += DeathHandler; _buildCtrl = BuildController.GetInstance(); _buildCtrl.SetMeteorController(); _taskCtrl = TaskController.GetInstance(); _taskCtrl.Avatar = _avatar; _taskCtrl.TaskCompleted += (ITask x) => Debug.Log(x); DuringDistanceTask.Avatar = _avatar.transform; _pursuitCtrl = PursuitController.GetInstance(); _pursuitCtrl.AvatarTf = _avatar.transform; _pursuitCtrl.Catched += CatchedHandler; _idGen = new IDGenerator(); _stuff = new SortedDictionary <int, GameObject>(); _mainProvider = new MultiGeneratorProvider(_stuff, _pursuitCtrl, _idGen); _mainProvider.SetIDGenerator(_idGen); _firstCarPos = new Vector2(0, 1); _firstCarDesc = new CarDescriptor(_firstCarPos, 0, 1); _playStats = new PlayStatistics(); _globStats = GlobalStatistics.GetInstance(); // Vehicle.Avatar = _avatar; ProjectileGun.SetAvatar(_avatar); _isInitialized = true; }
private void visibilityChanged(ValueChangedEvent <Visibility> state) { performanceLogging.Value = state.NewValue == Visibility.Visible; if (state.NewValue == Visibility.Visible) { GlobalStatistics.OutputToLog(); } }
public GlobalStatisticsDataScript(GlobalStatistics stats) { this.timePassed = stats.timePassed; this.enemiesKilled = stats.enemiesKilled; this.doubleKills = stats.doubleKills; this.fireDamageDealt = stats.fireDamageDealt; this.poisonDamageDealt = stats.poisonDamageDealt; this.bleedDamageDealt = stats.bleedDamageDealt; this.playerDeaths = stats.playerDeaths; }
/// <summary> /// Create a new pool instance. /// </summary> /// <param name="initialSize">The number of drawables to be prepared for initial consumption.</param> /// <param name="maximumSize">An optional maximum size after which the pool will no longer be expanded.</param> public DrawablePool(int initialSize, int?maximumSize = null) { this.maximumSize = maximumSize; this.initialSize = initialSize; int id = Interlocked.Increment(ref poolInstanceID); statistic = GlobalStatistics.Get <DrawablePoolUsageStatistic>(nameof(DrawablePool <T>), typeof(T).ReadableName() + $"`{id}"); statistic.Value = new DrawablePoolUsageStatistic(); }
protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); CountInUse = 0; CountConstructed = 0; CountAvailable = 0; GlobalStatistics.Remove(statistic); // Disallow any further Gets/Returns to adjust the statistics. statistic = null; }
private void visibilityChanged(ValueChangedEvent <Visibility> state) { performanceLogging.Value = state.NewValue == Visibility.Visible; if (state.NewValue == Visibility.Visible) { GlobalStatistics.OutputToLog(); listener = new DotNetRuntimeListener(); } else { listener?.Dispose(); } }
private void TurnOnHandler() { for (_curIndx = 0; _curIndx < _skins.Length; ++_curIndx) { if (_mv.Current.gameObject == _skins[_curIndx].Skin) { break; } } _current = _skins[_curIndx]; SetState(); Screen.Rect.transform.Find("Score").GetComponent <Text>().text = GlobalStatistics.GetInstance().Score.ToString(); }
public static void WriteReport(string path, GlobalStatistics globalStatistics, ImmutableArray <FileStatistics> fileStatistics) { var workbook = new XSSFWorkbook(); WriteGlobalStatistics(workbook, globalStatistics, fileStatistics.Length); fileStatistics = fileStatistics.Sort((a, b) => a.FileName.CompareTo(b.FileName)); WriteBasicFileStatistics(workbook, fileStatistics); WriteTokenFileStatistics(workbook, fileStatistics); WriteFeatureStatistics(workbook, fileStatistics); using var stream = File.Create(path); workbook.Write(stream); }
private void MapStateToProps(AppState state, WorldCasesChartProps props) { var stats = state?.Global; if (stats is null) { stats = new GlobalStatistics(); } _chartDataSet.Data.Clear(); _chartDataSet.Data.AddRange(new double[] { stats.Active, stats.Deaths, stats.Recovered }); var total = stats.Cases; props.States = new[]
public static bool Buy(ProgressData.DataType type, string name, int cost) { if (type != Skin && type != Task) { throw new ArgumentException(); } var gs = GlobalStatistics.GetInstance(); if (gs.Score < cost) { return(false); } gs.Score -= cost; ProgressData.GetInstance()[type, name] = true; return(true); }
private void MapStateToProps(AppState state, WorldStatisticsProps props) { var stats = state?.Global; if (stats is null) { stats = new GlobalStatistics(); } props.Cases = stats.Cases; props.Deaths = stats.Deaths; props.Recovered = stats.Recovered; props.Active = stats.Active; props.Critical = stats.Critical; props.Updated = stats.UpdatedDate; }
public void OpenMissionReportTest() { var parser = new LogParser(); parser.OpenMissionReport(); var globalstat = new GlobalStatistics(); globalstat.Config = globalstat.DefaultConfig; globalstat.Config.ConfigFields.Set("token", "0695da663534558c209f052ac2af4112"); foreach (var item in parser.History) { globalstat.AddToQueue(item); } Assert.IsTrue(true); }
/// <summary> /// Retrieve a <see cref="WorkingBeatmap"/> instance for the provided <see cref="BeatmapInfo"/> /// </summary> /// <param name="beatmapInfo">The beatmap to lookup.</param> /// <param name="previous">The currently loaded <see cref="WorkingBeatmap"/>. Allows for optimisation where elements are shared with the new beatmap. May be returned if beatmapInfo requested matches</param> /// <returns>A <see cref="WorkingBeatmap"/> instance correlating to the provided <see cref="BeatmapInfo"/>.</returns> public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null) { if (beatmapInfo?.ID > 0 && previous != null && previous.BeatmapInfo?.ID == beatmapInfo.ID) { return(previous); } if (beatmapInfo?.BeatmapSet == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo) { return(DefaultBeatmap); } if (beatmapInfo.BeatmapSet.Files == null) { var info = beatmapInfo; beatmapInfo = QueryBeatmap(b => b.ID == info.ID); } if (beatmapInfo == null) { return(DefaultBeatmap); } lock (workingCache) { var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == beatmapInfo.ID); if (working != null) { return(working); } beatmapInfo.Metadata ??= beatmapInfo.BeatmapSet.Metadata; workingCache.Add(working = new BeatmapManagerWorkingBeatmap(beatmapInfo, this)); // best effort; may be higher than expected. GlobalStatistics.Get <int>(nameof(Beatmaps), $"Cached {nameof(WorkingBeatmap)}s").Value = workingCache.Count(); return(working); } }
public void TestUpdateStats() { GlobalStatistic <double> stat = null; AddStep("Register test statistic", () => stat = GlobalStatistics.Get <double>("TestCase", "Test Statistic")); AddStep("Change value once", () => stat.Value = 10); AddStep("Change value again", () => stat.Value = 20); AddStep("Register statistics non-alphabetically", () => { GlobalStatistics.Get <int>("ZZZZZ", "BBBBB"); GlobalStatistics.Get <int>("ZZZZZ", "AAAAA"); }); AddStep("Register groups non-alphabetically", () => { GlobalStatistics.Get <int>("XXXXX", "BBBBB"); GlobalStatistics.Get <int>("TTTTT", "AAAAA"); }); }
protected override void LoadComplete() { base.LoadComplete(); GlobalStatistics.StatisticsChanged += (_, e) => { switch (e.Action) { case NotifyCollectionChangedAction.Add: add(e.NewItems.Cast <IGlobalStatistic>()); break; case NotifyCollectionChangedAction.Remove: remove(e.OldItems.Cast <IGlobalStatistic>()); break; } }; add(GlobalStatistics.GetStatistics()); State.BindValueChanged(visibilityChanged, true); }
public void SendDataToServerTest() { var gs = new GlobalStatistics(); gs.Config = new ScriptConfig() { ConfigFields = new ConfigFieldList() { { "token", "Token", "Server authentication token", FieldType.Text, "0695da663534558c209f052ac2af4112", true }, }, }; var startPacket = Data.GetTestMissionEvent(Data.testLines[EventType.MissionStart]); gs.AddToQueue(new { Type = 9999, Server = ((MissionLogEventHeader)startPacket).Server }); gs.AddToQueue(startPacket); gs.AddToQueue(Data.GetTestMissionEvent(Data.testLines[EventType.Hit])); gs.AddToQueue(Data.GetTestMissionEvent(Data.testLines[EventType.Damage])); gs.AddToQueue(Data.GetTestMissionEvent(Data.testLines[EventType.Join])); gs.AddToQueue(Data.GetTestMissionEvent(Data.testLines[EventType.Kill])); gs.SendDataToServer(gs); }
private void Use() { switch (_state) { case State.Select: AppSettings.GetInstance().SetAvatar(_current.Skin.name); break; case State.Price: var b = LocalStore.Buy(Skin, _current.Skin.name, _current.Cost); if (b) { Screen.Rect.transform.Find("Score").GetComponent <Text>().text = GlobalStatistics.GetInstance().Score.ToString(); } else { //todo not enough } break; } SetState(); }
public static GlobalStatistics GetInstance() { return(_instance ?? (_instance = new GlobalStatistics())); }
private static GlobalStatistic <long> getStatistic(object source) => GlobalStatistics.Get <long>("Native", source.GetType().Name);
public UpdateGlobalData(GlobalStatistics data) { Data = data; }
private void Awake() { instance = this; }
private void processLogEntry(LogEntry entry) { if (entry.Level < LogLevel.Verbose) { return; } var exception = entry.Exception; if (exception != null) { if (!shouldSubmitException(exception)) { return; } // framework does some weird exception redirection which means sentry does not see unhandled exceptions using its automatic methods. // but all unhandled exceptions still arrive via this pathway. we just need to mark them as unhandled for tagging purposes. // easiest solution is to check the message matches what the framework logs this as. // see https://github.com/ppy/osu-framework/blob/f932f8df053f0011d755c95ad9a2ed61b94d136b/osu.Framework/Platform/GameHost.cs#L336 bool wasUnhandled = entry.Message == @"An unhandled error has occurred."; bool wasUnobserved = entry.Message == @"An unobserved error has occurred."; if (wasUnobserved) { // see https://github.com/getsentry/sentry-dotnet/blob/c6a660b1affc894441c63df2695a995701671744/src/Sentry/Integrations/TaskUnobservedTaskExceptionIntegration.cs#L39 exception.Data[Mechanism.MechanismKey] = @"UnobservedTaskException"; } if (wasUnhandled) { // see https://github.com/getsentry/sentry-dotnet/blob/main/src/Sentry/Integrations/AppDomainUnhandledExceptionIntegration.cs#L38-L39 exception.Data[Mechanism.MechanismKey] = @"AppDomain.UnhandledException"; } exception.Data[Mechanism.HandledKey] = !wasUnhandled; SentrySdk.CaptureEvent(new SentryEvent(exception) { Message = entry.Message, Level = getSentryLevel(entry.Level), }, scope => { var beatmap = game.Dependencies.Get <IBindable <WorkingBeatmap> >().Value.BeatmapInfo; var ruleset = game.Dependencies.Get <IBindable <RulesetInfo> >().Value; scope.Contexts[@"config"] = new { Game = game.Dependencies.Get <OsuConfigManager>().GetLoggableState() // TODO: add framework config here. needs some consideration on how to expose. }; game.Dependencies.Get <RealmAccess>().Run(realm => { scope.Contexts[@"realm"] = new { Counts = new { BeatmapSets = realm.All <BeatmapSetInfo>().Count(), Beatmaps = realm.All <BeatmapInfo>().Count(), Files = realm.All <RealmFile>().Count(), Rulesets = realm.All <RulesetInfo>().Count(), RulesetsAvailable = realm.All <RulesetInfo>().Count(r => r.Available), Skins = realm.All <SkinInfo>().Count(), } }; }); scope.Contexts[@"global statistics"] = GlobalStatistics.GetStatistics() .GroupBy(s => s.Group) .ToDictionary(g => g.Key, items => items.ToDictionary(i => i.Name, g => g.DisplayValue)); scope.Contexts[@"beatmap"] = new { Name = beatmap.ToString(), Ruleset = beatmap.Ruleset.InstantiationInfo, beatmap.OnlineID, }; scope.Contexts[@"ruleset"] = new { ruleset.ShortName, ruleset.Name, ruleset.InstantiationInfo, ruleset.OnlineID }; scope.Contexts[@"clocks"] = new { Audio = game.Dependencies.Get <MusicController>().CurrentTrack.CurrentTime, Game = game.Clock.CurrentTime, }; scope.SetTag(@"beatmap", $"{beatmap.OnlineID}"); scope.SetTag(@"ruleset", ruleset.ShortName); scope.SetTag(@"os", $"{RuntimeInfo.OS} ({Environment.OSVersion})"); scope.SetTag(@"processor count", Environment.ProcessorCount.ToString()); }); } else { SentrySdk.AddBreadcrumb(entry.Message, entry.Target.ToString(), "navigation", level: getBreadcrumbLevel(entry.Level)); } }