KF2-YetAnotherScoreboard/ScoreboardExt/Classes/ScoreboardExtRepInfo.uc

148 lines
2.8 KiB
Ucode
Raw Normal View History

2021-05-31 01:46:53 +00:00
class ScoreboardExtRepInfo extends ReplicationInfo;
2021-06-08 21:48:03 +00:00
var public array<UIDRankRelation> PlayerRankRelations;
var public array<RankInfo> CustomRanks;
2021-05-31 01:46:53 +00:00
2021-06-08 23:43:00 +00:00
var public SCESettings Settings;
var public SCEStyle Style;
2021-05-31 01:46:53 +00:00
2021-06-08 21:21:28 +00:00
var private bool InitFinished, RanksFinished, InfosFinished;
var private int InfosReplicateProgress, RanksReplicateProgress;
2021-05-31 04:04:26 +00:00
var private KFScoreBoard SC;
2021-06-08 21:21:28 +00:00
public function ClientStartReplication()
2021-05-31 04:04:26 +00:00
{
GetScoreboard();
2021-06-08 23:43:00 +00:00
ClientInit(Settings, Style);
2021-06-08 21:21:28 +00:00
SetTimer(0.01f, true, nameof(ClientReplicateRanks));
2021-05-31 04:04:26 +00:00
SetTimer(0.01f, true, nameof(ClientReplicateInfos));
}
2021-06-08 21:21:28 +00:00
public function ClientReplicateRanks()
2021-05-31 04:04:26 +00:00
{
2021-06-08 21:48:03 +00:00
if (RanksReplicateProgress < CustomRanks.Length)
2021-05-31 04:04:26 +00:00
{
2021-06-08 21:48:03 +00:00
ClientAddPlayerRank(CustomRanks[RanksReplicateProgress]);
2021-06-08 21:21:28 +00:00
++RanksReplicateProgress;
2021-05-31 04:04:26 +00:00
}
else
{
2021-06-08 21:21:28 +00:00
ClearTimer(nameof(ClientReplicateRanks));
RankReplicationFinished();
2021-05-31 04:04:26 +00:00
}
}
2021-06-08 21:21:28 +00:00
public function ClientReplicateInfos()
2021-05-31 04:04:26 +00:00
{
2021-06-08 21:48:03 +00:00
if (InfosReplicateProgress < PlayerRankRelations.Length)
2021-05-31 04:04:26 +00:00
{
2021-06-08 21:48:03 +00:00
ClientAddPlayerInfo(PlayerRankRelations[InfosReplicateProgress]);
2021-05-31 04:04:26 +00:00
++InfosReplicateProgress;
}
else
{
ClearTimer(nameof(ClientReplicateInfos));
InfosReplicationFinished();
}
}
2021-06-08 21:21:28 +00:00
private reliable client function GetScoreboard()
2021-05-31 04:04:26 +00:00
{
if (SC != None)
{
ClearTimer(nameof(GetScoreboard));
return;
}
SC = ScoreboardExtHUD(GetALocalPlayerController().myHUD).Scoreboard;
SetTimer(0.1f, false, nameof(GetScoreboard));
}
2021-06-08 21:21:28 +00:00
private reliable client function ClientAddPlayerRank(RankInfo Rank)
2021-05-31 04:04:26 +00:00
{
2021-06-08 21:48:03 +00:00
CustomRanks.AddItem(Rank);
2021-05-31 04:04:26 +00:00
}
2021-06-08 21:21:28 +00:00
private reliable client function ClientAddPlayerInfo(UIDRankRelation PlayerInfo)
2021-05-31 04:04:26 +00:00
{
2021-06-08 21:48:03 +00:00
PlayerRankRelations.AddItem(PlayerInfo);
2021-05-31 04:04:26 +00:00
}
2021-06-08 21:21:28 +00:00
private reliable client function RankReplicationFinished()
2021-05-31 04:04:26 +00:00
{
2021-06-08 21:21:28 +00:00
RanksFinished = true;
ClientRanksApply();
2021-05-31 04:04:26 +00:00
}
2021-06-08 21:21:28 +00:00
private reliable client function InfosReplicationFinished()
2021-05-31 04:04:26 +00:00
{
InfosFinished = true;
ClientInfosApply();
}
2021-06-08 23:43:00 +00:00
private reliable client function ClientInit(SCESettings _Settings, SCEStyle _Style)
2021-05-31 01:46:53 +00:00
{
2021-06-08 23:43:00 +00:00
Settings = _Settings;
Style = _Style;
2021-05-31 01:46:53 +00:00
2021-05-31 04:04:26 +00:00
ClientSystemApply();
2021-05-31 01:46:53 +00:00
}
2021-06-08 21:21:28 +00:00
private reliable client function ClientSystemApply()
2021-05-31 01:46:53 +00:00
{
if (SC == None)
{
2021-05-31 04:04:26 +00:00
SetTimer(0.1f, false, nameof(ClientSystemApply));
2021-05-31 01:46:53 +00:00
return;
}
2021-06-08 23:43:00 +00:00
SC.Settings = Settings;
SC.Style = Style;
2021-05-31 01:46:53 +00:00
2021-06-08 21:21:28 +00:00
InitFinished = true;
2021-05-31 04:04:26 +00:00
Finished();
}
2021-06-08 21:21:28 +00:00
private reliable client function ClientRanksApply()
2021-05-31 04:04:26 +00:00
{
if (SC == None)
{
2021-06-08 21:21:28 +00:00
SetTimer(0.1f, false, nameof(ClientRanksApply));
2021-05-31 04:04:26 +00:00
return;
}
2021-06-08 21:48:03 +00:00
SC.CustomRanks = CustomRanks;
2021-06-08 21:21:28 +00:00
RanksFinished = true;
2021-05-31 04:04:26 +00:00
Finished();
}
2021-06-08 21:21:28 +00:00
private reliable client function ClientInfosApply()
2021-05-31 04:04:26 +00:00
{
if (SC == None)
{
SetTimer(0.1f, false, nameof(ClientInfosApply));
return;
}
2021-06-08 21:48:03 +00:00
SC.PlayerRankRelations = PlayerRankRelations;
2021-06-08 21:21:28 +00:00
RanksFinished = true;
2021-05-31 04:04:26 +00:00
Finished();
}
2021-06-08 21:21:28 +00:00
private reliable client function Finished()
2021-05-31 04:04:26 +00:00
{
2021-06-08 21:21:28 +00:00
if (InitFinished && RanksFinished && InfosFinished)
2021-05-31 04:04:26 +00:00
Destroy();
2021-05-31 01:46:53 +00:00
}
defaultproperties
{
2021-05-31 04:04:26 +00:00
InfosReplicateProgress=0
2021-06-08 21:21:28 +00:00
RanksReplicateProgress=0
2021-05-31 01:46:53 +00:00
2021-06-08 21:21:28 +00:00
InitFinished=false
RanksFinished=false
2021-05-31 04:04:26 +00:00
InfosFinished=false
2021-05-31 01:46:53 +00:00
}