本文整理汇总了C#中Vessel.GetTotalMass方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.GetTotalMass方法的具体用法?C# Vessel.GetTotalMass怎么用?C# Vessel.GetTotalMass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.GetTotalMass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KCT_Recon_Rollout
public KCT_Recon_Rollout(Vessel vessel, RolloutReconType type, string id)
{
RRType = type;
associatedID = id;
//BP = vessel.GetTotalMass() * KCT_GameStates.timeSettings.ReconditioningEffect * KCT_GameStates.timeSettings.OverallMultiplier; //1 day per 50 tons (default) * overall multiplier
BP = KCT_MathParsing.GetStandardFormulaValue("Reconditioning", new Dictionary<string, string>() {{"M", vessel.GetTotalMass().ToString()}, {"O", KCT_GameStates.timeSettings.OverallMultiplier.ToString()},
{"E", KCT_GameStates.timeSettings.ReconditioningEffect.ToString()}, {"X", KCT_GameStates.timeSettings.MaxReconditioning.ToString()}});
//if (BP > KCT_GameStates.timeSettings.MaxReconditioning) BP = KCT_GameStates.timeSettings.MaxReconditioning;
progress = 0;
if (type == RolloutReconType.Reconditioning)
{
BP *= (1 - KCT_GameStates.timeSettings.RolloutReconSplit);
name = "LaunchPad Reconditioning";
}
else if (type == RolloutReconType.Rollout)
{
BP *= KCT_GameStates.timeSettings.RolloutReconSplit;
name = "Vessel Rollout";
}
else if (type == RolloutReconType.Rollback)
{
BP *= KCT_GameStates.timeSettings.RolloutReconSplit;
name = "Vessel Rollback";
progress = BP;
}
else if (type == RolloutReconType.Recovery)
{
BP *= KCT_GameStates.timeSettings.RolloutReconSplit;
name = "Vessel Recovery";
double KSCDistance = (float)SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(vessel.latitude, vessel.longitude));
double maxDist = SpaceCenter.Instance.cb.Radius * Math.PI;
BP += BP * (KSCDistance / maxDist);
}
}
示例2: Awake
void Awake()
{
vessel = GetComponent<Vessel>();
windAudioSource = gameObject.AddComponent<AudioSource>();
windAudioSource.minDistance = 10;
windAudioSource.maxDistance = 10000;
windAudioSource.dopplerLevel = .35f;
windAudioSource.spatialBlend = 1;
AudioClip windclip = GameDatabase.Instance.GetAudioClip("CameraTools/Sounds/windloop");
if(!windclip)
{
Destroy (this);
return;
}
windAudioSource.clip = windclip;
windHowlAudioSource = gameObject.AddComponent<AudioSource>();
windHowlAudioSource.minDistance = 10;
windHowlAudioSource.maxDistance = 7000;
windHowlAudioSource.dopplerLevel = .5f;
windHowlAudioSource.pitch = 0.25f;
windHowlAudioSource.clip = GameDatabase.Instance.GetAudioClip("CameraTools/Sounds/windhowl");
windHowlAudioSource.spatialBlend = 1;
windTearAudioSource = gameObject.AddComponent<AudioSource>();
windTearAudioSource.minDistance = 10;
windTearAudioSource.maxDistance = 5000;
windTearAudioSource.dopplerLevel = 0.45f;
windTearAudioSource.pitch = 0.65f;
windTearAudioSource.clip = GameDatabase.Instance.GetAudioClip("CameraTools/Sounds/windtear");
windTearAudioSource.spatialBlend = 1;
sonicBoomSource = new GameObject().AddComponent<AudioSource>();
sonicBoomSource.transform.parent = vessel.transform;
sonicBoomSource.transform.localPosition = Vector3.zero;
sonicBoomSource.minDistance = 50;
sonicBoomSource.maxDistance = 20000;
sonicBoomSource.dopplerLevel = 0;
sonicBoomSource.clip = GameDatabase.Instance.GetAudioClip("CameraTools/Sounds/sonicBoom");
sonicBoomSource.volume = Mathf.Clamp01(vessel.GetTotalMass()/4f);
sonicBoomSource.Stop();
sonicBoomSource.spatialBlend = 1;
float angleToCam = Vector3.Angle(vessel.srf_velocity, FlightCamera.fetch.mainCamera.transform.position - vessel.transform.position);
angleToCam = Mathf.Clamp(angleToCam, 1, 180);
if(vessel.srfSpeed / (angleToCam) < 3.67f)
{
playedBoom = true;
}
CamTools.OnResetCTools += OnResetCTools;
}
示例3: getValues
/// <summary>
/// Returns all values related to this mission goal
/// </summary>
/// <returns>The values.</returns>
/// <param name="vessel">current vessel</param>
public List<Value> getValues(Vessel vessel, GameEvent events)
{
List<Value> vs = values (vessel, events);
if (crewCount != 0) {
if(vessel == null) {
vs.Add (new Value ("Crew count", "" + crewCount));
} else {
vs.Add (new Value ("Crew count", "" + crewCount, "" + vessel.GetCrewCount (),
crewCount <= vessel.GetCrewCount ()));
}
}
if (minTotalMass != 0.0) {
if (vessel == null) {
vs.Add(new Value("min. total mass", String.Format(MathTools.SingleDoubleValue, minTotalMass)));
} else {
vs.Add(new Value("min. total mass", String.Format(MathTools.SingleDoubleValue, minTotalMass),
String.Format(MathTools.SingleDoubleValue, vessel.GetTotalMass()),
vessel.GetTotalMass() >= minTotalMass));
}
}
if (maxTotalMass != 0.0) {
if (vessel == null) {
vs.Add(new Value("max. total mass", String.Format(MathTools.SingleDoubleValue, maxTotalMass)));
} else {
vs.Add(new Value("max. total mass", String.Format(MathTools.SingleDoubleValue, maxTotalMass),
String.Format(MathTools.SingleDoubleValue, vessel.GetTotalMass()),
vessel.GetTotalMass() <= maxTotalMass));
}
}
bool done = true;
foreach (Value v in vs) {
done = done && v.done;
}
// If the mission goal is finished so far and we need to throttle down in order
// to finish the mission goal, add another value if not throttled down
if (vessel != null) {
if (done && throttleDown && FlightInputHandler.state.mainThrottle != 0.0) {
vs.Add (new Value ("Throttle down!", "true", "false", false));
done = false;
}
}
if (done && timeStarted == -1.0 && minSeconds > 0.0) {
timeStarted = Planetarium.GetUniversalTime ();
}
if (minSeconds > 0.0 && !done) {
timeStarted = -1.0;
}
if (minSeconds > 0.0) {
if (vessel != null) {
double diff = (timeStarted == -1.0 ? 0 : Planetarium.GetUniversalTime () - timeStarted);
vs.Add (new Value("Minimal time", MathTools.formatTime(minSeconds), MathTools.formatTime(diff), diff > minSeconds));
} else {
vs.Add (new Value("Minimal time", MathTools.formatTime(minSeconds)));
}
}
return vs;
}
示例4: is_vessel_fits_to_mission
// Create mission from the Vessel
private Boolean is_vessel_fits_to_mission(Vessel ves)
{
if (ves == null) return false;
VesselType type = ves.vesselType;
//return type == VesselType.Ship | type == VesselType.Probe;
if (type != VesselType.SpaceObject & type != VesselType.EVA & type != VesselType.Flag & type != VesselType.Debris)
{
#region Debug information
// === Debug information ===
KDebug.Log("Vessel debug information: ", KDebug.Type.CREATE);
KDebug.Log("ves.name: " + ves.name, KDebug.Type.CREATE);
KDebug.Log("ves.vesselName: " + ves.vesselName, KDebug.Type.CREATE);
KDebug.Log("ves.GetInstanceID: " + ves.GetInstanceID().ToString(), KDebug.Type.CREATE);
//KDebug.Log("ves.GetVessel: " + ves.GetVessel().ToString());
//KDebug.Log("ves.vesselType: " + ves.vesselType.ToString());
//KDebug.Log("ves.vesselRanges: " + ves.vesselRanges.ToString());
//KDebug.Log("ves.vesselTransform: " + ves.vesselTransform.ToString());
//KDebug.Log("ves.VesselValues: " + ves.VesselValues.ToString());
//KDebug.Log("ves.GetType: " + ves.GetType().ToString());
KDebug.Log("ves.GetTotalMass: " + ves.GetTotalMass().ToString(), KDebug.Type.CREATE);
//KDebug.Log("ves.GetTransform: " + ves.GetTransform().ToString());
//KDebug.Log("ves.tag: " + ves.tag.ToString());
KDebug.Log("ves.loaded: " + ves.loaded.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.isActiveAndEnabled: " + ves.isActiveAndEnabled.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.isActiveVessel: " + ves.isActiveVessel.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.isCommandable: " + ves.isCommandable.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.IsControllable: " + ves.IsControllable.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.launchTime: " + ves.launchTime.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.missionTime: " + ves.missionTime.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.packed: " + ves.packed.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.situation: " + ves.situation.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.state: " + ves.state.ToString(), KDebug.Type.CREATE);
//KDebug.Log("ves.ctrlState: " + ves.ctrlState.ToString());
KDebug.Log("ves.currentStage: " + ves.currentStage.ToString(), KDebug.Type.CREATE);
}else if(type == VesselType.EVA)
{
KDebug.Log("EVA debug information: ", KDebug.Type.CREATE);
KDebug.Log("ves.vesselName: " + ves.vesselName, KDebug.Type.CREATE);
KDebug.Log("ves.rootPart: " + ves.rootPart.ToString(), KDebug.Type.CREATE);
}
/*
* ves.situation: PRELAUNCH () <- ?
* ves.state: INACTIVE
* ves.currentStage: 1
* ves.missionTime: 0 (!)
* ves.IsControllable: False (.)
* ves.isCommandable: True (.)
* ves.isActiveVessel: False
* ves.isActiveAndEnabled: True (?)
* ves.loaded: False
* ves.vesselType: Ship (!) <- ?
*/
#endregion
// (ves.missionTime < 0.1); Condition for the mission time. It should be checked only if we create a new flight.
// This conditions should be ok
Boolean is_ok = ( (ves.isCommandable | ves.IsControllable) & (type == VesselType.Ship | type == VesselType.Probe) & ves.loaded ); // Apparently the last parameter (ves.loaded) needs to be check
KDebug.Log("Is vessel conditions are ok for aproove for " + VesselType.Ship.ToString() + " " + ves.name + "? " + is_ok.ToString(), KDebug.Type.CREATE);
return is_ok;
}
示例5: getVesselDetail
private KMPVesselDetail getVesselDetail(Vessel vessel)
{
KMPVesselDetail detail = new KMPVesselDetail();
detail.idle = isIdle;
detail.mass = vessel.GetTotalMass();
bool is_eva = false;
bool parachutes_open = false;
//Check if the vessel is an EVA Kerbal
if (vessel.isEVA && vessel.parts.Count > 0 && vessel.parts.First().Modules.Count > 0)
{
foreach (PartModule module in vessel.parts.First().Modules)
{
if (module is KerbalEVA)
{
KerbalEVA kerbal = (KerbalEVA) module;
detail.percentFuel = (byte)Math.Round(kerbal.Fuel / kerbal.FuelCapacity * 100);
detail.percentRCS = byte.MaxValue;
detail.numCrew = byte.MaxValue;
is_eva = true;
break;
}
}
}
if (!is_eva)
{
if (vessel.GetCrewCapacity() > 0)
detail.numCrew = (byte)vessel.GetCrewCount();
else
detail.numCrew = byte.MaxValue;
Dictionary<string, float> fuel_densities = new Dictionary<string, float>();
Dictionary<string, float> rcs_fuel_densities = new Dictionary<string, float>();
bool has_engines = false;
bool has_rcs = false;
foreach (Part part in vessel.parts)
{
foreach (PartModule module in part.Modules)
{
if (module is ModuleEngines)
{
//Determine what kinds of fuel this vessel can use and their densities
ModuleEngines engine = (ModuleEngines)module;
has_engines = true;
foreach (ModuleEngines.Propellant propellant in engine.propellants)
{
if (propellant.name == "ElectricCharge" || propellant.name == "IntakeAir")
{
continue;
}
if (!fuel_densities.ContainsKey(propellant.name))
fuel_densities.Add(propellant.name, PartResourceLibrary.Instance.GetDefinition(propellant.id).density);
}
}
if (module is ModuleRCS)
{
ModuleRCS rcs = (ModuleRCS)module;
if (rcs.requiresFuel)
{
has_rcs = true;
if (!rcs_fuel_densities.ContainsKey(rcs.resourceName))
rcs_fuel_densities.Add(rcs.resourceName, PartResourceLibrary.Instance.GetDefinition(rcs.resourceName).density);
}
}
if (module is ModuleParachute)
{
ModuleParachute parachute = (ModuleParachute)module;
if (parachute.deploymentState == ModuleParachute.deploymentStates.DEPLOYED)
parachutes_open = true;
}
}
}
//Determine how much fuel this vessel has and can hold
float fuel_capacity = 0.0f;
float fuel_amount = 0.0f;
float rcs_capacity = 0.0f;
float rcs_amount = 0.0f;
foreach (Part part in vessel.parts)
{
if (part != null && part.Resources != null)
{
foreach (PartResource resource in part.Resources)
//.........这里部分代码省略.........
示例6: OnVesselRecoveryRequested
public void OnVesselRecoveryRequested(Vessel v)
{
vesselMass = v.GetTotalMass();
//Get total ship cost
KerbalGUIManager.print("[rusty] OnVesselRecoveryRequested");
}
示例7: GetDominantVessel
private Vessel GetDominantVessel(Vessel v1, Vessel v2)
{
// Check 1 - Dominant vessel will be the higher type
if (v1.vesselType > v2.vesselType) {
return v1;
}
if (v1.vesselType < v2.vesselType) {
return v2;
}
// Check 2- If type are the same, dominant vessel will be the heaviest
float diffMass = Mathf.Abs((v1.GetTotalMass() - v2.GetTotalMass()));
if (diffMass >= 0.01f) {
return v1.GetTotalMass() <= v2.GetTotalMass() ? v2 : v1;
}
// Check 3 - If weight is similar, dominant vessel will be the one with the higher ID
return v1.id.CompareTo(v2.id) <= 0 ? v2 : v1;
}
示例8: on_vessel_loaded
/// TEMPORARY FUNCTION
private void on_vessel_loaded(Vessel ves)
{
KDebug.Log("on loaded: ", KDebug.Type.EVENT);
if (ves == null) return;
VesselType type = ves.vesselType;
if (type != VesselType.SpaceObject & type != VesselType.EVA & type != VesselType.Flag & type != VesselType.Debris)
{
// === Debug information ===
KDebug.Log("Vessel debug information: ", KDebug.Type.CREATE);
KDebug.Log("ves.name: " + ves.name, KDebug.Type.CREATE);
KDebug.Log("ves.vesselName: " + ves.vesselName, KDebug.Type.CREATE);
KDebug.Log("ves.GetInstanceID: " + ves.GetInstanceID().ToString(), KDebug.Type.CREATE);
//KDebug.Log("ves.GetVessel: " + ves.GetVessel().ToString());
KDebug.Log("ves.vesselType: " + ves.vesselType.ToString(), KDebug.Type.CREATE);
//KDebug.Log("ves.vesselRanges: " + ves.vesselRanges.ToString());
//KDebug.Log("ves.vesselTransform: " + ves.vesselTransform.ToString());
//KDebug.Log("ves.VesselValues: " + ves.VesselValues.ToString());
//KDebug.Log("ves.GetType: " + ves.GetType().ToString());
KDebug.Log("ves.GetTotalMass: " + ves.GetTotalMass().ToString(), KDebug.Type.CREATE);
//KDebug.Log("ves.GetTransform: " + ves.GetTransform().ToString());
//KDebug.Log("ves.tag: " + ves.tag.ToString());
KDebug.Log("ves.loaded: " + ves.loaded.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.isActiveAndEnabled: " + ves.isActiveAndEnabled.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.isActiveVessel: " + ves.isActiveVessel.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.isCommandable: " + ves.isCommandable.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.IsControllable: " + ves.IsControllable.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.launchTime: " + ves.launchTime.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.missionTime: " + ves.missionTime.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.packed: " + ves.packed.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.situation: " + ves.situation.ToString(), KDebug.Type.CREATE);
KDebug.Log("ves.state: " + ves.state.ToString(), KDebug.Type.CREATE);
//KDebug.Log("ves.ctrlState: " + ves.ctrlState.ToString());
KDebug.Log("ves.currentStage: " + ves.currentStage.ToString(), KDebug.Type.CREATE);
}
}
示例9: SteerShipToward
public static void SteerShipToward(Direction targetDir, FlightCtrlState c, Vessel vessel)
{
// I take no credit for this, this is a stripped down, rearranged version of MechJeb's attitude control system
var CoM = vessel.findWorldCenterOfMass();
var MoI = vessel.findLocalMOI(CoM);
var mass = vessel.GetTotalMass();
var up = (CoM - vessel.mainBody.position).normalized;
var target = targetDir.Rotation;
var vesselR = vessel.transform.rotation;
Quaternion delta;
delta = Quaternion.Inverse(Quaternion.Euler(90, 0, 0) * Quaternion.Inverse(vesselR) * target);
Vector3d deltaEuler = ReduceAngles(delta.eulerAngles);
deltaEuler.y *= -1;
Vector3d torque = GetTorque(vessel, c.mainThrottle);
Vector3d inertia = GetEffectiveInertia(vessel, torque);
Vector3d err = deltaEuler * Math.PI / 180.0F;
err += new Vector3d(inertia.x, inertia.z, inertia.y);
//err.Scale(SwapYZ(Vector3d.Scale(MoI, Inverse(torque))));
prev_err = err;
Vector3d act = 120.0f * err;
float precision = Mathf.Clamp((float)torque.x * 20f / MoI.magnitude, 0.5f, 10f);
float drive_limit = Mathf.Clamp01((float)(err.magnitude * 420.0f / precision));
act.x = Mathf.Clamp((float)act.x, -drive_limit, drive_limit);
act.y = Mathf.Clamp((float)act.y, -drive_limit, drive_limit);
act.z = Mathf.Clamp((float)act.z, -drive_limit, drive_limit);
//act = averageVector3d(averagedAct, act, 2);
c.roll = Mathf.Clamp((float)(c.roll + act.z), -drive_limit, drive_limit);
c.pitch = Mathf.Clamp((float)(c.pitch + act.x), -drive_limit, drive_limit);
c.yaw = Mathf.Clamp((float)(c.yaw + act.y), -drive_limit, drive_limit);
}
示例10: RecycleVessel
public float RecycleVessel(Vessel v)
{
float ConversionEfficiency = 0.8f;
double amount;
VesselResources scrap = new VesselResources (v);
PartResourceDefinition rp_def;
string target_resource = ExSettings.HullRecycleTarget;
rp_def = PartResourceLibrary.Instance.GetDefinition (target_resource);
if (FlightGlobals.ActiveVessel == v)
FlightGlobals.ForceSetActiveVessel (this.vessel);
float mass = 0;
foreach (var crew in v.GetVesselCrew ()) {
mass += RecycleKerbal (crew, null);
}
foreach (string resource in scrap.resources.Keys) {
amount = scrap.ResourceAmount (resource);
mass += ReclaimResource (resource, amount, v.name);
scrap.TransferResource (resource, -amount);
}
float hull_mass = v.GetTotalMass ();
amount = hull_mass * ConversionEfficiency / rp_def.density;
mass += ReclaimResource (target_resource, amount, v.name, String.Format ("hull({0})", target_resource));
v.Die ();
return mass;
}
示例11: createSpectralData
private static ImpactScienceData createSpectralData(CelestialBody crashBody, Vessel crashVessel, uint flightID)
{
double crashVelocity = crashVessel.srf_velocity.magnitude;
Log("Velocity=" + crashVelocity);
float crashMasss = crashVessel.GetTotalMass() * 1000;
double crashEnergy = 0.5 * crashMasss * crashVelocity * crashVelocity; //KE of crash
ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment("ImpactSpectrometer");
String biome = ScienceUtil.GetExperimentBiome(crashBody, crashVessel.latitude, crashVessel.longitude);
CBAttributeMapSO m = crashBody.BiomeMap;
CBAttributeMapSO.MapAttribute[] atts = m.Attributes;
foreach (CBAttributeMapSO.MapAttribute att in atts)
{
Log("att=" + att.name+"-"+att.value);
}
ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, ExperimentSituations.InSpaceLow, crashBody, biome);
double science = subject.scienceCap;
Log("Impact took place in " + biome + " at " + crashVessel.latitude + "," + crashVessel.longitude);
String flavourText = "Impact at {0} on {1}";
science = Math.Max(0, science - subject.science);
science /= subject.subjectValue;
ImpactScienceData data = new ImpactScienceData(ImpactScienceData.DataTypes.Spectral,
0, biome, crashVessel.latitude,
(float)(science * subject.dataScale), 1f, 0, subject.id,
String.Format(flavourText, biome, crashBody.theName), false, flightID);
ScreenMessages.PostScreenMessage(
String.Format("Recorded spectrographic impact data at {0} on {1}", biome, crashBody.theName),
5.0f, ScreenMessageStyle.UPPER_RIGHT);
return data;
}
示例12: createSeismicData
private static ImpactScienceData createSeismicData(CelestialBody crashBody, Vessel crashVessel, uint flightID)
{
double crashVelocity = crashVessel.srf_velocity.magnitude;
Log("Velocity=" + crashVelocity);
float crashMasss = crashVessel.GetTotalMass() * 1000;
double crashEnergy = 0.5 * crashMasss * crashVelocity * crashVelocity; //KE of crash
ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment("ImpactSeismometer");
ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, ExperimentSituations.SrfLanded, crashBody, "");
double science = translateKEToScience(crashEnergy, crashBody, subject);
String flavourText = "Impact of {0} on {1}";
Log(" caluculated science =" + science);
science = Math.Max(0.01, science - subject.science);
Log("residual science =" + science);
science /= subject.subjectValue;
Log("divided science =" + science);
ImpactScienceData data = new ImpactScienceData(ImpactScienceData.DataTypes.Seismic,
(float)crashEnergy, null, crashVessel.latitude,
(float)(science * subject.dataScale), 1f, 0, subject.id,
String.Format(flavourText, energyFormat(crashEnergy), crashBody.theName), false, flightID);
ScreenMessages.PostScreenMessage(
String.Format("Recorded seismic impact of {0} on {1}",energyFormat(crashEnergy), crashBody.theName),
5.0f, ScreenMessageStyle.UPPER_RIGHT);
return data;
}
示例13: createAsteroidSpectralData
private static ImpactScienceData createAsteroidSpectralData(CelestialBody crashBody, Vessel asteroid, Vessel crashVessel, uint flightID)
{
double crashVelocity = crashVessel.srf_velocity.magnitude;
Log("Velocity=" + crashVelocity);
float crashMasss = crashVessel.GetTotalMass() * 1000;
double crashEnergy = 0.5 * crashMasss * crashVelocity * crashVelocity; //KE of crash
ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment("AsteroidSpectometry");
ExperimentSituations situation = ScienceUtil.GetExperimentSituation(asteroid);
ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, situation, asteroid.id.ToString(), asteroid.GetName(), crashBody, "");
double science = subject.scienceCap;
Log("Impact took place in " + situation);
String flavourText = "Impact at {0} on {1}";
science /= subject.subjectValue;
ImpactScienceData data = new ImpactScienceData(0, asteroid.GetName(),
(float)(science * subject.dataScale), 1f, 0, subject.id,
String.Format(flavourText, asteroid.GetName(), crashBody.theName), false, flightID);
ScreenMessages.PostScreenMessage(
String.Format("Recorded spectrographic impact data at {0} around {1}", asteroid.GetName(), crashBody.theName),
5.0f, ScreenMessageStyle.UPPER_RIGHT);
return data;
}
示例14: getVesselUpdate
private KLFVesselUpdate getVesselUpdate(Vessel vessel)
{
if (vessel == null || vessel.mainBody == null)
return null;
//Create a KLFVesselUpdate from the vessel data
KLFVesselUpdate update = new KLFVesselUpdate();
if (vessel.vesselName.Length <= MAX_VESSEL_NAME_LENGTH)
update.name = vessel.vesselName;
else
update.name = vessel.vesselName.Substring(0, MAX_VESSEL_NAME_LENGTH);
update.player = playerName;
update.id = vessel.id;
Vector3 pos = vessel.mainBody.transform.InverseTransformPoint(vessel.GetWorldPos3D());
Vector3 dir = vessel.mainBody.transform.InverseTransformDirection(vessel.transform.up);
Vector3 vel = vessel.mainBody.transform.InverseTransformDirection(vessel.GetObtVelocity());
for (int i = 0; i < 3; i++)
{
update.pos[i] = pos[i];
update.dir[i] = dir[i];
update.vel[i] = vel[i];
}
//Determine situation
if (vessel.loaded && vessel.GetTotalMass() <= 0.0)
update.situation = Situation.DESTROYED;
else
{
switch (vessel.situation)
{
case Vessel.Situations.LANDED:
update.situation = Situation.LANDED;
break;
case Vessel.Situations.SPLASHED:
update.situation = Situation.SPLASHED;
break;
case Vessel.Situations.PRELAUNCH:
update.situation = Situation.PRELAUNCH;
break;
case Vessel.Situations.SUB_ORBITAL:
if (vessel.orbit.timeToAp < vessel.orbit.period / 2.0)
update.situation = Situation.ASCENDING;
else
update.situation = Situation.DESCENDING;
break;
case Vessel.Situations.ORBITING:
update.situation = Situation.ORBITING;
break;
case Vessel.Situations.ESCAPING:
if (vessel.orbit.timeToPe > 0.0)
update.situation = Situation.ENCOUNTERING;
else
update.situation = Situation.ESCAPING;
break;
case Vessel.Situations.DOCKED:
update.situation = Situation.DOCKED;
break;
case Vessel.Situations.FLYING:
update.situation = Situation.FLYING;
break;
default:
update.situation = Situation.UNKNOWN;
break;
}
}
if (vessel == FlightGlobals.ActiveVessel)
{
update.state = State.ACTIVE;
//Set vessel details since it's the active vessel
update.detail = getVesselDetail(vessel);
}
else if (vessel.isCommandable)
update.state = State.INACTIVE;
else
update.state = State.DEAD;
update.timeScale = (float)Planetarium.TimeScale;
update.bodyName = vessel.mainBody.bodyName;
return update;
}
示例15: RecycleVessel
public float RecycleVessel(Vessel v)
{
float ConversionEfficiency = 0.8f;
double amount;
VesselResources scrap = new VesselResources (v);
string target_resource;
PartResourceDefinition rp_def;
if (ExLaunchPad.kethane_present) {
target_resource = "Metal";
} else {
target_resource = "RocketParts";
}
rp_def = PartResourceLibrary.Instance.GetDefinition (target_resource);
if (FlightGlobals.ActiveVessel == v)
FlightGlobals.ForceSetActiveVessel (this.vessel);
float mass = 0;
foreach (var crew in v.GetVesselCrew ()) {
mass += RecycleKerbal (crew, null);
}
foreach (string resource in scrap.resources.Keys) {
amount = scrap.ResourceAmount (resource);
mass += ReclaimResource (resource, amount, v.name);
scrap.TransferResource (resource, -amount);
}
float hull_mass = v.GetTotalMass ();
amount = hull_mass * ConversionEfficiency / rp_def.density;
mass += ReclaimResource (target_resource, amount, v.name, "hull");
v.Die ();
return mass;
}