本文整理汇总了C#中ProtoVessel类的典型用法代码示例。如果您正苦于以下问题:C# ProtoVessel类的具体用法?C# ProtoVessel怎么用?C# ProtoVessel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProtoVessel类属于命名空间,在下文中一共展示了ProtoVessel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RecoveryWatcher
private void RecoveryWatcher(float sci, ScienceSubject sub, ProtoVessel pv, bool reverse)
{
if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
{
float DMScience = sci;
DMUtils.DebugLog("Science Data Recovered For {0} Science", sci);
DMScienceData DMData = DMScienceScenario.SciScenario.getDMScience(sub.title);
if (DMData != null)
{
float oldSciVal = 0f;
if (sub.scienceCap != 0)
oldSciVal = Math.Max(0f, 1f - ((sub.science - sci) / sub.scienceCap));
DMScience = sub.subjectValue * DMData.BaseValue * DMData.SciVal * oldSciVal;
DMScienceScenario.SciScenario.submitDMScience(DMData, DMScience);
}
if (DMScience != sci)
{
float extraScience = sci - DMScience;
Debug.LogWarning(string.Format("[DMagic Orbital Science] [Asteroid Science Retrieval] Remove {0} Science From R&D Center After Asteroid Calculations", extraScience));
DMUtils.DebugLog("Remove {0} Science From R&D Center: From {1} To {2}", extraScience, ResearchAndDevelopment.Instance.Science, ResearchAndDevelopment.Instance.Science - extraScience);
ResearchAndDevelopment.Instance.AddScience(-1f * extraScience, TransactionReasons.ScienceTransmission);
}
}
}
开发者ID:kenjinsama,项目名称:Orbital-Science,代码行数:25,代码来源:DMRecoveryWatcher.cs
示例2: Save
public void Save()
{
if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && (FlightGlobals.fetch.activeVessel != null))
{
if (FlightGlobals.fetch.activeVessel.loaded && !FlightGlobals.fetch.activeVessel.packed)
{
if (FlightGlobals.fetch.activeVessel.situation != Vessel.Situations.FLYING)
{
savedVessel = new ConfigNode();
ProtoVessel tempVessel = new ProtoVessel(FlightGlobals.fetch.activeVessel);
tempVessel.Save(savedVessel);
savedSubspace = new Subspace();
savedSubspace.planetTime = Planetarium.GetUniversalTime();
savedSubspace.serverClock = TimeSyncer.fetch.GetServerClock();
savedSubspace.subspaceSpeed = 1f;
ScreenMessages.PostScreenMessage("Quicksaved!", 3f, ScreenMessageStyle.UPPER_CENTER);
}
else
{
ScreenMessages.PostScreenMessage("Cannot quicksave - Active vessel is in flight!", 3f, ScreenMessageStyle.UPPER_CENTER);
}
}
else
{
ScreenMessages.PostScreenMessage("Cannot quicksave - Active vessel is not loaded!", 3f, ScreenMessageStyle.UPPER_CENTER);
}
}
else
{
ScreenMessages.PostScreenMessage("Cannot quicksave - Not in flight!", 3f, ScreenMessageStyle.UPPER_CENTER);
}
}
开发者ID:martindevans,项目名称:DarkMultiPlayer,代码行数:32,代码来源:QuickSaveLoader.cs
示例3: OnVesselRecovered
private void OnVesselRecovered(ProtoVessel v)
{
// Don't check if we're not ready to complete
if (!ReadyToComplete())
{
return;
}
// Special handling for null vessel cases
if (v.vesselRef == null)
{
VesselParameterGroup vpg = GetParameterGroupHost();
if (vpg == null)
{
SetState(ParameterState.Complete);
}
else
{
}
}
recovered[v.vesselRef] = true;
CheckVessel(v.vesselRef);
}
开发者ID:linuxgurugamer,项目名称:ContractConfigurator,代码行数:26,代码来源:RecoverVessel.cs
示例4: addCrew
//add some crew to a vessel
public static void addCrew(ProtoVessel vsl, List<ProtoCrewMember> crew)
{
foreach(var p in vsl.protoPartSnapshots)
{
if(crew.Count == 0) break;
addCrew(p, crew);
}
}
开发者ID:pjslauta,项目名称:hangar,代码行数:9,代码来源:CrewTransfer.cs
示例5: scienceReceived
private void scienceReceived(float sci, ScienceSubject sub, ProtoVessel pv, bool reverse)
{
if (HighLogic.LoadedSceneIsFlight)
{
DMScienceData DMData = DMScienceScenario.SciScenario.getDMScience(sub.title);
if (DMData != null)
DMScienceScenario.SciScenario.submitDMScience(DMData, sci);
}
}
开发者ID:kenjinsama,项目名称:Orbital-Science,代码行数:9,代码来源:DMTransmissionWatcher.cs
示例6: GetVesselMissionID
/// <summary>
/// Gets the missionID of the ROOT part of the given vessel.
/// </summary>
/// <returns>The missionID</returns>
/// <param name="pvessel">The ProtoVessel to get the missionID of.</param>
public static uint GetVesselMissionID(ProtoVessel pvessel)
{
if(pvessel.protoPartSnapshots[pvessel.rootIndex] == null)
{
return 0;
} else {
return pvessel.protoPartSnapshots[pvessel.rootIndex].missionID;
}
}
开发者ID:OverloadUT,项目名称:OATBeanCounter,代码行数:14,代码来源:BCUtils.cs
示例7: vesselRecoveryProcessingEvent
public void vesselRecoveryProcessingEvent(ProtoVessel pvessel, MissionRecoveryDialog dialog, float recoveryFactor)
{
BeanCounter.LogFormatted_DebugOnly("---------- vesselRecoveryProcessingEvent ------------");
BeanCounter.LogFormatted_DebugOnly("recoveryFactor: {0:f3}", recoveryFactor);
BeanCounter.LogFormatted_DebugOnly("Vessel root missionID: {0}", BCUtils.GetVesselMissionID(pvessel));
// Get a list of every missionID from the recovered parts
List<uint> recovered_mission_ids =
(from ppart in pvessel.protoPartSnapshots
select ppart.missionID).ToList();
// Get a list of every unique part ID so we can match them up
List<uint> recovered_part_ids =
(from ppart in pvessel.protoPartSnapshots
select ppart.flightID).ToList();
// Now lets get all of the launches that contain recovered parts
List<BCLaunchData> recovered_launches =
(from launch in OATBeanCounterData.data.launches
where recovered_mission_ids.Contains(launch.missionID)
select launch).ToList();
// And finally we get the full list of every recovered part so we can flag them all as recovered
var recoveredparts =
from launch in recovered_launches
from part in launch.parts
where recovered_part_ids.Contains(part.uid)
select part;
foreach(BCVesselPartData partdata in recoveredparts)
{
BeanCounter.LogFormatted_DebugOnly("Flagging part as recovered: {0} - {1}", partdata.partName, partdata.uid);
partdata.status = BCVesselPartStatus.Recovered;
}
BCRecoveryData recovery = new BCRecoveryData(true);
OATBeanCounterData.data.recoveries.Add(recovery);
recovery.partIDs = recovered_part_ids;
recovery.recoveryFactor = recoveryFactor;
// Try to match this to the transaction
BCTransactionData transaction =
(from trans in OATBeanCounterData.data.transactions
where trans.time == HighLogic.fetch.currentGame.UniversalTime
&& trans.reason == TransactionReasons.VesselRecovery
select trans).SingleOrDefault();
if (transaction != null)
{
BeanCounter.LogFormatted_DebugOnly("Found matching transaction for this recovery: {0}", transaction.id);
recovery.transactionID = transaction.id;
transaction.dataID = recovery.id;
}
BeanCounter.LogFormatted_DebugOnly("--------- /vesselRecoveryProcessingEvent ------------");
}
开发者ID:OverloadUT,项目名称:OATBeanCounter,代码行数:56,代码来源:BCEvents.cs
示例8: GetTotalVesselCost
public static float GetTotalVesselCost(ProtoVessel vessel)
{
float total = 0;
foreach (ProtoPartSnapshot part in vessel.protoPartSnapshots)
{
float dry, wet;
total += ShipConstruction.GetPartCosts(part, part.partInfo, out dry, out wet);
}
return total;
}
开发者ID:MartynasStropa,项目名称:KSP_rusty,代码行数:10,代码来源:rustyRecoveryEvents.cs
示例9: AllocVessel
public void AllocVessel(NetworkViewID id, byte[] binaryCfg)
{
if (FlightGlobals.Vessels.Any(v => v.networkView != null && v.networkView.viewID == id))
return;
var cfg = (ConfigNode)IOUtils.DeserializeFromBinary(binaryCfg);
var protovessel = new ProtoVessel(cfg, HighLogic.CurrentGame.flightState);
protovessel.orbitSnapShot.meanAnomalyAtEpoch += 1;
protovessel.Load(HighLogic.CurrentGame.flightState);
var vessel = protovessel.vesselRef;
vessel.gameObject.AddNetworkView(id);
vessel.gameObject.AddComponent<VesselNetworker>();
}
开发者ID:Arduinology,项目名称:Khylib,代码行数:12,代码来源:Kestrel.cs
示例10: 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);
}
}
}
开发者ID:Kerbas-ad-astra,项目名称:FinalFrontier,代码行数:12,代码来源:AchievementRecorder.cs
示例11: OnVesselRecovered
private void OnVesselRecovered(ProtoVessel vessel, bool quick)
{
foreach (ProtoCrewMember pcm in VesselUtil.GetVesselCrew(vessel.vesselRef))
{
// Award the media star XP for each planet landed on
foreach (string target in pcm.flightLog.Entries.
Where(fle => fle.type == FlightLog.EntryType.Land.ToString()).
Select(fle => fle.target).ToList())
{
pcm.flightLog.AddEntry(MEDIA_STAR_XP, target);
}
}
}
开发者ID:jrossignol,项目名称:Strategia,代码行数:13,代码来源:MediaStar.cs
示例12: OnScienceReceived
private void OnScienceReceived(float amount, ScienceSubject subject, ProtoVessel vessel, bool reverseEngineered)
{
// Check that the science is for home
CelestialBody body = Science.GetCelestialBody(subject);
if (body == null || !body.isHomeWorld)
{
return;
}
Biome biome = Science.GetBiome(subject);
bool isKSC = biome != null && biome.IsKSC();
if (KSCScienceMultiplier > 0.0f && isKSC)
{
float delta = KSCScienceMultiplier * amount - amount;
ResearchAndDevelopment.Instance.AddScience(delta, TransactionReasons.Strategies);
CurrencyPopup.Instance.AddPopup(Currency.Science, delta, TransactionReasons.Strategies, Parent.Config.Title, true);
}
else if (nonKSCScienceMultiplier > 0.0f && !isKSC)
{
float delta = nonKSCScienceMultiplier * amount - amount;
ResearchAndDevelopment.Instance.AddScience(delta, TransactionReasons.Strategies);
CurrencyPopup.Instance.AddPopup(Currency.Science, delta, TransactionReasons.Strategies, Parent.Config.Title, true);
}
}
开发者ID:jrossignol,项目名称:Strategia,代码行数:24,代码来源:ScienceBooster.cs
示例13: protovesselHasDoneExperiement
public override bool protovesselHasDoneExperiement(ProtoVessel pv, AvailablePart experiment, CelestialBody targetBody, double contractAccepted)
{
NE_Helper.log("KEES-Experiement stategy");
foreach (ProtoPartSnapshot part in pv.protoPartSnapshots)
{
NE_Helper.log("KEES-Experiement stategy, Part: " + part.partName);
if (part.partName == experiment.name)
{
if (experimentFound(part, experiment, targetBody, contractAccepted))
return true;
}
else if (part.partName == KEES_PC)
{
if (payloadCarrierFound(part, experiment, targetBody, contractAccepted))
return true;
}
else if (isKasContainerPart(part))
{
if (payloadCarrierFound(part, experiment, targetBody, contractAccepted))
return true;
}
}
return false;
}
开发者ID:N3h3miah,项目名称:OrbitalMaterialScience,代码行数:24,代码来源:KEESExperimentRecovery.cs
示例14: onVesselRecoveryProcessing
// recoveryFraction - percentage of funds added after recovery, based on distance from KSC
public void onVesselRecoveryProcessing(ProtoVessel v, MissionRecoveryDialog dialog, float recoveryFraction)
{
KerbalGUIManager.print("[rusty] onVesselRecoveryProcessing: x = " + recoveryFraction);
KerbalGUIManager.print("[rusty] onVesselRecoveryProcessing: AddFunds = " + -dialog.fundsEarned);
// deduct recovered funds
Funding.Instance.AddFunds(-dialog.fundsEarned, TransactionReasons.VesselRecovery);
// calculate distance
// longest possible ground distance on Kerbin [km]
//const double HALF_CIRCLE = 2 * Mathf.PI * 600 / 2;
// distance from KSC [m]
double distance = SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(v.latitude, v.longitude));
// KSC is supposedly 25 m^2 in size, so no more than 5 km can be considered free
if (distance <= 5000.0)
{
distance = 0.0f;
}
KerbalGUIManager.print("[rusty] onVesselRecoveryProcessing: distance = " + distance + " m");
// calculate recovery price
// price of 1 metric tone per 1km
const double recoveryRate = 100.0;
double recoveryPrice = (double)vesselMass * (distance / 1000.0) * recoveryRate;
// reset funds
dialog.fundsEarned = 0.0;
// show recovery GUI
GUIRecovery wndRecovery = new GUIRecovery();
wndRecovery.vesselMass = vesselMass;
wndRecovery.vesselTitle = v.vesselName;
wndRecovery.recoveryPrice = recoveryPrice;
wndRecovery.recoveryDistance = Math.Ceiling(distance / 1000.0);
wndRecovery.show();
}
开发者ID:MartynasStropa,项目名称:KSP_rusty,代码行数:37,代码来源:rustyRecoveryEvents.cs
示例15: applyVesselUpdate
private void applyVesselUpdate(KMPVesselUpdate vessel_update, KMPVessel vessel)
{
serverVessels_RemoteID[vessel_update.id] = vessel_update.kmpID;
//Find the CelestialBody that matches the one in the update
CelestialBody update_body = null;
if (vessel.mainBody != null && vessel.mainBody.bodyName == vessel_update.bodyName)
update_body = vessel.mainBody; //Vessel already has the correct body
else
{
//Find the celestial body in the list of bodies
foreach (CelestialBody body in FlightGlobals.Bodies)
{
if (body.bodyName == vessel_update.bodyName)
{
update_body = body;
break;
}
}
}
Vector3 oldPosition = vessel.worldPosition;
if (update_body != null)
{
//Convert float arrays to Vector3s
Vector3 pos = new Vector3(vessel_update.pos[0], vessel_update.pos[1], vessel_update.pos[2]);
Vector3 dir = new Vector3(vessel_update.dir[0], vessel_update.dir[1], vessel_update.dir[2]);
Vector3 vel = new Vector3(vessel_update.vel[0], vessel_update.vel[1], vessel_update.vel[2]);
vessel.info = vessel_update;
vessel.setOrbitalData(update_body, pos, vel, dir);
}
KMPClientMain.DebugLog("vessel state: " + vessel_update.state.ToString() + ", tick=" + vessel_update.tick + ", realTick=" + Planetarium.GetUniversalTime());
if (vessel_update.state == State.ACTIVE && !vessel_update.isSyncOnlyUpdate && vessel_update.relTime != RelativeTime.FUTURE && !vessel_update.isDockUpdate)
{
//Update the player status info
VesselStatusInfo status = new VesselStatusInfo();
if (vessel_update.relTime == RelativeTime.PRESENT) status.info = vessel_update;
status.ownerName = vessel_update.player;
status.vesselName = vessel_update.name;
if (vessel.orbitValid)
status.orbit = vessel.orbitRenderer.driver.orbit;
status.lastUpdateTime = UnityEngine.Time.realtimeSinceStartup;
status.color = KMPVessel.generateActiveColor(status.ownerName);
if (playerStatus.ContainsKey(status.ownerName))
playerStatus[status.ownerName] = status;
else
playerStatus.Add(status.ownerName, status);
}
if (!vessel_update.id.Equals(Guid.Empty) && !docking)
{
//Update vessel privacy locks
if (!isInFlight || vessel_update.id != FlightGlobals.ActiveVessel.id)
{
serverVessels_InUse[vessel_update.id] = vessel_update.state == State.ACTIVE;
serverVessels_IsPrivate[vessel_update.id] = vessel_update.isPrivate;
serverVessels_IsMine[vessel_update.id] = vessel_update.isMine;
KMPClientMain.DebugLog("status flags updated: " + (vessel_update.state == State.ACTIVE) + " " + vessel_update.isPrivate + " " + vessel_update.isMine);
if (vessel_update.situation == Situation.DESTROYED)
{
KMPClientMain.DebugLog("killing vessel");
Vessel extant_vessel = FlightGlobals.Vessels.Find(v => v.id == vessel_update.id);
if (extant_vessel != null && !extant_vessel.isEVA) try { extant_vessel.Die(); } catch {}
return;
}
}
//Store protovessel if included
if (vessel_update.getProtoVesselNode() != null && (!isInFlight || vessel_update.id != FlightGlobals.ActiveVessel.id)) serverVessels_ProtoVessels[vessel_update.id] = vessel_update.getProtoVesselNode();
}
if (isInFlightOrTracking)
{
if (vessel_update.id != FlightGlobals.ActiveVessel.id)
{
KMPClientMain.DebugLog("retrieving vessel: " + vessel_update.id.ToString());
if (!vessel_update.id.Equals(Guid.Empty))
{
Vessel extant_vessel = vessel.vesselRef;
if (extant_vessel == null) extant_vessel = FlightGlobals.Vessels.Find(v => v.id == vessel_update.id);
if (isInFlight)
{
if (extant_vessel != null && vessel_update.state == State.ACTIVE && !vessel_update.isSyncOnlyUpdate)
{
extant_vessel.name = vessel_update.name + " <" + vessel_update.player + ">";
extant_vessel.vesselName = vessel_update.name + " <" + vessel_update.player + ">";
}
else if (extant_vessel != null)
{
extant_vessel.name = vessel_update.name;
extant_vessel.vesselName = vessel_update.name;
}
}
if (!serverVessels_LoadDelay.ContainsKey(vessel_update.id)
|| (serverVessels_LoadDelay.ContainsKey(vessel_update.id) ? (serverVessels_LoadDelay[vessel_update.id] < UnityEngine.Time.realtimeSinceStartup) : false))
{
float incomingDistance = 2500f;
//.........这里部分代码省略.........
开发者ID:Jumba,项目名称:KerbalMultiPlayer,代码行数:101,代码来源:KMPManager.cs
示例16: LoadVesselsIntoGame
//Called from main
public void LoadVesselsIntoGame()
{
DarkLog.Debug("Loading vessels into game");
foreach (KeyValuePair<string, Queue<VesselProtoUpdate>> vesselQueue in vesselProtoQueue)
{
while (vesselQueue.Value.Count > 0)
{
ConfigNode currentNode = vesselQueue.Value.Dequeue().vesselNode;
if (currentNode != null)
{
DodgeVesselActionGroups(currentNode);
DodgeVesselCrewValues(currentNode);
ProtoVessel pv = new ProtoVessel(currentNode, HighLogic.CurrentGame);
if (pv != null)
{
RegisterServerVessel(pv.vesselID.ToString());
HighLogic.CurrentGame.flightState.protoVessels.Add(pv);
}
}
}
}
DarkLog.Debug("Vessels loaded into game");
}
开发者ID:kevin-ye,项目名称:DarkMultiPlayer,代码行数:24,代码来源:VesselWorker.cs
示例17: OnVesselTerminated
public void OnVesselTerminated(ProtoVessel terminatedVessel)
{
string terminatedVesselID = terminatedVessel.vesselID.ToString();
//Check the vessel hasn't been changed in the future
if (LockSystem.fetch.LockExists("control-" + terminatedVesselID) && !LockSystem.fetch.LockIsOurs("control-" + terminatedVesselID))
{
ScreenMessages.PostScreenMessage("Cannot terminate vessel, the vessel is in use.", 5f, ScreenMessageStyle.UPPER_CENTER);
return;
}
if (VesselUpdatedInFuture(terminatedVesselID))
{
ScreenMessages.PostScreenMessage("Cannot terminate vessel, the vessel been changed in the future.", 5f, ScreenMessageStyle.UPPER_CENTER);
return;
}
if (!serverVessels.Contains(terminatedVesselID))
{
DarkLog.Debug("Cannot terminate a non-server vessel!");
return;
}
DarkLog.Debug("Removing vessel " + terminatedVesselID + ", name: " + terminatedVessel.vesselName + " from the server: Terminated");
unassignKerbals(terminatedVesselID);
serverVessels.Remove(terminatedVesselID);
NetworkWorker.fetch.SendVesselRemove(terminatedVesselID, false);
}
开发者ID:kevin-ye,项目名称:DarkMultiPlayer,代码行数:27,代码来源:VesselWorker.cs
示例18: SendVesselUpdateIfNeeded
private void SendVesselUpdateIfNeeded(Vessel checkVessel)
{
//Check vessel parts
if (ModWorker.fetch.modControl != ModControlMode.DISABLED)
{
if (!vesselPartsOk.ContainsKey(checkVessel.id.ToString()))
{
CheckVesselParts(checkVessel);
}
if (!vesselPartsOk[checkVessel.id.ToString()])
{
//Vessel with bad parts
return;
}
}
if (checkVessel.state == Vessel.State.DEAD)
{
//Don't send dead vessels
return;
}
if (checkVessel.vesselType == VesselType.Flag && checkVessel.id == Guid.Empty && checkVessel.vesselName != "Flag")
{
DarkLog.Debug("Fixing flag GUID for " + checkVessel.vesselName);
checkVessel.id = Guid.NewGuid();
}
//Only send updates for craft we have update locks for. Request the lock if it's not taken.
if (!LockSystem.fetch.LockExists("update-" + checkVessel.id.ToString()))
{
LockSystem.fetch.ThrottledAcquireLock("update-" + checkVessel.id.ToString());
//Wait until we have the update lock
return;
}
//Take the update lock off another player if we have the control lock and it's our vessel
if (checkVessel.id.ToString() == FlightGlobals.fetch.activeVessel.id.ToString())
{
if (LockSystem.fetch.LockExists("update-" + checkVessel.id.ToString()) && !LockSystem.fetch.LockIsOurs("update-" + checkVessel.id.ToString()) && LockSystem.fetch.LockIsOurs("control-" + checkVessel.id.ToString()))
{
LockSystem.fetch.ThrottledAcquireLock("update-" + checkVessel.id.ToString());
//Wait until we have the update lock
return;
}
}
//Send updates for unpacked vessels that aren't being flown by other players
bool notRecentlySentProtoUpdate = serverVesselsProtoUpdate.ContainsKey(checkVessel.id.ToString()) ? ((UnityEngine.Time.realtimeSinceStartup - serverVesselsProtoUpdate[checkVessel.id.ToString()]) > VESSEL_PROTOVESSEL_UPDATE_INTERVAL) : true;
bool notRecentlySentPositionUpdate = serverVesselsPositionUpdate.ContainsKey(checkVessel.id.ToString()) ? ((UnityEngine.Time.realtimeSinceStartup - serverVesselsPositionUpdate[checkVessel.id.ToString()]) > (1f / (float)DynamicTickWorker.fetch.sendTickRate)) : true;
//Check that is hasn't been recently sent
if (notRecentlySentProtoUpdate)
{
ProtoVessel checkProto = new ProtoVessel(checkVessel);
//TODO: Fix sending of flying vessels.
if (checkProto != null)
{
if (checkProto.vesselID != Guid.Empty)
{
//Also check for kerbal state changes
foreach (ProtoPartSnapshot part in checkProto.protoPartSnapshots)
{
foreach (ProtoCrewMember pcm in part.protoModuleCrew)
{
if (!serverKerbals.ContainsKey(pcm.name))
{
//New kerbal
DarkLog.Debug("Found new kerbal, sending...");
serverKerbals[pcm.name] = new ProtoCrewMember(pcm);
NetworkWorker.fetch.SendKerbalProtoMessage(pcm);
}
else
{
bool kerbalDifferent = false;
kerbalDifferent = (pcm.name != serverKerbals[pcm.name].name) || kerbalDifferent;
kerbalDifferent = (pcm.courage != serverKerbals[pcm.name].courage) || kerbalDifferent;
kerbalDifferent = (pcm.isBadass != serverKerbals[pcm.name].isBadass) || kerbalDifferent;
kerbalDifferent = (pcm.seatIdx != serverKerbals[pcm.name].seatIdx) || kerbalDifferent;
kerbalDifferent = (pcm.stupidity != serverKerbals[pcm.name].stupidity) || kerbalDifferent;
kerbalDifferent = (pcm.UTaR != serverKerbals[pcm.name].UTaR) || kerbalDifferent;
if (kerbalDifferent)
{
DarkLog.Debug("Found changed kerbal, sending...");
NetworkWorker.fetch.SendKerbalProtoMessage(pcm);
serverKerbals[pcm.name].name = pcm.name;
serverKerbals[pcm.name].courage = pcm.courage;
serverKerbals[pcm.name].isBadass = pcm.isBadass;
serverKerbals[pcm.name].rosterStatus = pcm.rosterStatus;
serverKerbals[pcm.name].seatIdx = pcm.seatIdx;
serverKerbals[pcm.name].stupidity = pcm.stupidity;
serverKerbals[pcm.name].UTaR = pcm.UTaR;
}
}
}
}
RegisterServerVessel(checkProto.vesselID.ToString());
//Mark the update as sent
serverVesselsProtoUpdate[checkVessel.id.ToString()] = UnityEngine.Time.realtimeSinceStartup;
//.........这里部分代码省略.........
开发者ID:kevin-ye,项目名称:DarkMultiPlayer,代码行数:101,代码来源:VesselWorker.cs
示例19: LoadVessel
//Also called from QuickSaveLoader
public void LoadVessel(ConfigNode vesselNode)
{
if (vesselNode != null)
{
//Fix crew value numbers to Kerbal Names
bool kerbalsDodged = DodgeVesselCrewValues(vesselNode);
//Fix the "cannot control actiongroups bug" by dodging the last used time.
DodgeVesselActionGroups(vesselNode);
//Can be used for debugging incoming vessel config nodes.
//vesselNode.Save(Path.Combine(KSPUtil.ApplicationRootPath, Path.Combine("DMP-RX", Planetarium.GetUniversalTime() + ".txt")));
ProtoVessel currentProto = new ProtoVessel(vesselNode, HighLogic.CurrentGame);
if (kerbalsDodged && (NetworkWorker.fetch.state == ClientState.STARTING) && !LockSystem.fetch.LockExists("control-" + currentProto.vesselID) && !LockSystem.fetch.LockExists("update-" + currentProto.vesselID))
{
DarkLog.Debug("Sending kerbal-dodged vessel " + currentProto.vesselID + ", name: " + currentProto.vesselName);
NetworkWorker.fetch.SendVesselProtoMessage(currentProto, false, false);
foreach (ProtoPartSnapshot pps in currentProto.protoPartSnapshots)
{
if (pps.protoModuleCrew != null)
{
foreach (ProtoCrewMember pcm in pps.protoModuleCrew)
{
if (pcm != null)
{
NetworkWorker.fetch.SendKerbalProtoMessage(pcm);
}
}
}
}
}
if (currentProto != null)
{
//Skip already loaded EVA's
if ((currentProto.vesselType == VesselType.EVA) && (FlightGlobals.fetch.vessels.Find(v => v.id == currentProto.vesselID) != null))
{
return;
}
//Register asteroids from other players
if (currentProto.vesselType == VesselType.SpaceObject)
{
if (currentProto.protoPartSnapshots != null)
{
if (currentProto.protoPartSnapshots.Count == 1)
{
if (currentProto.protoPartSnapshots[0].partName == "PotatoRoid")
{
DarkLog.Debug("Registering remote server asteroid");
AsteroidWorker.fetch.RegisterServerAsteroid(currentProto.vesselID.ToString());
}
}
}
}
//Skip vessels that try to load in the safety bubble
if (isProtoVesselInSafetyBubble(currentProto))
{
DarkLog.Debug("Skipped loading protovessel " + currentProto.vesselID.ToString() + ", name: " + currentProto.vesselName + " because it is inside the safety bubble");
return;
}
//Skip flying vessel that are too far away
bool usingHackyAtmoLoad = false;
if (currentProto.situation == Vessel.Situations.FLYING)
{
DarkLog.Debug("Got a flying update for " + currentProto.vesselID + ", name: " + currentProto.vesselName);
if (currentProto.orbitSnapShot == null)
{
DarkLog.Debug("Skipping flying vessel load - Protovessel does not have an orbit snapshot");
return;
}
CelestialBody updateBody = FlightGlobals.fetch.bodies[currentProto.orbitSnapShot.ReferenceBodyIndex];
if (updateBody == null)
{
DarkLog.Debug("Skipping flying vessel load - Could not find celestial body index " + currentProto.orbitSnapShot.ReferenceBodyIndex);
return;
}
bool willGetKilledInAtmo = false;
if (updateBody.atmosphere)
{
double atmoPressure = updateBody.staticPressureASL * Math.Pow(Math.E, ((-currentProto.altitude) / (updateBody.atmosphereScaleHeight * 1000)));
//KSP magic cut off limit for killing vessels. Works out to be ~23km on kerbin.
if (atmoPressure > 0.01f)
{
willGetKilledInAtmo = true;
}
}
if (willGetKilledInAtmo)
{
if (HighLogic.LoadedScene == GameScenes.FLIGHT)
{
if ((FlightGlobals.fetch.vessels.Find(v => v.id == currentProto.vesselID) != null) && vesselPartCount.ContainsKey(currentProto.vesselID.ToString()) ? currentProto.protoPartSnapshots.Count == vesselPartCount[currentProto.vesselID.ToString()] : false)
{
DarkLog.Debug("Skipping flying vessel load - Vessel has the same part count");
return;
}
//.........这里部分代码省略.........
开发者ID:kevin-ye,项目名称:DarkMultiPlayer,代码行数:101,代码来源:VesselWorker.cs
示例20: HandleDocking
private void HandleDocking()
{
if (sentDockingDestroyUpdate)
{
//One of them will be null, the other one will be the docked craft.
string dockedID = fromDockedVesselID != null ? fromDockedVesselID : toDockedVesselID;
//Find the docked craft
Vessel dockedVessel = FlightGlobals.fetch.vessels.FindLast(v => v.id.ToString() == dockedID);
if (dockedVessel != null ? !dockedVessel.packed : false)
{
ProtoVessel sendProto = new ProtoVessel(dockedVessel);
if (sendProto != null)
{
DarkLog.Debug("Sending docked protovessel " + dockedID);
//Mark the vessel as sent
serverVesselsProtoUpdate[dockedID] = UnityEngine.Time.realtimeSinceStartup;
serverVesselsPositionUpdate[dockedID] = UnityEngine.Time.realtimeSinceStartup;
RegisterServerVessel(dockedID);
vesselPartCount[dockedID] = dockedVessel.parts.Count;
vesselNames[dockedID] = dockedVessel.vesselName;
vesselTypes[dockedID] = dockedVessel.vesselType;
vesselSituations[dockedID] = dockedVessel.situation;
//Update status if it's us.
if (dockedVessel == FlightGlobals.fetch.activeVessel)
{
//Release old control locks
if (lastVesselID != FlightGlobals.fetch.activeVessel.id.ToString())
{
LockSystem.fetch.ReleasePlayerLocksWithPrefix(Settings.fetch.playerName, "control-");
lastVesselID = FlightGlobals.fetch.activeVessel.id.ToString();
}
//Force the control lock off any other player
LockSystem.fetch.AcquireLock("control-" + dockedID, true);
PlayerStatusWorker.fetch.myPlayerStatus.vesselText = FlightGlobals.fetch.activeVessel.vesselName;
}
fromDockedVesselID = null;
toDockedVesselID = null;
sentDockingDestroyUpdate = false;
bool isFlyingUpdate = (sendProto.situation == Vessel.Situations.FLYING);
NetworkWorker.fetch.SendVesselProtoMessage(sendProto, true, isFlyingUpdate);
if (dockingMessage != null)
{
dockingMessage.duration = 0f;
}
dockingMessage = ScreenMessages.PostScreenMessage("Docked!", 3f, ScreenMessageStyle.UPPER_CENTER);
DarkLog.Debug("Docking event over!");
}
else
{
DarkLog.Debug("Error sending protovessel!");
PrintDockingInProgress();
}
}
else
{
PrintDockingInProgre
|
请发表评论