diff --git a/QSB/PlayerBodySetup/Remote/FixMaterialsInAllChildren.cs b/QSB/PlayerBodySetup/Remote/FixMaterialsInAllChildren.cs index 232e4675..7877f1da 100644 --- a/QSB/PlayerBodySetup/Remote/FixMaterialsInAllChildren.cs +++ b/QSB/PlayerBodySetup/Remote/FixMaterialsInAllChildren.cs @@ -70,7 +70,6 @@ namespace QSB.PlayerBodySetup.Remote public static void ReplaceMaterials(Transform rootObject) { - /* if (_materialDefinitions.Count == 0) { GenerateMaterialDefinitions(); @@ -83,7 +82,6 @@ namespace QSB.PlayerBodySetup.Remote ReplaceMaterials(renderer, materialName, replacementMaterial); } } - */ } } } diff --git a/QSB/PlayerBodySetup/Remote/RemotePlayerCreation.cs b/QSB/PlayerBodySetup/Remote/RemotePlayerCreation.cs index 3d1d77ee..2bf77df4 100644 --- a/QSB/PlayerBodySetup/Remote/RemotePlayerCreation.cs +++ b/QSB/PlayerBodySetup/Remote/RemotePlayerCreation.cs @@ -10,6 +10,20 @@ namespace QSB.PlayerBodySetup.Remote { public static class RemotePlayerCreation { + private static GameObject _prefab; + + private static GameObject GetPrefab() + { + if (_prefab != null) + { + return _prefab; + } + + _prefab = QSBCore.NetworkAssetBundle.LoadAsset<GameObject>("Assets/Prefabs/REMOTE_Player_Body.prefab"); + ShaderReplacer.ReplaceShaders(_prefab); + return _prefab; + } + public static Transform CreatePlayer( PlayerInfo player, out Transform visibleCameraRoot, @@ -27,7 +41,7 @@ namespace QSB.PlayerBodySetup.Remote // Variable naming convention is broken here to reflect OW unity project (with REMOTE_ prefixed) for readability - var REMOTE_Player_Body = Object.Instantiate(QSBCore.NetworkAssetBundle.LoadAsset<GameObject>("Assets/Prefabs/REMOTE_Player_Body.prefab")); + var REMOTE_Player_Body = Object.Instantiate(GetPrefab()); var REMOTE_PlayerCamera = REMOTE_Player_Body.transform.Find("REMOTE_PlayerCamera").gameObject; var REMOTE_RoastingSystem = REMOTE_Player_Body.transform.Find("REMOTE_RoastingSystem").gameObject; var REMOTE_Stick_Root = REMOTE_RoastingSystem.transform.Find("REMOTE_Stick_Root").gameObject; @@ -41,8 +55,6 @@ namespace QSB.PlayerBodySetup.Remote player.Body = REMOTE_Player_Body; - FixMaterialsInAllChildren.ReplaceMaterials(REMOTE_Player_Body.transform); - player.AnimationSync.InitRemote(REMOTE_Traveller_HEA_Player_v2.transform); REMOTE_Player_Body.GetComponent<PlayerHUDMarker>().Init(player); diff --git a/QSB/PlayerBodySetup/Remote/ShaderReplacer.cs b/QSB/PlayerBodySetup/Remote/ShaderReplacer.cs new file mode 100644 index 00000000..9d5f04ec --- /dev/null +++ b/QSB/PlayerBodySetup/Remote/ShaderReplacer.cs @@ -0,0 +1,13 @@ +using QSB.Utility; +using UnityEngine; + +namespace QSB.PlayerBodySetup.Remote +{ + public static class ShaderReplacer + { + public static void ReplaceShaders(GameObject prefab) + { + DebugLog.DebugWrite($"TODO: replace shaders for prefab {prefab}"); + } + } +} diff --git a/QSB/Tools/FlashlightTool/FlashlightCreator.cs b/QSB/Tools/FlashlightTool/FlashlightCreator.cs index 94a0ada2..de512667 100644 --- a/QSB/Tools/FlashlightTool/FlashlightCreator.cs +++ b/QSB/Tools/FlashlightTool/FlashlightCreator.cs @@ -6,7 +6,7 @@ namespace QSB.Tools.FlashlightTool { internal static void CreateFlashlight(PlayerInfo player) { - var REMOTE_FlashlightRoot = player.CameraBody.transform.Find("REMOTE_FlashlightRoot"); + var REMOTE_FlashlightRoot = player.CameraBody.transform.Find("REMOTE_FlashlightRoot").gameObject; var qsbFlashlight = REMOTE_FlashlightRoot.GetComponent<QSBFlashlight>(); qsbFlashlight.Player = player; diff --git a/QSB/Tools/ProbeTool/ProbeCreator.cs b/QSB/Tools/ProbeTool/ProbeCreator.cs index f549d638..1da1b091 100644 --- a/QSB/Tools/ProbeTool/ProbeCreator.cs +++ b/QSB/Tools/ProbeTool/ProbeCreator.cs @@ -6,19 +6,31 @@ namespace QSB.Tools.ProbeTool { internal static class ProbeCreator { + private static GameObject _prefab; + + private static GameObject GetPrefab() + { + if (_prefab != null) + { + return _prefab; + } + + _prefab = QSBCore.NetworkAssetBundle.LoadAsset<GameObject>("Assets/Prefabs/REMOTE_Probe_Body.prefab"); + ShaderReplacer.ReplaceShaders(_prefab); + return _prefab; + } + public static Transform CreateProbe(PlayerInfo player) { - var REMOTE_Probe_Body = Object.Instantiate(QSBCore.NetworkAssetBundle.LoadAsset<GameObject>("Assets/Prefabs/REMOTE_Probe_Body.prefab")).transform; + var REMOTE_Probe_Body = Object.Instantiate(GetPrefab()); - var qsbProbe = REMOTE_Probe_Body.gameObject.GetComponent<QSBProbe>(); + var qsbProbe = REMOTE_Probe_Body.GetComponent<QSBProbe>(); player.Probe = qsbProbe; qsbProbe.SetOwner(player); - FixMaterialsInAllChildren.ReplaceMaterials(REMOTE_Probe_Body); + player.ProbeBody = REMOTE_Probe_Body; - player.ProbeBody = REMOTE_Probe_Body.gameObject; - - return REMOTE_Probe_Body; + return REMOTE_Probe_Body.transform; } } }