Merge pull request #169 from Raicuparta/alek/fast-forward-clock

showing clock when fast forwarding
This commit is contained in:
Mister_Nebula 2020-08-14 11:06:59 +01:00 committed by GitHub
commit d159733fb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 54 deletions

View File

@ -1,7 +1,6 @@
using OWML.Common;
using OWML.ModHelper;
using QSB.ElevatorSync;
using QSB.Events;
using QSB.GeyserSync;
using QSB.Utility;
using UnityEngine;

View File

@ -180,7 +180,7 @@
<Compile Include="TransformSync\PlayerHUDMarker.cs" />
<Compile Include="Tools\PlayerToolsManager.cs" />
<Compile Include="Utility\Patches.cs" />
<Compile Include="Utility\QSBExtensions.cs" />
<Compile Include="Tools\ToolExtensions.cs" />
<Compile Include="Utility\QuaternionHelper.cs" />
<Compile Include="TimeSync\PreserveTimeScale.cs" />
<Compile Include="TransformSync\ShipTransformSync.cs" />

View File

@ -1,8 +1,4 @@
using QSB.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OWML.ModHelper.Events;
namespace QSB.TimeSync
{
@ -10,14 +6,14 @@ namespace QSB.TimeSync
{
public static void AddPatches()
{
QSB.Helper.HarmonyHelper.AddPrefix<PlayerCameraEffectController>("OnStartOfTimeLoop", typeof(WakeUpPatches), nameof(WakeUpPatches.OnStartOfTimeLoopPrefix));
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.Call("WakeUp");
__instance.Invoke("WakeUp");
}
return false;
}

View File

@ -1,5 +1,5 @@
using QSB.Events;
using QSB.Messaging;
using OWML.ModHelper.Events;
using QSB.Events;
using UnityEngine;
using UnityEngine.Networking;
@ -133,7 +133,7 @@ namespace QSB.TimeSync
}
_timeScale = MaxFastForwardSpeed;
_state = State.FastForwarding;
SpinnerUI.Show();
FindObjectOfType<SleepTimerUI>().Invoke("OnStartFastForward");
}
private void StartPausing()
@ -159,6 +159,7 @@ namespace QSB.TimeSync
_isFirstFastForward = false;
Physics.SyncTransforms();
SpinnerUI.Hide();
FindObjectOfType<SleepTimerUI>().Invoke("OnEndFastForward");
GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest);
}
@ -217,8 +218,9 @@ namespace QSB.TimeSync
if (LoadManager.GetCurrentScene() == OWScene.SolarSystem && _isFirstFastForward)
{
Locator.GetPlayerTransform().position = Locator.GetPlayerBody().GetComponent<PlayerSpawner>().GetInitialSpawnPoint().transform.position;
Locator.GetPlayerTransform().rotation = Locator.GetPlayerBody().GetComponent<PlayerSpawner>().GetInitialSpawnPoint().transform.rotation;
var spawnPoint = Locator.GetPlayerBody().GetComponent<PlayerSpawner>().GetInitialSpawnPoint().transform;
Locator.GetPlayerTransform().position = spawnPoint.position;
Locator.GetPlayerTransform().rotation = spawnPoint.rotation;
Physics.SyncTransforms();
}
}

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,40 +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;
}
public static object Call(this object obj, string methodName, params object[] args)
{
var method = obj.GetType().GetMethod(methodName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (method != null)
{
return method.Invoke(obj, args);
}
return null;
}
}
}