quantum-space-buddies/QSB/PlayerBodySetup/Local/LocalPlayerCreation.cs

55 lines
1.6 KiB
C#
Raw Normal View History

2022-08-16 23:57:17 +00: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-03 03:46:33 +00:00
namespace QSB.PlayerBodySetup.Local;
public static class LocalPlayerCreation
{
2022-03-03 03:46:33 +00:00
public static Transform CreatePlayer(
PlayerInfo player,
QSBSectorDetector sectorDetector,
out Transform visibleCameraRoot,
out Transform visibleRoastingSystem,
out Transform visibleStickPivot,
out Transform visibleStickTip)
{
2022-03-03 03:46:33 +00: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 21:25:41 +00:00
player.ThrusterLightTracker = player.Body.GetComponentInChildren<ThrusterLightTracker>();
2022-03-03 03:46:33 +00:00
// camera
var cameraBody = Locator.GetPlayerCamera().gameObject.transform;
player.Camera = Locator.GetPlayerCamera();
player.CameraBody = cameraBody.gameObject;
visibleCameraRoot = cameraBody;
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.InitLocal();
// stick
2022-05-03 07:48:24 +00:00
var pivot = QSBWorldSync.GetUnityObject<RoastingStickController>().transform.Find("Stick_Root/Stick_Pivot");
2022-03-03 03:46:33 +00: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 23:57:17 +00:00
}