merge dev

This commit is contained in:
Mister_Nebula 2021-02-26 21:55:39 +00:00
commit 7a53d8c2cf
6 changed files with 45 additions and 2 deletions

View File

@ -184,6 +184,7 @@
<Compile Include="QuantumSync\Events\SocketStateChangeMessage.cs" />
<Compile Include="QuantumSync\Patches\QuantumPatches.cs" />
<Compile Include="QuantumSync\WorldObjects\QSBMultiStateQuantumObject.cs" />
<Compile Include="QuantumSync\WorldObjects\QSBQuantumMoon.cs" />
<Compile Include="QuantumSync\WorldObjects\QSBQuantumObject.cs" />
<Compile Include="QuantumSync\WorldObjects\QSBQuantumShuffleObject.cs" />
<Compile Include="QuantumSync\WorldObjects\QSBSocketedQuantumObject.cs" />

View File

@ -111,13 +111,18 @@ namespace QSB
public void OnGUI()
{
if (!DebugMode)
{
return;
}
var offset = 10f;
GUI.Label(new Rect(220, 10, 200f, 20f), $"FPS : {Mathf.Round(1f / Time.smoothDeltaTime)}");
offset += _debugLineSpacing;
GUI.Label(new Rect(220, offset, 200f, 20f), $"HasWokenUp : {HasWokenUp}");
offset += _debugLineSpacing;
if (!HasWokenUp || !DebugMode)
if (!HasWokenUp)
{
return;
}

View File

@ -29,6 +29,7 @@ namespace QSB.QuantumSync.Patches
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShrine>("OnEntry", typeof(QuantumPatches), nameof(Shrine_OnEntry));
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShrine>("OnExit", typeof(QuantumPatches), nameof(Shrine_OnExit));
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumMoon>("CheckPlayerFogProximity", typeof(QuantumPatches), nameof(Moon_CheckPlayerFogProximity));
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumObject>("IsLockedByPlayerContact", typeof(QuantumPatches), nameof(Object_IsLockedByPlayerContact));
}
public override void DoUnpatches()
@ -43,6 +44,14 @@ namespace QSB.QuantumSync.Patches
QSBCore.Helper.HarmonyHelper.Unpatch<QuantumShrine>("OnEntry");
QSBCore.Helper.HarmonyHelper.Unpatch<QuantumShrine>("OnExit");
QSBCore.Helper.HarmonyHelper.Unpatch<QuantumMoon>("CheckPlayerFogProximity");
QSBCore.Helper.HarmonyHelper.Unpatch<QuantumObject>("IsLockedByPlayerContact");
}
public static bool Object_IsLockedByPlayerContact(ref bool __result, QuantumObject __instance)
{
var playersEntangled = QuantumManager.GetEntangledPlayers(__instance);
__result = playersEntangled.Count() != 0 && __instance.IsIlluminated();
return false;
}
public static bool Socketed_ChangeQuantumState(
@ -151,8 +160,14 @@ namespace QSB.QuantumSync.Patches
public static void Socketed_MoveToSocket(SocketedQuantumObject __instance, QuantumSocket socket)
{
if (socket == null)
{
DebugLog.ToConsole($"Error - Trying to move {__instance.name} to a null socket!", MessageType.Error);
return;
}
var objectWorldObject = QSBWorldSync.GetWorldFromUnity<QSBSocketedQuantumObject, SocketedQuantumObject>(__instance);
var socketWorldObject = QSBWorldSync.GetWorldFromUnity<QSBQuantumSocket, QuantumSocket>(socket);
if (objectWorldObject == null)
{
DebugLog.ToConsole($"Worldobject is null for {__instance.name}!");

View File

@ -32,6 +32,7 @@ namespace QSB.QuantumSync
QSBWorldSync.Init<QSBMultiStateQuantumObject, MultiStateQuantumObject>();
QSBWorldSync.Init<QSBQuantumSocket, QuantumSocket>();
QSBWorldSync.Init<QSBQuantumShuffleObject, QuantumShuffleObject>();
QSBWorldSync.Init<QSBQuantumMoon, QuantumMoon>();
if (scene == OWScene.SolarSystem)
{
Shrine = Resources.FindObjectsOfTypeAll<QuantumShrine>().First();
@ -105,6 +106,10 @@ namespace QSB.QuantumSync
{
worldObj = QSBWorldSync.GetWorldFromUnity<QSBQuantumShuffleObject, QuantumShuffleObject>((QuantumShuffleObject)unityObject);
}
else if (unityObject.GetType() == typeof(QuantumMoon))
{
worldObj = QSBWorldSync.GetWorldObject<QSBQuantumMoon, QuantumMoon>((QuantumMoon)unityObject);
}
else
{
DebugLog.ToConsole($"Warning - couldn't work out type of QuantumObject {unityObject.name}.", MessageType.Warning);

View File

@ -0,0 +1,12 @@
namespace QSB.QuantumSync.WorldObjects
{
class QSBQuantumMoon : QSBQuantumObject<QuantumMoon>
{
public override void Init(QuantumMoon moonObject, int id)
{
ObjectId = id;
AttachedObject = moonObject;
ControllingPlayer = 1u;
}
}
}

View File

@ -38,11 +38,16 @@ namespace QSB.WorldSync
where TUnityObject : MonoBehaviour
{
var allWorldObjects = GetWorldObjects<TWorldObject>();
if (allWorldObjects.Count() == 0)
if (allWorldObjects == null || allWorldObjects.Count() == 0)
{
DebugLog.ToConsole($"Error - No worldobjects exist of type {typeof(TWorldObject).Name}!", MessageType.Error);
return null;
}
if (unityObject == null)
{
DebugLog.ToConsole($"Error - Can't get world object from a null unity object! Type:{typeof(TUnityObject).Name}", MessageType.Error);
return null;
}
var correctWorldObject = allWorldObjects.First(x => x.AttachedObject == unityObject);
return correctWorldObject;
}