renamed "direction" to "isGoingUp"

This commit is contained in:
Mister_Nebula 2020-11-11 08:31:20 +00:00
parent f701577074
commit ceb3b77d6b
6 changed files with 100 additions and 20 deletions

View File

@ -12,11 +12,11 @@ namespace QSB.ElevatorSync.Events
public override void CloseListener() => GlobalMessenger<int, bool>.RemoveListener(EventNames.QSBStartLift, Handler);
private void Handler(int id, bool direction) => SendEvent(CreateMessage(id, direction));
private void Handler(int id, bool isGoingUp) => SendEvent(CreateMessage(id, isGoingUp));
private BoolWorldObjectMessage CreateMessage(int id, bool direction) => new BoolWorldObjectMessage
private BoolWorldObjectMessage CreateMessage(int id, bool isGoingUp) => new BoolWorldObjectMessage
{
State = direction,
State = isGoingUp,
ObjectId = id
};

View File

@ -30,15 +30,14 @@ namespace QSB.ElevatorSync
_owAudioSourceLP = _elevator.GetValue<OWAudioSource>("_owAudioSourceLP");
}
public void RemoteCall(bool direction)
public void RemoteCall(bool isGoingUp)
{
SetDirection(direction);
SetDirection(isGoingUp);
RemoteStartLift();
}
private void SetDirection(bool direction)
private void SetDirection(bool isGoingUp)
{
var isGoingUp = direction;
var targetPos = isGoingUp ? _endLocalPos : _startLocalPos;
_elevator.SetValue("_goingToTheEnd", isGoingUp);
_elevator.SetValue("_targetLocalPos", targetPos);

View File

@ -2,6 +2,7 @@
using QSB.EventsCore;
using QSB.Instruments.QSBCamera;
using QSB.Player;
using QSB.Utility;
using UnityEngine;
namespace QSB.Instruments
@ -15,24 +16,44 @@ namespace QSB.Instruments
{
Instance = this;
gameObject.AddComponent<CameraManager>();
QSBInputManager.ChertTaunt += () => StartInstrument(AnimationType.Chert);
QSBInputManager.EskerTaunt += () => StartInstrument(AnimationType.Esker);
QSBInputManager.FeldsparTaunt += () => StartInstrument(AnimationType.Feldspar);
QSBInputManager.GabbroTaunt += () => StartInstrument(AnimationType.Gabbro);
QSBInputManager.RiebeckTaunt += () => StartInstrument(AnimationType.Riebeck);
QSBInputManager.SolanumTaunt += () => StartInstrument(AnimationType.Solanum);
}
private void Update()
private void OnDestroy()
{
if (Input.GetKeyDown(KeyCode.Keypad9))
QSBInputManager.ChertTaunt -= () => StartInstrument(AnimationType.Chert);
QSBInputManager.EskerTaunt -= () => StartInstrument(AnimationType.Esker);
QSBInputManager.FeldsparTaunt -= () => StartInstrument(AnimationType.Feldspar);
QSBInputManager.GabbroTaunt -= () => StartInstrument(AnimationType.Gabbro);
QSBInputManager.RiebeckTaunt -= () => StartInstrument(AnimationType.Riebeck);
QSBInputManager.SolanumTaunt -= () => StartInstrument(AnimationType.Solanum);
}
public void StartInstrument(AnimationType type)
{
if (QSBPlayerManager.LocalPlayer.PlayingInstrument)
{
if (!QSBPlayerManager.LocalPlayer.PlayingInstrument)
{
_savedType = QSBPlayerManager.LocalPlayer.Animator.CurrentType;
CameraManager.Instance.SwitchTo3rdPerson();
SwitchToType(AnimationType.Chert);
}
else
{
CameraManager.Instance.SwitchTo1stPerson();
SwitchToType(_savedType);
}
return;
}
_savedType = QSBPlayerManager.LocalPlayer.Animator.CurrentType;
CameraManager.Instance.SwitchTo3rdPerson();
SwitchToType(type);
}
public void ReturnToPlayer()
{
if (!QSBPlayerManager.LocalPlayer.PlayingInstrument)
{
return;
}
CameraManager.Instance.SwitchTo1stPerson();
SwitchToType(_savedType);
}
public void SwitchToType(AnimationType type)

View File

@ -16,6 +16,7 @@ namespace QSB
{
public class QSB : ModBehaviour
{
public static IModBehaviour ModBehaviour { get; private set; }
public static IModHelper Helper { get; private set; }
public static string DefaultServerIP { get; private set; }
public static int Port { get; private set; }
@ -30,6 +31,8 @@ namespace QSB
var instance = TextTranslation.Get().GetValue<TextTranslation.TranslationTable>("m_table");
instance.theUITable[(int)UITextType.PleaseUseController] =
"<color=orange>Quantum Space Buddies</color> is best experienced with friends...";
ModBehaviour = this;
}
private void Start()
@ -55,6 +58,7 @@ namespace QSB
gameObject.AddComponent<QSBSectorManager>();
gameObject.AddComponent<ConversationManager>();
gameObject.AddComponent<InstrumentsManager>();
gameObject.AddComponent<QSBInputManager>();
Helper.Events.Unity.RunWhen(() => PlayerData.IsLoaded(), RebuildSettingsSave);
}

View File

@ -163,6 +163,7 @@
<Compile Include="Patches\QSBPatchManager.cs" />
<Compile Include="Player\Events\ServerSendPlayerStatesEvent.cs" />
<Compile Include="Player\PlayerSyncObject.cs" />
<Compile Include="QSBInputManager.cs" />
<Compile Include="QSBNetworkLobby.cs" />
<Compile Include="Patches\QSBPatch.cs" />
<Compile Include="Patches\QSBPatchTypes.cs" />

55
QSB/QSBInputManager.cs Normal file
View File

@ -0,0 +1,55 @@
using OWML.Common;
using QSB.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace QSB
{
public delegate void TauntEvent();
public class QSBInputManager : MonoBehaviour
{
public static QSBInputManager Instance;
public static event TauntEvent ChertTaunt;
public static event TauntEvent EskerTaunt;
public static event TauntEvent FeldsparTaunt;
public static event TauntEvent GabbroTaunt;
public static event TauntEvent RiebeckTaunt;
public static event TauntEvent SolanumTaunt;
public void Awake()
{
Instance = this;
if (Input.GetKeyDown(KeyCode.T))
{
if (Input.GetKeyDown(KeyCode.Alpha1))
{
ChertTaunt?.Invoke();
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
EskerTaunt?.Invoke();
}
if (Input.GetKeyDown(KeyCode.Alpha3))
{
FeldsparTaunt?.Invoke();
}
if (Input.GetKeyDown(KeyCode.Alpha4))
{
GabbroTaunt?.Invoke();
}
if (Input.GetKeyDown(KeyCode.Alpha5))
{
RiebeckTaunt?.Invoke();
}
if (Input.GetKeyDown(KeyCode.Alpha6))
{
SolanmTaunt?.Invoke();
}
}
}
}
}