KF2-ZedSpawner/ZedSpawner/Classes/ZedSpawnerRepLink.uc
2022-07-13 12:09:18 +03:00

73 lines
1.4 KiB
Ucode

class ZedSpawnerRepLink extends ReplicationInfo;
var public ZedSpawner ZS;
var public E_LogLevel LogLevel;
var public Array<class<KFPawn_Monster> > CustomZeds;
var private int Recieved;
replication
{
if (bNetInitial && Role == ROLE_Authority)
LogLevel;
}
public simulated function bool SafeDestroy()
{
return (bPendingDelete || bDeleteMe || Destroy());
}
public reliable client function ClientSync(class<KFPawn_Monster> CustomZed)
{
`Log_Trace(`Location);
`Log_Debug("Received:" @ CustomZed);
CustomZeds.AddItem(CustomZed);
ServerSync();
}
public reliable client function SyncFinished()
{
local class<KFPawn_Monster> CustomZed;
`Log_Trace(`Location);
foreach CustomZeds(CustomZed)
{
`Log_Debug("Preload Content for" @ CustomZed);
CustomZed.static.PreloadContent();
}
SafeDestroy();
}
public reliable server function ServerSync()
{
`Log_Trace(`Location);
if (bPendingDelete || bDeleteMe) return;
if (CustomZeds.Length == Recieved || WorldInfo.NetMode == NM_StandAlone)
{
`Log_Debug("Sync finished");
SyncFinished();
if (!ZS.DestroyRepLink(Controller(Owner)))
{
SafeDestroy();
}
}
else
{
`Log_Debug("Sync:" @ CustomZeds[Recieved]);
ClientSync(CustomZeds[Recieved++]);
}
}
defaultproperties
{
bAlwaysRelevant = false;
bOnlyRelevantToOwner = true;
bSkipActorPropertyReplication = false;
Recieved = 0
}