class SkinReplicatorRepInfo extends ReplicationInfo dependson(WeaponReplacements); const Replacements = class'WeaponReplacements'; var public E_LogLevel LogLevel; var public SkinReplicator SkinReplicator; var private KFPlayerController KFPC; var private KFPlayerReplicationInfo KFPRI; replication { if (bNetInitial && Role == ROLE_Authority) LogLevel; } public simulated function bool SafeDestroy() { `Log_Trace(); return (bPendingDelete || bDeleteMe || Destroy()); } public simulated event PostBeginPlay() { if (WorldInfo.NetMode == NM_StandAlone || Role <= ROLE_Authority) { SetTimer(1.0f, true, nameof(UpdateSkinsDLC)); } } private simulated function UpdateSkinsDLC() { local SWeapReplace WeapReplace; `Log_Debug("Wait for spawn"); if (GetKFPRI() != None && KFPRI.bHasSpawnedIn) { foreach Replacements.default.List(WeapReplace) { if (WeapReplace.WeapParent.default.SkinItemId > 0 && WeapReplace.Weap.default.SkinItemId != WeapReplace.WeapParent.default.SkinItemId) { `Log_Debug("Update skin for:" @ String(WeapReplace.WeapDef) @ "SkinId:" @ WeapReplace.WeapParent.default.SkinItemId); class'KFWeaponSkinList'.static.SaveWeaponSkin(WeapReplace.WeapDef, WeapReplace.WeapParent.default.SkinItemId); } } ClearTimer(nameof(UpdateSkinsDLC)); ClientCleanup(); } } private simulated function KFPlayerController GetKFPC() { `Log_Trace(); if (KFPC != None) return KFPC; KFPC = KFPlayerController(Owner); if (KFPC == None && ROLE < ROLE_Authority) { KFPC = KFPlayerController(GetALocalPlayerController()); } return KFPC; } private simulated function KFPlayerReplicationInfo GetKFPRI() { `Log_Trace(); if (KFPRI != None) return KFPRI; if (GetKFPC() == None) return None; KFPRI = KFPlayerReplicationInfo(KFPC.PlayerReplicationInfo); return KFPRI; } private simulated function ClientCleanup() { ServerCleanup(); SafeDestroy(); } private reliable server function ServerCleanup() { `Log_Trace(); `Log_Debug("Cleanup"); if (!SkinReplicator.DestroyRepInfo(GetKFPC())) { `Log_Debug("Cleanup (forced)"); SafeDestroy(); } } defaultproperties { bAlwaysRelevant = false bOnlyRelevantToOwner = true bSkipActorPropertyReplication = false }