2022-02-02 20:33:53 +00:00
|
|
|
|
using QSB.Audio;
|
2022-08-16 23:57:17 +00:00
|
|
|
|
using QSB.EchoesOfTheEye.LightSensorSync;
|
2022-02-02 20:33:53 +00:00
|
|
|
|
using QSB.Player;
|
|
|
|
|
using QSB.RoastingSync;
|
|
|
|
|
using QSB.Tools;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.PlayerBodySetup.Remote;
|
|
|
|
|
|
|
|
|
|
public static class RemotePlayerCreation
|
2022-02-02 20:33:53 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
private static GameObject _prefab;
|
2022-02-27 12:40:44 +00:00
|
|
|
|
|
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_Player_Body.prefab");
|
|
|
|
|
ShaderReplacer.ReplaceShaders(_prefab);
|
2022-06-30 15:50:42 +00:00
|
|
|
|
FontReplacer.ReplaceFonts(_prefab);
|
2022-03-11 10:12:41 +00:00
|
|
|
|
QSBDopplerFixer.AddDopplerFixers(_prefab);
|
2022-03-03 03:46:33 +00:00
|
|
|
|
return _prefab;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Transform CreatePlayer(
|
|
|
|
|
PlayerInfo player,
|
|
|
|
|
out Transform visibleCameraRoot,
|
|
|
|
|
out Transform visibleRoastingSystem,
|
|
|
|
|
out Transform visibleStickPivot,
|
|
|
|
|
out Transform visibleStickTip)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* CREATE PLAYER STRUCTURE
|
|
|
|
|
*/
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
// Variable naming convention is broken here to reflect OW unity project (with REMOTE_ prefixed) for readability
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
var REMOTE_Player_Body = Object.Instantiate(GetPrefab());
|
2022-06-02 10:29:17 +00:00
|
|
|
|
var REMOTE_PlayerDetector = REMOTE_Player_Body.transform.Find("REMOTE_PlayerDetector");
|
2022-03-03 03:46:33 +00:00
|
|
|
|
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;
|
|
|
|
|
var REMOTE_Traveller_HEA_Player_v2 = REMOTE_Player_Body.transform.Find("REMOTE_Traveller_HEA_Player_v2").gameObject;
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* SET UP PLAYER BODY
|
|
|
|
|
*/
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
player.Body = REMOTE_Player_Body;
|
2022-03-07 21:25:41 +00:00
|
|
|
|
player.ThrusterLightTracker = player.Body.GetComponentInChildren<ThrusterLightTracker>();
|
2022-06-02 10:29:17 +00:00
|
|
|
|
player.FluidDetector = REMOTE_PlayerDetector.GetComponent<RemotePlayerFluidDetector>();
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
player.AnimationSync.InitRemote(REMOTE_Traveller_HEA_Player_v2.transform);
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
REMOTE_Player_Body.GetComponent<PlayerHUDMarker>().Init(player);
|
2022-08-14 11:41:50 +00:00
|
|
|
|
REMOTE_Player_Body.GetComponent<PlayerMapMarker>().Init(player);
|
2022-03-03 03:46:33 +00:00
|
|
|
|
player._ditheringAnimator = REMOTE_Player_Body.GetComponent<QSBDitheringAnimator>();
|
2022-03-26 14:17:40 +00:00
|
|
|
|
player.DreamWorldSpawnAnimator = REMOTE_Player_Body.GetComponent<DreamWorldSpawnAnimator>();
|
2022-03-03 03:46:33 +00:00
|
|
|
|
player.AudioController = REMOTE_Player_Body.transform.Find("REMOTE_Audio_Player").GetComponent<QSBPlayerAudioController>();
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* SET UP PLAYER CAMERA
|
|
|
|
|
*/
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
REMOTE_PlayerCamera.GetComponent<Camera>().enabled = false;
|
|
|
|
|
var owcamera = REMOTE_PlayerCamera.GetComponent<OWCamera>();
|
|
|
|
|
player.Camera = owcamera;
|
|
|
|
|
player.CameraBody = REMOTE_PlayerCamera;
|
|
|
|
|
visibleCameraRoot = REMOTE_PlayerCamera.transform;
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-08-17 00:05:13 +00:00
|
|
|
|
player.LightSensor.gameObject.GetAddComponent<QSBPlayerLightSensor>();
|
2022-08-16 23:57:17 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
PlayerToolsManager.InitRemote(player);
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
/*
|
|
|
|
|
* SET UP ROASTING STICK
|
|
|
|
|
*/
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
var REMOTE_Stick_Pivot = REMOTE_Stick_Root.transform.GetChild(0);
|
|
|
|
|
var mallowRoot = REMOTE_Stick_Pivot.Find("REMOTE_Stick_Tip/Mallow_Root");
|
|
|
|
|
var newSystem = mallowRoot.Find("MallowSmoke").gameObject.GetComponent<CustomRelativisticParticleSystem>();
|
|
|
|
|
newSystem.Init(player);
|
|
|
|
|
player.RoastingStick = REMOTE_Stick_Pivot.gameObject;
|
|
|
|
|
var marshmallow = mallowRoot.GetComponent<QSBMarshmallow>();
|
|
|
|
|
player.Marshmallow = marshmallow;
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
visibleRoastingSystem = REMOTE_RoastingSystem.transform;
|
|
|
|
|
visibleStickPivot = REMOTE_Stick_Pivot;
|
|
|
|
|
visibleStickTip = REMOTE_Stick_Pivot.Find("REMOTE_Stick_Tip");
|
2022-02-02 20:33:53 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
return REMOTE_Player_Body.transform;
|
2022-02-02 20:33:53 +00:00
|
|
|
|
}
|
2022-08-16 23:57:17 +00:00
|
|
|
|
}
|