// Token: 0x060019C5 RID: 6597 RVA: 0x0007B1FC File Offset: 0x000793FC
        public static bool Save([NotNull] RunReport runReport, [NotNull] string fileName)
        {
            string text = RunReport.FileNameToPath(fileName);
            bool   result;

            try
            {
                if (!Directory.Exists(RunReport.runReportsFolder))
                {
                    Directory.CreateDirectory(RunReport.runReportsFolder);
                }
                XDocument xdocument = new XDocument();
                xdocument.Add(HGXml.ToXml <RunReport>("RunReport", runReport));
                xdocument.Save(text);
                result = true;
            }
            catch (Exception ex)
            {
                Debug.LogFormat("Could not save RunReport {0}: {1}", new object[]
                {
                    text,
                    ex.Message
                });
                result = false;
            }
            return(result);
        }
Exemplo n.º 2
0
        // Token: 0x06001786 RID: 6022 RVA: 0x0006F750 File Offset: 0x0006D950
        protected void ClientSubmitLeaderboardScore(RunReport runReport)
        {
            if (runReport.gameResultType != GameResultType.Won)
            {
                return;
            }
            bool flag = false;

            using (IEnumerator <NetworkUser> enumerator = NetworkUser.readOnlyLocalPlayersList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current.isParticipating)
                    {
                        flag = true;
                        break;
                    }
                }
            }
            if (!flag)
            {
                return;
            }
            int num = PlayerCharacterMasterController.instances.Count;

            if (num <= 0)
            {
                return;
            }
            if (num >= 3)
            {
                if (num > 4)
                {
                    return;
                }
                num = 4;
            }
            string name = WeeklyRun.GetLeaderboardName(num, this.serverSeedCycle);

            int[]      subScores  = new int[64];
            GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(NetworkUser.readOnlyLocalPlayersList[0].bodyIndexPreference);

            if (!bodyPrefab)
            {
                return;
            }
            SurvivorDef survivorDef = SurvivorCatalog.FindSurvivorDefFromBody(bodyPrefab);

            if (survivorDef == null)
            {
                return;
            }
            subScores[1] = (int)survivorDef.survivorIndex;
            Leaderboard leaderboard = Client.Instance.GetLeaderboard(name, Client.LeaderboardSortMethod.Ascending, Client.LeaderboardDisplayType.TimeMilliSeconds);

            leaderboard.OnBoardInformation = delegate()
            {
                leaderboard.AddScore(true, (int)Math.Ceiling((double)runReport.snapshotTime.t * 1000.0), subScores);
            };
        }
        public static RunReport Load([NotNull] string fileName)
        {
            string    text = RunReport.FileNameToPath(fileName);
            RunReport result;

            try
            {
                XElement xelement = XDocument.Load(text).Element("RunReport");
                if (xelement == null)
                {
                    Debug.LogFormat("Could not load RunReport {0}: {1}", new object[]
                    {
                        text,
                        "File is malformed."
                    });
                    result = null;
                }
                else
                {
                    RunReport runReport = new RunReport();
                    RunReport.FromXml(xelement, ref runReport);
                    result = runReport;
                }
            }
            catch (Exception ex)
            {
                Debug.LogFormat("Could not load RunReport {0}: {1}", new object[]
                {
                    text,
                    ex.Message
                });
                result = null;
            }
            return(result);
        }
        // Token: 0x060019C1 RID: 6593 RVA: 0x0007AF98 File Offset: 0x00079198
        public static bool FromXml(XElement element, ref RunReport runReport)
        {
            string   text     = "NO_VERSION";
            XElement xelement = element.Element("version");

            if (xelement != null)
            {
                xelement.Deserialize(ref text);
            }
            if (text != "2" && !(text == "1"))
            {
                Debug.LogFormat("Could not load RunReport with non-upgradeable version \"{0}\".", new object[]
                {
                    text
                });
                runReport = null;
                return(false);
            }
            string   gameModeName = runReport.gameModeName;
            XElement xelement2    = element.Element("gameModeName");

            if (xelement2 != null)
            {
                xelement2.Deserialize(ref gameModeName);
            }
            runReport.gameModeName = gameModeName;
            XElement xelement3 = element.Element("gameResultType");

            if (xelement3 != null)
            {
                xelement3.Deserialize(ref runReport.gameResultType);
            }
            XElement xelement4 = element.Element("seed");

            if (xelement4 != null)
            {
                xelement4.Deserialize(ref runReport.seed);
            }
            XElement xelement5 = element.Element("snapshotTime");

            if (xelement5 != null)
            {
                xelement5.Deserialize(ref runReport.snapshotTime);
            }
            XElement xelement6 = element.Element("ruleBook");

            if (xelement6 != null)
            {
                xelement6.Deserialize(ref runReport.ruleBook);
            }
            XElement xelement7 = element.Element("playerInfos");

            if (xelement7 != null)
            {
                xelement7.Deserialize(ref runReport.playerInfos);
            }
            return(true);
        }
        // Token: 0x060019C6 RID: 6598 RVA: 0x0007B27C File Offset: 0x0007947C
        public static void TestSerialization(RunReport runReport)
        {
            NetworkWriter networkWriter = new NetworkWriter();

            runReport.Write(networkWriter);
            NetworkReader reader = new NetworkReader(networkWriter.AsArray());

            new RunReport().Read(reader);
        }
Exemplo n.º 6
0
 public void SetRunReport([NotNull] RunReport newRunReport)
 {
     if (!NetworkServer.active)
     {
         Debug.LogWarning("[Server] function 'System.Void RoR2.GameOverController::SetRunReport(RoR2.RunReport)' called on client");
         return;
     }
     base.SetDirtyBit(1u);
     this.runReport = newRunReport;
 }
 // Token: 0x060019C0 RID: 6592 RVA: 0x0007AEEC File Offset: 0x000790EC
 public static void ToXml(XElement element, RunReport runReport)
 {
     element.RemoveAll();
     element.Add(HGXml.ToXml <string>("version", "2"));
     element.Add(HGXml.ToXml <string>("gameModeName", runReport.gameModeName));
     element.Add(HGXml.ToXml <GameResultType>("gameResultType", runReport.gameResultType));
     element.Add(HGXml.ToXml <ulong>("seed", runReport.seed));
     element.Add(HGXml.ToXml <Run.FixedTimeStamp>("snapshotTime", runReport.snapshotTime));
     element.Add(HGXml.ToXml <RuleBook>("ruleBook", runReport.ruleBook));
     element.Add(HGXml.ToXml <RunReport.PlayerInfo[]>("playerInfos", runReport.playerInfos));
 }
        // Token: 0x060019BC RID: 6588 RVA: 0x0007ACE4 File Offset: 0x00078EE4
        public static RunReport Generate([NotNull] Run run, GameResultType resultType)
        {
            RunReport runReport = new RunReport();

            runReport.gameModeIndex  = GameModeCatalog.FindGameModeIndex(run.gameObject.name);
            runReport.seed           = run.seed;
            runReport.snapshotTime   = Run.FixedTimeStamp.now;
            runReport.gameResultType = resultType;
            runReport.ruleBook.Copy(run.ruleBook);
            runReport.playerInfos = new RunReport.PlayerInfo[PlayerCharacterMasterController.instances.Count];
            for (int i = 0; i < runReport.playerInfos.Length; i++)
            {
                runReport.playerInfos[i] = RunReport.PlayerInfo.Generate(PlayerCharacterMasterController.instances[i]);
            }
            runReport.ResolveLocalInformation();
            return(runReport);
        }
Exemplo n.º 9
0
 // Token: 0x0600177E RID: 6014 RVA: 0x0006F4AD File Offset: 0x0006D6AD
 public override void OnClientGameOver(RunReport runReport)
 {
     base.OnClientGameOver(runReport);
     this.ClientSubmitLeaderboardScore(runReport);
 }
Exemplo n.º 10
0
 private void EndRaveDeath(On.RoR2.GameOverController.orig_SetRunReport orig, RoR2.GameOverController self, RoR2.RunReport newRunReport)
 {
     EndRave();
     orig(self, newRunReport);
 }