KF2-YetAnotherScoreboard/ScoreboardExt/Classes/ScoreboardExtRepInfo.uc

174 lines
4.0 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-05-31 04:04:26 +00:00
var public string SystemAdminRank;
2021-06-08 23:22:35 +00:00
var public ColorRGBA SystemAdminColor;
2021-05-31 04:04:26 +00:00
var public Fields SystemAdminApplyColorToFields;
2021-05-31 01:46:53 +00:00
2021-05-31 04:04:26 +00:00
var public string SystemPlayerRank;
2021-06-08 23:22:35 +00:00
var public ColorRGBA SystemPlayerColor;
2021-05-31 04:04:26 +00:00
var public Fields SystemPlayerApplyColorToFields;
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();
ClientInitSystem(
SystemAdminRank,
SystemAdminColor,
SystemAdminApplyColorToFields,
SystemPlayerRank,
SystemPlayerColor,
SystemPlayerApplyColorToFields);
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 21:21:28 +00:00
private reliable client function ClientInitSystem(
2021-05-31 01:46:53 +00:00
string _SystemAdminRank,
2021-06-08 23:22:35 +00:00
ColorRGBA _SystemAdminColor,
2021-05-31 01:46:53 +00:00
Fields _SystemAdminApplyColorToFields,
string _SystemPlayerRank,
2021-06-08 23:22:35 +00:00
ColorRGBA _SystemPlayerColor,
2021-05-31 01:46:53 +00:00
Fields _SystemPlayerApplyColorToFields)
{
SystemAdminRank = _SystemAdminRank;
SystemAdminColor = _SystemAdminColor;
SystemAdminApplyColorToFields = _SystemAdminApplyColorToFields;
SystemPlayerRank = _SystemPlayerRank;
SystemPlayerColor = _SystemPlayerColor;
SystemPlayerApplyColorToFields = _SystemPlayerApplyColorToFields;
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;
}
SC.SystemAdminRank = SystemAdminRank;
SC.SystemAdminColor = SystemAdminColor;
SC.SystemAdminApplyColorToFields = SystemAdminApplyColorToFields;
SC.SystemPlayerRank = SystemPlayerRank;
SC.SystemPlayerColor = SystemPlayerColor;
SC.SystemPlayerApplyColorToFields = SystemPlayerApplyColorToFields;
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
}