quantum-space-buddies/QSB/Tools/ProbeTool/ProbeCreator.cs

36 lines
808 B
C#
Raw Normal View History

using QSB.Player;
2022-02-13 15:30:35 +00:00
using QSB.PlayerBodySetup.Remote;
using UnityEngine;
2022-03-03 03:46:33 +00:00
namespace QSB.Tools.ProbeTool;
internal static class ProbeCreator
{
2022-03-03 03:46:33 +00:00
private static GameObject _prefab;
2022-03-03 03:46:33 +00:00
private static GameObject GetPrefab()
{
if (_prefab != null)
2022-02-18 01:31:38 +00:00
{
return _prefab;
}
2022-03-03 03:46:33 +00:00
_prefab = QSBCore.NetworkAssetBundle.LoadAsset<GameObject>("Assets/Prefabs/REMOTE_Probe_Body.prefab");
ShaderReplacer.ReplaceShaders(_prefab);
QSBDopplerFixer.AddDopplerFixers(_prefab);
2022-03-03 03:46:33 +00:00
return _prefab;
}
public static Transform CreateProbe(PlayerInfo player)
{
var REMOTE_Probe_Body = Object.Instantiate(GetPrefab());
2022-03-03 03:46:33 +00:00
var qsbProbe = REMOTE_Probe_Body.GetComponent<QSBProbe>();
player.Probe = qsbProbe;
qsbProbe.SetOwner(player);
2022-03-03 03:46:33 +00:00
player.ProbeBody = REMOTE_Probe_Body;
2022-02-13 15:30:35 +00:00
2022-03-03 03:46:33 +00:00
return REMOTE_Probe_Body.transform;
}
}