2022-08-16 06:59:16 +00:00
|
|
|
class MSKGS_RepInfo extends ReplicationInfo;
|
2021-12-09 04:34:12 +00:00
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
const MSKGS_LMT = class'MSKGS_LocalMessage';
|
2021-12-26 04:18:50 +00:00
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
enum MSKGS_PlayerType
|
|
|
|
{
|
|
|
|
MSKGS_Unknown,
|
2022-08-17 07:53:13 +00:00
|
|
|
MSKGS_Player,
|
2022-08-16 23:07:11 +00:00
|
|
|
MSKGS_Group,
|
2022-08-17 07:53:13 +00:00
|
|
|
MSKGS_Admin,
|
|
|
|
MSKGS_Owner
|
2022-08-16 23:07:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var private IMSKGS MSKGS;
|
|
|
|
var private bool ServerOwner;
|
|
|
|
var private bool GroupMember;
|
2021-12-09 04:34:12 +00:00
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
var private repnotify E_LogLevel LogLevel;
|
|
|
|
var private repnotify UniqueNetId GroupID;
|
|
|
|
var private repnotify float CheckGroupTimer;
|
2021-12-09 04:34:12 +00:00
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
var private bool ObtainLogLevel;
|
|
|
|
var private bool ObtainGroupID;
|
|
|
|
var private bool ObtainCheckGroupTimer;
|
|
|
|
|
|
|
|
var private KFPlayerController KFPC;
|
|
|
|
var private OnlineSubsystemSteamworks OSS;
|
2022-08-16 06:59:16 +00:00
|
|
|
|
|
|
|
replication
|
|
|
|
{
|
2022-08-16 23:07:11 +00:00
|
|
|
if (bNetInitial)
|
|
|
|
LogLevel, GroupID, CheckGroupTimer, ServerOwner;
|
|
|
|
}
|
|
|
|
|
|
|
|
public simulated event ReplicatedEvent(name VarName)
|
|
|
|
{
|
|
|
|
`Log_Trace();
|
|
|
|
|
|
|
|
switch (VarName)
|
|
|
|
{
|
|
|
|
case 'LogLevel':
|
|
|
|
ObtainLogLevel = true;
|
|
|
|
CheckGroupMembership();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'GroupID':
|
|
|
|
ObtainGroupID = true;
|
|
|
|
CheckGroupMembership();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'CheckGroupTimer':
|
|
|
|
ObtainCheckGroupTimer = true;
|
|
|
|
CheckGroupMembership();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
super.ReplicatedEvent(VarName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Init(
|
|
|
|
E_LogLevel _LogLevel,
|
|
|
|
IMSKGS _MSKGS,
|
|
|
|
UniqueNetId _GroupID,
|
|
|
|
float _CheckGroupTimer,
|
|
|
|
bool _ServerOwner)
|
|
|
|
{
|
|
|
|
LogLevel = _LogLevel;
|
|
|
|
MSKGS = _MSKGS;
|
|
|
|
GroupID = _GroupID;
|
|
|
|
CheckGroupTimer = _CheckGroupTimer;
|
|
|
|
ServerOwner = _ServerOwner;
|
|
|
|
|
|
|
|
`Log_Trace();
|
2022-08-16 06:59:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
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()
|
|
|
|
{
|
2022-08-16 23:07:11 +00:00
|
|
|
`Log_Trace();
|
|
|
|
|
|
|
|
if (WorldInfo.NetMode == NM_StandAlone
|
|
|
|
|| (ObtainLogLevel && ObtainGroupID && ObtainCheckGroupTimer && Role < ROLE_Authority))
|
|
|
|
{
|
2022-08-17 07:53:13 +00:00
|
|
|
if (GetKFPC() != None && KFPC.bIsEosPlayer)
|
|
|
|
{
|
|
|
|
`Log_Debug("EGS Player, skip group check");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
if (OSS == None)
|
|
|
|
{
|
|
|
|
OSS = OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OSS != None)
|
|
|
|
{
|
|
|
|
if (OSS.CheckPlayerGroup(GroupID))
|
|
|
|
{
|
|
|
|
ClearTimer(nameof(CheckGroupMembership));
|
|
|
|
GroupMember = true;
|
|
|
|
ServerApplyMembership();
|
|
|
|
}
|
|
|
|
else if (!IsTimerActive(nameof(CheckGroupMembership)) && CheckGroupTimer > 0.0f)
|
|
|
|
{
|
|
|
|
SetTimer(CheckGroupTimer, true, nameof(CheckGroupMembership));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
`Log_Error("Can't get online subsystem steamworks!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public simulated function MSKGS_PlayerType PlayerType()
|
|
|
|
{
|
|
|
|
`Log_Trace();
|
|
|
|
|
|
|
|
if (IsServerOwner())
|
|
|
|
{
|
|
|
|
return MSKGS_Owner;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsAdmin())
|
|
|
|
{
|
|
|
|
return MSKGS_Admin;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsGroupMember())
|
2021-12-09 04:34:12 +00:00
|
|
|
{
|
2022-08-16 23:07:11 +00:00
|
|
|
return MSKGS_Group;
|
2021-12-09 04:34:12 +00:00
|
|
|
}
|
2022-08-16 23:07:11 +00:00
|
|
|
|
|
|
|
return MSKGS_Player;
|
|
|
|
}
|
|
|
|
|
|
|
|
public simulated function bool IsServerOwner()
|
|
|
|
{
|
|
|
|
return ServerOwner;
|
|
|
|
}
|
|
|
|
|
|
|
|
public simulated function bool IsAdmin()
|
|
|
|
{
|
|
|
|
return (GetKFPC() != None && KFPC.PlayerReplicationInfo != None && KFPC.PlayerReplicationInfo.bAdmin);
|
|
|
|
}
|
|
|
|
|
|
|
|
public simulated function bool IsGroupMember()
|
|
|
|
{
|
|
|
|
return GroupMember;
|
|
|
|
}
|
|
|
|
|
|
|
|
public simulated function KFPlayerController GetKFPC()
|
|
|
|
{
|
|
|
|
`Log_Trace();
|
|
|
|
|
|
|
|
if (KFPC != None) return KFPC;
|
|
|
|
|
|
|
|
KFPC = KFPlayerController(Owner);
|
|
|
|
|
|
|
|
if (KFPC == None && ROLE < ROLE_Authority)
|
2021-12-09 04:34:12 +00:00
|
|
|
{
|
2022-08-16 23:07:11 +00:00
|
|
|
KFPC = KFPlayerController(GetALocalPlayerController());
|
2021-12-09 04:34:12 +00:00
|
|
|
}
|
2022-08-16 23:07:11 +00:00
|
|
|
|
|
|
|
return KFPC;
|
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 23:07:11 +00:00
|
|
|
`Log_Trace();
|
|
|
|
|
2022-08-16 06:59:16 +00:00
|
|
|
GroupMember = true;
|
2022-08-17 07:53:13 +00:00
|
|
|
|
|
|
|
if (PlayerType() <= MSKGS_Group)
|
|
|
|
{
|
|
|
|
`Log_Info("Increase boost:" @ PlayerType());
|
|
|
|
MSKGS.IncreaseXPBoost(GetKFPC());
|
|
|
|
}
|
2021-12-09 04:34:12 +00:00
|
|
|
}
|
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
public reliable client function WriteToChatLocalized(E_MSKGS_LocalMessageType LMT, String HexColor, optional String String1, optional String String2, optional String String3)
|
2021-12-09 04:34:12 +00:00
|
|
|
{
|
2022-08-16 06:59:16 +00:00
|
|
|
`Log_Trace();
|
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
WriteToChat(MSKGS_LMT.static.GetLocalizedString(LogLevel, LMT, String1, String2, String3), HexColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
public reliable client function WriteToChat(String Message, String HexColor)
|
|
|
|
{
|
|
|
|
local KFGFxHudWrapper HUD;
|
|
|
|
|
|
|
|
`Log_Trace();
|
|
|
|
|
|
|
|
if (GetKFPC() == None) return;
|
|
|
|
|
|
|
|
if (KFPC.MyGFxManager.PartyWidget != None && KFPC.MyGFxManager.PartyWidget.PartyChatWidget != None)
|
2021-12-09 04:34:12 +00:00
|
|
|
{
|
2022-08-16 23:07:11 +00:00
|
|
|
KFPC.MyGFxManager.PartyWidget.PartyChatWidget.AddChatMessage(Message, HexColor);
|
2021-12-09 04:34:12 +00:00
|
|
|
}
|
2022-08-16 23:07:11 +00:00
|
|
|
|
|
|
|
HUD = KFGFxHudWrapper(KFPC.myHUD);
|
|
|
|
if (HUD != None && HUD.HUDMovie != None && HUD.HUDMovie.HudChatBox != None)
|
2022-08-16 06:59:16 +00:00
|
|
|
{
|
2022-08-16 23:07:11 +00:00
|
|
|
HUD.HUDMovie.HudChatBox.AddChatMessage(Message, HexColor);
|
2022-08-16 06:59:16 +00:00
|
|
|
}
|
2022-08-16 23:07:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public reliable client function WriteToHUDLocalized(E_MSKGS_LocalMessageType LMT, optional String String1, optional String String2, optional String String3, optional float DisplayTime = 0.0f)
|
|
|
|
{
|
|
|
|
`Log_Trace();
|
2022-08-16 06:59:16 +00:00
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
WriteToHUD(MSKGS_LMT.static.GetLocalizedString(LogLevel, LMT, String1, String2, String3), DisplayTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
public reliable client function WriteToHUD(String Message, optional float DisplayTime = 0.0f)
|
|
|
|
{
|
|
|
|
`Log_Trace();
|
|
|
|
|
|
|
|
if (GetKFPC() == None) return;
|
|
|
|
|
|
|
|
if (DisplayTime <= 0.0f)
|
2022-08-16 06:59:16 +00:00
|
|
|
{
|
2022-08-16 23:07:11 +00:00
|
|
|
DisplayTime = CalcDisplayTime(Message);
|
2022-08-16 06:59:16 +00:00
|
|
|
}
|
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
if (KFPC.MyGFxHUD != None)
|
|
|
|
{
|
|
|
|
KFPC.MyGFxHUD.DisplayMapText(Message, DisplayTime, false);
|
|
|
|
}
|
2022-08-16 06:59:16 +00:00
|
|
|
}
|
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
public reliable client function DefferedClearMessageHUD(optional float Time = 0.0f)
|
2022-08-16 06:59:16 +00:00
|
|
|
{
|
|
|
|
`Log_Trace();
|
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
SetTimer(Time, false, nameof(ClearMessageHUD));
|
|
|
|
}
|
|
|
|
|
|
|
|
public reliable client function ClearMessageHUD()
|
|
|
|
{
|
|
|
|
`Log_Trace();
|
2022-08-16 06:59:16 +00:00
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
if (GetKFPC() == None) return;
|
2022-08-16 06:59:16 +00:00
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
if (KFPC.MyGFxHUD != None && KFPC.MyGFxHUD.MapTextWidget != None)
|
2022-08-16 06:59:16 +00:00
|
|
|
{
|
2022-08-16 23:07:11 +00:00
|
|
|
KFPC.MyGFxHUD.MapTextWidget.StoredMessageList.Length = 0;
|
|
|
|
KFPC.MyGFxHUD.MapTextWidget.HideMessage();
|
2022-08-16 06:59:16 +00:00
|
|
|
}
|
2022-08-16 23:07:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private simulated function float CalcDisplayTime(String Message)
|
|
|
|
{
|
|
|
|
`Log_Trace();
|
2021-12-26 04:18:50 +00:00
|
|
|
|
2022-08-16 23:07:11 +00:00
|
|
|
return FClamp(Len(Message) / 20.0f, 3, 30);
|
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;
|
2022-08-16 23:07:11 +00:00
|
|
|
|
|
|
|
ObtainLogLevel = false;
|
|
|
|
ObtainGroupID = false;
|
|
|
|
ObtainCheckGroupTimer = false;
|
2021-12-09 04:34:12 +00:00
|
|
|
}
|