use new bundles

This commit is contained in:
Mister_Nebula 2021-11-24 22:16:56 +00:00
parent 7d8ce99ddd
commit c505c01390
3 changed files with 20 additions and 57 deletions

View File

@ -1,20 +1,14 @@
using OWML.Common;
using OWML.Utils;
using QSB.Animation.Player;
using QSB.Animation.Player.Thrusters;
using QSB.ClientServerStateSync;
using QSB.DeathSync;
using QSB.Events;
using QSB.Instruments;
using QSB.OrbSync.TransformSync;
using QSB.Patches;
using QSB.Player;
using QSB.Player.TransformSync;
using QSB.PoolSync;
using QSB.ShipSync.TransformSync;
using QSB.Anglerfish.TransformSync;
using QSB.TimeSync;
using QSB.Tools.ProbeTool.TransformSync;
using QSB.Utility;
using QSB.WorldSync;
using QuantumUNET;
@ -56,38 +50,18 @@ namespace QSB
PlayerName = GetPlayerName();
_assetBundle = QSBCore.NetworkAssetBundle;
playerPrefab = _assetBundle.LoadAsset<GameObject>("assets/NETWORK_Player_Body.prefab");
SetupNetworkId(playerPrefab, 1);
SetupNetworkTransform(playerPrefab);
playerPrefab.AddComponent<PlayerTransformSync>();
playerPrefab.AddComponent<AnimationSync>();
playerPrefab.AddComponent<CrouchSync>();
playerPrefab.AddComponent<WakeUpSync>();
playerPrefab.AddComponent<JetpackAccelerationSync>();
playerPrefab.AddComponent<InstrumentsManager>();
playerPrefab = _assetBundle.LoadAsset<GameObject>("Assets/Prefabs/NETWORK_Player_Body.prefab");
ShipPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkship.prefab");
SetupNetworkId(ShipPrefab, 2);
SetupNetworkTransform(ShipPrefab);
ShipPrefab.AddComponent<ShipTransformSync>();
ShipPrefab = _assetBundle.LoadAsset<GameObject>("assets/Prefabs/networkship.prefab");
spawnPrefabs.Add(ShipPrefab);
_probePrefab = _assetBundle.LoadAsset<GameObject>("assets/networkprobe.prefab");
SetupNetworkId(_probePrefab, 3);
SetupNetworkTransform(_probePrefab);
_probePrefab.AddComponent<PlayerProbeSync>();
_probePrefab = _assetBundle.LoadAsset<GameObject>("assets/Prefabs/networkprobe.prefab");
spawnPrefabs.Add(_probePrefab);
OrbPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkorb.prefab");
SetupNetworkId(OrbPrefab, 4);
SetupNetworkTransform(OrbPrefab);
OrbPrefab.AddComponent<NomaiOrbTransformSync>();
OrbPrefab = _assetBundle.LoadAsset<GameObject>("assets/Prefabs/networkorb.prefab");
spawnPrefabs.Add(OrbPrefab);
AnglerPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkangler.prefab");
SetupNetworkId(AnglerPrefab, 5);
SetupNetworkTransform(AnglerPrefab);
AnglerPrefab.AddComponent<AnglerTransformSync>();
AnglerPrefab = _assetBundle.LoadAsset<GameObject>("assets/Prefabs/networkangler.prefab");
spawnPrefabs.Add(AnglerPrefab);
ConfigureNetworkManager();
@ -110,29 +84,6 @@ namespace QSB
}
}
private void SetupNetworkId(GameObject go, int assetId)
{
var ident = go.AddComponent<QNetworkIdentity>();
ident.LocalPlayerAuthority = true;
var networkIdentity = go.GetComponent<NetworkIdentity>();
ident.SetValue("m_AssetId", assetId);
ident.SetValue("m_SceneId", networkIdentity.GetComponent<NetworkIdentity>().sceneId);
}
private void SetupNetworkTransform(GameObject go)
{
foreach (var item in go.GetComponents<NetworkTransformChild>())
{
var child = go.AddComponent<QNetworkTransformChild>();
child.Target = item.target;
child.m_ChildIndex = item.childIndex;
Destroy(item);
}
Destroy(go.GetComponent<NetworkTransform>());
Destroy(go.GetComponent<NetworkIdentity>());
}
private void ConfigureNetworkManager()
{
networkAddress = QSBCore.DefaultServerIP;

View File

@ -31,9 +31,9 @@ namespace QSB.QuantumSync.WorldObjects
public override void Init(T attachedObject, int id)
{
var debugBundle = QSBCore.DebugAssetBundle;
var sphere = debugBundle.LoadAsset<GameObject>("Assets/Sphere.prefab");
var cube = debugBundle.LoadAsset<GameObject>("Assets/Cube.prefab");
var capsule = debugBundle.LoadAsset<GameObject>("Assets/Capsule.prefab");
var sphere = debugBundle.LoadAsset<GameObject>("Assets/Prefabs/Sphere.prefab");
var cube = debugBundle.LoadAsset<GameObject>("Assets/Prefabs/Cube.prefab");
var capsule = debugBundle.LoadAsset<GameObject>("Assets/Prefabs/Capsule.prefab");
if (cube == null)
{

View File

@ -250,6 +250,18 @@ namespace QSB.TimeSync
{
_serverTime = Time.timeSinceLevelLoad;
if (ServerStateManager.Instance == null)
{
DebugLog.ToConsole($"Warning - ServerStateManager.Instance is null!", MessageType.Warning);
return;
}
if (QSBPlayerManager.LocalPlayer == null)
{
DebugLog.ToConsole($"Warning - LocalPlayer is null!", MessageType.Warning);
return;
}
var serverState = ServerStateManager.Instance.GetServerState();
var clientState = QSBPlayerManager.LocalPlayer.State;