示例#1
0
    public override GameObject Build(
        PartConfig config,
        GameObject root,
        string label
        )
    {
        GameObject partsGo = null;
        GameObject bodyGo  = null;

        // build out part model first
        partsGo = base.Build(config, root, label);
        bodyGo  = partsGo.transform.Find(partsGo.name + ".body").gameObject;
        bodyGo.GetComponent <Rigidbody>().centerOfMass = Vector3.zero;

        // now build out parts hierarchy - frame is instantiated under parts.body
        if (frame != null)
        {
            frame.Build(config, bodyGo, "frame");
        }

        // flipper goes next (if specified) under parts
        if (flipper != null)
        {
            flipper.Build(config, partsGo, "flipper");
        }

        return(partsGo);
    }
示例#2
0
        private void comboBox2_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            e.DrawBackground();
            Font drawFont = e.Font;
            bool outFont  = false;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                outFont  = true;
                drawFont = new Font(drawFont, FontStyle.Bold); // 黑体显示
            }

            using (Brush brush = new SolidBrush(e.ForeColor))
            {
                PartConfig cd  = (PartConfig)comboBox2.Items[e.Index];
                string     str = cd.PartID + " " + cd.Description;

                e.Graphics.DrawString(str, drawFont, brush, e.Bounds);
                if (outFont)
                {
                    drawFont.Dispose();
                }
            }

            e.DrawFocusRectangle();
        }
    protected override Joint ApplyJoint(GameObject rigidbodyGo, PartConfig config, GameObject target)
    {
        // add joint component to target
        var joint = rigidbodyGo.AddComponent <HingeJoint>();

        // apply hinge properties
        if (axis == 2)
        {
            joint.axis = new Vector3(0, 0, 1);
        }
        else if (axis == 1)
        {
            joint.axis = new Vector3(0, 1, 0);
        }
        else
        {
            joint.axis = new Vector3(1, 0, 0);
        }
        joint.anchor = anchor;

        // setup joint motor
        var motor = joint.motor;

        motor.force    = turnForce;
        joint.motor    = motor;
        joint.useMotor = true;

        // add actuator
        var actuator = rigidbodyGo.AddComponent <TurretActuator>();

        actuator.turnSpeed = turnSpeed;
        actuator.turnForce = turnForce;
        actuator.debug     = debug;
        return(joint);
    }
示例#4
0
    public static GameObject BuildGo(
        PartConfig config,
        GameObject root,
        string label,
        params Type[] components
        )
    {
        // create empty game object w/ rigidbody component
        var go = new GameObject(label, components);

        if (root != null)
        {
            go.transform.parent        = root.transform;
            go.transform.localPosition = Vector3.zero;
            go.transform.localRotation = Quaternion.identity;
        }

        // look in config to determine if we are in display or build mode
        if (config != null && config.Get <bool>(ConfigTag.PartHide))
        {
            go.hideFlags |= HideFlags.HideInHierarchy;
        }
        if (config != null && config.Get <bool>(ConfigTag.PartDontSave))
        {
            go.hideFlags |= HideFlags.DontSave;
        }
        if (config != null && config.Get <bool>(ConfigTag.PartReadOnly))
        {
            go.hideFlags |= HideFlags.NotEditable;
        }
        return(go);
    }
    protected override Joint ApplyJoint(GameObject rigidbodyGo, PartConfig config, GameObject target)
    {
        var joint = rigidbodyGo.AddComponent <HingeJoint>();

        // add motor
        var applyMotor = motor;

        if (config != null && config.Has(ConfigTag.MotorEnable) && !config.Get <bool>(ConfigTag.MotorEnable))    // config override
        {
            applyMotor = false;
        }
        if (applyMotor)
        {
            var motorActuator = rigidbodyGo.AddComponent <MotorActuator>();
            motorActuator.maxTorque = motorMaxTorque;
            motorActuator.maxSpeed  = motorMaxSpeed;
            motorActuator.motorSfx  = motorSfx;
            // apply motor.left from config
            if (config != null && config.Get <bool>(ConfigTag.MotorLeft))
            {
                motorActuator.isLeft = true;
            }
            // apply motor.left from config
            if (config != null && config.Get <bool>(ConfigTag.MotorReverse))
            {
                motorActuator.reverse = true;
            }
        }
        return(joint);
    }
    public override void Apply(PartConfig config, GameObject target)
    {
        if (target == null)
        {
            return;
        }

        // find rigid body gameobject under target
        var rigidbodyGo = PartUtil.GetBodyGo(target);

        if (rigidbodyGo == null)
        {
            return;
        }

        // add rigid body properties
        var rigidbody = rigidbodyGo.GetComponent <Rigidbody>();

        if (rigidbody == null)
        {
            return;
        }
        rigidbody.mass        = mass;
        rigidbody.drag        = drag;
        rigidbody.angularDrag = angularDrag;
    }
    public GameObject Build(
        PartConfig config,
        GameObject root,
        string label
        )
    {
        GameObject modelGo = null;

        if (model != null)
        {
            if (Application.isPlaying)
            {
                modelGo = Object.Instantiate(model, (root != null) ? root.transform : null) as GameObject;
#if UNITY_EDITOR
            }
            else
            {
                modelGo           = PrefabUtility.InstantiatePrefab(model) as GameObject;
                modelGo.hideFlags = HideFlags.HideAndDontSave;
                if (root != null)
                {
                    modelGo.transform.parent = root.transform;
                }
#endif
            }
            // preserve model's original rotation (prior to parenting)
            modelGo.transform.localRotation = Quaternion.identity;
            modelGo.name = label + ".model";
            modelGo.transform.localPosition    = offset;
            modelGo.transform.localEulerAngles = rotation;
        }
        return(modelGo);
    }
示例#8
0
    public override GameObject Build(
        PartConfig config,
        GameObject root,
        string label
        )
    {
        GameObject partsGo = null;
        GameObject bodyGo  = null;

        // build out part model first
        partsGo = base.Build(config, root, label);
        bodyGo  = partsGo.transform.Find(partsGo.name + ".body").gameObject;

        // now build out parts hierarchy - frame is instantiated under parts.body
        if (frame != null)
        {
            frame.Build(config, bodyGo, "frame");
        }

        // flipper goes next (if specified) under parts
        if (ram != null)
        {
            ram.Build(config, partsGo, "ram");
        }

        return(partsGo);
    }
示例#9
0
        /// <summary>
        /// 在工件配置列表中查找测量程序
        /// </summary>
        /// <param name="partId">工件标识</param>
        /// <returns></returns>
        private string FindProgFile(string partId)
        {
            // 从工件配置管理器中获得工件列表
            PartConfig pc       = PartConfigManager.Instance.GetPartConfig(partId);
            string     filePath = PathManager.Instance.GetPartProgramPath(pc);

            Debug.Assert(string.IsNullOrEmpty(filePath)); // 正常情况FilePath不是空字符串
            return(filePath);
        }
示例#10
0
 public void SetPartConfig(PartConfig partConfig)
 {
     PartConfig = partConfig;
     BaseSprite.GetComponent <SpriteRenderer>().sprite = PartConfig.BaseImageSprite;
     LeftWall.GetComponent <SpriteRenderer>().sprite   = PartConfig.LeftImageSprite;
     RightWall.GetComponent <SpriteRenderer>().sprite  = PartConfig.RightImageSprite;
     BottomWall.GetComponent <SpriteRenderer>().sprite = PartConfig.BottomImageSprite;
     TopWall.GetComponent <SpriteRenderer>().sprite    = PartConfig.TopImageSprite;
 }
示例#11
0
 public bool AddPartConfig(PartConfig partConfig)
 {
     if (Exists(partConfig.PartID))
     {
         //System.Windows.Forms.MessageBox.Show("");
         return(false);
     }
     _partConfigs.Add(partConfig);
     return(true);
 }
示例#12
0
        public PartData Load(PartConfig config)
        {
            return(new PartData
            {
                Id = config.Id,
                Name = config.Name,

                Image = config.Image,

                Count = wrapper.GetInt(config.Id, CountKey)
            });
        }
示例#13
0
        /// <summary>
        /// 确认本地文件是否完整
        /// </summary>
        /// <param name="partId"></param>
        /// <returns></returns>
        private bool VerifyLocalFiles(string partId)
        {
            PartConfig partConfig = PartConfigManager.Instance.GetPartConfig(partId);

            if (!File.Exists(PathManager.Instance.GetPartProgramPath(partConfig)) ||
                !File.Exists(PathManager.Instance.GetPartFlvPath(partConfig)) ||
                !File.Exists(PathManager.Instance.GetPartNomPath(partConfig)) ||
                !File.Exists(PathManager.Instance.GetPartTolPath(partConfig)))
            {
                return(false);
            }
            return(true);
        }
示例#14
0
        public void MeasurePart(string partId) // todo MeasureServiceContext 测试方法
        {
            _part = PartConfigManager.Instance.GetPartConfig(partId);
            Debug.Assert(_part != null);
            string partProgFileName = PathManager.Instance.GetPartProgramPath(_part);

            if (!File.Exists(partProgFileName))
            {
                LogCollector.Instance.PostSvrErrorMessage("程序文件不存在");
                return;
            }
            LocalLogCollector.WriteMessage($"测量工件: {partId}, 程序:{partProgFileName}");
            BackToSafePosition(partProgFileName);
        }
 void Build()
 {
     if (part != null)
     {
         var displayConfig = new PartConfig();
         // if just showing in editor, set readonly and dontsave flag on generated objects
         if (!Application.isPlaying)
         {
             displayConfig.Save <bool>(ConfigTag.PartReadOnly, true);
             displayConfig.Save <bool>(ConfigTag.PartDontSave, true);
         }
         partGo = part.Build(displayConfig, gameObject, part.name);
     }
 }
    public override GameObject Build(
        PartConfig config,
        GameObject root,
        string label
        )
    {
        GameObject partsGo    = null;
        GameObject bodyGo     = null;
        GameObject steeringGo = null;
        GameObject hubBodyGo  = null;

        // build out part model first
        partsGo = base.Build(config, root, label);
        bodyGo  = partsGo.transform.Find(partsGo.name + ".body").gameObject;

        // now build out wheel parts hierarchy
        // frame is instantiated under parts.body
        if (frame != null)
        {
            frame.Build(config, bodyGo, "frame");
        }

        // steering goes next (if specified) under parts
        if (steering != null)
        {
            steeringGo = steering.Build(config, partsGo, "steering");
        }

        // hub/wheel goes next under parts
        if (hub != null)
        {
            var hubGo = hub.Build(config, (steeringGo != null) ? steeringGo : partsGo, "hub");
            // if hub part isn't specified, build dummy hub rigidbody for wheel
            if (hubGo == null)
            {
                hubBodyGo = PartUtil.BuildGo(config, partsGo, "hub.body", typeof(Rigidbody), typeof(KeepInBounds));
            }
            else
            {
                hubBodyGo = PartUtil.GetBodyGo(hubGo);
            }
            if (wheel != null)
            {
                wheel.Build(config, hubBodyGo, "wheel");
            }
        }

        return(partsGo);
    }
    public override void Apply(PartConfig config, GameObject target)
    {
        if (target == null)
        {
            return;
        }

        // find rigid body gameobject under target
        var rigidbodyGo = PartUtil.GetBodyGo(target);

        if (rigidbodyGo == null)
        {
            return;
        }

        // add fixed joint component to target
        var joint = ApplyJoint(rigidbodyGo, config, target);

        if (joint == null)
        {
            return;
        }
        //joint.enablePreprocessing = false;

        // apply break limits, as specified
        if (applyBreakForce)
        {
            joint.breakForce = breakForce;
        }
        if (applyBreakTorque)
        {
            joint.breakTorque = breakTorque;
        }

        // add damage actuator to joint rigidbody if joint can be damaged
        if (applyDamageToForce || applyDamageToTorque)
        {
            var actuator = rigidbodyGo.AddComponent <JointDamageActuator>();
            actuator.applyDamageToForce  = applyDamageToForce;
            actuator.applyDamageToTorque = applyDamageToTorque;
            actuator.gameEventChannel    = gameEventChannel;
        }

        // add simple joiner script to target, allowing quick joint join
        var joiner = target.AddComponent <Joiner>();

        joiner.joint = joint;
    }
    protected virtual void DisplayModel()
    {
        if (displayedGos != null)
        {
            ClearModel();
        }
        // don't display if application is playing
        if (Application.isPlaying)
        {
            return;
        }
        // build display config to hide built objects and not save
        var displayConfig = new PartConfig();

        displayConfig.Save <bool>(ConfigTag.PartHide, true);
        displayConfig.Save <bool>(ConfigTag.PartDontSave, true);

        // build the part
        for (var i = 0; i < targets.Length; i++)
        {
            var panel = (PanelApplicator)targets[i];
            if (panel.top != null)
            {
                displayedGos.Add(panel.top.Build(displayConfig, null, "display"));
            }
            if (panel.bottom != null)
            {
                displayedGos.Add(panel.bottom.Build(displayConfig, null, "display"));
            }
            if (panel.left != null)
            {
                displayedGos.Add(panel.left.Build(displayConfig, null, "display"));
            }
            if (panel.right != null)
            {
                displayedGos.Add(panel.right.Build(displayConfig, null, "display"));
            }
            if (panel.front != null)
            {
                displayedGos.Add(panel.front.Build(displayConfig, null, "display"));
            }
            if (panel.back != null)
            {
                displayedGos.Add(panel.back.Build(displayConfig, null, "display"));
            }
        }
    }
示例#19
0
    public override void Apply(PartConfig config, GameObject target)
    {
        if (target == null)
        {
            return;
        }

        // find rigid body gameobject under target
        var rigidbodyGo = PartUtil.GetBodyGo(target);

        if (rigidbodyGo == null)
        {
            return;
        }

        // apply impact damage actuator
        if (impactApplyDamage)
        {
            var actuator = rigidbodyGo.AddComponent <ImpactDamageActuator>();
            actuator.minDamage                = impactMinDamage;
            actuator.maxDamage                = impactMaxDamage;
            actuator.damageModifier           = impactDamageModifier;
            actuator.emitScrews               = impactScrews;
            actuator.minScrewDamage           = impactScrewDamage;
            actuator.smallImpactSfx           = smallImpactSfx;
            actuator.smallImpactSfxThreshold  = smallImpactSfxThreshold;
            actuator.mediumImpactSfx          = mediumImpactSfx;
            actuator.mediumImpactSfxThreshold = mediumImpactSfxThreshold;
            actuator.largeImpactSfx           = largeImpactSfx;
            actuator.largeImpactSfxThreshold  = largeImpactSfxThreshold;
            actuator.debug = debug;
        }

        // apply fire damage applicator
        if (fireApplyDamage)
        {
            var actuator = rigidbodyGo.AddComponent <FlameDamageActuator>();
            actuator.fireRate        = fireRate;
            actuator.fireDamageDelay = fireDamageDelay;
            //actuator.plume = plume;
            //actuator.sparks = sparks;
            actuator.burntMaterial    = burntMaterial;
            actuator.burnThreshold    = burnThreshold;
            actuator.explodeThreshold = explodeThreshold;
            actuator.debug            = debug;
        }
    }
示例#20
0
    protected override Joint ApplyJoint(GameObject rigidbodyGo, PartConfig config, GameObject target)
    {
        // add joint component to target
        var joint = rigidbodyGo.AddComponent <HingeJoint>();

        // apply hinge properties
        if (axis == 2)
        {
            joint.axis = new Vector3(0, 0, 1);
        }
        else if (axis == 1)
        {
            joint.axis = new Vector3(0, 1, 0);
        }
        else
        {
            joint.axis = new Vector3(1, 0, 0);
        }
        var hingeSpring = joint.spring;

        hingeSpring.spring         = springForce;
        hingeSpring.damper         = springDamper;
        hingeSpring.targetPosition = (reverse) ? maxAngle : minAngle;
        joint.spring    = hingeSpring;
        joint.useSpring = true;

        var limits = joint.limits;

        limits.min      = minAngle;
        limits.max      = maxAngle;
        joint.limits    = limits;
        joint.useLimits = true;
        joint.anchor    = anchor;

        // add motor
        var actuator = rigidbodyGo.AddComponent <FlipperActuator>();

        actuator.minAngle    = minAngle;
        actuator.maxAngle    = maxAngle;
        actuator.reverse     = reverse;
        actuator.impactForce = impactForce;
        actuator.impactForceVelocityMultiplier = impactForceVelocityMultiplier;
        actuator.impactDamageMultiplier        = impactDamageMultiplier;
        actuator.debug = debug;
        return(joint);
    }
示例#21
0
        private void addPartToolStripButton_Click(object sender, EventArgs e)
        {
            PartConfForm pcfm = new PartConfForm();

            if (pcfm.ShowDialog() == DialogResult.OK)
            {
                // 查找blades文件
                string path = PathManager.Instance.GetBladesFullPath(pcfm.PartID);
                if (!Directory.Exists(path))
                {
                    MessageBox.Show("blades目录不存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (Directory.GetFiles(path, "*.nom", SearchOption.TopDirectoryOnly).Length != 1 ||
                        Directory.GetFiles(path, "*.flv", SearchOption.TopDirectoryOnly).Length != 1 ||
                        Directory.GetFiles(path, "*.tol", SearchOption.TopDirectoryOnly).Length != 1)
                    {
                        MessageBox.Show("blades文件缺失", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                // 添加工件配置
                if (PartConfigManager.Instance./*AddPartConfig*/ Exists(pcfm.PartID))
                {
                    MessageBox.Show("工件已存在", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                PartConfig pc = new PartConfig();
                pc.FlvFileName  = Path.GetFileName(Directory.GetFiles(path, "*.flv", SearchOption.TopDirectoryOnly)[0]);
                pc.NormFileName = Path.GetFileName(Directory.GetFiles(path, "*.nom", SearchOption.TopDirectoryOnly)[0]);
                pc.TolFileName  = Path.GetFileName(Directory.GetFiles(path, "*.Tol", SearchOption.TopDirectoryOnly)[0]);
                pc.PartID       = pcfm.PartID;
                pc.ProgFileName = Path.GetFileName(pcfm.PartProgram);
                pc.Description  = pcfm.PartDescription;

                partConfBs.Add(pc);

                // 更新工件Panel
                //partConfList.Add(pc);
                //partView.Refresh();
            }
        }
        public void _pcdmisCore_PCDmisMeasureEventTest()
        {
            //PathConfig ptcf = new PathConfig();
            PathManager.Instance.RootPath    = @"D:\ServerPathRoot";
            PathManager.Instance.BladesPath  = "blades";
            PathManager.Instance.ReportsPath = "Results";
            PathManager.Instance.TempPath    = "Temp";
            //PathManager.Instance.Configration = ptcf;
            PartConfig part = new PartConfig();

            part.PartID       = "TestPart";
            part.FlvFileName  = "xx10_1.flv";
            part.NormFileName = "xx10_1.nom";
            part.TolFileName  = "xx10_1.tol";

            LocalLogCollector.LogFilePath = @"d:\log.txt";
            ServerSettings.BladeExe       = @"C:\Program Files (x86)\Hexagon\PC-DMIS Blade 5.0 (Release)\Blade.exe";
            BladeMeasAssist _bladeMeasAssist = new BladeMeasAssist();

            _bladeMeasAssist.RtfFileName = @"C:\BladeRunner\blade.RTF";
            _bladeMeasAssist.ProbeDiam   = 2;
            _bladeMeasAssist.SectionNum  = 3;
            List <string> sn = new List <string>()
            {
                "8-8", "5-5", "2-2"
            };

            _bladeMeasAssist.SectionNames = sn;
            _bladeMeasAssist.Part         = part;

            MeasureServiceContext msc = new MeasureServiceContext(10, 10);

            msc.SetBladeMeasAssist(_bladeMeasAssist);
            PCDmisEventArgs pca = new PCDmisEventArgs();

            pca.IsCompleted = true;
            msc._pcdmisCore_PCDmisMeasureEvent(null, pca);

            while (true)
            {
                ;
            }
        }
示例#23
0
    public override void Apply(PartConfig config, GameObject target)
    {
        if (target == null)
        {
            return;
        }

        // find rigid body gameobject under target
        var rigidbodyGo = PartUtil.GetBodyGo(target);

        if (rigidbodyGo == null)
        {
            return;
        }

        // add damage modifier
        var modifier = rigidbodyGo.AddComponent <ImpactDamageModifier>();

        modifier.impactDamageMultiplier = impactDamageMultiplier;
    }
    public override void Apply(PartConfig config, GameObject target)
    {
        if (target == null)
        {
            return;
        }

        // find rigid body gameobject under target
        var rigidbodyGo = PartUtil.GetBodyGo(target);

        if (rigidbodyGo == null)
        {
            return;
        }

        // add health component
        var actuator = rigidbodyGo.AddComponent <MaterialActuator>();

        actuator.materials = materials;
        actuator.debug     = debug;
    }
    public override GameObject Build(
        PartConfig config,
        GameObject root,
        string label
        )
    {
        GameObject partsGo = null;
        GameObject bodyGo  = null;

        // build out part model first
        partsGo = base.Build(config, root, label);
        bodyGo  = partsGo.transform.Find(partsGo.name + ".body").gameObject;

        // now build out parts hierarchy - frame is instantiated under parts.body
        if (frame != null)
        {
            frame.Build(config, bodyGo, "frame");
        }

        // spinner goes next (if specified) under parts
        if (spinner != null)
        {
            spinner.Build(config, partsGo, "spinner");

            /*
             * if (spinnerGo != null) {
             *  var spinnerBodyGo = PartUtil.GetBodyGo(spinnerGo);
             *  if (spinnerBodyGo != null) {
             *      spinnerJoint.Apply(config, spinnerBodyGo);
             *      var joiner = spinnerBodyGo.GetComponent<Joiner>();
             *      if (joiner != null) {
             *          joiner.Join(bodyGo.GetComponent<Rigidbody>());
             *      }
             *  }
             * }
             */
        }

        return(partsGo);
    }
示例#26
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //PathConfig ptcnf = new PathConfig();
            PathManager.Instance.RootPath         = @"D:\clientPathRoot";
            PathManager.Instance.PartProgramsPath = @"Progs";
            PathManager.Instance.BladesPath       = @"blades";
            PathManager.Instance.ReportsPath      = @"Results";
            //PathManager.Instance.Configration = ptcnf;

            PartConfig prcnf = new PartConfig();

            prcnf.PartID       = "TestPart";
            prcnf.ProgFileName = "1.prg";
            prcnf.FlvFileName  = "blade5.flv";
            prcnf.NormFileName = "blade5.nom";
            prcnf.TolFileName  = "blade5.tol";
            PartConfigManager.Instance.InitPartConfigManager(/*@"d:\clientPathRoot\parts.xml"*/);
            PartConfigManager.Instance.AddPartConfig(prcnf);
            PartConfigManager.Instance.SavePartConfigToXml(@"d:\clientPathRoot\parts.xml");
            _cmmClient = new CmmClient(serverCnf);
            _cmmClient.InitClient();
        }
示例#27
0
    public override void Apply(PartConfig config, GameObject target)
    {
        if (target == null)
        {
            return;
        }

        // find rigid body gameobject under target
        var rigidbodyGo = PartUtil.GetBodyGo(target);

        if (rigidbodyGo == null)
        {
            return;
        }

        // add health component
        var health = rigidbodyGo.AddComponent <Health>();

        health.maxHealth = (int)maxHealth;
        health.healthTag = healthTag;
        health.debug     = debug;
    }
    public GameObject Build(
        PartConfig config,
        GameObject root,
        string label
        )
    {
        GameObject partGo = null;

        // instantiate part
        if (part != null)
        {
            partGo = part.Build(config, root, label != null ? label : part.name);
            if (partGo == null)
            {
                return(null);
            }
            partGo.transform.localPosition    = offset;
            partGo.transform.localEulerAngles = rotation;
        }

        // joint specifies how part is to be attached to root, if specified, apply joint and join to root
        if (joint != null && partGo != null)
        {
            var partBodyGo = PartUtil.GetBodyGo(partGo);
            if (partBodyGo != null)
            {
                joint.Apply(config, partBodyGo);
                var joiner     = partBodyGo.GetComponent <Joiner>();
                var rootBodyGo = PartUtil.GetBodyGo(root);
                if (joiner != null && rootBodyGo != null)
                {
                    joiner.Join(rootBodyGo.GetComponent <Rigidbody>());
                }
            }
        }

        return(partGo);
    }
示例#29
0
    // create new copy of config w/ merged values between one and other
    // other overrides one
    public static PartConfig Merge(PartConfig one, PartConfig other)
    {
        var merged = new PartConfig();

        // first copy other to merged
        if (other != null)
        {
            Array.Resize(ref merged.rows, other.rows.Length);
            for (var i = 0; i < other.rows.Length; i++)
            {
                merged.rows[i] = other.rows[i];
            }
        }

        // now copy one to merged, only if key not already in merged
        if (one != null)
        {
            for (var i = 0; i < one.rows.Length; i++)
            {
                bool found = false;
                for (var j = 0; j < merged.rows.Length; j++)
                {
                    if (one.rows[i].key == merged.rows[j].key)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    Array.Resize(ref merged.rows, merged.rows.Length + 1);
                    merged.rows[merged.rows.Length - 1] = one.rows[i];
                }
            }
        }

        return(merged);
    }
示例#30
0
    protected virtual void DisplayModel()
    {
        if (displayedGos != null)
        {
            ClearModel();
        }
        // don't display if application is playing
        if (Application.isPlaying)
        {
            return;
        }
        // build display config to hide built objects and not save
        var displayConfig = new PartConfig();

        displayConfig.Save <bool>(ConfigTag.PartHide, true);
        displayConfig.Save <bool>(ConfigTag.PartDontSave, true);

        // build the part
        for (var i = 0; i < targets.Length; i++)
        {
            displayedGos.Add(((Part)targets[i]).Build(displayConfig, null, "display"));
        }
    }