mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-06 01:00:16 +00:00
changed all Resources.FindObjectsOfTypeAll to QSBWorldSync.GetUnityObjects, which doesnt include prefabs
This commit is contained in:
parent
66d1f2bed9
commit
cef8cf23e5
@ -16,7 +16,7 @@ namespace QSB.Animation.NPC
|
||||
|
||||
//MOVE : this is the wrong place to put this... move it to Conversations?
|
||||
QSBWorldSync.OldDialogueTrees.Clear();
|
||||
QSBWorldSync.OldDialogueTrees = Resources.FindObjectsOfTypeAll<CharacterDialogueTree>().ToList();
|
||||
QSBWorldSync.OldDialogueTrees = QSBWorldSync.GetUnityObjects<CharacterDialogueTree>().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using OWML.Utils;
|
||||
using QSB.Events;
|
||||
using QSB.Player;
|
||||
using QSB.Player.TransformSync;
|
||||
using QSB.WorldSync;
|
||||
using QSB.Utility;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@ -75,7 +76,7 @@ namespace QSB.DeathSync
|
||||
}
|
||||
else
|
||||
{
|
||||
var allAstroobjects = Resources.FindObjectsOfTypeAll<AstroObject>().Where(x => x.GetAstroObjectName() != AstroObject.Name.None && x.GetAstroObjectType() != AstroObject.Type.Satellite);
|
||||
var allAstroobjects = QSBWorldSync.GetUnityObjects<AstroObject>().Where(x => x.GetAstroObjectName() != AstroObject.Name.None && x.GetAstroObjectType() != AstroObject.Type.Satellite);
|
||||
var ordered = allAstroobjects.OrderBy(x => Vector3.SqrMagnitude(x.transform.position));
|
||||
DeathClosestAstroObject = ordered.First().transform;
|
||||
}
|
||||
@ -138,4 +139,4 @@ namespace QSB.DeathSync
|
||||
&& spawnPoint.IsShipSpawn() == false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,30 +4,14 @@ namespace QSB.MeteorSync.WorldObjects
|
||||
{
|
||||
public class QSBMeteor : WorldObject<MeteorController>
|
||||
{
|
||||
private bool _initialized;
|
||||
|
||||
public override void Init(MeteorController attachedObject, int id)
|
||||
{
|
||||
ObjectId = id;
|
||||
AttachedObject = attachedObject;
|
||||
|
||||
// remove WorldObject if prefab
|
||||
if (AttachedObject.gameObject.scene.name == null)
|
||||
{
|
||||
QSBWorldSync.RemoveWorldObject(this);
|
||||
return;
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public override void OnRemoval()
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MeteorManager.MeteorsReady = false;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace QSB.OrbSync
|
||||
{
|
||||
QSBWorldSync.OldOrbList.Clear();
|
||||
NomaiOrbTransformSync.OrbTransformSyncs.Clear();
|
||||
QSBWorldSync.OldOrbList = Resources.FindObjectsOfTypeAll<NomaiInterfaceOrb>().ToList();
|
||||
QSBWorldSync.OldOrbList = QSBWorldSync.GetUnityObjects<NomaiInterfaceOrb>().ToList();
|
||||
if (QSBCore.IsHost)
|
||||
{
|
||||
_orbs.ForEach(x => QNetworkServer.Destroy(x));
|
||||
@ -41,4 +41,4 @@ namespace QSB.OrbSync
|
||||
DebugLog.DebugWrite($"Finished orb build with {QSBWorldSync.OldOrbList.Count} orbs.", MessageType.Success);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace QSB.Player.TransformSync
|
||||
protected Quaternion _roastingRotationVelocity;
|
||||
|
||||
private Transform GetStickPivot()
|
||||
=> Resources.FindObjectsOfTypeAll<RoastingStickController>().First().transform.Find("Stick_Root/Stick_Pivot");
|
||||
=> QSBWorldSync.GetUnityObjects<RoastingStickController>().First().transform.Find("Stick_Root/Stick_Pivot");
|
||||
|
||||
public override void OnStartLocalPlayer()
|
||||
=> LocalInstance = this;
|
||||
@ -275,4 +275,4 @@ namespace QSB.Player.TransformSync
|
||||
|
||||
public override bool UseInterpolation => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,17 @@ namespace QSB.PoolSync
|
||||
{
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
foreach (var streaming in Resources.FindObjectsOfTypeAll<NomaiRemoteCameraStreaming>())
|
||||
foreach (var streaming in QSBWorldSync.GetUnityObjects<NomaiRemoteCameraStreaming>())
|
||||
{
|
||||
streaming.gameObject.AddComponent<CustomNomaiRemoteCameraStreaming>();
|
||||
}
|
||||
|
||||
foreach (var camera in Resources.FindObjectsOfTypeAll<NomaiRemoteCamera>())
|
||||
foreach (var camera in QSBWorldSync.GetUnityObjects<NomaiRemoteCamera>())
|
||||
{
|
||||
camera.gameObject.AddComponent<CustomNomaiRemoteCamera>();
|
||||
}
|
||||
|
||||
foreach (var platform in Resources.FindObjectsOfTypeAll<NomaiRemoteCameraPlatform>())
|
||||
foreach (var platform in QSBWorldSync.GetUnityObjects<NomaiRemoteCameraPlatform>())
|
||||
{
|
||||
platform.gameObject.AddComponent<CustomNomaiRemoteCameraPlatform>();
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ namespace QSB
|
||||
DebugLog.DebugWrite("OnStartServer", MessageType.Info);
|
||||
if (QSBWorldSync.OldDialogueTrees.Count == 0 && QSBSceneManager.IsInUniverse)
|
||||
{
|
||||
QSBWorldSync.OldDialogueTrees = Resources.FindObjectsOfTypeAll<CharacterDialogueTree>().ToList();
|
||||
QSBWorldSync.OldDialogueTrees = QSBWorldSync.GetUnityObjects<CharacterDialogueTree>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,17 +283,17 @@ namespace QSB
|
||||
{
|
||||
QSBWorldSync.RemoveWorldObjects<IWorldObjectTypeSubset>();
|
||||
QSBWorldSync.RemoveWorldObjects<IWorldObject>();
|
||||
foreach (var platform in Resources.FindObjectsOfTypeAll<CustomNomaiRemoteCameraPlatform>())
|
||||
foreach (var platform in QSBWorldSync.GetUnityObjects<CustomNomaiRemoteCameraPlatform>())
|
||||
{
|
||||
Destroy(platform);
|
||||
}
|
||||
|
||||
foreach (var camera in Resources.FindObjectsOfTypeAll<CustomNomaiRemoteCamera>())
|
||||
foreach (var camera in QSBWorldSync.GetUnityObjects<CustomNomaiRemoteCamera>())
|
||||
{
|
||||
Destroy(camera);
|
||||
}
|
||||
|
||||
foreach (var streaming in Resources.FindObjectsOfTypeAll<CustomNomaiRemoteCameraStreaming>())
|
||||
foreach (var streaming in QSBWorldSync.GetUnityObjects<CustomNomaiRemoteCameraStreaming>())
|
||||
{
|
||||
Destroy(streaming);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace QSB.QuantumSync
|
||||
QSBWorldSync.Init<QSBEyeProxyQuantumMoon, EyeProxyQuantumMoon>();
|
||||
if (scene == OWScene.SolarSystem)
|
||||
{
|
||||
Shrine = Resources.FindObjectsOfTypeAll<QuantumShrine>().First();
|
||||
Shrine = QSBWorldSync.GetUnityObjects<QuantumShrine>().First();
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,4 +148,4 @@ namespace QSB.QuantumSync
|
||||
return QSBPlayerManager.PlayerList.Where(x => x.EntangledObject == worldObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
@ -66,7 +67,7 @@ namespace QSB.RoastingSync.Events
|
||||
var stick = player.RoastingStick;
|
||||
var stickTip = stick.transform.GetChild(0);
|
||||
|
||||
var mallowPrefab = Resources.FindObjectsOfTypeAll<RoastingStickController>().First().GetValue<GameObject>("_mallowBodyPrefab");
|
||||
var mallowPrefab = QSBWorldSync.GetUnityObjects<RoastingStickController>().First().GetValue<GameObject>("_mallowBodyPrefab");
|
||||
|
||||
var tossedMallow = Object.Instantiate(mallowPrefab, stickTip.position, stickTip.rotation);
|
||||
var rigidbody = tossedMallow.GetComponent<OWRigidbody>();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using QSB.WorldSync;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.SatelliteSync
|
||||
@ -21,7 +22,7 @@ namespace QSB.SatelliteSync
|
||||
{
|
||||
if (newScene == OWScene.SolarSystem)
|
||||
{
|
||||
Projector = Resources.FindObjectsOfTypeAll<SatelliteSnapshotController>().First();
|
||||
Projector = QSBWorldSync.GetUnityObjects<SatelliteSnapshotController>().First();
|
||||
Projector._loopingSource.spatialBlend = 1f;
|
||||
Projector._oneShotSource.spatialBlend = 1f;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ namespace QSB.SectorSync.WorldObjects
|
||||
}
|
||||
else if (QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse)
|
||||
{
|
||||
var shuttleController = Resources.FindObjectsOfTypeAll<EyeShuttleController>().First();
|
||||
var shuttleController = QSBWorldSync.GetUnityObjects<EyeShuttleController>().First();
|
||||
if (shuttleController == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Expected to find a EyeShuttleController for {AttachedObject.name}!", MessageType.Warning);
|
||||
@ -98,4 +98,4 @@ namespace QSB.SectorSync.WorldObjects
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,9 +61,9 @@ namespace QSB.ShipSync
|
||||
}
|
||||
|
||||
HatchInteractZone = HatchController.GetComponent<InteractZone>();
|
||||
ShipTractorBeam = Resources.FindObjectsOfTypeAll<ShipTractorBeamSwitch>().First();
|
||||
CockpitController = Resources.FindObjectsOfTypeAll<ShipCockpitController>().First();
|
||||
ShipElectricalComponent = Resources.FindObjectsOfTypeAll<ShipElectricalComponent>().First();
|
||||
ShipTractorBeam = QSBWorldSync.GetUnityObjects<ShipTractorBeamSwitch>().First();
|
||||
CockpitController = QSBWorldSync.GetUnityObjects<ShipCockpitController>().First();
|
||||
ShipElectricalComponent = QSBWorldSync.GetUnityObjects<ShipElectricalComponent>().First();
|
||||
|
||||
var sphereShape = HatchController.GetComponent<SphereShape>();
|
||||
sphereShape.radius = 2.5f;
|
||||
|
@ -28,7 +28,7 @@ namespace QSB.Syncs
|
||||
if (wantedSync == default)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - _storedTransformSyncs does not contain type:{typeof(T)} under player {player.PlayerId}. Attempting to find manually...", MessageType.Error);
|
||||
var allSyncs = Resources.FindObjectsOfTypeAll<T>();
|
||||
var allSyncs = QSBWorldSync.GetUnityObjects<T>();
|
||||
wantedSync = allSyncs.First(x => x.Player == player);
|
||||
if (wantedSync == default)
|
||||
{
|
||||
@ -100,7 +100,7 @@ namespace QSB.Syncs
|
||||
|
||||
public virtual void Start()
|
||||
{
|
||||
var lowestBound = Resources.FindObjectsOfTypeAll<PlayerTransformSync>()
|
||||
var lowestBound = QSBWorldSync.GetUnityObjects<PlayerTransformSync>()
|
||||
.Where(x => x.NetId.Value <= NetId.Value).OrderBy(x => x.NetId.Value).Last();
|
||||
NetIdentity.SetRootIdentity(lowestBound.NetIdentity);
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
using OWML.Utils;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -30,7 +32,7 @@ namespace QSB.TimeSync
|
||||
private void OnUniverseSceneLoad(OWScene oldScene, OWScene newScene)
|
||||
{
|
||||
_isSetUp = true;
|
||||
var obj = Resources.FindObjectsOfTypeAll<SleepTimerUI>()[0];
|
||||
var obj = QSBWorldSync.GetUnityObjects<SleepTimerUI>().First();
|
||||
_canvas = obj.GetValue<Canvas>("_canvas");
|
||||
_text = obj.GetValue<Text>("_text");
|
||||
_canvas.enabled = false;
|
||||
@ -126,4 +128,4 @@ namespace QSB.TimeSync
|
||||
_text.text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace QSB.Tools.ProbeTool
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_probe = Resources.FindObjectsOfTypeAll<QSBProbe>().First(x => gameObject.transform.IsChildOf(x.transform));
|
||||
_probe = QSBWorldSync.GetUnityObjects<QSBProbe>().First(x => gameObject.transform.IsChildOf(x.transform));
|
||||
if (_probe == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
@ -22,7 +23,7 @@ namespace QSB.Tools.ProbeTool
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_probe = Resources.FindObjectsOfTypeAll<QSBProbe>().First(x => gameObject.transform.IsChildOf(x.transform));
|
||||
_probe = QSBWorldSync.GetUnityObjects<QSBProbe>().First(x => gameObject.transform.IsChildOf(x.transform));
|
||||
if (_probe == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
@ -16,7 +17,7 @@ namespace QSB.Tools.ProbeTool
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_probe = Resources.FindObjectsOfTypeAll<QSBProbe>().First(x => gameObject.transform.IsChildOf(x.transform));
|
||||
_probe = QSBWorldSync.GetUnityObjects<QSBProbe>().First(x => gameObject.transform.IsChildOf(x.transform));
|
||||
if (_probe == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error);
|
||||
|
@ -152,34 +152,17 @@ namespace QSB.WorldSync
|
||||
WorldObjects.RemoveAll(x => x is TWorldObject);
|
||||
}
|
||||
|
||||
public static void RemoveWorldObject<TWorldObject>(TWorldObject item)
|
||||
where TWorldObject : IWorldObject
|
||||
{
|
||||
public static IEnumerable<TUnityObject> GetUnityObjects<TUnityObject>()
|
||||
where TUnityObject : MonoBehaviour
|
||||
=> Resources.FindObjectsOfTypeAll<TUnityObject>()
|
||||
.Where(x => x.gameObject.scene.name != null);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Trying to remove a null WorldObject of type {typeof(TWorldObject).Name}.", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
WorldObjects.Remove(item);
|
||||
WorldObjectsToUnityObjects.Remove(item.ReturnObject());
|
||||
item.OnRemoval();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Exception in OnRemoval() for {item.GetType()}. Message : {e.Message}, Stack trace : {e.StackTrace}", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<TUnityObject> Init<TWorldObject, TUnityObject>()
|
||||
public static void Init<TWorldObject, TUnityObject>()
|
||||
where TWorldObject : WorldObject<TUnityObject>
|
||||
where TUnityObject : MonoBehaviour
|
||||
{
|
||||
RemoveWorldObjects<TWorldObject>();
|
||||
var list = Resources.FindObjectsOfTypeAll<TUnityObject>().ToList();
|
||||
var list = GetUnityObjects<TUnityObject>().ToList();
|
||||
//DebugLog.DebugWrite($"{typeof(TWorldObject).Name} init : {list.Count} instances.", MessageType.Info);
|
||||
for (var id = 0; id < list.Count; id++)
|
||||
{
|
||||
@ -187,8 +170,6 @@ namespace QSB.WorldSync
|
||||
obj.Init(list[id], id);
|
||||
WorldObjectsToUnityObjects.Add(list[id], obj);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static TWorldObject CreateWorldObject<TWorldObject>()
|
||||
|
Loading…
Reference in New Issue
Block a user