using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using NewHorizons.Components.Orbital;
using NewHorizons.Utility;
using Newtonsoft.Json;
namespace NewHorizons.External.Modules
{
[JsonObject]
public class OrbitModule : IOrbitalParameters
{
///
/// Specify this if you want the body to remain stationary at a given location (ie not orbit its parent). Required for Bramble dimensions
///
public MVector3 staticPosition;
///
/// The name of the body this one will orbit around
///
public string primaryBody;
///
/// Is this the moon of a planet? Used for determining when its name is shown on the map.
///
public bool isMoon;
///
/// The angle between the normal to the orbital plane and its axis of rotation.
///
public float axialTilt;
///
/// Rotation period in minutes.
///
public float siderealPeriod;
///
/// Should the body always have one side facing its primary?
///
public bool isTidallyLocked;
///
/// If it is tidally locked, this direction will face towards the primary. Ex: Interloper uses `0, -1, 0`. Most planets
/// will want something like `-1, 0, 0`.
///
public MVector3 alignmentAxis;
///
/// Referring to the orbit line in the map screen.
///
[DefaultValue(true)]
public bool showOrbitLine = true;
///
/// Should the orbit line be dotted?
///
public bool dottedOrbitLine;
///
/// Is the body meant to stay in one place without moving? If staticPosition is not set, the initial position
/// will be determined using its orbital parameters.
///
public bool isStatic;
///
/// Colour of the orbit-line in the map view.
///
public MColor tint;
///
/// Should we just draw a line behind its orbit instead of the entire circle/ellipse?
///
public bool trackingOrbitLine;
///
/// The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius.
///
[Range(0f, double.MaxValue)]
public float semiMajorAxis { get; set; }
///
/// The angle (in degrees) between the body's orbit and the plane of the star system
///
public float inclination { get; set; }
///
/// An angle (in degrees) defining the point where the orbit of the body rises above the orbital plane if it has
/// nonzero inclination.
///
public float longitudeOfAscendingNode { get; set; }
///
/// At 0 the orbit is a circle. The closer to 1 it is, the more oval-shaped the orbit is.
///
[Range(0f, 0.9999999999f)]
public float eccentricity { get; set; }
///
/// An angle (in degrees) defining the location of the periapsis (the closest distance to it's primary body) if it has
/// nonzero eccentricity.
///
public float argumentOfPeriapsis { get; set; }
///
/// Where the planet should start off in its orbit in terms of the central angle.
///
public float trueAnomaly { get; set; }
public OrbitalParameters GetOrbitalParameters(Gravity primaryGravity, Gravity secondaryGravity)
{
return OrbitalParameters.FromTrueAnomaly(primaryGravity, secondaryGravity, eccentricity, semiMajorAxis,
inclination, argumentOfPeriapsis, longitudeOfAscendingNode, trueAnomaly);
}
}
}