Initial commit

This commit is contained in:
2026-02-18 12:00:34 +00:00
commit 5d353cf5fa
1947 changed files with 335322 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
using UnityEngine;
public class Altimeter : MonoBehaviour
{
void Start() { }
void Update() { }
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 467a162ba38457a3eaec2d8b2e313aee

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class ElectricalSystem : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d6745c4db30d5b379867e65816543337

View File

@@ -0,0 +1,7 @@
using UnityEngine;
public class FaliureManager : MonoBehaviour
{
void Start() { }
void Update() { }
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2d2aaaef6e8061fa596aafffb1cc2aea

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class FlightController : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: adbd88387b1837dde80cd7f4f87863e2

View File

@@ -0,0 +1,21 @@
using UnityEngine;
public class FuelTank : MonoBehaviour
{
public float fuelAmount = 1000f; // kg of fuel available in the tank
public bool isEmpty => fuelAmount <= 0f;
public float RequestFuel(float amount)
{
float fuelGiven = Mathf.Min(amount, fuelAmount);
fuelAmount -= fuelGiven;
return fuelGiven;
}
public float GetFuelAmount() => fuelAmount;
void Update()
{
if (fuelAmount <= 0f)
{
fuelAmount = 0f;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fc938096137ba144eacbf580b405ba37

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class GimbalSystem : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a1205446b72eb1daeb13064fb0454b99

View File

@@ -0,0 +1,7 @@
using UnityEngine;
public class IMUSensor : MonoBehaviour
{
void Start() { }
void Update() { }
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5d3d6415f5572e1c3b47b6fef7651a91

View File

@@ -0,0 +1,64 @@
using UnityEngine;
using UnityEngine.InputSystem;
using TMPro;
using UnityEngine.UI;
public class ThrottleController : MonoBehaviour
{
[Header("Input")]
public InputActionReference throttleAction; // Your Input Action reference
[Header("Throttle Settings")]
public float rampSpeed = 1f; // Units per second
[Header("References")]
public MainEngine mainEngine; // Reference to your engine script
// Referance to TextMeshPro Throttle slider
public Slider throttleDisplay; // Reference to UI Slider component
void OnEnable()
{
if (throttleAction != null)
{
throttleAction.action.Enable();
Debug.Log("Throttle action enabled.");
}
else
{
Debug.LogWarning("Throttle action reference is not set!");
}
}
void OnDisable()
{
if (throttleAction != null)
throttleAction.action.Disable();
}
void Update()
{
if (throttleAction == null || mainEngine == null)
return;
// Read input (-1, 0, +1)
float input = throttleAction.action.ReadValue<float>();
// Debug what the input is reading
//Debug.Log($"Input value: {input}");
// Calculate new throttle target
float target = mainEngine.throttleInput + input * rampSpeed * Time.deltaTime;
// Clamp between 0 and 1
mainEngine.throttleInput = Mathf.Clamp01(target);
// Debug the throttle value
//Debug.Log($"Throttle value: {mainEngine.throttleInput}");
// Update the throttle display
if (throttleDisplay != null)
{
throttleDisplay.value = mainEngine.throttleInput;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0b829ffad31babea7b993cfd70db13aa

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class InstrumentManager : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2826e1784dd637a5e9b4fbdd6e93cb39

View File

@@ -0,0 +1,192 @@
using UnityEngine;
public class MainEngine : MonoBehaviour
{
[Header("Fuel Source")]
public FuelTank fuelTank; // Reference to the fuel tank supplying this engine
[Header("Engine Settings")]
public float maxThrust = 1000f; // kN
public float Isp = 300f; // seconds
public float throttleRampTime = 2f; // seconds to reach full throttle
public float minStartupFlow = 0.05f; // minimum fraction of max flow to maintain ignition
public float g = 9.81f; // gravitational acceleration (m/s^2) (to be replaced)
public AnimationCurve throttleCurve = AnimationCurve.Linear(0, 0, 1, 1);
[Header("Efficiency Settings")]
[Range(0f, 1f)] public float engineEfficiency = 1f; // e.g., reduce if engine is hot or damaged
[Header("Engine Status")]
public bool engineOnline = false; // true if engine is running
public bool engineIgnited = false; // true if ignition completed
public bool restartable = true; // if false, engine cannot restart once shut down
public float throttleInput = 0f; // 0-1 input from pilot
public float thrust = 0f; // kN
public float fuelFlowRate = 0f; // kg/s
private float effectiveThrottle = 0f; // ramped throttle for smooth startup/shutdown
private float startupTimer = 0f;
private bool everStarted = false; // tracks if engine has ever been started
private float postIgnitionTimer = 0f; // timer for post-ignition grace period
private const float postIgnitionGrace = 0.5f; // seconds to allow ramp-up after ignition
void Update()
{
HandleEngineState();
UpdateThrottle();
// Only calculate thrust and fuel flow if engine is ignited
if (engineOnline && engineIgnited)
{
// Update post-ignition timer
if (postIgnitionTimer < postIgnitionGrace)
postIgnitionTimer += Time.deltaTime;
CalculateThrustAndFuelFlow();
}
else
{
thrust = 0f;
fuelFlowRate = 0f;
postIgnitionTimer = 0f;
}
}
/// <summary>
/// Handles startup, shutdown, and engine cutout.
/// </summary>
private void HandleEngineState()
{
// Check if engine is offline and restartable conditions
if (!engineOnline)
{
effectiveThrottle = Mathf.MoveTowards(effectiveThrottle, 0f, Time.deltaTime / throttleRampTime);
thrust = 0f;
fuelFlowRate = 0f;
// Mark engine as having been started
if (engineIgnited) everStarted = true;
if (engineIgnited)
Debug.Log("[MainEngine] Engine shutdown: engineOnline set to false.");
engineIgnited = false;
return;
}
// Prevent restart if engine is not restartable and was previously started
if (!restartable && everStarted)
{
Debug.Log("[MainEngine] Engine shutdown: not restartable and already started.");
engineOnline = false;
effectiveThrottle = 0f;
thrust = 0f;
fuelFlowRate = 0f;
engineIgnited = false;
return;
}
// Engine is commanded online
if (!engineIgnited)
{
// Startup delay / ignition sequence
startupTimer += Time.deltaTime;
if (startupTimer >= throttleRampTime)
{
engineIgnited = true;
startupTimer = 0f;
postIgnitionTimer = 0f; // reset grace period timer
Debug.Log("[MainEngine] Engine ignition complete.");
}
else
{
// Slowly ramp effective throttle during startup
effectiveThrottle = Mathf.Lerp(0f, throttleInput, startupTimer / throttleRampTime);
}
}
}
/// <summary>
/// Smooths throttle input over time (fuel ramping)
/// </summary>
private void UpdateThrottle()
{
if (!engineOnline || !engineIgnited)
return;
// Smooth throttle changes to avoid instant jumps
effectiveThrottle = Mathf.MoveTowards(effectiveThrottle, throttleInput, Time.deltaTime / throttleRampTime);
}
/// <summary>
/// Calculates thrust and fuel flow based on current throttle and efficiency
/// </summary>
private void CalculateThrustAndFuelFlow()
{
// Base thrust from throttle curve and max thrust
thrust = throttleCurve.Evaluate(effectiveThrottle) * maxThrust * engineEfficiency;
// Fuel flow based on thrust and Isp
fuelFlowRate = thrust / (Isp * g);
// Request fuel from the tank if assigned
if (fuelTank != null)
{
float fuelRequested = fuelFlowRate * Time.deltaTime;
float fuelProvided = fuelTank.RequestFuel(fuelRequested);
if (fuelProvided < fuelRequested)
{
Debug.Log($"[MainEngine] Engine flameout: insufficient fuel (requested {fuelRequested:F3}, got {fuelProvided:F3}).");
engineIgnited = false;
effectiveThrottle = 0f;
thrust = 0f;
fuelFlowRate = 0f;
return;
}
}
// Only check for flameout if engine is fully ignited and grace period has passed
float nominalFlow = maxThrust / (Isp * g);
if (engineIgnited && postIgnitionTimer >= postIgnitionGrace && (fuelFlowRate / nominalFlow) < minStartupFlow)
{
Debug.Log($"[MainEngine] Engine flameout: fuel flow below minimum ({fuelFlowRate / nominalFlow:F3} < {minStartupFlow}).");
engineIgnited = false; // engine flameout
effectiveThrottle = 0f;
thrust = 0f;
fuelFlowRate = 0f;
}
}
/// <summary>
/// Call to turn the engine on
/// </summary>
public void StartEngine()
{
if (!engineOnline)
{
// Prevent starting if not restartable and already started
if (!restartable && everStarted)
{
Debug.Log("[MainEngine] StartEngine() called but engine is not restartable and has already started.");
return;
}
Debug.Log("[MainEngine] Engine start command received.");
engineOnline = true;
startupTimer = 0f;
}
}
/// <summary>
/// Call to turn the engine off
/// </summary>
public void ShutdownEngine()
{
Debug.Log("[MainEngine] Engine shutdown command received.");
engineOnline = false;
engineIgnited = false;
}
public void SetThrottle(float value)
{
throttleInput = Mathf.Clamp01(value);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0f3b769483adcd10fa66f2eba664c4e2

View File

@@ -0,0 +1,7 @@
using UnityEngine;
public class OrbitEstimator : MonoBehaviour
{
void Start() { }
void Update() { }
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5e6fe1e74fc348cabbd08f81532b9fb0

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class RCSController : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d943606e96a65aeceaa19bb4a56c515b

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class RocketPhysics : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 219e9801db9b4c278907929162e4507c

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class SASController : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a8bcf6e8fe75d635aa395c1f55eb351a

View File

@@ -0,0 +1,7 @@
using UnityEngine;
public class StructuralSystem : MonoBehaviour
{
void Start() { }
void Update() { }
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f2755b5074e3bfa138bf9103f4b23688

View File

@@ -0,0 +1,7 @@
using UnityEngine;
public class ThermalSystem : MonoBehaviour
{
void Start() { }
void Update() { }
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 34910c72af21a04eb9e263b11a74e9a8