55 lines
1.6 KiB
C#
Raw Normal View History

2022-08-16 16:57:17 -07:00
using QSB.EchoesOfTheEye.LightSensorSync;
using QSB.Messaging;
using QSB.Player;
using QSB.Player.Messages;
using QSB.SectorSync;
using QSB.Tools;
using QSB.WorldSync;
using UnityEngine;
2022-03-02 19:46:33 -08:00
namespace QSB.PlayerBodySetup.Local;
public static class LocalPlayerCreation
{
2022-03-02 19:46:33 -08:00
public static Transform CreatePlayer(
PlayerInfo player,
QSBSectorDetector sectorDetector,
out Transform visibleCameraRoot,
out Transform visibleRoastingSystem,
out Transform visibleStickPivot,
out Transform visibleStickTip)
{
2022-03-02 19:46:33 -08:00
sectorDetector.Init(Locator.GetPlayerSectorDetector());
// player body
var playerBody = Locator.GetPlayerTransform();
var playerModel = playerBody.Find("Traveller_HEA_Player_v2");
player.AnimationSync.InitLocal(playerModel);
player.Body = playerBody.gameObject;
2022-03-07 13:25:41 -08:00
player.ThrusterLightTracker = player.Body.GetComponentInChildren<ThrusterLightTracker>();
2022-03-02 19:46:33 -08:00
// camera
var cameraBody = Locator.GetPlayerCamera().gameObject.transform;
player.Camera = Locator.GetPlayerCamera();
player.CameraBody = cameraBody.gameObject;
visibleCameraRoot = cameraBody;
2022-08-16 17:05:13 -07:00
player.LightSensor.gameObject.GetAddComponent<QSBPlayerLightSensor>();
2022-08-16 16:57:17 -07:00
2022-03-02 19:46:33 -08:00
PlayerToolsManager.InitLocal();
// stick
2022-05-03 08:48:24 +01:00
var pivot = QSBWorldSync.GetUnityObject<RoastingStickController>().transform.Find("Stick_Root/Stick_Pivot");
2022-03-02 19:46:33 -08:00
player.RoastingStick = pivot.parent.gameObject;
visibleRoastingSystem = pivot.parent.parent;
visibleStickPivot = pivot;
visibleStickTip = pivot.Find("Stick_Tip");
player.IsReady = true;
new PlayerReadyMessage(true).Send();
new RequestStateResyncMessage().Send();
return playerBody;
}
2022-08-16 16:57:17 -07:00
}