当前位置: 首页>>代码示例>>C#>>正文


C# ProtoVessel类代码示例

本文整理汇总了C#中ProtoVessel的典型用法代码示例。如果您正苦于以下问题:C# ProtoVessel类的具体用法?C# ProtoVessel怎么用?C# ProtoVessel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ProtoVessel类属于命名空间,在下文中一共展示了ProtoVessel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的ProtoVessel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。