KF2-YetAnotherScoreboard/ScoreboardExt/Classes/ScoreboardExtRepInfo.uc

185 lines
3.6 KiB
Ucode
Raw Normal View History

2021-05-31 01:46:53 +00:00
class ScoreboardExtRepInfo extends ReplicationInfo;
2021-06-12 20:11:37 +00:00
`include(Build.uci)
`include(Logger.uci)
2021-06-12 18:44:20 +00:00
// Server vars
var public ScoreboardExtMut Mut;
// Client vars
var private KFScoreBoard SC;
var private OnlineSubsystemSteamworks SW;
2021-05-31 01:46:53 +00:00
2021-06-12 18:44:20 +00:00
// Fitst time replication
var public array<UIDRankRelation> SteamGroupRelations;
var public array<RankInfo> CustomRanks;
2021-06-08 23:43:00 +00:00
var public SCESettings Settings;
2021-06-12 18:44:20 +00:00
var public UIDRankRelation RankRelation; // Current player rank relation
2021-05-31 01:46:53 +00:00
2021-06-12 18:44:20 +00:00
var private int CustomRanksRepProgress, SteamGroupsRepProgress;
2021-05-31 04:04:26 +00:00
2021-06-12 18:44:20 +00:00
simulated event PostBeginPlay()
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
super.PostBeginPlay();
2021-05-31 04:04:26 +00:00
2021-06-12 18:44:20 +00:00
if (bDeleteMe) return;
if (Role < ROLE_Authority)
{
ClientInit();
}
}
private reliable client function ClientInit()
2021-05-31 04:04:26 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
if (SC == None)
SC = ScoreboardExtHUD(GetALocalPlayerController().myHUD).Scoreboard;
2021-05-31 04:04:26 +00:00
2021-06-12 18:44:20 +00:00
if (SW == None)
SW = OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem());
if (SC == None || SW == None)
SetTimer(0.1f, false, nameof(ClientInit));
else
ClearTimer(nameof(ClientInit));
}
public function StartFirstTimeReplication()
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
SetTimer(0.01f, true, nameof(ReplicateCustomRanks));
SetTimer(0.01f, true, nameof(ReplicateSteamGroupRelations));
}
private reliable client function ClientSetSettings(SCESettings Set)
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
SC.Settings = Set;
2021-05-31 04:04:26 +00:00
}
2021-06-12 18:44:20 +00:00
private function ReplicateCustomRanks()
2021-05-31 04:04:26 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
if (CustomRanksRepProgress < CustomRanks.Length)
2021-05-31 04:04:26 +00:00
{
2021-06-12 18:44:20 +00:00
ClientAddCustomRank(CustomRanks[CustomRanksRepProgress]);
++CustomRanksRepProgress;
2021-05-31 04:04:26 +00:00
}
else
{
2021-06-12 18:44:20 +00:00
ClearTimer(nameof(ReplicateCustomRanks));
2021-05-31 04:04:26 +00:00
}
}
2021-06-12 18:44:20 +00:00
private reliable client function ClientAddCustomRank(RankInfo Rank)
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
CustomRanks.AddItem(Rank);
}
private function ReplicateSteamGroupRelations()
2021-05-31 04:04:26 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
if (SteamGroupsRepProgress < SteamGroupRelations.Length)
2021-05-31 04:04:26 +00:00
{
2021-06-12 18:44:20 +00:00
ClientAddSteamGroupRelation(SteamGroupRelations[SteamGroupsRepProgress]);
++SteamGroupsRepProgress;
2021-05-31 04:04:26 +00:00
}
else
{
2021-06-12 18:44:20 +00:00
ClearTimer(nameof(ReplicateSteamGroupRelations));
if (RankRelation.RankID == INDEX_NONE)
FindMyRankInSteamGroups();
2021-05-31 04:04:26 +00:00
}
}
2021-06-12 18:44:20 +00:00
private reliable client function ClientAddSteamGroupRelation(UIDRankRelation Rel)
2021-05-31 04:04:26 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
SteamGroupRelations.AddItem(Rel);
2021-05-31 04:04:26 +00:00
}
2021-06-12 18:44:20 +00:00
private reliable client function FindMyRankInSteamGroups()
2021-05-31 04:04:26 +00:00
{
2021-06-12 18:44:20 +00:00
local UIDRankRelation SteamGroupRel;
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
foreach SteamGroupRelations(SteamGroupRel)
if (SW.CheckPlayerGroup(SteamGroupRel.UID))
RankRelation.RankID = SteamGroupRel.RankID;
if (RankRelation.RankID != INDEX_NONE)
ServerApplyRank(RankRelation.RankID);
2021-05-31 04:04:26 +00:00
}
2021-06-12 18:44:20 +00:00
private reliable server function ServerApplyRank(int RankID)
2021-05-31 04:04:26 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
RankRelation.RankID = RankID;
Mut.UpdatePlayerRank(RankRelation);
2021-05-31 04:04:26 +00:00
}
2021-06-12 18:44:20 +00:00
public function AddRankRelation(UIDRankRelation Rel)
2021-05-31 04:04:26 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
ClientAddRankRelation(Rel);
2021-05-31 04:04:26 +00:00
}
2021-06-12 18:44:20 +00:00
private reliable client function ClientAddRankRelation(UIDRankRelation Rel)
2021-05-31 04:04:26 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
SC.RankRelations.AddItem(Rel);
2021-05-31 04:04:26 +00:00
}
2021-06-12 18:44:20 +00:00
public function RemoveRankRelation(UIDRankRelation Rel)
2021-05-31 01:46:53 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
ClientRemoveRankRelation(Rel);
2021-05-31 01:46:53 +00:00
}
2021-06-12 18:44:20 +00:00
private unreliable client function ClientRemoveRankRelation(UIDRankRelation Rel)
2021-05-31 01:46:53 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
SC.RankRelations.RemoveItem(Rel);
2021-05-31 04:04:26 +00:00
}
2021-06-12 18:44:20 +00:00
public function UpdateRankRelation(UIDRankRelation Rel)
2021-05-31 04:04:26 +00:00
{
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
ClientUpdateRankRelation(Rel);
2021-05-31 04:04:26 +00:00
}
2021-06-12 18:44:20 +00:00
private reliable client function ClientUpdateRankRelation(UIDRankRelation Rel)
2021-05-31 04:04:26 +00:00
{
2021-06-12 18:44:20 +00:00
local int Index;
2021-05-31 04:04:26 +00:00
2021-06-12 20:11:37 +00:00
`callstack();
2021-06-12 18:44:20 +00:00
Index = SC.RankRelations.Find('UID', Rel.UID);
if (Index != INDEX_NONE)
SC.RankRelations[Index] = Rel;
2021-05-31 01:46:53 +00:00
}
defaultproperties
2021-06-12 18:44:20 +00:00
{
CustomRanksRepProgress = 0;
SteamGroupsRepProgress = 0;
2021-05-31 01:46:53 +00:00
}