Skip to content

Commit

Permalink
Merge pull request #595 from misternebula/dev
Browse files Browse the repository at this point in the history
0.25.0
  • Loading branch information
misternebula authored Feb 8, 2023
2 parents 548d12f + b4741c6 commit 33bd827
Show file tree
Hide file tree
Showing 47 changed files with 1,070 additions and 739 deletions.
1 change: 0 additions & 1 deletion DevEnv.template.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<GameDir>C:\Program Files\Epic Games\OuterWilds</GameDir>
<OwmlDir>$(AppData)\OuterWildsModManager\OWML</OwmlDir>
<UnityAssetsDir>$(SolutionDir)\qsb-unityproject\Assets</UnityAssetsDir>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public static bool Update(GhostPartyPathDirector __instance)
var ghostBrain = __instance._dispatchedGhosts[i].GetWorldObject<QSBGhostBrain>();
if (ghostBrain.GetCurrentActionName() == GhostAction.Name.PartyPath)
{
// BUG: breaks on client cuz cast
var partyPathAction = (QSBPartyPathAction)ghostBrain.GetCurrentAction();
if (partyPathAction.hasReachedEndOfPath)
{
Expand Down Expand Up @@ -105,7 +104,6 @@ public static bool Update(GhostPartyPathDirector __instance)
var num = Random.Range(0, __instance._ghostSpawns.Length);
ghostBrain2.AttachedObject.transform.position = __instance._ghostSpawns[num].spawnTransform.position;
ghostBrain2.AttachedObject.transform.eulerAngles = Vector3.up * __instance._ghostSpawns[num].spawnTransform.eulerAngles.y;
// BUG: breaks on client cuz cast
((QSBPartyPathAction)ghostBrain2.GetCurrentAction()).StartFollowPath();
__instance._ghostSpawns[num].spawnDoor.Open();
__instance._ghostSpawns[num].spawnDoorTimer = Time.timeSinceLevelLoad + 4f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ public static bool OnLightsExtinguished(GhostZone2Director __instance)
DebugLog.DebugWrite($"- fade light down");
QSBGhostZone2Director.ElevatorsStatus[j].elevatorPair.elevator.topLight.FadeTo(0f, 0.2f);
DebugLog.DebugWrite($"- get action");
// BUG: breaks on client cuz cast
QSBGhostZone2Director.ElevatorsStatus[j].elevatorAction = (QSBElevatorWalkAction)__instance._elevators[j].ghost.GetWorldObject<QSBGhostBrain>().GetAction(GhostAction.Name.ElevatorWalk);
DebugLog.DebugWrite($"- CallToUseElevator on action");
QSBGhostZone2Director.ElevatorsStatus[j].elevatorAction.CallToUseElevator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ protected override void ApplyToAttached()

playerBody.SetPosition(AttachedTransform.FromRelPos(relPos));
playerBody.SetRotation(AttachedTransform.FromRelRot(relRot));

if (!Physics.autoSyncTransforms)
{
Physics.SyncTransforms();
}
}
}
else
Expand Down
4 changes: 4 additions & 0 deletions QSB/Messaging/OWEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ public static class OWEvents
public const string StartShipIgnition = nameof(StartShipIgnition);
public const string CompleteShipIgnition = nameof(CompleteShipIgnition);
public const string CancelShipIgnition = nameof(CancelShipIgnition);
public const string ProbeEnterQuantumMoon = nameof(ProbeEnterQuantumMoon);
public const string ProbeExitQuantumMoon = nameof(ProbeExitQuantumMoon);
public const string EnterCloak = nameof(EnterCloak);
public const string ExitCloak = nameof(ExitCloak);
}
2 changes: 2 additions & 0 deletions QSB/Player/EnterLeaveType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ public enum EnterLeaveType
ExitPlatform,
EnterShip,
ExitShip,
EnterCloak,
ExitCloak
}
8 changes: 8 additions & 0 deletions QSB/Player/Messages/EnterLeaveMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ static EnterLeaveMessage()
GlobalMessenger.AddListener(OWEvents.PlayerExitQuantumMoon, () => Handler(EnterLeaveType.ExitMoon));
GlobalMessenger.AddListener(OWEvents.EnterShip, () => Handler(EnterLeaveType.EnterShip));
GlobalMessenger.AddListener(OWEvents.ExitShip, () => Handler(EnterLeaveType.ExitShip));
GlobalMessenger.AddListener(OWEvents.EnterCloak, () => Handler(EnterLeaveType.EnterCloak));
GlobalMessenger.AddListener(OWEvents.ExitCloak, () => Handler(EnterLeaveType.ExitCloak));
}

private static void Handler(EnterLeaveType type, int objectId = -1)
Expand Down Expand Up @@ -62,6 +64,12 @@ public override void OnReceiveRemote()
case EnterLeaveType.ExitMoon:
player.IsInMoon = false;
break;
case EnterLeaveType.EnterCloak:
player.IsInCloak = true;
break;
case EnterLeaveType.ExitCloak:
player.IsInCloak = false;
break;
case EnterLeaveType.EnterPlatform:
CustomNomaiRemoteCameraPlatform.CustomPlatformList[ObjectId]
.OnRemotePlayerEnter(From);
Expand Down
13 changes: 13 additions & 0 deletions QSB/Player/Messages/PlayerInformationMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class PlayerInformationMessage : QSBMessage
private bool TranslatorEquipped;
private bool ProbeActive;
private ClientState ClientState;
private float FieldOfView;
private bool IsInShip;

public PlayerInformationMessage()
{
Expand All @@ -30,6 +32,8 @@ public PlayerInformationMessage()
TranslatorEquipped = player.TranslatorEquipped;
ProbeActive = player.ProbeActive;
ClientState = player.State;
FieldOfView = PlayerData.GetGraphicSettings().fieldOfView;
IsInShip = player.IsInShip;
}

public override void Serialize(NetworkWriter writer)
Expand All @@ -44,6 +48,8 @@ public override void Serialize(NetworkWriter writer)
writer.Write(TranslatorEquipped);
writer.Write(ProbeActive);
writer.Write(ClientState);
writer.Write(FieldOfView);
writer.Write(IsInShip);
}

public override void Deserialize(NetworkReader reader)
Expand All @@ -58,6 +64,8 @@ public override void Deserialize(NetworkReader reader)
TranslatorEquipped = reader.Read<bool>();
ProbeActive = reader.Read<bool>();
ClientState = reader.Read<ClientState>();
FieldOfView = reader.ReadFloat();
IsInShip = reader.ReadBool();
}

public override void OnReceiveRemote()
Expand All @@ -74,11 +82,16 @@ public override void OnReceiveRemote()
player.SignalscopeEquipped = SignalscopeEquipped;
player.TranslatorEquipped = TranslatorEquipped;
player.ProbeActive = ProbeActive;
player.IsInShip = IsInShip;
if (QSBPlayerManager.LocalPlayer.IsReady && player.IsReady)
{
player.UpdateObjectsFromStates();
}

Delay.RunWhen(
() => player.Camera != null,
() => player.Camera.fieldOfView = FieldOfView);

player.State = ClientState;
}
else
Expand Down
20 changes: 20 additions & 0 deletions QSB/Player/Messages/UpdateFOVMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using QSB.Messaging;
using QSB.Utility;

namespace QSB.Player.Messages;

internal class UpdateFOVMessage : QSBMessage<float>
{
static UpdateFOVMessage()
=> GlobalMessenger<GraphicSettings>.AddListener(
"GraphicSettingsUpdated",
(GraphicSettings settings) => new UpdateFOVMessage(settings.fieldOfView).Send());

private UpdateFOVMessage(float fov) : base(fov) { }

public override void OnReceiveRemote()
{
var player = QSBPlayerManager.GetPlayer(From);
player.Camera.fieldOfView = Data;
}
}
2 changes: 2 additions & 0 deletions QSB/Player/PlayerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public partial class PlayerInfo
public bool IsInMoon { get; set; }
public bool IsInShrine { get; set; }
public bool IsInEyeShuttle { get; set; }
public bool IsInShip { get; set; }
public bool IsInCloak { get; set; }
public IQSBQuantumObject EntangledObject { get; set; }
public QSBPlayerAudioController AudioController { get; set; }
public bool IsLocalPlayer => TransformSync.isLocalPlayer; // if TransformSync is ever null, i give permission for nebula to make fun of me about it for the rest of time - johncorby
Expand Down
15 changes: 15 additions & 0 deletions QSB/QuantumSync/Patches/Client/ClientEyeProxyQuantumMoonPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using HarmonyLib;
using QSB.Patches;

namespace QSB.QuantumSync.Patches.Client;

[HarmonyPatch(typeof(EyeProxyQuantumMoon))]
internal class ClientEyeProxyQuantumMoonPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnNonServerClientConnect;

[HarmonyPrefix]
[HarmonyPatch(nameof(EyeProxyQuantumMoon.ChangeQuantumState))]
public static bool ChangeQuantumState()
=> false;
}
20 changes: 20 additions & 0 deletions QSB/QuantumSync/Patches/Client/ClientQuantumMoonPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using HarmonyLib;
using QSB.Patches;

namespace QSB.QuantumSync.Patches.Client;

[HarmonyPatch(typeof(QuantumMoon))]
internal class ClientQuantumMoonPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnNonServerClientConnect;

[HarmonyPostfix]
[HarmonyPatch(nameof(QuantumMoon.Start))]
public static void Start(QuantumMoon __instance)
=> __instance.SetSurfaceState(-1);

[HarmonyPrefix]
[HarmonyPatch(nameof(QuantumMoon.ChangeQuantumState))]
public static bool ChangeQuantumState()
=> false;
}
25 changes: 0 additions & 25 deletions QSB/QuantumSync/Patches/ClientQuantumPatches.cs

This file was deleted.

68 changes: 68 additions & 0 deletions QSB/QuantumSync/Patches/Common/MultiStateQuantumObjectPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using HarmonyLib;
using QSB.Patches;
using QSB.Player;
using QSB.QuantumSync.WorldObjects;
using QSB.WorldSync;

namespace QSB.QuantumSync.Patches.Common;

[HarmonyPatch(typeof(MultiStateQuantumObject))]
public class MultiStateQuantumObjectPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;

[HarmonyPrefix]
[HarmonyPatch(nameof(MultiStateQuantumObject.Start))]
public static bool Start(MultiStateQuantumObject __instance)
{
if (!QSBWorldSync.AllObjectsReady)
{
return true;
}

var qsbObj = __instance.GetWorldObject<QSBMultiStateQuantumObject>();
if (qsbObj.ControllingPlayer == 0)
{
return true;
}

foreach (var state in qsbObj.QuantumStates)
{
if (!state.IsMeantToBeEnabled)
{
state.SetVisible(false);
}
}

if (__instance._sector == null)
{
__instance.CheckEnabled();
}

if (__instance._collapseOnStart)
{
__instance.Collapse(true);
}

return false;
}

[HarmonyPrefix]
[HarmonyPatch(nameof(MultiStateQuantumObject.ChangeQuantumState))]
public static bool ChangeQuantumState(MultiStateQuantumObject __instance)
{
if (!QSBWorldSync.AllObjectsReady)
{
return true;
}

var qsbObj = __instance.GetWorldObject<QSBMultiStateQuantumObject>();
if (qsbObj.ControllingPlayer == 0 && qsbObj.CurrentState == -1)
{
return true;
}

var isInControl = qsbObj.ControllingPlayer == QSBPlayerManager.LocalPlayerId;
return isInControl;
}
}
Loading

0 comments on commit 33bd827

Please sign in to comment.