|
Last change
on this file since 504 was 457, checked in by alloc, 2 years ago |
|
Refactored APIs GamePrefs, GameStats, ServerInfo: Using arrays as result instead of objects, code sharing
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | using JetBrains.Annotations;
|
|---|
| 2 | using Utf8Json;
|
|---|
| 3 |
|
|---|
| 4 | namespace Webserver.WebAPI.APIs.ServerState {
|
|---|
| 5 | [UsedImplicitly]
|
|---|
| 6 | public class GameStats : KeyValueListAbs {
|
|---|
| 7 | public GameStats () : base ("GameStats") {
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | protected override void iterateList (ref JsonWriter _writer, ref bool _first) {
|
|---|
| 11 | foreach (EnumGameStats stat in EnumUtils.Values<EnumGameStats> ()) {
|
|---|
| 12 | string name = stat.ToStringCached ();
|
|---|
| 13 | global::GameStats.EnumType? type = global::GameStats.GetStatType (stat);
|
|---|
| 14 |
|
|---|
| 15 | switch (type) {
|
|---|
| 16 | case global::GameStats.EnumType.Int:
|
|---|
| 17 | addItem (ref _writer, ref _first, name, global::GameStats.GetInt (stat));
|
|---|
| 18 | break;
|
|---|
| 19 | case global::GameStats.EnumType.Float:
|
|---|
| 20 | addItem (ref _writer, ref _first, name, global::GameStats.GetFloat (stat));
|
|---|
| 21 | break;
|
|---|
| 22 | case global::GameStats.EnumType.String:
|
|---|
| 23 | addItem (ref _writer, ref _first, name, global::GameStats.GetString (stat));
|
|---|
| 24 | break;
|
|---|
| 25 | case global::GameStats.EnumType.Bool:
|
|---|
| 26 | addItem (ref _writer, ref _first, name, global::GameStats.GetBool (stat));
|
|---|
| 27 | break;
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|
| 30 | }
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.