mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-30 22:20:54 +00:00
fixes
This commit is contained in:
parent
d6e459b494
commit
c7005765a0
@ -19,6 +19,8 @@
|
||||
public static string RestartTimeLoop = "RestartTimeLoop";
|
||||
public static string WakeUp = "WakeUp";
|
||||
public static string DialogueCondition = "DialogueConditionChanged";
|
||||
public static string EnterQuantumMoon = "PlayerEnterQuantumMoon";
|
||||
public static string ExitQuantumMoon = "PlayerExitQuantumMoon";
|
||||
|
||||
// Custom event names -- change if you want! These can be anything, as long as both
|
||||
// sides of the GlobalMessenger (fireevent and setuplistener) reference the same thing.
|
||||
@ -45,6 +47,7 @@
|
||||
public static string QSBIdentifyFrequency = "QSBIdentifyFrequency";
|
||||
public static string QSBIdentifySignal = "QSBIdentifySignal";
|
||||
public static string QSBTextTranslated = "QSBTextTranslated";
|
||||
public static string QSBShrineRotation = "QSBShrineRotation";
|
||||
public static string QSBEnterShrine = "QSBEnterShrine";
|
||||
public static string QSBExitShrine = "QSBExitShrine";
|
||||
}
|
||||
}
|
@ -33,6 +33,6 @@
|
||||
IdentifyFrequency,
|
||||
IdentifySignal,
|
||||
TextTranslated,
|
||||
ShrineRotation
|
||||
EnterLeave
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ namespace QSB.Events
|
||||
new SetAsTranslatedEvent(),
|
||||
new QuantumShuffleEvent(),
|
||||
new MoonStateChangeEvent(),
|
||||
new ShrineRotationEvent(),
|
||||
new EnterLeaveEvent(),
|
||||
// Conversation/dialogue/exploration
|
||||
new ConversationEvent(),
|
||||
new ConversationStartEndEvent(),
|
||||
|
@ -1,5 +1,4 @@
|
||||
using QSB.Events;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.LogSync.Events
|
||||
@ -23,7 +22,6 @@ namespace QSB.LogSync.Events
|
||||
|
||||
public override void OnReceiveLocal(bool server, RevealFactMessage message)
|
||||
{
|
||||
DebugLog.DebugWrite($"GOT LOCAL FACT MESSAGE - {message.FactId} - isServer:{server}");
|
||||
if (server)
|
||||
{
|
||||
QSBWorldSync.AddFactReveal(message.FactId, message.SaveGame, message.ShowNotification);
|
||||
@ -32,7 +30,6 @@ namespace QSB.LogSync.Events
|
||||
|
||||
public override void OnReceiveRemote(bool server, RevealFactMessage message)
|
||||
{
|
||||
DebugLog.DebugWrite($"GOT REMOTE FACT MESSAGE - {message.FactId} - isServer:{server}");
|
||||
if (server)
|
||||
{
|
||||
QSBWorldSync.AddFactReveal(message.FactId, message.SaveGame, message.ShowNotification);
|
||||
|
@ -34,10 +34,11 @@ namespace QSB.Patches
|
||||
new WakeUpPatches(),
|
||||
new LogPatches(),
|
||||
new QuantumVisibilityPatches(),
|
||||
new ServerQuantumStateChangePatches(),
|
||||
new ClientQuantumStateChangePatches(),
|
||||
new ServerQuantumPatches(),
|
||||
new ClientQuantumPatches(),
|
||||
new FrequencyPatches(),
|
||||
new SpiralPatches()
|
||||
new SpiralPatches(),
|
||||
new QuantumPatches()
|
||||
};
|
||||
|
||||
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
|
||||
|
@ -36,6 +36,10 @@ namespace QSB.Player
|
||||
public bool PlayingInstrument => AnimationSync.CurrentType != AnimationType.PlayerSuited
|
||||
&& AnimationSync.CurrentType != AnimationType.PlayerUnsuited;
|
||||
|
||||
// Misc
|
||||
public bool IsInMoon;
|
||||
public bool IsInShrine;
|
||||
|
||||
public PlayerInfo(uint id)
|
||||
{
|
||||
PlayerId = id;
|
||||
|
@ -152,24 +152,25 @@
|
||||
<Compile Include="Patches\QSBPatch.cs" />
|
||||
<Compile Include="Patches\QSBPatchTypes.cs" />
|
||||
<Compile Include="QSBSceneManager.cs" />
|
||||
<Compile Include="QuantumSync\EnterLeaveType.cs" />
|
||||
<Compile Include="QuantumSync\Events\EnterLeaveEvent.cs" />
|
||||
<Compile Include="QuantumSync\Events\MoonStateChangeEvent.cs" />
|
||||
<Compile Include="QuantumSync\Events\MoonStateChangeMessage.cs" />
|
||||
<Compile Include="QuantumSync\Events\QuantumShuffleEvent.cs" />
|
||||
<Compile Include="QuantumSync\Events\QuantumShuffleMessage.cs" />
|
||||
<Compile Include="QuantumSync\Events\ShrineRotationEvent.cs" />
|
||||
<Compile Include="QuantumSync\Events\ShrineRotationMessage.cs" />
|
||||
<Compile Include="QuantumSync\Patches\ClientQuantumStateChangePatches.cs" />
|
||||
<Compile Include="QuantumSync\Patches\ClientQuantumPatches.cs" />
|
||||
<Compile Include="QuantumSync\Events\MultiStateChangeEvent.cs" />
|
||||
<Compile Include="QuantumSync\Events\MultiStateChangeMessage.cs" />
|
||||
<Compile Include="QuantumSync\Events\SocketStateChangeEvent.cs" />
|
||||
<Compile Include="QuantumSync\Events\SocketStateChangeMessage.cs" />
|
||||
<Compile Include="QuantumSync\Patches\QuantumPatches.cs" />
|
||||
<Compile Include="QuantumSync\WorldObjects\QSBMultiStateQuantumObject.cs" />
|
||||
<Compile Include="QuantumSync\WorldObjects\QSBQuantumShuffleObject.cs" />
|
||||
<Compile Include="QuantumSync\WorldObjects\QSBSocketedQuantumObject.cs" />
|
||||
<Compile Include="QuantumSync\WorldObjects\QSBQuantumSocket.cs" />
|
||||
<Compile Include="QuantumSync\QuantumManager.cs" />
|
||||
<Compile Include="QuantumSync\Patches\QuantumVisibilityPatches.cs" />
|
||||
<Compile Include="QuantumSync\Patches\ServerQuantumStateChangePatches.cs" />
|
||||
<Compile Include="QuantumSync\Patches\ServerQuantumPatches.cs" />
|
||||
<Compile Include="TranslationSync\Events\SetAsTranslatedEvent.cs" />
|
||||
<Compile Include="TranslationSync\Events\SetAsTranslatedMessage.cs" />
|
||||
<Compile Include="TranslationSync\NomaiTextType.cs" />
|
||||
|
@ -40,7 +40,6 @@ namespace QSB
|
||||
{
|
||||
PlayerName = GetPlayerName();
|
||||
CanEditName = true;
|
||||
QSBCore.Helper.HarmonyHelper.EmptyMethod<NetworkManagerHUD>("Update");
|
||||
}
|
||||
|
||||
private string GetPlayerName()
|
||||
|
10
QSB/QuantumSync/EnterLeaveType.cs
Normal file
10
QSB/QuantumSync/EnterLeaveType.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace QSB.QuantumSync
|
||||
{
|
||||
public enum EnterLeaveType
|
||||
{
|
||||
EnterMoon = 0,
|
||||
ExitMoon = 1,
|
||||
EnterShrine = 2,
|
||||
ExitShrine = 3
|
||||
}
|
||||
}
|
63
QSB/QuantumSync/Events/EnterLeaveEvent.cs
Normal file
63
QSB/QuantumSync/Events/EnterLeaveEvent.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
|
||||
namespace QSB.QuantumSync.Events
|
||||
{
|
||||
internal class EnterLeaveEvent : QSBEvent<EnumMessage<EnterLeaveType>>
|
||||
{
|
||||
public override EventType Type => EventType.EnterLeave;
|
||||
|
||||
public override void SetupListener()
|
||||
{
|
||||
GlobalMessenger.AddListener(EventNames.EnterQuantumMoon, () => Handler(EnterLeaveType.EnterMoon));
|
||||
GlobalMessenger.AddListener(EventNames.ExitQuantumMoon, () => Handler(EnterLeaveType.ExitMoon));
|
||||
GlobalMessenger.AddListener(EventNames.QSBEnterShrine, () => Handler(EnterLeaveType.EnterShrine));
|
||||
GlobalMessenger.AddListener(EventNames.QSBExitShrine, () => Handler(EnterLeaveType.ExitShrine));
|
||||
}
|
||||
|
||||
public override void CloseListener()
|
||||
{
|
||||
GlobalMessenger.RemoveListener(EventNames.EnterQuantumMoon, () => Handler(EnterLeaveType.EnterMoon));
|
||||
GlobalMessenger.RemoveListener(EventNames.ExitQuantumMoon, () => Handler(EnterLeaveType.ExitMoon));
|
||||
GlobalMessenger.RemoveListener(EventNames.QSBEnterShrine, () => Handler(EnterLeaveType.EnterShrine));
|
||||
GlobalMessenger.RemoveListener(EventNames.QSBExitShrine, () => Handler(EnterLeaveType.ExitShrine));
|
||||
}
|
||||
|
||||
private void Handler(EnterLeaveType type) => SendEvent(CreateMessage(type));
|
||||
|
||||
private EnumMessage<EnterLeaveType> CreateMessage(EnterLeaveType type) => new EnumMessage<EnterLeaveType>
|
||||
{
|
||||
AboutId = LocalPlayerId,
|
||||
Value = type
|
||||
};
|
||||
|
||||
public override void OnReceiveLocal(bool server, EnumMessage<EnterLeaveType> message)
|
||||
=> OnReceiveRemote(server, message);
|
||||
|
||||
public override void OnReceiveRemote(bool server, EnumMessage<EnterLeaveType> message)
|
||||
{
|
||||
var player = QSBPlayerManager.GetPlayer(message.FromId);
|
||||
DebugLog.DebugWrite($"Get enter/leave event of {message.Value} from {player.PlayerId}");
|
||||
switch (message.Value)
|
||||
{
|
||||
case EnterLeaveType.EnterMoon:
|
||||
player.IsInMoon = true;
|
||||
break;
|
||||
case EnterLeaveType.ExitMoon:
|
||||
player.IsInMoon = false;
|
||||
break;
|
||||
case EnterLeaveType.EnterShrine:
|
||||
player.IsInShrine = true;
|
||||
break;
|
||||
case EnterLeaveType.ExitShrine:
|
||||
player.IsInShrine = false;
|
||||
break;
|
||||
default:
|
||||
DebugLog.ToConsole($"Warning - Unknown EnterLeaveType : {message.Value}", OWML.Common.MessageType.Warning);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using QSB.Events;
|
||||
using QSB.Utility;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.QuantumSync.Events
|
||||
@ -29,8 +30,11 @@ namespace QSB.QuantumSync.Events
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DebugLog.DebugWrite($"MOON TO INDEX {message.StateIndex}, ANGLE {message.OrbitAngle}, POINT {message.OnUnitSphere}");
|
||||
var moon = Locator.GetQuantumMoon();
|
||||
var wasPlayerEntangled = moon.IsPlayerEntangled();
|
||||
var location = new RelativeLocationData(Locator.GetPlayerTransform().GetComponent<OWRigidbody>(), moon.transform);
|
||||
var moonBody = moon.GetValue<OWRigidbody>("_moonBody");
|
||||
var constantFoceDetector = (ConstantForceDetector)moonBody.GetAttachedForceDetector();
|
||||
var orbits = moon.GetValue<QuantumOrbit[]>("_orbits");
|
||||
@ -46,6 +50,13 @@ namespace QSB.QuantumSync.Events
|
||||
constantFoceDetector.AddConstantVolume(owRigidbody.GetAttachedGravityVolume(), true, true);
|
||||
moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(owRigidbody, moonBody, message.OrbitAngle) + owRigidbody.GetVelocity());
|
||||
moon.SetValue("_stateIndex", message.StateIndex);
|
||||
|
||||
moon.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(moon, new object[] { message.StateIndex });
|
||||
|
||||
if (wasPlayerEntangled)
|
||||
{
|
||||
Locator.GetPlayerTransform().GetComponent<OWRigidbody>().MoveToRelativeLocation(location, moon.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
using QSB.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.QuantumSync.Events
|
||||
{
|
||||
class ShrineRotationEvent : QSBEvent<ShrineRotationMessage>
|
||||
{
|
||||
public override QSB.Events.EventType Type => QSB.Events.EventType.ShrineRotation;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger<Quaternion>.AddListener(EventNames.QSBMoonStateChange, Handler);
|
||||
public override void CloseListener() => GlobalMessenger<Quaternion>.RemoveListener(EventNames.QSBMoonStateChange, Handler);
|
||||
|
||||
private void Handler(Quaternion rotation) => SendEvent(CreateMessage(rotation));
|
||||
|
||||
private ShrineRotationMessage CreateMessage(Quaternion rotation) => new ShrineRotationMessage
|
||||
{
|
||||
AboutId = LocalPlayerId,
|
||||
Rotation = rotation
|
||||
};
|
||||
|
||||
public override void OnReceiveRemote(bool server, ShrineRotationMessage message)
|
||||
{
|
||||
if (!QSBCore.HasWokenUp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Resources.FindObjectsOfTypeAll<QuantumShrine>().First().transform.rotation = message.Rotation;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
using QSB.Messaging;
|
||||
using QuantumUNET.Transport;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.QuantumSync.Events
|
||||
{
|
||||
class ShrineRotationMessage : PlayerMessage
|
||||
{
|
||||
public Quaternion Rotation { get; set; }
|
||||
|
||||
public override void Deserialize(QNetworkReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
Rotation = reader.ReadQuaternion();
|
||||
}
|
||||
|
||||
public override void Serialize(QNetworkWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(Rotation);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using QSB.Events;
|
||||
using QSB.Player;
|
||||
using QSB.QuantumSync.WorldObjects;
|
||||
using QSB.WorldSync;
|
||||
using System.Reflection;
|
||||
@ -32,7 +33,18 @@ namespace QSB.QuantumSync.Events
|
||||
var obj = QSBWorldSync.GetWorldObject<QSBSocketedQuantumObject>(message.ObjectId).AttachedObject;
|
||||
var socket = QSBWorldSync.GetWorldObject<QSBQuantumSocket>(message.SocketId).AttachedObject;
|
||||
obj.GetType().GetMethod("MoveToSocket", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(obj, new object[] { socket });
|
||||
obj.transform.localRotation = message.LocalRotation;
|
||||
if ((QuantumManager.Instance.Shrine as SocketedQuantumObject) != obj)
|
||||
{
|
||||
obj.transform.localRotation = message.LocalRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
var playerToShrine = QSBPlayerManager.GetPlayer(message.FromId).Body.transform.position - obj.transform.position;
|
||||
var projectOnPlace = Vector3.ProjectOnPlane(playerToShrine, obj.transform.up);
|
||||
var angle = OWMath.Angle(obj.transform.forward, projectOnPlace, obj.transform.up);
|
||||
angle = OWMath.RoundToNearestMultiple(angle, 120f);
|
||||
obj.transform.rotation = Quaternion.AngleAxis(angle, obj.transform.up) * obj.transform.rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,17 +2,17 @@
|
||||
|
||||
namespace QSB.QuantumSync.Patches
|
||||
{
|
||||
public class ClientQuantumStateChangePatches : QSBPatch
|
||||
public class ClientQuantumPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnNonServerClientConnect;
|
||||
|
||||
public override void DoPatches()
|
||||
{
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<SocketedQuantumObject>("ChangeQuantumState", typeof(ClientQuantumStateChangePatches), nameof(ReturnFalsePatch));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<MultiStateQuantumObject>("ChangeQuantumState", typeof(ClientQuantumStateChangePatches), nameof(ReturnFalsePatch));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShuffleObject>("ChangeQuantumState", typeof(ClientQuantumStateChangePatches), nameof(ReturnFalsePatch));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumMoon>("ChangeQuantumState", typeof(ClientQuantumStateChangePatches), nameof(ReturnFalsePatch));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShrine>("ChangeQuantumState", typeof(ClientQuantumStateChangePatches), nameof(ReturnFalsePatch));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<SocketedQuantumObject>("ChangeQuantumState", typeof(ClientQuantumPatches), nameof(ReturnFalsePatch));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<MultiStateQuantumObject>("ChangeQuantumState", typeof(ClientQuantumPatches), nameof(ReturnFalsePatch));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShuffleObject>("ChangeQuantumState", typeof(ClientQuantumPatches), nameof(ReturnFalsePatch));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumMoon>("ChangeQuantumState", typeof(ClientQuantumPatches), nameof(ReturnFalsePatch));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShrine>("ChangeQuantumState", typeof(ClientQuantumPatches), nameof(ReturnFalsePatch));
|
||||
}
|
||||
|
||||
public static bool ReturnFalsePatch() => false;
|
59
QSB/QuantumSync/Patches/QuantumPatches.cs
Normal file
59
QSB/QuantumSync/Patches/QuantumPatches.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using QSB.Events;
|
||||
using QSB.Patches;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.QuantumSync.Patches
|
||||
{
|
||||
public class QuantumPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
public override void DoPatches()
|
||||
{
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShrine>("OnEntry", typeof(QuantumPatches), nameof(Shrine_OnEntry));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShrine>("OnExit", typeof(QuantumPatches), nameof(Shrine_OnExit));
|
||||
}
|
||||
|
||||
public static bool Shrine_OnEntry(
|
||||
GameObject hitObj,
|
||||
ref bool ____isPlayerInside,
|
||||
ref bool ____fading,
|
||||
OWLightController ____exteriorLightController,
|
||||
ref bool ____isProbeInside)
|
||||
{
|
||||
if (hitObj.CompareTag("PlayerDetector"))
|
||||
{
|
||||
____isPlayerInside = true;
|
||||
____fading = true;
|
||||
____exteriorLightController.FadeTo(0f, 1f);
|
||||
GlobalMessenger.FireEvent(EventNames.QSBEnterShrine);
|
||||
}
|
||||
else if (hitObj.CompareTag("ProbeDetector"))
|
||||
{
|
||||
____isProbeInside = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Shrine_OnExit(
|
||||
GameObject hitObj,
|
||||
ref bool ____isPlayerInside,
|
||||
ref bool ____fading,
|
||||
OWLightController ____exteriorLightController,
|
||||
ref bool ____isProbeInside)
|
||||
{
|
||||
if (hitObj.CompareTag("PlayerDetector"))
|
||||
{
|
||||
____isPlayerInside = false;
|
||||
____fading = true;
|
||||
____exteriorLightController.FadeTo(1f, 1f);
|
||||
GlobalMessenger.FireEvent(EventNames.QSBExitShrine);
|
||||
}
|
||||
else if (hitObj.CompareTag("ProbeDetector"))
|
||||
{
|
||||
____isProbeInside = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using QSB.Events;
|
||||
using OWML.Common;
|
||||
using QSB.Events;
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
using QSB.QuantumSync.WorldObjects;
|
||||
@ -6,25 +7,25 @@ using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.QuantumSync.Patches
|
||||
{
|
||||
public class ServerQuantumStateChangePatches : QSBPatch
|
||||
public class ServerQuantumPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnServerClientConnect;
|
||||
|
||||
public override void DoPatches()
|
||||
{
|
||||
QSBCore.Helper.HarmonyHelper.AddPostfix<SocketedQuantumObject>("MoveToSocket", typeof(ServerQuantumStateChangePatches), nameof(Socketed_MoveToSocket));
|
||||
QSBCore.Helper.HarmonyHelper.AddPostfix<QuantumState>("SetVisible", typeof(ServerQuantumStateChangePatches), nameof(QuantumState_SetVisible));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShuffleObject>("ChangeQuantumState", typeof(ServerQuantumStateChangePatches), nameof(Shuffle_ChangeQuantumState));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumMoon>("ChangeQuantumState", typeof(ServerQuantumStateChangePatches), nameof(Moon_ChangeQuantumState));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumMoon>("CheckPlayerFogProximity", typeof(ServerQuantumStateChangePatches), nameof(Moon_CheckPlayerFogProximity));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShrine>("ChangeQuantumState", typeof(ServerQuantumStateChangePatches), nameof(Shrine_ChangeQuantumState));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<ShapeManager>("AddToRetryQueue", typeof(ServerQuantumStateChangePatches), nameof(Shape_AddToRetryQueue));
|
||||
QSBCore.Helper.HarmonyHelper.AddPostfix<SocketedQuantumObject>("MoveToSocket", typeof(ServerQuantumPatches), nameof(Socketed_MoveToSocket));
|
||||
QSBCore.Helper.HarmonyHelper.AddPostfix<QuantumState>("SetVisible", typeof(ServerQuantumPatches), nameof(QuantumState_SetVisible));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShuffleObject>("ChangeQuantumState", typeof(ServerQuantumPatches), nameof(Shuffle_ChangeQuantumState));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumMoon>("ChangeQuantumState", typeof(ServerQuantumPatches), nameof(Moon_ChangeQuantumState));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumMoon>("CheckPlayerFogProximity", typeof(ServerQuantumPatches), nameof(Moon_CheckPlayerFogProximity));
|
||||
QSBCore.Helper.HarmonyHelper.AddPrefix<QuantumShrine>("IsPlayerInDarkness", typeof(ServerQuantumPatches), nameof(Shrine_IsPlayerInDarkness));
|
||||
}
|
||||
|
||||
public static void Socketed_MoveToSocket(SocketedQuantumObject __instance, QuantumSocket socket)
|
||||
@ -105,13 +106,15 @@ namespace QSB.QuantumSync.Patches
|
||||
GameObject[] ____deactivateAtEye
|
||||
)
|
||||
{
|
||||
if (skipInstantVisibilityCheck)
|
||||
if (IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, skipInstantVisibilityCheck) && !QuantumManager.Instance.Shrine.IsPlayerInDarkness())
|
||||
{
|
||||
if (IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, true))
|
||||
if (!skipInstantVisibilityCheck)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
var method = new StackTrace().GetFrame(3).GetMethod();
|
||||
DebugLog.DebugWrite($"Warning - Tried to change moon state while still observed. Called by {method.DeclaringType}.{method.Name}", MessageType.Warning);
|
||||
}
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
var flag = false;
|
||||
if (____isPlayerInside && ____hasSunCollapsed)
|
||||
@ -143,7 +146,7 @@ namespace QSB.QuantumSync.Patches
|
||||
}
|
||||
if (orbitIndex == -1)
|
||||
{
|
||||
Debug.LogError("QUANTUM MOON FAILED TO FIND ORBIT FOR STATE " + stateIndex);
|
||||
UnityEngine.Debug.LogError("QUANTUM MOON FAILED TO FIND ORBIT FOR STATE " + stateIndex);
|
||||
}
|
||||
var orbitRadius = (orbitIndex == -1) ? 10000f : ____orbits[orbitIndex].GetOrbitRadius();
|
||||
var owRigidbody = (orbitIndex == -1) ? Locator.GetAstroObject(AstroObject.Name.Sun).GetOWRigidbody() : ____orbits[orbitIndex].GetAttachedOWRigidbody();
|
||||
@ -194,7 +197,7 @@ namespace QSB.QuantumSync.Patches
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Quantum moon orbit position occupied! Aborting collapse.");
|
||||
UnityEngine.Debug.LogError("Quantum moon orbit position occupied! Aborting collapse.");
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
@ -300,7 +303,7 @@ namespace QSB.QuantumSync.Patches
|
||||
component.SetDegreesY(component.GetMinDegreesY());
|
||||
____vortexAudio.SetLocalVolume(0f);
|
||||
____collapseToIndex = 1;
|
||||
// TODO : Handle players exiting eye state when other players are still one eye state, etc...
|
||||
// TODO : Handle players exiting eye state when other players are still on eye state, etc...
|
||||
__instance.GetType().GetMethod("Collapse", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { true });
|
||||
}
|
||||
}
|
||||
@ -310,43 +313,30 @@ namespace QSB.QuantumSync.Patches
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Shrine_ChangeQuantumState(QuantumShrine __instance, ref bool __result, bool skipInstantVisibilityCheck)
|
||||
public static bool Shrine_IsPlayerInDarkness(ref bool __result, Light[] ____lamps, float ____fadeFraction, bool ____isProbeInside, NomaiGateway ____gate)
|
||||
{
|
||||
DebugLog.DebugWrite("Shrine changequantumstate");
|
||||
var baseObject = __instance as SocketedQuantumObject;
|
||||
if (baseObject == null)
|
||||
foreach (var lamp in ____lamps)
|
||||
{
|
||||
DebugLog.DebugWrite("baseobject null");
|
||||
if (lamp.intensity > 0f)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var method = typeof(SocketedQuantumObject).GetMethod("ChangeQuantumState", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (method == null)
|
||||
{
|
||||
DebugLog.DebugWrite("method null");
|
||||
}
|
||||
var pointer = method.MethodHandle.GetFunctionPointer();
|
||||
if (pointer == null)
|
||||
{
|
||||
DebugLog.DebugWrite("pointer null");
|
||||
}
|
||||
var function = (Func<bool, bool>)Activator.CreateInstance(typeof(Func<bool, bool>), __instance, pointer);
|
||||
var flag = function(skipInstantVisibilityCheck);
|
||||
if (flag)
|
||||
{
|
||||
var vector = Locator.GetPlayerTransform().position - __instance.transform.position;
|
||||
var to = Vector3.ProjectOnPlane(vector, __instance.transform.up);
|
||||
var num = OWMath.Angle(__instance.transform.forward, to, __instance.transform.up);
|
||||
num = OWMath.RoundToNearestMultiple(num, 120f);
|
||||
__instance.transform.rotation = Quaternion.AngleAxis(num, __instance.transform.up) * __instance.transform.rotation;
|
||||
GlobalMessenger<Quaternion>.FireEvent(EventNames.QSBShrineRotation, __instance.transform.rotation);
|
||||
}
|
||||
__result = flag;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Shape_AddToRetryQueue(QuantumObject obj)
|
||||
{
|
||||
DebugLog.DebugWrite($"adding {obj.name} to retry queue");
|
||||
return true;
|
||||
var playersInMoon = QSBPlayerManager.PlayerList.Where(x => x.IsInMoon);
|
||||
if (playersInMoon.Any(x => !x.IsInShrine)
|
||||
|| playersInMoon.Any(x => x.FlashLight != null && x.FlashLight.FlashlightOn)
|
||||
|| (QSBPlayerManager.LocalPlayer.IsInShrine && PlayerState.IsFlashlightOn()))
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
// TODO : make this *really* check for all players - check other probes and other jetpacks!
|
||||
__result = ____gate.GetOpenFraction() == 0f
|
||||
&& !____isProbeInside
|
||||
&& Locator.GetThrusterLightTracker().GetLightRange() <= 0f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using QSB.Player;
|
||||
using QSB.QuantumSync.WorldObjects;
|
||||
using QSB.WorldSync;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
@ -16,6 +17,7 @@ namespace QSB.QuantumSync
|
||||
private List<MultiStateQuantumObject> _multiStateQuantumObjects;
|
||||
private List<QuantumSocket> _quantumSockets;
|
||||
private List<QuantumShuffleObject> _quantumShuffleObjects;
|
||||
public QuantumShrine Shrine;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
@ -31,20 +33,53 @@ namespace QSB.QuantumSync
|
||||
_multiStateQuantumObjects = QSBWorldSync.Init<QSBMultiStateQuantumObject, MultiStateQuantumObject>();
|
||||
_quantumSockets = QSBWorldSync.Init<QSBQuantumSocket, QuantumSocket>();
|
||||
_quantumShuffleObjects = QSBWorldSync.Init<QSBQuantumShuffleObject, QuantumShuffleObject>();
|
||||
Shrine = Resources.FindObjectsOfTypeAll<QuantumShrine>().First();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
public void OnGUI()
|
||||
{
|
||||
if (!QSBCore.HasWokenUp || !QSBCore.DebugMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GUI.Label(new Rect(220, 10, 200f, 20f), $"QM Visible:{Locator.GetQuantumMoon().IsVisible()}");
|
||||
|
||||
Popcron.Gizmos.Sphere(Shrine.transform.position, 10f, Color.magenta, true);
|
||||
|
||||
GUI.Label(new Rect(220, 10, 200f, 20f), $"QM Visible : {Locator.GetQuantumMoon().IsVisible()}");
|
||||
var offset = 40f;
|
||||
var tracker = Locator.GetQuantumMoon().GetValue<ShapeVisibilityTracker>("_visibilityTracker");
|
||||
foreach (var camera in QSBPlayerManager.GetPlayerCameras())
|
||||
{
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"{camera.name} : {tracker.GetType().GetMethod("IsInFrustum", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(tracker, new object[] { camera.GetFrustumPlanes() })}");
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"- {camera.name} : {tracker.GetType().GetMethod("IsInFrustum", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(tracker, new object[] { camera.GetFrustumPlanes() })}");
|
||||
offset += 30f;
|
||||
}
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"Entangled with QM : {Locator.GetQuantumMoon().IsPlayerEntangled()}");
|
||||
offset += 30f;
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"Inside QM : {Locator.GetQuantumMoon().IsPlayerInside()}");
|
||||
offset += 30f;
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"QM illuminated : {Locator.GetQuantumMoon().IsIlluminated()}");
|
||||
offset += 30f;
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"QM locked : {Locator.GetQuantumMoon().IsLocked()}");
|
||||
offset += 30f;
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"Entangled with Shrine : {Shrine.IsPlayerEntangled()}");
|
||||
offset += 30f;
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"Player in darkness : {Shrine.IsPlayerInDarkness()}");
|
||||
offset += 30f;
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"Shrine fade fraction : {Shrine.GetValue<float>("_fadeFraction")}");
|
||||
|
||||
offset = 10f;
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"Players in QM :");
|
||||
offset += 30f;
|
||||
foreach (var player in QSBPlayerManager.PlayerList.Where(x => x.IsInMoon))
|
||||
{
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"- {player.PlayerId}");
|
||||
offset += 30f;
|
||||
}
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"Players in Shrine :");
|
||||
offset += 30f;
|
||||
foreach (var player in QSBPlayerManager.PlayerList.Where(x => x.IsInShrine))
|
||||
{
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"- {player.PlayerId}");
|
||||
offset += 30f;
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,11 @@ namespace QSB.Tools
|
||||
private Transform _root;
|
||||
private Transform _basePivot;
|
||||
private Transform _wobblePivot;
|
||||
|
||||
private bool _flashlightOn;
|
||||
private Vector3 _baseForward;
|
||||
private Quaternion _baseRotation;
|
||||
|
||||
public bool FlashlightOn;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_baseForward = _basePivot.forward;
|
||||
@ -33,7 +33,7 @@ namespace QSB.Tools
|
||||
light.GetLight().enabled = false;
|
||||
light.GetLight().shadows = LightShadows.Soft;
|
||||
}
|
||||
_flashlightOn = false;
|
||||
FlashlightOn = false;
|
||||
}
|
||||
|
||||
public void UpdateState(bool value)
|
||||
@ -50,7 +50,7 @@ namespace QSB.Tools
|
||||
|
||||
private void TurnOn()
|
||||
{
|
||||
if (_flashlightOn)
|
||||
if (FlashlightOn)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -58,7 +58,7 @@ namespace QSB.Tools
|
||||
{
|
||||
light.GetLight().enabled = true;
|
||||
}
|
||||
_flashlightOn = true;
|
||||
FlashlightOn = true;
|
||||
var rotation = _root.rotation;
|
||||
_basePivot.rotation = rotation;
|
||||
_baseRotation = rotation;
|
||||
@ -67,7 +67,7 @@ namespace QSB.Tools
|
||||
|
||||
private void TurnOff()
|
||||
{
|
||||
if (!_flashlightOn)
|
||||
if (!FlashlightOn)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -75,7 +75,7 @@ namespace QSB.Tools
|
||||
{
|
||||
light.GetLight().enabled = false;
|
||||
}
|
||||
_flashlightOn = false;
|
||||
FlashlightOn = false;
|
||||
}
|
||||
|
||||
public void FixedUpdate()
|
||||
|
@ -1,5 +1,4 @@
|
||||
using QSB.Utility;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Popcron
|
||||
{
|
||||
@ -16,16 +15,16 @@ namespace Popcron
|
||||
|
||||
//bottom left
|
||||
buffer[0] = camera.ScreenToWorldPoint(new Vector3(0, 0, camera.nearClipPlane));
|
||||
buffer[1] = camera.ScreenToWorldPoint(new Vector3(0, 0, camera.farClipPlane/2));
|
||||
buffer[1] = camera.ScreenToWorldPoint(new Vector3(0, 0, camera.farClipPlane / 2));
|
||||
//bottom right
|
||||
buffer[2] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, 0, camera.nearClipPlane));
|
||||
buffer[3] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, 0, camera.farClipPlane/2));
|
||||
buffer[3] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, 0, camera.farClipPlane / 2));
|
||||
//top left
|
||||
buffer[4] = camera.ScreenToWorldPoint(new Vector3(0, camera.pixelHeight, camera.nearClipPlane));
|
||||
buffer[5] = camera.ScreenToWorldPoint(new Vector3(0, camera.pixelHeight, camera.farClipPlane/2));
|
||||
buffer[5] = camera.ScreenToWorldPoint(new Vector3(0, camera.pixelHeight, camera.farClipPlane / 2));
|
||||
//top right
|
||||
buffer[6] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, camera.pixelHeight, camera.nearClipPlane));
|
||||
buffer[7] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, camera.pixelHeight, camera.farClipPlane/2));
|
||||
buffer[7] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, camera.pixelHeight, camera.farClipPlane / 2));
|
||||
//bottom left to bottom right
|
||||
buffer[8] = camera.ScreenToWorldPoint(new Vector3(0, 0, camera.farClipPlane / 2));
|
||||
buffer[9] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, 0, camera.farClipPlane / 2));
|
||||
|
@ -148,10 +148,7 @@ namespace Popcron
|
||||
/// <summary>
|
||||
/// Draws an array of lines. Useful for things like paths.
|
||||
/// </summary>
|
||||
public static void Lines(Vector3[] lines, Color? color = null, bool dashed = false)
|
||||
{
|
||||
GizmosInstance.Submit(lines, color, dashed);
|
||||
}
|
||||
public static void Lines(Vector3[] lines, Color? color = null, bool dashed = false) => GizmosInstance.Submit(lines, color, dashed);
|
||||
|
||||
/// <summary>
|
||||
/// Draw line in world space.
|
||||
|
@ -1,4 +1,3 @@
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -140,10 +139,7 @@ namespace Popcron
|
||||
Camera.onPostRender += OnRendered;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Camera.onPostRender -= OnRendered;
|
||||
}
|
||||
private void OnDisable() => Camera.onPostRender -= OnRendered;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ namespace QSB.WorldSync
|
||||
}
|
||||
if (ShipLogFacts.Any(x => x.Id == id))
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Fact with id {id} already exists in list!", MessageType.Warning);
|
||||
DebugLog.ToConsole($"Warning - Fact id {id} already in list!", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
ShipLogFacts.Add(new FactReveal
|
||||
|
Loading…
x
Reference in New Issue
Block a user