mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-28 22:13:23 +00:00
remove instrument/taunt stuff
This commit is contained in:
parent
25c6ce5ae1
commit
6d5f4b4807
@ -20,14 +20,8 @@ namespace QSB.Animation.Player
|
|||||||
private PlayerCharacterController _playerController;
|
private PlayerCharacterController _playerController;
|
||||||
private CrouchSync _crouchSync;
|
private CrouchSync _crouchSync;
|
||||||
|
|
||||||
private RuntimeAnimatorController _chertController;
|
|
||||||
//private readonly RuntimeAnimatorController _eskerController;
|
|
||||||
//private readonly RuntimeAnimatorController _feldsparController;
|
|
||||||
//private readonly RuntimeAnimatorController _gabbroController;
|
|
||||||
private RuntimeAnimatorController _riebeckController;
|
|
||||||
|
|
||||||
public AnimatorMirror Mirror { get; private set; }
|
public AnimatorMirror Mirror { get; private set; }
|
||||||
public AnimationType CurrentType { get; set; }
|
public bool InSuitedUpState { get; set; }
|
||||||
public Animator VisibleAnimator { get; private set; }
|
public Animator VisibleAnimator { get; private set; }
|
||||||
public Animator InvisibleAnimator { get; private set; }
|
public Animator InvisibleAnimator { get; private set; }
|
||||||
public NetworkAnimator NetworkAnimator { get; private set; }
|
public NetworkAnimator NetworkAnimator { get; private set; }
|
||||||
@ -37,29 +31,12 @@ namespace QSB.Animation.Player
|
|||||||
InvisibleAnimator = gameObject.GetRequiredComponent<Animator>();
|
InvisibleAnimator = gameObject.GetRequiredComponent<Animator>();
|
||||||
NetworkAnimator = gameObject.GetRequiredComponent<NetworkAnimator>();
|
NetworkAnimator = gameObject.GetRequiredComponent<NetworkAnimator>();
|
||||||
NetworkAnimator.enabled = false;
|
NetworkAnimator.enabled = false;
|
||||||
|
|
||||||
QSBSceneManager.OnUniverseSceneLoaded += OnUniverseSceneLoaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void OnDestroy() => QSBSceneManager.OnUniverseSceneLoaded -= OnUniverseSceneLoaded;
|
|
||||||
|
|
||||||
private void OnUniverseSceneLoaded(OWScene oldScene, OWScene newScene) => LoadControllers();
|
|
||||||
|
|
||||||
private void LoadControllers()
|
|
||||||
{
|
|
||||||
var bundle = QSBCore.InstrumentAssetBundle;
|
|
||||||
_chertController = bundle.LoadAsset("assets/Chert/Traveller_Chert.controller") as RuntimeAnimatorController;
|
|
||||||
_riebeckController = bundle.LoadAsset("assets/Riebeck/Traveller_Riebeck.controller") as RuntimeAnimatorController;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitCommon(Transform modelRoot)
|
private void InitCommon(Transform modelRoot)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (QSBSceneManager.IsInUniverse)
|
|
||||||
{
|
|
||||||
LoadControllers();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modelRoot == null)
|
if (modelRoot == null)
|
||||||
{
|
{
|
||||||
@ -107,7 +84,7 @@ namespace QSB.Animation.Player
|
|||||||
public void InitRemote(Transform body)
|
public void InitRemote(Transform body)
|
||||||
{
|
{
|
||||||
InitCommon(body);
|
InitCommon(body);
|
||||||
SetAnimationType(AnimationType.PlayerUnsuited);
|
SetSuitState(false);
|
||||||
InitCrouchSync();
|
InitCrouchSync();
|
||||||
InitAccelerationSync();
|
InitAccelerationSync();
|
||||||
ThrusterManager.CreateRemotePlayerVFX(Player);
|
ThrusterManager.CreateRemotePlayerVFX(Player);
|
||||||
@ -129,50 +106,24 @@ namespace QSB.Animation.Player
|
|||||||
_crouchSync.Init(_playerController, VisibleAnimator);
|
_crouchSync.Init(_playerController, VisibleAnimator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SuitUp()
|
public void SetSuitState(bool suitedUp)
|
||||||
{
|
|
||||||
if (Player == QSBPlayerManager.LocalPlayer)
|
|
||||||
{
|
|
||||||
new ChangeAnimTypeMessage(AnimationType.PlayerSuited).Send();
|
|
||||||
}
|
|
||||||
|
|
||||||
SetAnimationType(AnimationType.PlayerSuited);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SuitDown()
|
|
||||||
{
|
|
||||||
if (Player == QSBPlayerManager.LocalPlayer)
|
|
||||||
{
|
|
||||||
new ChangeAnimTypeMessage(AnimationType.PlayerUnsuited).Send();
|
|
||||||
}
|
|
||||||
|
|
||||||
SetAnimationType(AnimationType.PlayerUnsuited);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSuitState(bool state)
|
|
||||||
{
|
{
|
||||||
if (!Player.IsReady)
|
if (!Player.IsReady)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state)
|
if (Player == QSBPlayerManager.LocalPlayer)
|
||||||
{
|
{
|
||||||
SuitUp();
|
new PlayerSuitMessage(suitedUp).Send();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SuitDown();
|
if (InSuitedUpState == suitedUp)
|
||||||
}
|
|
||||||
|
|
||||||
public void SetAnimationType(AnimationType type)
|
|
||||||
{
|
|
||||||
if (CurrentType == type)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentType = type;
|
InSuitedUpState = suitedUp;
|
||||||
if (_unsuitedAnimController == null)
|
if (_unsuitedAnimController == null)
|
||||||
{
|
{
|
||||||
DebugLog.ToConsole($"Error - Unsuited controller is null. ({PlayerId})", MessageType.Error);
|
DebugLog.ToConsole($"Error - Unsuited controller is null. ({PlayerId})", MessageType.Error);
|
||||||
@ -193,56 +144,15 @@ namespace QSB.Animation.Player
|
|||||||
DebugLog.ToConsole($"Warning - _suitedGraphics is null! ({PlayerId})", MessageType.Warning);
|
DebugLog.ToConsole($"Warning - _suitedGraphics is null! ({PlayerId})", MessageType.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeAnimatorController controller = default;
|
var controller = suitedUp ? _suitedAnimController : _unsuitedAnimController;
|
||||||
switch (type)
|
if (_unsuitedGraphics != null)
|
||||||
{
|
{
|
||||||
case AnimationType.PlayerSuited:
|
_unsuitedGraphics?.SetActive(!suitedUp);
|
||||||
controller = _suitedAnimController;
|
}
|
||||||
if (_unsuitedGraphics != null)
|
|
||||||
{
|
|
||||||
_unsuitedGraphics?.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_suitedGraphics != null)
|
if (_suitedGraphics != null)
|
||||||
{
|
{
|
||||||
_suitedGraphics?.SetActive(true);
|
_suitedGraphics?.SetActive(suitedUp);
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AnimationType.PlayerUnsuited:
|
|
||||||
controller = _unsuitedAnimController;
|
|
||||||
if (_unsuitedGraphics != null)
|
|
||||||
{
|
|
||||||
_unsuitedGraphics?.SetActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_suitedGraphics != null)
|
|
||||||
{
|
|
||||||
_suitedGraphics?.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AnimationType.Chert:
|
|
||||||
controller = _chertController;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AnimationType.Esker:
|
|
||||||
//controller = _eskerController;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AnimationType.Feldspar:
|
|
||||||
//controller = _feldsparController;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AnimationType.Gabbro:
|
|
||||||
//controller = _gabbroController;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AnimationType.Riebeck:
|
|
||||||
controller = _riebeckController;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InvisibleAnimator == null)
|
if (InvisibleAnimator == null)
|
||||||
@ -263,30 +173,15 @@ namespace QSB.Animation.Player
|
|||||||
VisibleAnimator.runtimeAnimatorController = controller;
|
VisibleAnimator.runtimeAnimatorController = controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type is not AnimationType.PlayerSuited and not AnimationType.PlayerUnsuited)
|
// Avoids "jumping" when putting on suit
|
||||||
|
if (VisibleAnimator != null)
|
||||||
{
|
{
|
||||||
if (VisibleAnimator != null)
|
VisibleAnimator.SetTrigger("Grounded");
|
||||||
{
|
|
||||||
VisibleAnimator.SetTrigger("Playing");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InvisibleAnimator != null)
|
|
||||||
{
|
|
||||||
InvisibleAnimator.SetTrigger("Playing");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Avoids "jumping" when exiting instrument and putting on suit
|
|
||||||
if (VisibleAnimator != null)
|
|
||||||
{
|
|
||||||
VisibleAnimator.SetTrigger("Grounded");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InvisibleAnimator != null)
|
if (InvisibleAnimator != null)
|
||||||
{
|
{
|
||||||
InvisibleAnimator.SetTrigger("Grounded");
|
InvisibleAnimator.SetTrigger("Grounded");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NetworkAnimator == null)
|
if (NetworkAnimator == null)
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
namespace QSB.Animation.Player
|
|
||||||
{
|
|
||||||
public enum AnimationType
|
|
||||||
{
|
|
||||||
Chert,
|
|
||||||
Esker,
|
|
||||||
Feldspar,
|
|
||||||
Gabbro,
|
|
||||||
PlayerSuited,
|
|
||||||
PlayerUnsuited,
|
|
||||||
Riebeck
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
using QSB.Messaging;
|
|
||||||
using QSB.Player;
|
|
||||||
using QSB.WorldSync;
|
|
||||||
|
|
||||||
namespace QSB.Animation.Player.Messages
|
|
||||||
{
|
|
||||||
public class ChangeAnimTypeMessage : QSBMessage<AnimationType>
|
|
||||||
{
|
|
||||||
public ChangeAnimTypeMessage(AnimationType type) => Value = type;
|
|
||||||
|
|
||||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
|
||||||
|
|
||||||
public override void OnReceiveRemote()
|
|
||||||
{
|
|
||||||
var player = QSBPlayerManager.GetPlayer(From);
|
|
||||||
if (!player.IsReady)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.AnimationSync.SetAnimationType(Value);
|
|
||||||
player.InstrumentsManager.CheckInstrumentProps(Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,7 +21,7 @@ namespace QSB.Animation.Player.Messages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerSuitMessage(bool on) => Value = on;
|
public PlayerSuitMessage(bool on) => Value = on;
|
||||||
|
|
||||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||||
|
|
||||||
@ -36,16 +36,14 @@ namespace QSB.Animation.Player.Messages
|
|||||||
}
|
}
|
||||||
|
|
||||||
var animator = player.AnimationSync;
|
var animator = player.AnimationSync;
|
||||||
var type = Value ? AnimationType.PlayerSuited : AnimationType.PlayerUnsuited;
|
animator.SetSuitState(Value);
|
||||||
animator.SetAnimationType(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnReceiveLocal()
|
public override void OnReceiveLocal()
|
||||||
{
|
{
|
||||||
QSBPlayerManager.LocalPlayer.SuitedUp = Value;
|
QSBPlayerManager.LocalPlayer.SuitedUp = Value;
|
||||||
var animator = QSBPlayerManager.LocalPlayer.AnimationSync;
|
var animator = QSBPlayerManager.LocalPlayer.AnimationSync;
|
||||||
var type = Value ? AnimationType.PlayerSuited : AnimationType.PlayerUnsuited;
|
animator.InSuitedUpState = Value;
|
||||||
animator.CurrentType = type;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,141 +0,0 @@
|
|||||||
using OWML.Common;
|
|
||||||
using QSB.Animation.Player;
|
|
||||||
using QSB.Animation.Player.Messages;
|
|
||||||
using QSB.Instruments.QSBCamera;
|
|
||||||
using QSB.Messaging;
|
|
||||||
using QSB.Player;
|
|
||||||
using QSB.Utility;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace QSB.Instruments
|
|
||||||
{
|
|
||||||
public class InstrumentsManager : PlayerSyncObject
|
|
||||||
{
|
|
||||||
private Transform _rootObj;
|
|
||||||
private AnimationType _savedType;
|
|
||||||
private GameObject _chertDrum;
|
|
||||||
|
|
||||||
public void InitLocal(Transform root)
|
|
||||||
{
|
|
||||||
_rootObj = root;
|
|
||||||
gameObject.AddComponent<CameraManager>();
|
|
||||||
|
|
||||||
//QSBInputManager.ChertTaunt += OnChertTaunt;
|
|
||||||
//QSBInputManager.EskerTaunt += OnEskerTaunt;
|
|
||||||
//QSBInputManager.FeldsparTaunt += OnFeldsparTaunt;
|
|
||||||
//QSBInputManager.GabbroTaunt += OnGabbroTaunt;
|
|
||||||
//QSBInputManager.RiebeckTaunt += OnRiebeckTaunt;
|
|
||||||
//QSBInputManager.ExitTaunt += ReturnToPlayer;
|
|
||||||
|
|
||||||
Delay.RunWhen(() => Locator.GetPlayerBody() != null, SetupInstruments);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitRemote(Transform root)
|
|
||||||
{
|
|
||||||
_rootObj = root;
|
|
||||||
Delay.RunWhen(() => Locator.GetPlayerBody() != null, SetupInstruments);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void OnDestroy()
|
|
||||||
{
|
|
||||||
if (!isLocalPlayer)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//QSBInputManager.ChertTaunt -= OnChertTaunt;
|
|
||||||
//QSBInputManager.EskerTaunt -= OnEskerTaunt;
|
|
||||||
//QSBInputManager.FeldsparTaunt -= OnFeldsparTaunt;
|
|
||||||
//QSBInputManager.GabbroTaunt -= OnGabbroTaunt;
|
|
||||||
//QSBInputManager.RiebeckTaunt -= OnRiebeckTaunt;
|
|
||||||
//QSBInputManager.ExitTaunt -= ReturnToPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnChertTaunt() => StartInstrument(AnimationType.Chert);
|
|
||||||
private void OnEskerTaunt() => StartInstrument(AnimationType.Esker);
|
|
||||||
private void OnFeldsparTaunt() => StartInstrument(AnimationType.Feldspar);
|
|
||||||
private void OnGabbroTaunt() => StartInstrument(AnimationType.Gabbro);
|
|
||||||
private void OnRiebeckTaunt() => StartInstrument(AnimationType.Riebeck);
|
|
||||||
|
|
||||||
private void SetupInstruments()
|
|
||||||
{
|
|
||||||
var bundle = QSBCore.InstrumentAssetBundle;
|
|
||||||
_chertDrum = MakeChertDrum(bundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private GameObject MakeChertDrum(AssetBundle bundle)
|
|
||||||
{
|
|
||||||
var drum = new GameObject();
|
|
||||||
var mf = drum.AddComponent<MeshFilter>();
|
|
||||||
mf.sharedMesh = bundle.LoadAsset("assets/Chert/hourglasstwinsmeshescharacters2.asset") as Mesh;
|
|
||||||
var mr = drum.AddComponent<MeshRenderer>();
|
|
||||||
if (QSBSceneManager.CurrentScene == OWScene.SolarSystem)
|
|
||||||
{
|
|
||||||
mr.sharedMaterial = GameObject.Find("NewDrum:polySurface2").GetComponent<MeshRenderer>().material;
|
|
||||||
}
|
|
||||||
else if (QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse)
|
|
||||||
{
|
|
||||||
//mr.sharedMaterial = GameObject.Find("Props_HEA_Drums").GetComponent<MeshRenderer>().material;
|
|
||||||
// TODO : fix for instrument release
|
|
||||||
mr.sharedMaterial = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
drum.transform.parent = _rootObj;
|
|
||||||
drum.transform.rotation = _rootObj.rotation;
|
|
||||||
drum.transform.localPosition = Vector3.zero;
|
|
||||||
drum.transform.localScale = new Vector3(16.0f, 16.5f, 16.0f);
|
|
||||||
drum.SetActive(false);
|
|
||||||
|
|
||||||
return drum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartInstrument(AnimationType type)
|
|
||||||
{
|
|
||||||
if (!isLocalPlayer)
|
|
||||||
{
|
|
||||||
DebugLog.ToConsole("Error - Tried to start instrument on non-local player!", MessageType.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Player.PlayingInstrument || !Locator.GetPlayerController().IsGrounded())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_savedType = Player.AnimationSync.CurrentType;
|
|
||||||
CameraManager.Instance.SwitchTo3rdPerson();
|
|
||||||
SwitchToType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReturnToPlayer()
|
|
||||||
{
|
|
||||||
if (!Player.PlayingInstrument)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CameraManager.Instance.SwitchTo1stPerson();
|
|
||||||
SwitchToType(_savedType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SwitchToType(AnimationType type)
|
|
||||||
{
|
|
||||||
new ChangeAnimTypeMessage(type).Send();
|
|
||||||
QSBPlayerManager.LocalPlayer.AnimationSync.SetAnimationType(type);
|
|
||||||
CheckInstrumentProps(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CheckInstrumentProps(AnimationType type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case AnimationType.Chert:
|
|
||||||
_chertDrum?.SetActive(true);
|
|
||||||
break;
|
|
||||||
case AnimationType.PlayerSuited:
|
|
||||||
case AnimationType.PlayerUnsuited:
|
|
||||||
_chertDrum?.SetActive(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace QSB.Instruments.QSBCamera
|
|
||||||
{
|
|
||||||
internal class CameraController : MonoBehaviour
|
|
||||||
{
|
|
||||||
public GameObject CameraObject { get; set; }
|
|
||||||
|
|
||||||
private float _degreesX;
|
|
||||||
private float _degreesY;
|
|
||||||
private Quaternion _rotationX;
|
|
||||||
private Quaternion _rotationY;
|
|
||||||
|
|
||||||
// How far along the ray to move the camera. Avoids clipping into the walls.
|
|
||||||
private const float PercentToMove = 0.80f;
|
|
||||||
|
|
||||||
// Maximum distance for camera clipping
|
|
||||||
private const float RayLength = 5f;
|
|
||||||
|
|
||||||
public void FixedUpdate()
|
|
||||||
{
|
|
||||||
if (CameraManager.Instance.Mode != CameraMode.ThirdPerson)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdatePosition();
|
|
||||||
UpdateInput();
|
|
||||||
UpdateRotation();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdatePosition()
|
|
||||||
{
|
|
||||||
var origin = transform.position;
|
|
||||||
var localDirection = CameraObject.transform.localPosition.normalized;
|
|
||||||
Vector3 localTargetPoint;
|
|
||||||
if (Physics.Raycast(origin, transform.TransformDirection(localDirection), out var outRay, RayLength, LayerMask.GetMask("Default")))
|
|
||||||
{
|
|
||||||
// Raycast hit collider, get target from hitpoint.
|
|
||||||
localTargetPoint = transform.InverseTransformPoint(outRay.point) * PercentToMove;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Raycast didn't hit collider, get target from camera direction
|
|
||||||
localTargetPoint = RayLength * PercentToMove * localDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
var targetDistance = Vector3.Distance(origin, transform.TransformPoint(localTargetPoint));
|
|
||||||
var currentDistance = Vector3.Distance(origin, CameraObject.transform.position);
|
|
||||||
var movement = targetDistance < currentDistance
|
|
||||||
? localTargetPoint
|
|
||||||
: Vector3.MoveTowards(CameraObject.transform.localPosition, localTargetPoint, Time.fixedDeltaTime * 2f);
|
|
||||||
CameraObject.transform.localPosition = movement;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateInput()
|
|
||||||
{
|
|
||||||
var input = InputLibrary.look.GetAxisValue(false);
|
|
||||||
_degreesX += input.x * 180f * Time.fixedDeltaTime;
|
|
||||||
_degreesY += input.y * 180f * Time.fixedDeltaTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateRotation()
|
|
||||||
{
|
|
||||||
_degreesX %= 360f;
|
|
||||||
_degreesY %= 360f;
|
|
||||||
_degreesY = Mathf.Clamp(_degreesY, -80f, 80f);
|
|
||||||
_rotationX = Quaternion.AngleAxis(_degreesX, Vector3.up);
|
|
||||||
_rotationY = Quaternion.AngleAxis(_degreesY, Vector3.left);
|
|
||||||
var localRotation = _rotationX * _rotationY * Quaternion.identity;
|
|
||||||
transform.localRotation = localRotation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,121 +0,0 @@
|
|||||||
using OWML.Common;
|
|
||||||
using QSB.Utility;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.PostProcessing;
|
|
||||||
|
|
||||||
namespace QSB.Instruments.QSBCamera
|
|
||||||
{
|
|
||||||
public class CameraManager : MonoBehaviour
|
|
||||||
{
|
|
||||||
public static CameraManager Instance;
|
|
||||||
|
|
||||||
public bool IsSetUp { get; private set; }
|
|
||||||
public CameraMode Mode { get; private set; }
|
|
||||||
|
|
||||||
private GameObject _cameraBase;
|
|
||||||
private GameObject _cameraObj;
|
|
||||||
private Camera _camera;
|
|
||||||
private OWCamera _owCamera;
|
|
||||||
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
Instance = this;
|
|
||||||
SetupCamera();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupCamera()
|
|
||||||
{
|
|
||||||
_cameraBase = new GameObject();
|
|
||||||
_cameraBase.SetActive(false);
|
|
||||||
_cameraBase.transform.parent = Locator.GetPlayerTransform();
|
|
||||||
_cameraBase.transform.localPosition = Vector3.zero;
|
|
||||||
_cameraBase.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
|
||||||
|
|
||||||
_cameraObj = new GameObject();
|
|
||||||
_cameraObj.transform.parent = _cameraBase.transform;
|
|
||||||
_cameraObj.transform.localPosition = new Vector3(0, 0, -5f);
|
|
||||||
_cameraObj.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
|
||||||
_camera = _cameraObj.AddComponent<Camera>();
|
|
||||||
_camera.cullingMask = (Locator.GetPlayerCamera().mainCamera.cullingMask & ~(1 << 27)) | (1 << 22);
|
|
||||||
_camera.clearFlags = CameraClearFlags.Color;
|
|
||||||
_camera.backgroundColor = Color.black;
|
|
||||||
_camera.fieldOfView = 90f;
|
|
||||||
_camera.nearClipPlane = 0.1f;
|
|
||||||
_camera.farClipPlane = 40000f;
|
|
||||||
_camera.depth = 0f;
|
|
||||||
_camera.enabled = false;
|
|
||||||
_owCamera = _cameraObj.AddComponent<OWCamera>();
|
|
||||||
_owCamera.renderSkybox = true;
|
|
||||||
|
|
||||||
_cameraBase.AddComponent<CameraController>().CameraObject = _cameraObj;
|
|
||||||
|
|
||||||
var screenGrab = _cameraObj.AddComponent<FlashbackScreenGrabImageEffect>();
|
|
||||||
screenGrab._downsampleShader = Locator.GetPlayerCamera().gameObject.GetComponent<FlashbackScreenGrabImageEffect>()._downsampleShader;
|
|
||||||
|
|
||||||
var fogImage = _cameraObj.AddComponent<PlanetaryFogImageEffect>();
|
|
||||||
fogImage.fogShader = Locator.GetPlayerCamera().gameObject.GetComponent<PlanetaryFogImageEffect>().fogShader;
|
|
||||||
|
|
||||||
_cameraBase.SetActive(true);
|
|
||||||
|
|
||||||
IsSetUp = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SwitchTo3rdPerson()
|
|
||||||
{
|
|
||||||
if (!IsSetUp)
|
|
||||||
{
|
|
||||||
DebugLog.ToConsole("Warning - Camera not set up!", MessageType.Warning);
|
|
||||||
OWInput.ChangeInputMode(InputMode.None);
|
|
||||||
Mode = CameraMode.ThirdPerson;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Mode == CameraMode.ThirdPerson)
|
|
||||||
{
|
|
||||||
DebugLog.ToConsole("Warning - Already in 3rd person!", MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OWInput.GetInputMode() != InputMode.Character)
|
|
||||||
{
|
|
||||||
DebugLog.ToConsole("Warning - Cannot change to 3rd person while not in Character inputmode!", MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OWInput.ChangeInputMode(InputMode.None);
|
|
||||||
GlobalMessenger<OWCamera>.FireEvent("SwitchActiveCamera", _owCamera);
|
|
||||||
Locator.GetPlayerCamera().mainCamera.enabled = false;
|
|
||||||
if (_cameraObj.GetComponent<PostProcessingBehaviour>() == null)
|
|
||||||
{
|
|
||||||
var postProcessing = _cameraObj.AddComponent<PostProcessingBehaviour>();
|
|
||||||
postProcessing.profile = Locator.GetPlayerCamera().gameObject.GetComponent<PostProcessingBehaviour>().profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
_camera.enabled = true;
|
|
||||||
Mode = CameraMode.ThirdPerson;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SwitchTo1stPerson()
|
|
||||||
{
|
|
||||||
if (!IsSetUp)
|
|
||||||
{
|
|
||||||
DebugLog.ToConsole("Warning - Camera not set up!", MessageType.Warning);
|
|
||||||
OWInput.ChangeInputMode(InputMode.Character);
|
|
||||||
Mode = CameraMode.FirstPerson;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Mode == CameraMode.FirstPerson)
|
|
||||||
{
|
|
||||||
DebugLog.ToConsole("Warning - Already in 1st person!", MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OWInput.ChangeInputMode(InputMode.Character);
|
|
||||||
GlobalMessenger<OWCamera>.FireEvent("SwitchActiveCamera", Locator.GetPlayerCamera());
|
|
||||||
Locator.GetActiveCamera().mainCamera.enabled = true;
|
|
||||||
_camera.enabled = false;
|
|
||||||
Mode = CameraMode.FirstPerson;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace QSB.Instruments.QSBCamera
|
|
||||||
{
|
|
||||||
public enum CameraMode
|
|
||||||
{
|
|
||||||
FirstPerson,
|
|
||||||
ThirdPerson
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,6 @@ using QSB.Animation.Player.Thrusters;
|
|||||||
using QSB.Audio;
|
using QSB.Audio;
|
||||||
using QSB.CampfireSync.WorldObjects;
|
using QSB.CampfireSync.WorldObjects;
|
||||||
using QSB.ClientServerStateSync;
|
using QSB.ClientServerStateSync;
|
||||||
using QSB.Instruments;
|
|
||||||
using QSB.ItemSync.WorldObjects.Items;
|
using QSB.ItemSync.WorldObjects.Items;
|
||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
using QSB.Player.Messages;
|
using QSB.Player.Messages;
|
||||||
@ -31,7 +30,6 @@ namespace QSB.Player
|
|||||||
public PlayerHUDMarker HudMarker { get; set; }
|
public PlayerHUDMarker HudMarker { get; set; }
|
||||||
public PlayerTransformSync TransformSync { get; }
|
public PlayerTransformSync TransformSync { get; }
|
||||||
public AnimationSync AnimationSync { get; }
|
public AnimationSync AnimationSync { get; }
|
||||||
public InstrumentsManager InstrumentsManager { get; }
|
|
||||||
public ClientState State { get; set; }
|
public ClientState State { get; set; }
|
||||||
public EyeState EyeState { get; set; }
|
public EyeState EyeState { get; set; }
|
||||||
public bool IsDead { get; set; }
|
public bool IsDead { get; set; }
|
||||||
@ -152,9 +150,6 @@ namespace QSB.Player
|
|||||||
public GameObject CurrentDialogueBox { get; set; }
|
public GameObject CurrentDialogueBox { get; set; }
|
||||||
|
|
||||||
// Animation
|
// Animation
|
||||||
public bool PlayingInstrument => AnimationSync.CurrentType
|
|
||||||
is not AnimationType.PlayerSuited
|
|
||||||
and not AnimationType.PlayerUnsuited;
|
|
||||||
public JetpackAccelerationSync JetpackAcceleration { get; set; }
|
public JetpackAccelerationSync JetpackAcceleration { get; set; }
|
||||||
|
|
||||||
// Local only
|
// Local only
|
||||||
@ -219,7 +214,6 @@ namespace QSB.Player
|
|||||||
PlayerId = transformSync.netId;
|
PlayerId = transformSync.netId;
|
||||||
TransformSync = transformSync;
|
TransformSync = transformSync;
|
||||||
AnimationSync = transformSync.GetComponent<AnimationSync>();
|
AnimationSync = transformSync.GetComponent<AnimationSync>();
|
||||||
InstrumentsManager = transformSync.GetComponent<InstrumentsManager>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateObjectsFromStates()
|
public void UpdateObjectsFromStates()
|
||||||
|
@ -28,7 +28,6 @@ namespace QSB.PlayerBodySetup.Local
|
|||||||
var playerBody = Locator.GetPlayerTransform();
|
var playerBody = Locator.GetPlayerTransform();
|
||||||
var playerModel = playerBody.Find("Traveller_HEA_Player_v2");
|
var playerModel = playerBody.Find("Traveller_HEA_Player_v2");
|
||||||
player.AnimationSync.InitLocal(playerModel);
|
player.AnimationSync.InitLocal(playerModel);
|
||||||
player.InstrumentsManager.InitLocal(playerBody);
|
|
||||||
player.Body = playerBody.gameObject;
|
player.Body = playerBody.gameObject;
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
|
@ -47,7 +47,6 @@ namespace QSB.PlayerBodySetup.Remote
|
|||||||
FixMaterialsInAllChildren.ReplaceMaterials(REMOTE_Player_Body.transform);
|
FixMaterialsInAllChildren.ReplaceMaterials(REMOTE_Player_Body.transform);
|
||||||
|
|
||||||
player.AnimationSync.InitRemote(REMOTE_Traveller_HEA_Player_v2.transform);
|
player.AnimationSync.InitRemote(REMOTE_Traveller_HEA_Player_v2.transform);
|
||||||
player.InstrumentsManager.InitRemote(REMOTE_Player_Body.transform);
|
|
||||||
|
|
||||||
REMOTE_Player_Body.GetComponent<PlayerHUDMarker>().Init(player);
|
REMOTE_Player_Body.GetComponent<PlayerHUDMarker>().Init(player);
|
||||||
REMOTE_Player_Body.GetComponent<PlayerMapMarker>().PlayerName = player.Name;
|
REMOTE_Player_Body.GetComponent<PlayerMapMarker>().PlayerName = player.Name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user