quantum-space-buddies/QSB/Player/PlayerInfoParts/Body.cs

91 lines
1.6 KiB
C#
Raw Normal View History

2022-03-24 15:02:31 +00:00
using OWML.Common;
using QSB.Utility;
using UnityEngine;
namespace QSB.Player;
public partial class PlayerInfo
{
public OWCamera Camera
{
2023-03-04 13:17:59 +00:00
get => _camera;
2022-03-24 15:02:31 +00:00
set
{
if (value == null)
{
DebugLog.ToConsole($"Warning - Setting {PlayerId}.Camera to null.", MessageType.Warning);
}
_camera = value;
}
}
private OWCamera _camera;
public GameObject CameraBody { get; set; }
public GameObject Body
{
get
{
if (_body == null && IsReady)
{
DebugLog.ToConsole($"Warning - {PlayerId}.Body is null!", MessageType.Warning);
}
return _body;
}
set
{
if (value == null)
{
DebugLog.ToConsole($"Warning - Setting {PlayerId}.Body to null.", MessageType.Warning);
}
_body = value;
}
}
private GameObject _body;
2022-08-17 00:05:13 +00:00
/// <summary>
/// remote light sensor is disabled.
/// it only acts as a storage of data and is always synced with the local light sensor.
/// </summary>
public LightSensor LightSensor
{
get
{
2022-04-10 22:16:44 +00:00
if (IsLocalPlayer)
{
return Locator.GetPlayerLightSensor();
}
if (CameraBody == null)
{
DebugLog.ToConsole($"Error - Can't get LightSensor for {PlayerId}, because CameraBody is null.", MessageType.Error);
return null;
}
return CameraBody.transform.Find("REMOTE_CameraDetector").GetComponent<LightSensor>();
}
}
public Vector3 Velocity
{
get
{
if (IsLocalPlayer)
{
return Locator.GetPlayerBody().GetVelocity();
}
if (Body == null)
{
DebugLog.ToConsole($"Error - Can't get velocity for {PlayerId}, because Body is null.", MessageType.Error);
return Vector3.zero;
}
return Body.GetComponent<RemotePlayerVelocity>().Velocity;
}
}
2022-03-24 15:02:31 +00:00
}