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