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


C# ShipConstruct.Add方法代码示例

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


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

示例1: buildConstruct

        public static ShipConstruct buildConstruct(ConfigNode vessel)
        {
            ShipConstruct ship = new ShipConstruct();
            ConfigNode[] partNodes = vessel.GetNodes("PART");
            List<Part> parts = new List<Part>();
            string[] partNameByIdx = new string[partNodes.Length];
            Dictionary<string, Part> partByName = new Dictionary<string, Part>();

            int part_idx = 0;
            foreach (ConfigNode partNode in partNodes)
            {
                // get part name
                string[] str_part = partNode.GetValue("part").Split('_');
                partNameByIdx[part_idx] = partNode.GetValue("part");

                // get part from loader
                Part part = PartLoader.getPartInfoByName(str_part[0]).partPrefab;
                partByName[partNode.GetValue("part")] = part;

                // add info
                part.orgPos = Utils.StringToVector3(partNode.GetValue("pos"));
                part.attPos = Utils.StringToVector3(partNode.GetValue("attPos"));
                part.attPos0 = Utils.StringToVector3(partNode.GetValue("attPos0"));

                part.orgRot = Utils.StringToQuaternion(partNode.GetValue("rot"));
                part.attRotation = Utils.StringToQuaternion(partNode.GetValue("attRot"));
                part.attRotation0 = Utils.StringToQuaternion(partNode.GetValue("attRot0"));

                part.mirrorVector = Utils.StringToVector3(partNode.GetValue("mir"));

                string symMethod = partNode.GetValue("symMethod");
                if (symMethod == "Radial")
                {
                    part.symMethod = SymmetryMethod.Radial;
                }
                else if (symMethod == "Mirror")
                {
                    part.symMethod = SymmetryMethod.Mirror;
                }

                part.inverseStage = int.Parse(partNode.GetValue("istg"));
                part.defaultInverseStage = int.Parse(partNode.GetValue("istg"));
                part.stageOffset = int.Parse(partNode.GetValue("sidx"));
                //part.manualStageOffset = int.Parse(partNode.GetValue("sqor"));
                part.separationIndex = int.Parse(partNode.GetValue("sepI"));
                string attm = partNode.GetValue("attm");
                if (attm == "0")
                {
                    part.attachMode = AttachModes.STACK;
                }
                else if (attm == "1")
                {
                    part.attachMode = AttachModes.SRF_ATTACH;
                }
                // modCost = 0
                // modMass = 0
                // modSize = (0.0, 0.0, 0.0)

                // add to part list
                parts.Add(part);
                ship.Add(part);
                ++part_idx;
            }

            // add links
            part_idx = 0;
            foreach (Part part in parts)
            {
                string[] links = partNodes[part_idx].GetValues("link");
                foreach (string link in links)
                {
                    Part linkedPart = partByName[link];
                    if (linkedPart != null)
                    {
                        part.editorLinks.Add(linkedPart);
                        part.children.Add(linkedPart);

                        //AttachNode attN = new AttachNode(
                        //part.attachNodes.Add
                        //part.AddAttachNode(partNodes[part_idx]);
                    }
                }
                ++part_idx;
            }

            ship.shipFacility = EditorFacility.VAB;
            return ship;
        }
开发者ID:MartynasStropa,项目名称:KSP_rusty,代码行数:88,代码来源:rustyInventory.cs

示例2: 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

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