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


C# ShipConstruct.SaveShip方法代码示例

本文整理汇总了C#中ShipConstruct.SaveShip方法的典型用法代码示例。如果您正苦于以下问题:C# ShipConstruct.SaveShip方法的具体用法?C# ShipConstruct.SaveShip怎么用?C# ShipConstruct.SaveShip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ShipConstruct的用法示例。


在下文中一共展示了ShipConstruct.SaveShip方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: KCT_BuildListVessel

        public KCT_BuildListVessel(ShipConstruct s, String ls, double bP, String flagURL)
        {
            ship = s;
            shipNode = s.SaveShip();
            shipName = s.shipName;
            //Get total ship cost
            float dry, fuel;
            s.GetShipCosts(out dry, out fuel);
            cost = dry + fuel;
            TotalMass = 0;
            foreach (Part p in s.Parts)
            {
                TotalMass += p.mass;
                TotalMass += p.GetResourceMass();
            }

            launchSite = ls;
            buildPoints = bP;
            progress = 0;
            flag = flagURL;
            if (launchSite == "LaunchPad")
                type = ListType.VAB;
            else
                type = ListType.SPH;
            InventoryParts = new Dictionary<string, int>();
            id = Guid.NewGuid();
            cannotEarnScience = false;
        }
开发者ID:fingerboxes,项目名称:KCT,代码行数:28,代码来源:KCT_BuildListVessel.cs

示例2: KCT_BuildListVessel

        public KCT_BuildListVessel(ShipConstruct s, String ls, double bP, String flagURL)
        {
            ship = s;
            shipNode = s.SaveShip();
            shipName = s.shipName;
            //Get total ship cost
            float dry, fuel;
            s.GetShipCosts(out dry, out fuel);
            cost = dry + fuel;

            launchSite = ls;
            buildPoints = bP;
            progress = 0;
            flag = flagURL;
            if (launchSite == "LaunchPad")
                type = ListType.VAB;
            else
                type = ListType.SPH;
            InventoryParts = new List<string>();
            id = Guid.NewGuid();
            cannotEarnScience = false;
        }
开发者ID:ntwest,项目名称:KCT,代码行数:22,代码来源:KCT_BuildListVessel.cs

示例3: KCT_BuildListVessel

        public KCT_BuildListVessel(ShipConstruct s, String ls, double bP, String flagURL)
        {
            ship = s;
            shipNode = s.SaveShip();
            shipName = s.shipName;
            //Get total ship cost
            float fuel;
            cost = s.GetShipCosts(out emptyCost, out fuel);
            TotalMass = s.GetShipMass(out emptyMass, out fuel);

            launchSite = ls;
            buildPoints = bP;
            progress = 0;
            flag = flagURL;
            if (s.shipFacility == EditorFacility.VAB)
                type = ListType.VAB;
            else if (s.shipFacility == EditorFacility.SPH)
                type = ListType.SPH;
            else
                type = ListType.None;
            InventoryParts = new Dictionary<string, int>();
            id = Guid.NewGuid();
            cannotEarnScience = false;
        }
开发者ID:Kerbas-ad-astra,项目名称:KCT,代码行数:24,代码来源:KCT_BuildListVessel.cs

示例4: CreatePart

        public static Part CreatePart(AvailablePart avPart, Vector3 position, Quaternion rotation, Part flagFromPart)
        {
            UnityEngine.Object obj = UnityEngine.Object.Instantiate(avPart.partPrefab);
            if (!obj)
            {
                KAS_Shared.DebugError("CreatePart(Crate) Failed to instantiate " + avPart.partPrefab.name);
                return null;
            }

            Part newPart = (Part)obj;
            newPart.gameObject.SetActive(true);
            newPart.gameObject.name = avPart.name;
            newPart.partInfo = avPart;
            newPart.highlightRecurse = true;
            newPart.SetMirror(Vector3.one);

            ShipConstruct newShip = new ShipConstruct();
            newShip.Add(newPart);
            newShip.SaveShip();
            newShip.shipName = avPart.title;
            newShip.shipType = 1;

            VesselCrewManifest vessCrewManifest = new VesselCrewManifest();
            Vessel currentVessel = FlightGlobals.ActiveVessel;

            Vessel v = newShip.parts[0].localRoot.gameObject.AddComponent<Vessel>();
            v.id = Guid.NewGuid();
            v.vesselName = newShip.shipName;
            v.Initialize(false);
            v.Landed = true;
            v.rootPart.flightID = ShipConstruction.GetUniqueFlightID(HighLogic.CurrentGame.flightState);
            v.rootPart.missionID = flagFromPart.missionID;
            v.rootPart.flagURL = flagFromPart.flagURL;

            //v.rootPart.collider.isTrigger = true;

            //v.landedAt = "somewhere";
                        
            Staging.beginFlight();
            newShip.parts[0].vessel.ResumeStaging();
            Staging.GenerateStagingSequence(newShip.parts[0].localRoot);
            Staging.RecalculateVesselStaging(newShip.parts[0].vessel);

            FlightGlobals.SetActiveVessel(currentVessel);

            v.SetPosition(position);
            v.SetRotation(rotation);

            // Solar panels from containers don't work otherwise
            for (int i = 0; i < newPart.Modules.Count; i++)
            {
                ConfigNode node = new ConfigNode();
                node.AddValue("name", newPart.Modules[i].moduleName);
                newPart.LoadModule(node, ref i);
            }

            return newPart;
        }
开发者ID:ACCBizon,项目名称:KAS,代码行数:58,代码来源:KAS_Shared.cs

示例5: SpawnPartInFlight

 /// <remarks>
 ///     This code is based on KAS by KospY and the following license applies:
 ///     http://kerbal.curseforge.com/ksp-mods/223900-kerbal-attachment-system-kas/license (link valid 03.09.2014)
 ///     Usage of this code by me (marce) has been generously granted by KospY on 02.09.2014 per PM.
 /// </remarks>
 public static Part SpawnPartInFlight(string partName, Part referencePart, Vector3 referencePartOriginSpawnOffset, Quaternion spawnRotation, bool spawnLanded = true)
 {
     if (!HighLogic.LoadedSceneIsFlight)
     {
         Debug.Log(LogPrefix + " can only spawn in flight");
         return null;
     }
     var currentVessel = FlightGlobals.ActiveVessel;
     var avPart = PartLoader.getPartInfoByName(partName);
     var obj = UnityEngine.Object.Instantiate(avPart.partPrefab);
     if (obj == null)
     {
         Debug.Log(LogPrefix + " failed to instantiate part " + partName);
         return null;
     }
     try
     {
         var newPart = (Part) obj;
         newPart.gameObject.SetActive(true);
         newPart.gameObject.name = avPart.name;
         newPart.partInfo = avPart;
         newPart.highlightRecurse = true;
         newPart.SetMirror(Vector3.one);
         var newShip = new ShipConstruct {newPart};
         newShip.SaveShip();
         newShip.shipName = avPart.title;
         var type = Convert.ChangeType(VesselType.Debris, VesselType.Debris.GetTypeCode());
         if (type != null)
         {
             newShip.shipType = (int) type;
         }
         else
         {
             newShip.shipType = 1;
         }
         var v = newShip.parts[0].localRoot.gameObject.AddComponent<Vessel>();
         v.id = Guid.NewGuid();
         v.vesselName = newShip.shipName;
         v.Initialize();
         v.Landed = spawnLanded;
         v.rootPart.flightID = ShipConstruction.GetUniqueFlightID(HighLogic.CurrentGame.flightState);
         v.rootPart.missionID = referencePart.missionID;
         v.rootPart.flagURL = referencePart.flagURL;
         FlightGlobals.SetActiveVessel(currentVessel);
         v.SetPosition(referencePart.transform.position + referencePartOriginSpawnOffset);
         v.SetRotation(spawnRotation);
         for (var i = 0; i < newPart.Modules.Count; i++)
         {
             var node = new ConfigNode();
             node.AddValue("name", newPart.Modules[i].moduleName);
             var j = i;
             newPart.LoadModule(node, ref j);
         }
         return newPart;
     }
     catch (NullReferenceException)
     {
         Debug.Log(LogPrefix + " part unknown");
         return null;
     }
 }
开发者ID:Bear67,项目名称:KSP-CIT-Util,代码行数:66,代码来源:PartFactory.cs

示例6: FromInFlightVessel

        private ConfigNode FromInFlightVessel(Vessel VesselToSave)
        {
            //This code is taken from InflightShipSave by Claw, using the CC-BY-NC-SA license.
            //This code thus is licensed under the same license, despite the GPLv3 license covering original KCT code
            //See https://github.com/ClawKSP/InflightShipSave

            string ShipName = VesselToSave.vesselName;
               // Debug.LogWarning("Saving: " + ShipName);

            ShipConstruct ConstructToSave = new ShipConstruct(ShipName, "", VesselToSave.parts[0]);

            Quaternion OriginalRotation = VesselToSave.vesselTransform.rotation;
            Vector3 OriginalPosition = VesselToSave.vesselTransform.position;

            VesselToSave.SetRotation(new Quaternion(0, 0, 0, 1));
            Vector3 ShipSize = ShipConstruction.CalculateCraftSize(ConstructToSave);
            VesselToSave.SetPosition(new Vector3(0, ShipSize.y + 2, 0));

            ConfigNode CN = new ConfigNode("ShipConstruct");
            CN = ConstructToSave.SaveShip();
            SanitizeShipNode(CN);

            VesselToSave.SetRotation(OriginalRotation);
            VesselToSave.SetPosition(OriginalPosition);
            //End of Claw's code. Thanks Claw!
            return CN;
        }
开发者ID:fingerboxes,项目名称:KCT,代码行数:27,代码来源:KCT_BuildListVessel.cs

示例7: OnVesselRecoveryRequested

        public void OnVesselRecoveryRequested(Vessel v)
        {
            //Get total ship cost
            KerbalGUIManager.print("[rusty] OnVesselRecoveryRequested");
            KerbalGUIManager.print("[rusty] parts.Count: " + v.parts.Count);
            KerbalGUIManager.print("[rusty] Parts.Count: " + v.Parts.Count);
            KerbalGUIManager.print("[rusty] GetActiveParts().Count: " + v.GetActiveParts().Count);
            if (v.rootPart != null)
            {
                KerbalGUIManager.print("[rusty] Root part is alive");
            }
            else
            {
                KerbalGUIManager.print("[rusty] Root part is NULL");
            }

            ShipConstruct ship = new ShipConstruct(v.vesselName, "", v.rootPart);
            ship.shipFacility = EditorFacility.VAB;
            saveVesselLater = ship.SaveShip();
        }
开发者ID:MartynasStropa,项目名称:KSP_rusty,代码行数:20,代码来源:eventListener.cs

示例8: drawWindow

        public override void drawWindow(int windowID)
        {
            GUIStyle mySty = new GUIStyle(GUI.skin.window);
            mySty.normal.textColor = mySty.focused.textColor = Color.white;
            mySty.hover.textColor = mySty.active.textColor = Color.yellow;
            mySty.onNormal.textColor = mySty.onFocused.textColor = mySty.onHover.textColor = mySty.onActive.textColor = Color.green;
            mySty.padding = new RectOffset(8, 8, 8, 8);

            GUILayout.BeginVertical();

            GUILayout.Label("Select an assembly");

            if (GUILayout.Button("StorePart") && EditorLogic.SelectedPart != null)
            {
                EditorLogic editor = EditorLogic.fetch;
                ShipConstruct ship = new ShipConstruct();

                Utils.addPartToShipRecursive(ship, EditorLogic.SelectedPart);

                ship.SaveShip().Save("D:/rusty.cfg");
                ShipConstruction.CaptureThumbnail(ship, "rusty_thumbs", "rusty");

                // store thumb
                KSP_rusty.Inventory.Add(ship.SaveShip());

                // root or not?
                if (EditorLogic.SelectedPart == EditorLogic.RootPart)
                {
                    KerbalGUIManager.print("[rusty] GUIInventory:StorePart: is root");
                    EditorLogic.DeletePart(EditorLogic.SelectedPart);
                }
                else
                {
                    KerbalGUIManager.print("[rusty] GUIInventory:StorePart: is not root");
                    EditorLogic.DeletePart(EditorLogic.SelectedPart);
                }
            }

            /*
            if (GUILayout.Button("Store"))
            {
                try
                {
                    EditorLogic editor = EditorLogic.fetch;
                    ShipConstruct ship = new ShipConstruct(editor.ship.shipName, editor.ship.shipFacility, editor.getSortedShipList());

                    KerbalGUIManager.print("[rusty] GUIInventory: storing");

                    try
                    {
                        inv = new ShipConstruct();
                        if (inv.LoadShip(ship.SaveShip()))
                        {
                            KerbalGUIManager.print("[rusty] GUIInventory: load OK");
                        }
                        else
                        {
                            KerbalGUIManager.print("[rusty] GUIInventory: load failed");
                        }
                    }
                    catch (Exception e)
                    {
                        KerbalGUIManager.print("Exception GUIInventory:drawWindow():Store;saveShip: " + e.Message + "\n" + e.StackTrace);
                    }

                    KerbalGUIManager.print("[rusty] GUIInventory: deleting old");
                }
                catch (Exception e)
                {
                    KerbalGUIManager.print("Exception GUIInventory:drawWindow():Store: " + e.Message + "\n" + e.StackTrace);
                }
            }
             */

            if (GUILayout.Button("Load rusty.cfg"))
            {
                ConfigNode rusty2 = ConfigNode.Load("D:/rusty.cfg");

                EditorLogic editor = null;
                ShipConstruct ship = null;

                editor = EditorLogic.fetch;
                //editor.SpawnPart(PartLoader.getPartInfoByName("mk1pod"));
                //editor.SpawnConstruct(inv);

                // fix type
                rusty2.SetValue("type", "VAB", true);
                rusty2.Save("D:/rusty2.cfg");

                ship = new ShipConstruct();
                ship.LoadShip(rusty2);
            }

            if (KSP_rusty.Inventory != null)
            {
                foreach (ConfigNode inventoryItem in KSP_rusty.Inventory) {
                    string title = "";
                    int nrOfParts = 0;

                    try
//.........这里部分代码省略.........
开发者ID:MartynasStropa,项目名称:KSP_rusty,代码行数:101,代码来源:GUIInventory.cs

示例9: OnEditorUndo

 private void OnEditorUndo(ShipConstruct data)
 {
     ConfigNode n = data.SaveShip();
 }
开发者ID:Xemrox,项目名称:DarkMultiPlayer,代码行数:4,代码来源:EditSync.cs

示例10: CreatePart

        public static Part CreatePart(AvailablePart avPart, Vector3 position, Quaternion rotation, Part flagFromPart)
        {
            UnityEngine.Object obj = UnityEngine.Object.Instantiate(avPart.partPrefab);
            if (!obj)
            {
                KAS_Shared.DebugError("CreatePart(Crate) Failed to instantiate " + avPart.partPrefab.name);
                return null;
            }

            Part newPart = (Part)obj;
            newPart.gameObject.SetActive(true);
            newPart.gameObject.name = "KASCreatedPart";
            newPart.partInfo = avPart;
            newPart.highlightRecurse = true;

            ShipConstruct newShip = new ShipConstruct();
            newShip.Add(newPart);
            newShip.SaveShip();
            newShip.shipName = avPart.title;
            newShip.shipType = 1;

            VesselCrewManifest vessCrewManifest = new VesselCrewManifest();
            Vessel currentVessel = FlightGlobals.ActiveVessel;

            Vessel v = newShip.parts[0].localRoot.gameObject.AddComponent<Vessel>();
            v.id = Guid.NewGuid();
            v.vesselName = newShip.shipName;
            v.Initialize(false);
            v.Landed = true;
            v.rootPart.flightID = ShipConstruction.GetUniqueFlightID(HighLogic.CurrentGame.flightState);
            v.rootPart.missionID = (uint)Guid.NewGuid().GetHashCode();
            v.rootPart.flagURL = flagFromPart.flagURL;

            //v.rootPart.collider.isTrigger = true;

            v.rootPart.FindModelTransform("model").localScale *= v.rootPart.rescaleFactor;

            //v.landedAt = "somewhere";

            Staging.beginFlight();
            newShip.parts[0].vessel.ResumeStaging();
            Staging.GenerateStagingSequence(newShip.parts[0].localRoot);
            Staging.RecalculateVesselStaging(newShip.parts[0].vessel);

            FlightGlobals.SetActiveVessel(currentVessel);

            v.SetPosition(position);
            v.SetRotation(rotation);
            return newPart;
        }
开发者ID:ErzengelLichtes,项目名称:KAS,代码行数:50,代码来源:KAS_Shared.cs


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