本文整理汇总了C#中Vessel类的典型用法代码示例。如果您正苦于以下问题:C# Vessel类的具体用法?C# Vessel怎么用?C# Vessel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vessel类属于命名空间,在下文中一共展示了Vessel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: findVesselFwdAxis
/// <summary>
/// Find the vessel orientation at the CoM by interpolating from surrounding part transforms
/// This orientation should be significantly more resistant to vessel flex/wobble than the vessel transform (root part) as a free body rotates about it's CoM
///
/// Has an issue with the origin shifter causing random bounces
/// </summary>
public void findVesselFwdAxis(Vessel v)
{
Part closestPart = v.rootPart;
float offset = (closestPart.transform.position - v.CurrentCoM).sqrMagnitude; // only comparing magnitude, sign and actual value don't matter
foreach (Part p in v.Parts)
{
float partOffset = (p.partTransform.position - v.CurrentCoM).sqrMagnitude;
if (partOffset < offset)
{
closestPart = p;
offset = partOffset;
}
}
///
/// now require two things, accounting for any rotation in part placement, and interpolating with surrounding parts (parent/children/symmetry counterparts) to "shift" the location to the CoM
/// accounting for rotation is the most important, the nearby position will work for now.
/// Vector3 location = closestPart.partTransform.position - v.CurrentCoM;
///
vesselFacingAxis = closestPart.transform.localRotation * closestPart.orgRot.Inverse() * Vector3.up;
if (closestPart.symmetryCounterparts != null)
{
for (int i = 0; i < closestPart.symmetryCounterparts.Count; i++)
{
vesselFacingAxis += closestPart.symmetryCounterparts[i].transform.localRotation * closestPart.symmetryCounterparts[i].orgRot.Inverse() * Vector3.up;
}
vesselFacingAxis /= (closestPart.symmetryCounterparts.Count + 1);
}
}
示例2: values
protected override List<Value> values(Vessel vessel, GameEvent events)
{
List<Value> v = new List<Value> ();
double a = 0;
if (vessel != null) {
foreach (Part p in vessel.parts) {
if (p.Resources [name] != null) {
a += p.Resources [name].amount;
}
}
}
if (maxAmount != 0) {
if(vessel == null) {
v.Add(new Value("max. resource " + name, maxAmount));
} else {
v.Add(new Value("max. resource " + name, maxAmount, a, a <= maxAmount));
}
}
if (minAmount != 0) {
if(vessel == null) {
v.Add(new Value("min. resource " + name, minAmount));
} else {
v.Add(new Value("min. resource " + name, minAmount, a, a >= minAmount));
}
}
return v;
}
示例3: values
protected override List<Value> values(Vessel vessel, GameEvent events)
{
List<Value> values = new List<Value> ();
int count = 0;
if (vessel != null) {
foreach (Part p in vessel.Parts) {
if (p.partInfo.name.Equals (partName)) {
++count;
}
}
}
if(maxPartCount == -1) {
if (vessel == null) {
values.Add (new Value ("Part", partCount + "x " + partName));
} else {
values.Add (new Value ("Part", partCount + "x " + partName, "" + count, count >= partCount));
}
} else {
if (vessel == null) {
values.Add (new Value ("max part", maxPartCount + "x " + partName));
} else {
values.Add (new Value ("max part", maxPartCount + "x " + partName, "" + count, count <= maxPartCount));
}
}
return values;
}
示例4: endPipe
//called when un-clicking on a vessel
public void endPipe(Vessel end)
{
if(_currentlyConnecting != null)
_currentlyConnecting.setOutputVessel(end);
_currentlyConnecting = null;
}
示例5: FlyingCamera
public FlyingCamera(Part thatPart, RenderTexture screen, float aspect)
{
ourVessel = thatPart.vessel;
ourPart = thatPart;
screenTexture = screen;
cameraAspect = aspect;
}
示例6: OnVesselWasModified
private void OnVesselWasModified(Vessel data)
{
if (!ReferenceEquals(data, FlightGlobals.ActiveVessel))
{
DebugHelper.Debug("OnVesselWasModified called on non-active vessel, skipping");
return;
}
DebugHelper.Debug("OnVesselWasModified, groups count {0}", Groups.Count);
//_gui.ClearGroups();
foreach (var engineGroup in Groups.Values)
{
DebugHelper.Debug("Cleaning group {0}: {1} engine(s)", engineGroup.GroupId, engineGroup.EngineRefList.Count);
engineGroup.EngineRefList.Clear();
}
//Groups.Clear();
RecurseParts(data.rootPart,
x =>
{
//DebugHelper.Debug("Part {0}", x.name);
//x.FindModuleImplementing<>()
if (!x.Modules.Contains("EngineGroupModule"))
{
//DebugHelper.Debug("!x.Modules.Contains('EngineGroupModule')");
return;
}
var moduleRef = x.Modules["EngineGroupModule"] as EngineGroupModule;
if (moduleRef == null)
{
//DebugHelper.Debug("moduleRef == null");
return;
}
var groupId = moduleRef.EngineGroupId;
if (string.IsNullOrEmpty(groupId))
return;
if (!Groups.ContainsKey(groupId))
{
DebugHelper.Debug("Creating a group {0}", groupId);
Groups.Add(groupId, new EngineGroup(groupId));
_gui.AddGroup(Groups[groupId]);
}
foreach (var wrapper in moduleRef.Wrappers)
{
Groups[groupId].EngineRefList.Add(wrapper);
}
});
foreach (var groupId in Groups.Keys.ToList())
{
if (Groups[groupId].EngineRefList.Count == 0)
{
DebugHelper.Debug("Removing group {0} (no engines)", groupId);
_gui.RemoveGroup(Groups[groupId]);
Groups.Remove(groupId);
}
}
if (Groups.Count == 0)
{
_gui.DisplayNoGroupsMessage();
}
}
示例7: OnVesselPack
private void OnVesselPack(Vessel vessel)
{
if (vessel.situation == Vessel.Situations.FLYING)
{
lastPackTime[vessel.id] = UnityEngine.Time.realtimeSinceStartup;
}
}
示例8: ForgetVessel
public void ForgetVessel(Vessel hackyVessel)
{
if (loadingFlyingVessels.ContainsKey(hackyVessel.id))
{
loadingFlyingVessels.Remove(hackyVessel.id);
}
}
示例9: ActiveControlSysIsOnVessel
public static bool ActiveControlSysIsOnVessel(Vessel v)
{
if (FARControlSys.ActiveControlSys != null)
return FARControlSys.ActiveControlSys.vessel == v;
return false;
}
示例10: RemoveAllManeuverNodes
public static void RemoveAllManeuverNodes(Vessel vessel)
{
while (vessel.patchedConicSolver.maneuverNodes.Count > 0)
{
vessel.patchedConicSolver.RemoveManeuverNode(vessel.patchedConicSolver.maneuverNodes.Last());
}
}
示例11: isDone
public override bool isDone(Vessel vessel, GameEvent events)
{
if (vessel == null)
{
return false;
}
if (doneOnce)
{
return true;
}
List<Value> values = getValues(vessel, events);
foreach (Value v in values)
{
if (!v.done)
{
return false;
}
}
// We remember that we have previously completed this goal.
doneOnce = true;
return true;
}
示例12: GetThrustTorque
public static double GetThrustTorque(Part p, Vessel vessel)
{
if (p.State == PartStates.ACTIVE)
{
var gimbal = p.Modules.OfType<ModuleGimbal>().FirstOrDefault();
if (gimbal != null && !gimbal.gimbalLock)
{
var engine = p.Modules.OfType<ModuleEngines>().FirstOrDefault();
var fxengine = p.Modules.OfType<ModuleEnginesFX>().FirstOrDefault();
var magnitude = (p.Rigidbody.worldCenterOfMass - vessel.CoM).magnitude;
var gimbalRange = Math.Sin(Math.Abs(gimbal.gimbalRange));
var engineActive = engine != null && engine.isOperational;
var enginefxActive = fxengine != null && fxengine.isOperational;
if (engineActive)
{
return gimbalRange * engine.finalThrust * magnitude;
}
if (enginefxActive)
{
return gimbalRange * fxengine.finalThrust * magnitude;
}
}
}
return 0;
}
示例13: GetModel
public static VesselAerodynamicModel GetModel(Vessel ship, CelestialBody body)
{
foreach (var loadedAssembly in AssemblyLoader.loadedAssemblies)
{
try
{
switch (loadedAssembly.name)
{
case "FerramAerospaceResearch":
var FARAPIType = loadedAssembly.assembly.GetType("FerramAerospaceResearch.FARAPI");
var FARAPI_CalculateVesselAeroForces = FARAPIType.GetMethodEx("CalculateVesselAeroForces", BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(Vessel), typeof(Vector3).MakeByRefType(), typeof(Vector3).MakeByRefType(), typeof(Vector3), typeof(double) });
return new FARModel(ship, body, FARAPI_CalculateVesselAeroForces);
//case "MyModAssembly":
// implement here your atmo mod detection
// return new MyModModel(ship, body, any other parameter);
}
}
catch (Exception e)
{
Debug.Log("Trajectories: failed to interface with assembly " + loadedAssembly.name);
Debug.Log("Using stock model instead");
Debug.Log(e.ToString());
}
}
// Using stock model if no other aerodynamic is detected or if any error occured
return new StockModel(ship, body);
}
示例14: VesselDto
public VesselDto(Vessel vessel)
{
_VesselId = vessel.ID;
_OperatorId = vessel.OperatorId;
_VesselCode = vessel.VesselCode;
_VesselName = vessel.VesselName;
}
示例15: GetVesselCrew
/// <summary>
/// Gets the vessel crew and works for EVAs as well
/// </summary>
/// <param name="v"></param>
/// <returns></returns>
protected static IEnumerable<ProtoCrewMember> GetVesselCrew(Vessel v)
{
if (v == null)
{
yield break;
}
// EVA vessel
if (v.vesselType == VesselType.EVA)
{
if (v.parts == null)
{
yield break;
}
foreach (Part p in v.parts)
{
foreach (ProtoCrewMember pcm in p.protoModuleCrew)
{
yield return pcm;
}
}
}
else
{
// Vessel with crew
foreach (ProtoCrewMember pcm in v.GetVesselCrew())
{
yield return pcm;
}
}
}