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

101 lines
2.3 KiB
Ucode
Raw Normal View History

2021-02-25 23:55:43 +00:00
Class MskGsMut extends KFMutator
config(MskGs);
var const int SteamIDLen;
var const int UniqueIDLen;
var config array<string> ImportantPersonList;
2021-02-20 10:30:45 +00:00
2021-02-26 00:13:55 +00:00
function InitMutator(string Options, out string ErrorMessage)
{
local int MaxPlayers, MaxPlayersAllowed;
super.InitMutator(Options, ErrorMessage);
if (MyKFGI == none)
{
return;
}
MaxPlayers = Clamp(MyKFGI.GetIntOption(Options, "MaxPlayers", MaxPlayers), 1, 128);
MaxPlayersAllowed = MaxPlayers;
MyKFGI.MaxPlayers = MaxPlayers;
MyKFGI.MaxPlayersAllowed = MaxPlayersAllowed;
}
2021-02-20 10:30:45 +00:00
simulated event PostBeginPlay()
{
super.PostBeginPlay();
if (WorldInfo.Game.BaseMutator == None)
WorldInfo.Game.BaseMutator = Self;
else
WorldInfo.Game.BaseMutator.AddMutator(Self);
if (bDeleteMe)
return;
Initialize();
}
function Initialize()
{
2021-02-25 23:55:43 +00:00
local MskGsVoteCollector VoteCollector;
local OnlineSubsystem steamworks;
local string Person;
local UniqueNetId PersonUID;
2021-02-20 10:30:45 +00:00
if (MyKFGI == None || MyKFGI.MyKFGRI == None)
{
SetTimer(2.f, false, nameof(Initialize));
return;
}
MyKFGI.KFGFxManagerClass = class'MskGsGFxMoviePlayer_Manager';
MyKFGI.MyKFGRI.VoteCollectorClass = class'MskGsVoteCollector';
MyKFGI.MyKFGRI.PostBeginPlay();
2021-02-25 23:55:43 +00:00
steamworks = class'GameEngine'.static.GetOnlineSubsystem();
VoteCollector = MskGsVoteCollector(MyKFGI.MyKFGRI.VoteCollector);
if (VoteCollector == None)
{
`Log("[MskGsMut] ERROR: VoteCollector is None!");
return;
}
foreach ImportantPersonList(Person)
{
if (Len(Person) == UniqueIDLen && steamworks.StringToUniqueNetId(Person, PersonUID))
{
if (VoteCollector.ImportantPersonList.Find('Uid', PersonUID.Uid) == -1)
VoteCollector.ImportantPersonList.AddItem(PersonUID);
}
else if (Len(Person) == SteamIDLen && steamworks.Int64ToUniqueNetId(Person, PersonUID))
{
if (VoteCollector.ImportantPersonList.Find('Uid', PersonUID.Uid) == -1)
VoteCollector.ImportantPersonList.AddItem(PersonUID);
}
else `Log("[MskGsMut] WARN: Can't add person:"@Person);
}
2021-02-20 10:30:45 +00:00
`Log("[MskGsMut] Mutator loaded.");
}
function AddMutator(Mutator Mut)
{
if (Mut == Self)
return;
if (Mut.Class == Class)
Mut.Destroy();
else
Super.AddMutator(Mut);
}
defaultproperties
{
2021-02-25 23:55:43 +00:00
SteamIDLen=17
UniqueIDLen=18
2021-02-20 10:30:45 +00:00
}