Merge branch 'dev' into fix-default-sector

This commit is contained in:
Mister_Nebula 2020-08-14 12:57:38 +01:00
commit f09711a4de
8 changed files with 64 additions and 50 deletions

View File

@ -41,7 +41,7 @@ namespace QSB
public void UpdateStateObjects() public void UpdateStateObjects()
{ {
if (!QSB.WokenUp) if (OWInput.GetInputMode() == InputMode.None)
{ {
return; return;
} }

View File

@ -1,7 +1,6 @@
using OWML.Common; using OWML.Common;
using OWML.ModHelper; using OWML.ModHelper;
using QSB.ElevatorSync; using QSB.ElevatorSync;
using QSB.Events;
using QSB.GeyserSync; using QSB.GeyserSync;
using QSB.Utility; using QSB.Utility;
using UnityEngine; using UnityEngine;
@ -14,7 +13,6 @@ namespace QSB
public static IModHelper Helper; public static IModHelper Helper;
public static string DefaultServerIP; public static string DefaultServerIP;
public static bool DebugMode; public static bool DebugMode;
public static bool WokenUp;
private void Awake() private void Awake()
{ {
@ -32,20 +30,6 @@ namespace QSB
gameObject.AddComponent<UnityHelper>(); gameObject.AddComponent<UnityHelper>();
gameObject.AddComponent<ElevatorManager>(); gameObject.AddComponent<ElevatorManager>();
gameObject.AddComponent<GeyserManager>(); gameObject.AddComponent<GeyserManager>();
GlobalMessenger.AddListener(EventNames.RestartTimeLoop, OnLoopStart);
GlobalMessenger.AddListener(EventNames.WakeUp, OnWakeUp);
}
private void OnWakeUp()
{
WokenUp = true;
GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest);
}
private void OnLoopStart()
{
WokenUp = false;
} }
public override void Configure(IModConfig config) public override void Configure(IModConfig config)

View File

@ -97,6 +97,10 @@
<Reference Include="UnityEngine.Networking"> <Reference Include="UnityEngine.Networking">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.Networking.dll</HintPath> <HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.Networking.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath> <HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
@ -129,6 +133,7 @@
<Compile Include="ElevatorSync\ElevatorPatches.cs" /> <Compile Include="ElevatorSync\ElevatorPatches.cs" />
<Compile Include="Events\EventNames.cs" /> <Compile Include="Events\EventNames.cs" />
<Compile Include="DeathSync\PlayerDeathEvent.cs" /> <Compile Include="DeathSync\PlayerDeathEvent.cs" />
<Compile Include="TimeSync\WakeUpPatches.cs" />
<Compile Include="Tools\PlayerFlashlightEvent.cs" /> <Compile Include="Tools\PlayerFlashlightEvent.cs" />
<Compile Include="Events\PlayerJoinEvent.cs" /> <Compile Include="Events\PlayerJoinEvent.cs" />
<Compile Include="Events\PlayerLeaveEvent.cs" /> <Compile Include="Events\PlayerLeaveEvent.cs" />
@ -175,7 +180,7 @@
<Compile Include="TransformSync\PlayerHUDMarker.cs" /> <Compile Include="TransformSync\PlayerHUDMarker.cs" />
<Compile Include="Tools\PlayerToolsManager.cs" /> <Compile Include="Tools\PlayerToolsManager.cs" />
<Compile Include="Utility\Patches.cs" /> <Compile Include="Utility\Patches.cs" />
<Compile Include="Utility\QSBExtensions.cs" /> <Compile Include="Tools\ToolExtensions.cs" />
<Compile Include="Utility\QuaternionHelper.cs" /> <Compile Include="Utility\QuaternionHelper.cs" />
<Compile Include="TimeSync\PreserveTimeScale.cs" /> <Compile Include="TimeSync\PreserveTimeScale.cs" />
<Compile Include="TransformSync\ShipTransformSync.cs" /> <Compile Include="TransformSync\ShipTransformSync.cs" />

View File

@ -127,6 +127,7 @@ namespace QSB
{ {
gameObject.AddComponent<Events.PlayerState>(); gameObject.AddComponent<Events.PlayerState>();
GeyserManager.Instance.EmptyUpdate(); GeyserManager.Instance.EmptyUpdate();
WakeUpPatches.AddPatches();
} }
_canEditName = false; _canEditName = false;

View File

@ -0,0 +1,21 @@
using OWML.ModHelper.Events;
namespace QSB.TimeSync
{
public static class WakeUpPatches
{
public static void AddPatches()
{
QSB.Helper.HarmonyHelper.AddPrefix<PlayerCameraEffectController>("OnStartOfTimeLoop", typeof(WakeUpPatches), nameof(OnStartOfTimeLoopPrefix));
}
public static bool OnStartOfTimeLoopPrefix(ref PlayerCameraEffectController __instance)
{
if (__instance.gameObject.CompareTag("MainCamera") && LoadManager.GetCurrentScene() != OWScene.EyeOfTheUniverse)
{
__instance.Invoke("WakeUp");
}
return false;
}
}
}

View File

@ -1,5 +1,5 @@
using QSB.Events; using OWML.ModHelper.Events;
using QSB.Messaging; using QSB.Events;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
@ -21,6 +21,7 @@ namespace QSB.TimeSync
private float _serverTime; private float _serverTime;
private float _timeScale; private float _timeScale;
private bool _isInputEnabled = true; private bool _isInputEnabled = true;
private bool _isFirstFastForward = true;
private int _localLoopCount; private int _localLoopCount;
private int _serverLoopCount; private int _serverLoopCount;
@ -132,6 +133,7 @@ namespace QSB.TimeSync
} }
_timeScale = MaxFastForwardSpeed; _timeScale = MaxFastForwardSpeed;
_state = State.FastForwarding; _state = State.FastForwarding;
FindObjectOfType<SleepTimerUI>().Invoke("OnStartFastForward");
} }
private void StartPausing() private void StartPausing()
@ -142,6 +144,7 @@ namespace QSB.TimeSync
} }
_timeScale = 0f; _timeScale = 0f;
_state = State.Pausing; _state = State.Pausing;
SpinnerUI.Show();
} }
private void ResetTimeScale() private void ResetTimeScale()
@ -153,6 +156,11 @@ namespace QSB.TimeSync
{ {
EnableInput(); EnableInput();
} }
_isFirstFastForward = false;
Physics.SyncTransforms();
SpinnerUI.Hide();
FindObjectOfType<SleepTimerUI>().Invoke("OnEndFastForward");
GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest);
} }
private void DisableInput() private void DisableInput()
@ -207,6 +215,14 @@ namespace QSB.TimeSync
{ {
var diff = _serverTime - Time.timeSinceLevelLoad; var diff = _serverTime - Time.timeSinceLevelLoad;
Time.timeScale = Mathf.Lerp(MinFastForwardSpeed, MaxFastForwardSpeed, Mathf.Abs(diff) / MaxFastForwardDiff); Time.timeScale = Mathf.Lerp(MinFastForwardSpeed, MaxFastForwardSpeed, Mathf.Abs(diff) / MaxFastForwardDiff);
if (LoadManager.GetCurrentScene() == OWScene.SolarSystem && _isFirstFastForward)
{
var spawnPoint = Locator.GetPlayerBody().GetComponent<PlayerSpawner>().GetInitialSpawnPoint().transform;
Locator.GetPlayerTransform().position = spawnPoint.position;
Locator.GetPlayerTransform().rotation = spawnPoint.rotation;
Physics.SyncTransforms();
}
} }
else else
{ {

View File

@ -0,0 +1,17 @@
namespace QSB.Tools
{
public static class ToolExtensions
{
public static void ChangeEquipState(this PlayerTool tool, bool equipState)
{
if (equipState)
{
tool.EquipTool();
}
else
{
tool.UnequipTool();
}
}
}
}

View File

@ -1,30 +0,0 @@
using UnityEngine;
namespace QSB.Utility
{
public static class QSBExtensions
{
public static void ChangeEquipState(this PlayerTool tool, bool equipState)
{
if (equipState)
{
tool.EquipTool();
}
else
{
tool.UnequipTool();
}
}
public static string GetHierarchy(this GameObject go)
{
var name = go.name;
while (go.transform.parent != null)
{
go = go.transform.parent.gameObject;
name = go.name + "/" + name;
}
return name;
}
}
}