using GamecraftModdingAPI.Players;
using GamecraftModdingAPI.Utility;
using RobocraftX.Physics;
using Svelto.ECS.EntityStructs;
using Techblox.FlyCam;
using Unity.Mathematics;
using UnityEngine;
namespace GamecraftModdingAPI
{
public class FlyCam
{
private static FlyCamEngine Engine = new FlyCamEngine();
public uint Id { get; }
public FlyCam(uint id) => Id = id;
///
/// The local player's camera.
///
public static FlyCam LocalCamera => new FlyCam(Player.LocalPlayer.Id);
///
/// The current position of the camera.
///
public float3 Position
{
get => Engine.GetComponent(Id).Get().position;
set
{
Engine.GetComponent(Id).Get().position = value;
Engine.GetComponent(Id).Get().position = value;
}
}
///
/// The current rotation of the camera.
///
public float3 Rotation
{
get => ((Quaternion) Engine.GetComponent(Id).Get().rotation).eulerAngles;
set
{
Engine.GetComponent(Id).Get().rotation = Quaternion.Euler(value);
Engine.GetComponent(Id).Get().rotation = Quaternion.Euler(value);
}
}
///
/// The current direction the camera is moving.
///
public float3 MovementDirection
{
get => Engine.GetComponent(Id).Get().movementDirection;
set => Engine.GetComponent(Id).Get().movementDirection = value;
}
///
/// Whether the camera (player) is sprinting.
///
public bool Sprinting
{
get => Engine.GetComponent(Id).Get().sprinting;
set => Engine.GetComponent(Id).Get().sprinting = value;
}
///
/// The speed setting of the camera.
///
public float Speed
{
get => Engine.GetComponent(Id).Get().speed;
set => Engine.GetComponent(Id).Get().speed = value;
}
///
/// The multiplier setting to use when sprinting.
///
public float SpeedSprintMultiplier
{
get => Engine.GetComponent(Id).Get().speedSprintMultiplier;
set => Engine.GetComponent(Id).Get().speedSprintMultiplier = value;
}
///
/// The acceleration setting of the camera.
///
public float Acceleration
{
get => Engine.GetComponent(Id).Get().acceleration;
set => Engine.GetComponent(Id).Get().acceleration = value;
}
///
/// The current velocity of the camera.
///
public float3 Velocity
{
get => Engine.GetComponent(Id).Get().velocity;
set => Engine.GetComponent(Id).Get().velocity = value;
}
///
/// The current angular velocity of the camera.
///
public float3 AngularVelocity
{
get => Engine.GetComponent(Id).Get().angularVelocity;
set => Engine.GetComponent(Id).Get().angularVelocity = value;
}
public static void Init()
{
GameEngineManager.AddGameEngine(Engine);
}
}
}