mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-10 12:39:53 +00:00
stuff
This commit is contained in:
parent
9d4a205ead
commit
d6e459b494
@ -45,5 +45,6 @@
|
||||
public static string QSBIdentifyFrequency = "QSBIdentifyFrequency";
|
||||
public static string QSBIdentifySignal = "QSBIdentifySignal";
|
||||
public static string QSBTextTranslated = "QSBTextTranslated";
|
||||
public static string QSBShrineRotation = "QSBShrineRotation";
|
||||
}
|
||||
}
|
@ -32,6 +32,7 @@
|
||||
MoonStateChange,
|
||||
IdentifyFrequency,
|
||||
IdentifySignal,
|
||||
TextTranslated
|
||||
TextTranslated,
|
||||
ShrineRotation
|
||||
}
|
||||
}
|
@ -53,6 +53,7 @@ namespace QSB.Events
|
||||
new SetAsTranslatedEvent(),
|
||||
new QuantumShuffleEvent(),
|
||||
new MoonStateChangeEvent(),
|
||||
new ShrineRotationEvent(),
|
||||
// Conversation/dialogue/exploration
|
||||
new ConversationEvent(),
|
||||
new ConversationStartEndEvent(),
|
||||
|
@ -156,6 +156,8 @@
|
||||
<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\Events\MultiStateChangeEvent.cs" />
|
||||
<Compile Include="QuantumSync\Events\MultiStateChangeMessage.cs" />
|
||||
|
34
QSB/QuantumSync/Events/ShrineRotationEvent.cs
Normal file
34
QSB/QuantumSync/Events/ShrineRotationEvent.cs
Normal file
@ -0,0 +1,34 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
27
QSB/QuantumSync/Events/ShrineRotationMessage.cs
Normal file
27
QSB/QuantumSync/Events/ShrineRotationMessage.cs
Normal file
@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ namespace QSB.QuantumSync.Patches
|
||||
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));
|
||||
}
|
||||
|
||||
public static bool ReturnFalsePatch() => false;
|
||||
|
@ -2,6 +2,7 @@
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
using QSB.QuantumSync.WorldObjects;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -22,6 +23,8 @@ namespace QSB.QuantumSync.Patches
|
||||
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));
|
||||
}
|
||||
|
||||
public static void Socketed_MoveToSocket(SocketedQuantumObject __instance, QuantumSocket socket)
|
||||
@ -286,7 +289,7 @@ namespace QSB.QuantumSync.Patches
|
||||
else
|
||||
{
|
||||
var vector = Locator.GetPlayerTransform().position - __instance.transform.position;
|
||||
Locator.GetPlayerBody().SetVelocity(____moonBody.GetPointVelocity(Locator.GetPlayerTransform().position) - vector.normalized * 5f);
|
||||
Locator.GetPlayerBody().SetVelocity(____moonBody.GetPointVelocity(Locator.GetPlayerTransform().position) - (vector.normalized * 5f));
|
||||
var d = (!____hasSunCollapsed) ? (____fogRadius - 1f) : 80f;
|
||||
Locator.GetPlayerBody().SetPosition(__instance.transform.position + (____vortexReturnPivot.up * d));
|
||||
if (!Physics.autoSyncTransforms)
|
||||
@ -306,5 +309,44 @@ namespace QSB.QuantumSync.Patches
|
||||
____shipLandingCamFogBubble.SetFogAlpha(fogAlpha);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Shrine_ChangeQuantumState(QuantumShrine __instance, ref bool __result, bool skipInstantVisibilityCheck)
|
||||
{
|
||||
DebugLog.DebugWrite("Shrine changequantumstate");
|
||||
var baseObject = __instance as SocketedQuantumObject;
|
||||
if (baseObject == null)
|
||||
{
|
||||
DebugLog.DebugWrite("baseobject null");
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user