123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using System;
- namespace Pico.Platform.Models
- {
-
- public class Leaderboard
- {
-
- public readonly string ApiName;
-
- public readonly ulong ID;
-
- public readonly Destination DestinationOptional;
- public Leaderboard(IntPtr o)
- {
- ApiName = CLIB.ppf_Leaderboard_GetApiName(o);
- ID = CLIB.ppf_Leaderboard_GetID(o);
- var pointer = CLIB.ppf_Leaderboard_GetDestination(o);
- if (pointer == IntPtr.Zero)
- DestinationOptional = null;
- else
- DestinationOptional = new Destination(pointer);
- }
- }
-
- public class LeaderboardList : MessageArray<Leaderboard>
- {
-
- public readonly ulong TotalCount;
- public LeaderboardList(IntPtr a)
-
- {
- TotalCount = CLIB.ppf_LeaderboardArray_GetTotalCount(a);
- NextPageParam = CLIB.ppf_LeaderboardArray_HasNextPage(a) ? "true" : string.Empty;
- var count = (int) CLIB.ppf_LeaderboardArray_GetSize(a);
- this.Capacity = count;
- for (var i = 0; i < count; i++)
- {
- Add(new Leaderboard(CLIB.ppf_LeaderboardArray_GetElement(a, (UIntPtr) i)));
- }
- }
- }
-
- public class SupplementaryMetric
- {
-
- public readonly UInt64 ID;
-
- public readonly long Metric;
- public SupplementaryMetric(IntPtr o)
- {
- ID = CLIB.ppf_SupplementaryMetric_GetID(o);
- Metric = CLIB.ppf_SupplementaryMetric_GetMetric(o);
- }
- }
-
- public class LeaderboardEntry
- {
-
- public readonly string DisplayScore;
-
- public readonly byte[] ExtraData;
-
- public readonly UInt64 ID;
-
- public readonly int Rank;
-
- public readonly long Score;
-
- public readonly SupplementaryMetric SupplementaryMetricOptional;
-
- public readonly DateTime Timestamp;
-
- public readonly User User;
- public LeaderboardEntry(IntPtr o)
- {
- DisplayScore = CLIB.ppf_LeaderboardEntry_GetDisplayScore(o);
- var extraDataPtr = CLIB.ppf_LeaderboardEntry_GetExtraData(o);
- var extraDataSize = CLIB.ppf_LeaderboardEntry_GetExtraDataLength(o);
- ExtraData = MarshalUtil.ByteArrayFromNative(extraDataPtr, extraDataSize);
- ID = CLIB.ppf_LeaderboardEntry_GetID(o);
- Rank = CLIB.ppf_LeaderboardEntry_GetRank(o);
- Score = CLIB.ppf_LeaderboardEntry_GetScore(o);
- Timestamp = TimeUtil.SecondsToDateTime((long) CLIB.ppf_LeaderboardEntry_GetTimestamp(o));
- User = new User(CLIB.ppf_LeaderboardEntry_GetUser(o));
- {
- var pointer = CLIB.ppf_LeaderboardEntry_GetSupplementaryMetric(o);
- if (pointer == IntPtr.Zero)
- {
- SupplementaryMetricOptional = null;
- }
- else
- {
- SupplementaryMetricOptional = new SupplementaryMetric(pointer);
- }
- }
- }
- }
-
- public class LeaderboardEntryList : MessageArray<LeaderboardEntry>
- {
-
- public readonly ulong TotalCount;
- public LeaderboardEntryList(IntPtr a)
- {
- NextPageParam = CLIB.ppf_LeaderboardEntryArray_HasNextPage(a) ? "true" : string.Empty;
- PreviousPageParam = CLIB.ppf_LeaderboardEntryArray_HasPreviousPage(a) ? "true" : string.Empty;
- var count = (int) CLIB.ppf_LeaderboardEntryArray_GetSize(a);
- this.Capacity = count;
- for (uint i = 0; i < count; i++)
- {
- this.Add(new LeaderboardEntry(CLIB.ppf_LeaderboardEntryArray_GetElement(a, (UIntPtr) i)));
- }
- TotalCount = CLIB.ppf_LeaderboardEntryArray_GetTotalCount(a);
- }
- }
- }
|