KF2-MSK-GS/MskGs/Classes/MSKGS_RepInfo.uc

123 lines
2.2 KiB
Ucode
Raw Normal View History

2022-08-16 06:59:16 +00:00
class MSKGS_RepInfo extends ReplicationInfo;
2021-12-09 04:34:12 +00:00
2022-08-16 06:59:16 +00:00
const CfgXPBoost = class'CfgXPBoost';
2021-12-26 04:18:50 +00:00
2022-08-16 06:59:16 +00:00
var public E_LogLevel LogLevel;
var public MSKGS MSKGS;
var public UniqueNetId GroupID;
var public float CheckGroupTimer;
2021-12-09 04:34:12 +00:00
2022-08-16 06:59:16 +00:00
var private KFPlayerController KFPC;
var private OnlineSubsystem OS;
2021-12-09 04:34:12 +00:00
2022-08-16 06:59:16 +00:00
var public bool ServerOwner;
var private bool GroupMember;
replication
{
if (bNetInitial && Role == ROLE_Authority)
LogLevel, GroupID, CheckGroupTimer;
}
public simulated function bool SafeDestroy()
2021-12-09 04:34:12 +00:00
{
2022-08-16 06:59:16 +00:00
`Log_Trace();
2021-12-09 04:34:12 +00:00
2022-08-16 06:59:16 +00:00
return (bPendingDelete || bDeleteMe || Destroy());
}
public simulated event PreBeginPlay()
{
`Log_Trace();
2021-12-09 04:34:12 +00:00
if (Role < ROLE_Authority || WorldInfo.NetMode == NM_StandAlone)
{
2022-08-16 06:59:16 +00:00
OS = class'GameEngine'.static.GetOnlineSubsystem();
if (OS != None)
{
CheckGroupMembership();
}
else
{
`Log_Error("Can't get online subsystem!");
}
2021-12-09 04:34:12 +00:00
}
2022-08-16 06:59:16 +00:00
Super.PreBeginPlay();
2021-12-09 04:34:12 +00:00
}
2022-08-16 06:59:16 +00:00
public simulated event PostBeginPlay()
2021-12-09 04:34:12 +00:00
{
2022-08-16 06:59:16 +00:00
`Log_Trace();
2021-12-09 04:34:12 +00:00
2022-08-16 06:59:16 +00:00
if (bPendingDelete || bDeleteMe) return;
Super.PostBeginPlay();
}
private simulated function CheckGroupMembership()
{
if (OS.CheckPlayerGroup(GroupID))
2021-12-09 04:34:12 +00:00
{
2022-08-16 06:59:16 +00:00
ClearTimer(nameof(CheckGroupMembership));
ServerApplyMembership();
2021-12-09 04:34:12 +00:00
}
2022-08-16 06:59:16 +00:00
else if (CheckGroupTimer > 0.0f && !IsTimerActive(nameof(CheckGroupMembership)))
2021-12-09 04:34:12 +00:00
{
2022-08-16 06:59:16 +00:00
SetTimer(CheckGroupTimer, true, nameof(CheckGroupMembership));
2021-12-09 04:34:12 +00:00
}
}
2022-08-16 06:59:16 +00:00
private reliable server function ServerApplyMembership()
2021-12-09 04:34:12 +00:00
{
2022-08-16 06:59:16 +00:00
GroupMember = true;
MSKGS.IncreaseXPBoost(GetKFPC());
2021-12-09 04:34:12 +00:00
}
2022-08-16 06:59:16 +00:00
public function int XPBoost()
2021-12-09 04:34:12 +00:00
{
2022-08-16 06:59:16 +00:00
`Log_Trace();
if (ServerOwner)
2021-12-09 04:34:12 +00:00
{
2022-08-16 06:59:16 +00:00
return CfgXPBoost.default.BoostOwner;
2021-12-09 04:34:12 +00:00
}
2022-08-16 06:59:16 +00:00
if (GetKFPC() != None && GetKFPC().PlayerReplicationInfo != None && GetKFPC().PlayerReplicationInfo.bAdmin)
{
return CfgXPBoost.default.BoostAdmin;
}
if (GroupMember)
{
return CfgXPBoost.default.BoostGroup;
}
return CfgXPBoost.default.BoostPlayer;
}
private simulated function KFPlayerController GetKFPC()
{
`Log_Trace();
if (KFPC != None) return KFPC;
KFPC = KFPlayerController(Owner);
if (KFPC == None && ROLE < ROLE_Authority)
{
KFPC = KFPlayerController(GetALocalPlayerController());
}
2021-12-26 04:18:50 +00:00
2022-08-16 06:59:16 +00:00
return KFPC;
2021-12-09 04:34:12 +00:00
}
2022-08-16 06:59:16 +00:00
defaultproperties
2021-12-09 04:34:12 +00:00
{
2022-08-16 06:59:16 +00:00
bAlwaysRelevant = false
bOnlyRelevantToOwner = true
bSkipActorPropertyReplication = false
2021-12-26 04:18:50 +00:00
2022-08-16 06:59:16 +00:00
GroupMember = false;
ServerOwner = false;
2021-12-09 04:34:12 +00:00
}