本文整理汇总了C#中ProtoVessel.GetVesselCrew方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoVessel.GetVesselCrew方法的具体用法?C# ProtoVessel.GetVesselCrew怎么用?C# ProtoVessel.GetVesselCrew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoVessel
的用法示例。
在下文中一共展示了ProtoVessel.GetVesselCrew方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecordVesselRecovered
public void RecordVesselRecovered(ProtoVessel vessel)
{
List<ProtoCrewMember> crew = vessel.GetVesselCrew();
foreach (ProtoCrewMember member in crew)
{
if (!member.IsTourist())
{
Log.Info("kerbal " + member.name + " ended a mission ");
hallOfFame.RecordMissionFinished(member);
}
}
}
示例2: addRemoteVessel
private void addRemoteVessel(ProtoVessel protovessel, Guid vessel_id, KMPVesselUpdate update = null, double distance = 501d)
{
if (isInFlight && vessel_id == FlightGlobals.ActiveVessel.id)
{
KMPClientMain.DebugLog("Attempted to update controlled vessel!");
return;
}
KMPClientMain.DebugLog("addRemoteVessel");
Vector3 newWorldPos = Vector3.zero, newOrbitVel = Vector3.zero;
bool setTarget = false, wasLoaded = false;
try
{
//Ensure this vessel isn't already loaded
Vessel oldVessel = FlightGlobals.Vessels.Find (v => v.id == vessel_id);
if (oldVessel != null) {
KMPClientMain.DebugLog("killing extant vessel");
wasLoaded = oldVessel.loaded;
if (protovessel.vesselType == VesselType.EVA && wasLoaded)
{
return; //Don't touch EVAs here
}
else
{
setTarget = FlightGlobals.fetch.VesselTarget != null && FlightGlobals.fetch.VesselTarget.GetVessel().id == vessel_id;
if (oldVessel.loaded)
{
newWorldPos = oldVessel.transform.position;
if (oldVessel.altitude > 10000d)
newOrbitVel = oldVessel.GetObtVelocity();
}
oldVessel.Die();
}
}
if (protovessel.vesselType != VesselType.EVA && serverVessels_Parts.ContainsKey(vessel_id))
{
KMPClientMain.DebugLog("killing known precursor vessels");
foreach (Part part in serverVessels_Parts[vessel_id])
{
try { if (!part.vessel.isEVA) part.vessel.Die(); } catch {}
}
}
} catch {}
try
{
if ((protovessel.vesselType != VesselType.Debris && protovessel.vesselType != VesselType.Unknown) && protovessel.situation == Vessel.Situations.SUB_ORBITAL && protovessel.altitude < 25d)
{
//Land flags, vessels and EVAs that are on sub-orbital trajectory
KMPClientMain.DebugLog("Placing sub-orbital protovessel on surface");
protovessel.situation = Vessel.Situations.LANDED;
protovessel.landed = true;
if (protovessel.vesselType == VesselType.Flag) protovessel.height = -1;
}
//Don't bother with suborbital debris
else if (protovessel.vesselType == VesselType.Debris && protovessel.situation == Vessel.Situations.SUB_ORBITAL) return;
CelestialBody body = null;
if (update != null)
{
body = FlightGlobals.Bodies.Find(b => b.name == update.bodyName);
if (update.situation != Situation.LANDED && update.situation != Situation.SPLASHED)
{
if (body.atmosphere && body.maxAtmosphereAltitude > protovessel.altitude)
{
//In-atmo vessel--only load if within visible range
if (distance > 500d)
return;
}
}
}
if (isInSafetyBubble(protovessel.position, body, protovessel.altitude)) //refuse to load anything too close to the KSC
{
KMPClientMain.DebugLog("Tried to load vessel too close to KSC");
return;
}
IEnumerator<ProtoCrewMember> crewEnum = HighLogic.CurrentGame.CrewRoster.GetEnumerator();
int applicants = 0;
while (crewEnum.MoveNext())
if (crewEnum.Current.rosterStatus == ProtoCrewMember.RosterStatus.AVAILABLE) applicants++;
if (protovessel.GetVesselCrew().Count * 5 > applicants)
{
KMPClientMain.DebugLog("Adding crew applicants");
for (int i = 0; i < (protovessel.GetVesselCrew().Count * 5);)
{
ProtoCrewMember protoCrew = CrewGenerator.RandomCrewMemberPrototype();
if (!HighLogic.CurrentGame.CrewRoster.ExistsInRoster(protoCrew.name))
{
HighLogic.CurrentGame.CrewRoster.AddCrewMember(protoCrew);
i++;
}
}
}
if (vessels.ContainsKey(vessel_id.ToString()) && (!serverVessels_LoadDelay.ContainsKey(vessel_id) || (serverVessels_LoadDelay.ContainsKey(vessel_id) ? serverVessels_LoadDelay[vessel_id] < UnityEngine.Time.realtimeSinceStartup : false)))
{
protovessel.Load(HighLogic.CurrentGame.flightState);
Vessel created_vessel = protovessel.vesselRef;
//.........这里部分代码省略.........
示例3: OnVesselRecovered
private void OnVesselRecovered(ProtoVessel v)
{
// Don't check if we're not ready to complete
if (!ReadyToComplete())
{
return;
}
// EVA vessel
if (v.vesselType == VesselType.EVA)
{
if (v.protoPartSnapshots != null)
{
foreach (ProtoPartSnapshot p in v.protoPartSnapshots)
{
foreach (ProtoCrewMember pcm in p.protoModuleCrew)
{
recovered[pcm.name] = true;
}
}
}
}
else
{
foreach (ProtoCrewMember crew in v.GetVesselCrew())
{
if (recovered.ContainsKey(crew.name))
{
recovered[crew.name] = true;
}
}
}
TestConditions();
}
示例4: OnVesselRecovered
// callback for vessel recovered
private void OnVesselRecovered(ProtoVessel vessel, bool flag)
{
// its better to be safe than sorry
if (vessel == null) return;
//
// log crew statistics (not really useful)
foreach (ProtoCrewMember kerbal in vessel.GetVesselCrew())
{
Debug.Log("crew member " + kerbal.name + " total missions: " + adapter.GetMissionsFlownForKerbal(kerbal)); // without the current one
Debug.Log("crew member " + kerbal.name + " research points: " + adapter.GetResearchForKerbal(kerbal));
Debug.Log("crew member " + kerbal.name + " dockings: " + adapter.GetDockingsForKerbal(kerbal));
Debug.Log("crew member " + kerbal.name + " contracts complteted: " + adapter.GetContractsCompletedForKerbal(kerbal));
}
}
示例5: OnVesselRecovered
private void OnVesselRecovered(ProtoVessel v)
{
LoggingUtil.LogVerbose(this, "OnVesselRecovered: " + v);
// EVA vessel
if (v.vesselType == VesselType.EVA)
{
foreach (ProtoPartSnapshot p in v.protoPartSnapshots)
{
foreach (string name in p.protoCrewNames)
{
// Find this crew member in our data
foreach (KerbalData kd in kerbals)
{
if (kd.name == name && kd.addToRoster)
{
// Add them to the roster
kd.crewMember.type = ProtoCrewMember.KerbalType.Crew;
}
}
}
}
}
// Vessel with crew
foreach (ProtoCrewMember crewMember in v.GetVesselCrew())
{
foreach (KerbalData kd in kerbals)
{
if (kd.crewMember == crewMember && kd.addToRoster)
{
// Add them to the roster
crewMember.type = ProtoCrewMember.KerbalType.Crew;
}
}
}
}
示例6: addRemoteVessel
private void addRemoteVessel(ProtoVessel protovessel, Guid vessel_id, KMPVessel kvessel = null, KMPVesselUpdate update = null, double distance = 501d)
{
if (vessel_id == FlightGlobals.ActiveVessel.id && (serverVessels_InUse.ContainsKey(vessel_id) ? !serverVessels_InUse.ContainsKey(vessel_id) : false)) return;
KMPClientMain.DebugLog("addRemoteVessel");
Vector3 newWorldPos = Vector3.zero, newOrbitVel = Vector3.zero;
bool setTarget = false, wasLoaded = false, wasActive = false;
Vessel oldVessel = null;
try
{
//Ensure this vessel isn't already loaded
oldVessel = FlightGlobals.Vessels.Find (v => v.id == vessel_id);
if (oldVessel != null) {
wasLoaded = oldVessel.loaded;
if (protovessel.vesselType == VesselType.EVA && wasLoaded)
{
return; //Don't touch EVAs here
}
else
{
setTarget = FlightGlobals.fetch.VesselTarget != null && FlightGlobals.fetch.VesselTarget.GetVessel().id == vessel_id;
if (oldVessel.loaded)
{
newWorldPos = oldVessel.transform.position;
if (oldVessel.altitude > 10000d)
newOrbitVel = oldVessel.GetObtVelocity();
}
if (oldVessel.id == FlightGlobals.ActiveVessel.id)
wasActive = true;
}
}
if (protovessel.vesselType != VesselType.EVA && serverVessels_Parts.ContainsKey(vessel_id))
{
KMPClientMain.DebugLog("killing known precursor vessels");
foreach (Part part in serverVessels_Parts[vessel_id])
{
try { if (!part.vessel.isEVA && part.vessel.id != oldVessel.id) part.vessel.Die(); } catch {}
}
}
} catch {}
try
{
if ((protovessel.vesselType != VesselType.Debris && protovessel.vesselType != VesselType.Unknown) && protovessel.situation == Vessel.Situations.SUB_ORBITAL && protovessel.altitude < 25d)
{
//Land flags, vessels and EVAs that are on sub-orbital trajectory
KMPClientMain.DebugLog("Placing sub-orbital protovessel on surface");
protovessel.situation = Vessel.Situations.LANDED;
protovessel.landed = true;
if (protovessel.vesselType == VesselType.Flag) protovessel.height = -1;
}
//Don't bother with suborbital debris
else if (protovessel.vesselType == VesselType.Debris && protovessel.situation == Vessel.Situations.SUB_ORBITAL) return;
CelestialBody body = null;
if (update != null)
{
body = FlightGlobals.Bodies.Find(b => b.name == update.bodyName);
if (update.situation != Situation.LANDED && update.situation != Situation.SPLASHED)
{
if (body.atmosphere && body.maxAtmosphereAltitude > protovessel.altitude)
{
//In-atmo vessel--only load if within visible range
if (distance > 500d)
return;
}
}
}
if (isInSafetyBubble(protovessel.position, body, protovessel.altitude)) //refuse to load anything too close to the KSC
{
KMPClientMain.DebugLog("Tried to load vessel too close to KSC");
return;
}
IEnumerator<ProtoCrewMember> crewEnum = HighLogic.CurrentGame.CrewRoster.GetEnumerator();
int applicants = 0;
while (crewEnum.MoveNext())
if (crewEnum.Current.rosterStatus == ProtoCrewMember.RosterStatus.AVAILABLE) applicants++;
if (protovessel.GetVesselCrew().Count * 5 > applicants)
{
KMPClientMain.DebugLog("Adding crew applicants");
for (int i = 0; i < (protovessel.GetVesselCrew().Count * 5);)
{
ProtoCrewMember protoCrew = CrewGenerator.RandomCrewMemberPrototype();
if (!HighLogic.CurrentGame.CrewRoster.ExistsInRoster(protoCrew.name))
{
HighLogic.CurrentGame.CrewRoster.AddCrewMember(protoCrew);
i++;
}
}
}
if (vessels.ContainsKey(vessel_id.ToString()) && (serverVessels_LoadDelay.ContainsKey(vessel_id) ? serverVessels_LoadDelay[vessel_id] < UnityEngine.Time.realtimeSinceStartup : true))
{
if (wasActive)
{
KMPClientMain.DebugLog("Preparing active vessel for replacement");
oldVessel.MakeInactive();
foreach (Part part in oldVessel.Parts)
//.........这里部分代码省略.........
示例7: OnVesselRecovered
private void OnVesselRecovered(ProtoVessel v)
{
// Don't check if we're not ready to complete
if (!ReadyToComplete())
{
return;
}
foreach (ProtoCrewMember crew in v.GetVesselCrew())
{
if (recovered.ContainsKey(crew.name))
{
recovered[crew.name] = true;
}
}
TestConditions();
}
示例8: InitKMPVesselUpdate
private void InitKMPVesselUpdate(Vessel _vessel, bool includeProtoVessel)
{
pos = new float[3];
dir = new float[3];
vel = new float[3];
o_vel = new double[3];
s_vel = new double[3];
w_pos = new double[3];
rot = new float[4];
id = _vessel.id;
if (_vessel.packed)
{
flightCtrlState = new KMPFlightCtrlState(new FlightCtrlState());
}
else
{
flightCtrlState = new KMPFlightCtrlState(_vessel.ctrlState);
}
if (includeProtoVessel)
{
protoVesselNode = new ConfigNode();
ProtoVessel proto;
try
{
proto = new ProtoVessel(_vessel);
}
catch (Exception e)
{
Log.Debug("Exception thrown in InitKMPVesselUpdate(), catch 1, Exception: {0}", e.ToString());
proto = null;
}
if (proto != null)
{
foreach (ProtoCrewMember crewMember in proto.GetVesselCrew())
{
crewMember.KerbalRef = null;
}
proto.Save(protoVesselNode);
}
}
}
示例9: OnVesselRecovered
private void OnVesselRecovered(ProtoVessel v, bool quick)
{
LoggingUtil.LogVerbose(this, "OnVesselRecovered: " + v);
// EVA vessel
if (v.vesselType == VesselType.EVA)
{
foreach (ProtoPartSnapshot p in v.protoPartSnapshots)
{
foreach (string name in p.protoCrewNames)
{
// Find this crew member in our data and remove them
ProtoCrewMember passenger = passengers.Keys.Where(pcm => pcm.name == name).FirstOrDefault();
if (passenger != null)
{
passengers[passenger] = false;
}
}
}
}
// Vessel with crew
foreach (ProtoCrewMember crewMember in v.GetVesselCrew())
{
// Find this crew member in our data and remove them
ProtoCrewMember passenger = passengers.Keys.Where(pcm => pcm == crewMember).FirstOrDefault();
if (passenger != null)
{
passengers[passenger] = false;
}
}
}
示例10: OnVesselRecovered
private void OnVesselRecovered(ProtoVessel vessel)
{
if (vessel == null)
{
Log.Warning("vessel recover without a valid vessel detected");
return;
}
Log.Info("EventObserver:: OnVesselRecovered " + vessel.vesselName);
// record recover of vessel
recorder.RecordVesselRecovered(vessel);
// check for kerbal specific achiements
HallOfFame.Instance().BeginArwardOfRibbons();
foreach (ProtoCrewMember member in vessel.GetVesselCrew())
{
CheckAchievementsForCrew(member);
}
HallOfFame.Instance().EndArwardOfRibbons();
//
// ------ MissionSummary ------
if(HighLogic.LoadedScene == GameScenes.SPACECENTER)
{
if (FinalFrontier.configuration.IsMissionSummaryEnabled())
{
double technicalMissionEndTime = Planetarium.GetUniversalTime();
MissionSummaryWindow missionSummaryWindow = new MissionSummaryWindow();
missionSummaryWindow.SetSummaryForVessel(vessel, technicalMissionEndTime);
missionSummaryWindow.SetVisible(true);
}
}
//
// refresh roster status
HallOfFame.Instance().Refresh();
}
示例11: OnScienceReceived
private void OnScienceReceived(float science, ScienceSubject subject, ProtoVessel vessel, bool flag)
{
Log.Detail("EventObserver::OnScienceReceived: " + science + ", flag=" + flag);
if (vessel == null) return;
HallOfFame halloffame = HallOfFame.Instance();
//
halloffame.BeginArwardOfRibbons();
try
{
foreach (ProtoCrewMember kerbal in vessel.GetVesselCrew())
{
if (!kerbal.IsTourist())
{
halloffame.RecordScience(kerbal, science);
CheckAchievementsForCrew(kerbal, false);
}
}
}
finally
{
// commit ribbons
halloffame.EndArwardOfRibbons();
}
}
示例12: OnVesselRecovered
private void OnVesselRecovered(ProtoVessel v)
{
LoggingUtil.LogVerbose(this, "OnVesselRecovered: " + v);
// EVA vessel
if (v.vesselType == VesselType.EVA)
{
foreach (ProtoPartSnapshot p in v.protoPartSnapshots)
{
{
LoggingUtil.LogVerbose(this, " p: " + p);
foreach (string name in p.protoCrewNames)
{
// Find this crew member in our data
foreach (VesselData vd in vessels)
{
foreach (CrewData cd in vd.crew)
{
if (cd.name == name && cd.addToRoster)
{
// Add them to the roster
ProtoCrewMember pcm = HighLogic.CurrentGame.CrewRoster.AllKerbals().Where(cm => cm.name == cd.name).First();
pcm.type = ProtoCrewMember.KerbalType.Crew;
}
}
}
}
}
}
}
// Vessel with crew
foreach (ProtoCrewMember crewMember in v.GetVesselCrew())
{
// Find this crew member in our data
foreach (VesselData vd in vessels)
{
foreach (CrewData cd in vd.crew)
{
if (cd.name == crewMember.name && cd.addToRoster)
{
// Add them to the roster
ProtoCrewMember pcm = HighLogic.CurrentGame.CrewRoster.AllKerbals().Where(cm => cm.name == cd.name).First();
pcm.type = ProtoCrewMember.KerbalType.Crew;
}
}
// Remove any other crew
RemoveCrew(vd);
}
}
}
示例13: RemoveSnacks
/**
* Removes the calculated number of snacks from the vessel.
* returns the number of snacks that were required, but missing.
* */
public double RemoveSnacks(ProtoVessel pv)
{
double demand = pv.GetVesselCrew().Count * snacksPer;
double extra = CalculateExtraSnacksRequired(pv.GetVesselCrew());
//Debug.Log("SnackDemand(" + pv.vesselName +"): e: " + extra + " r:" + demand);
if ((demand + extra) <= 0)
return 0;
double fed = GetSnackResource(pv.protoPartSnapshots, demand + extra);
if (fed == 0)//unable to feed, no skipping or extra counted
return pv.GetVesselCrew().Count * snacksPer;
return demand + extra - fed;
}
示例14: SetSummaryForVessel
public void SetSummaryForVessel(ProtoVessel vessel, double missionEndTime = 0)
{
Summaries.Clear();
this.vessel = vessel;
if (vessel == null) return;
Log.Detail("showing mission summary for "+vessel);
foreach(ProtoCrewMember kerbal in vessel.GetVesselCrew())
{
Summary summary = new Summary(kerbal);
Summaries.Add(summary);
foreach (Ribbon ribbon in HallOfFame.Instance().GetRibbonsOfLatestMission(kerbal, missionEndTime))
{
summary.newRibbons.Add(ribbon);
}
}
}