2020-12-02 09:51:53 +00:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using QSB.Player;
|
|
|
|
|
using QSB.Utility;
|
2020-11-03 21:33:48 +00:00
|
|
|
|
using UnityEngine;
|
2020-02-21 21:51:58 +01:00
|
|
|
|
|
2020-02-21 23:36:07 +01:00
|
|
|
|
namespace QSB.TransformSync
|
2020-02-21 21:51:58 +01:00
|
|
|
|
{
|
2020-08-31 09:36:29 +01:00
|
|
|
|
public class ShipTransformSync : TransformSync
|
2020-02-21 21:51:58 +01:00
|
|
|
|
{
|
|
|
|
|
public static ShipTransformSync LocalInstance { get; private set; }
|
|
|
|
|
|
2020-07-28 00:13:43 +01:00
|
|
|
|
public override void OnStartLocalPlayer()
|
|
|
|
|
{
|
2020-12-02 09:51:53 +00:00
|
|
|
|
DebugLog.DebugWrite("OnStartLocalPlayer", MessageType.Info);
|
2020-07-28 00:13:43 +01:00
|
|
|
|
LocalInstance = this;
|
|
|
|
|
}
|
2020-08-19 22:29:53 +02:00
|
|
|
|
|
2020-02-21 21:51:58 +01:00
|
|
|
|
private Transform GetShipModel()
|
|
|
|
|
{
|
2020-03-13 20:44:32 +01:00
|
|
|
|
return Locator.GetShipTransform();
|
2020-02-21 21:51:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Transform InitLocalTransform()
|
|
|
|
|
{
|
|
|
|
|
return GetShipModel().Find("Module_Cockpit/Geo_Cockpit/Cockpit_Geometry/Cockpit_Exterior");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Transform InitRemoteTransform()
|
|
|
|
|
{
|
|
|
|
|
var shipModel = GetShipModel();
|
|
|
|
|
|
2020-09-02 11:17:04 +01:00
|
|
|
|
var remoteTransform = new GameObject("RemoteShipTransform").transform;
|
2020-02-21 21:51:58 +01:00
|
|
|
|
|
|
|
|
|
Instantiate(shipModel.Find("Module_Cockpit/Geo_Cockpit/Cockpit_Geometry/Cockpit_Exterior"), remoteTransform);
|
|
|
|
|
Instantiate(shipModel.Find("Module_Cabin/Geo_Cabin/Cabin_Geometry/Cabin_Exterior"), remoteTransform);
|
2020-07-28 00:13:43 +01:00
|
|
|
|
Instantiate(shipModel.Find("Module_Cabin/Geo_Cabin/Cabin_Tech/Cabin_Tech_Exterior"), remoteTransform);
|
2020-02-21 21:51:58 +01:00
|
|
|
|
Instantiate(shipModel.Find("Module_Supplies/Geo_Supplies/Supplies_Geometry/Supplies_Exterior"), remoteTransform);
|
|
|
|
|
Instantiate(shipModel.Find("Module_Engine/Geo_Engine/Engine_Geometry/Engine_Exterior"), remoteTransform);
|
|
|
|
|
|
|
|
|
|
var landingGearFront = Instantiate(shipModel.Find("Module_LandingGear/LandingGear_Front/Geo_LandingGear_Front"), remoteTransform);
|
|
|
|
|
var landingGearLeft = Instantiate(shipModel.Find("Module_LandingGear/LandingGear_Left/Geo_LandingGear_Left"), remoteTransform);
|
|
|
|
|
var landingGearRight = Instantiate(shipModel.Find("Module_LandingGear/LandingGear_Right/Geo_LandingGear_Right"), remoteTransform);
|
|
|
|
|
|
|
|
|
|
Destroy(landingGearFront.Find("LandingGear_FrontCollision").gameObject);
|
|
|
|
|
Destroy(landingGearLeft.Find("LandingGear_LeftCollision").gameObject);
|
|
|
|
|
Destroy(landingGearRight.Find("LandingGear_RightCollision").gameObject);
|
|
|
|
|
|
|
|
|
|
landingGearFront.localPosition
|
|
|
|
|
= landingGearLeft.localPosition
|
|
|
|
|
= landingGearRight.localPosition
|
|
|
|
|
+= Vector3.up * 3.762f;
|
|
|
|
|
|
|
|
|
|
return remoteTransform;
|
|
|
|
|
}
|
2020-03-13 20:44:32 +01:00
|
|
|
|
|
2020-09-04 20:10:01 +01:00
|
|
|
|
public override bool IsReady => GetShipModel() != null
|
|
|
|
|
&& Player != null
|
2020-11-03 21:18:40 +00:00
|
|
|
|
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
|
2020-09-03 17:09:38 +01:00
|
|
|
|
&& Player.IsReady
|
2020-12-02 09:51:53 +00:00
|
|
|
|
&& NetId.Value != uint.MaxValue
|
|
|
|
|
&& NetId.Value != 0U;
|
2020-02-21 21:51:58 +01:00
|
|
|
|
}
|
|
|
|
|
}
|