Пример #1
0
        public DesignPart Clone()
        {
            DesignPart retVal = new DesignPart(_options);

            retVal.Part2D = this.Part2D;                // this shouldn't be cloned, it's just a link to the source

            if (this.Part2D == null)
            {
                retVal.Part3D = BotConstructor.GetPartDesign(this.Part3D.GetDNA(), _options, this.Part3D.IsFinalModel);
            }
            else
            {
                retVal.Part3D = retVal.Part2D.GetNewDesignPart();
            }

            ModelVisual3D model = new ModelVisual3D();

            model.Content = retVal.Part3D.Model;
            retVal.Model  = model;

            retVal.Part3D.Position    = this.Part3D.Position;
            retVal.Part3D.Orientation = this.Part3D.Orientation;
            retVal.Part3D.Scale       = this.Part3D.Scale;

            if (this.GuideLines != null)                // this needs to be created after the position is set
            {
                retVal.CreateGuildLines();
            }

            return(retVal);
        }
Пример #2
0
        private static DesignPart CreateDesignPart(ShipPartDNA dna, EditorOptions options)
        {
            DesignPart retVal = new DesignPart(options)
            {
                Part2D = null,      // setting 2D to null will tell the editor that the part can't be resized or copied, only moved around
                Part3D = BotConstructor.GetPartDesign(dna, options, false),
            };

            ModelVisual3D visual = new ModelVisual3D();

            visual.Content = retVal.Part3D.Model;
            retVal.Model   = visual;

            return(retVal);
        }
Пример #3
0
        public Cargo_ShipPart(ShipPartDNA dna, ItemOptions options, EditorOptions editorOptions)
            : base(CargoType.ShipPart)
        {
            PartDesignBase part = BotConstructor.GetPartDesign(dna, editorOptions, true);

            //TODO: This is really ineficient, let design calculate it for real
            //TODO: Volume and Mass should be calculated by the design class (add to PartBase interface)
            var aabb = Math3D.GetAABB(UtilityWPF.GetPointsFromMesh(part.Model));

            this.Volume = (aabb.Item2.X - aabb.Item1.X) * (aabb.Item2.Y - aabb.Item1.Y) * (aabb.Item2.Y - aabb.Item1.Y);

            //TODO: Let the design class return this (expose a property called DryDensity)
            this.Density = Math1D.Avg(options.Thruster_Density, options.Sensor_Density);

            this.PartDNA = dna;
        }
Пример #4
0
        private static Tuple <InventoryEntry, PartDesignBase>[] GatherParts_FromPanel(UIElementCollection panel, EditorOptions editorOptions, bool isFinalModel)
        {
            var retVal = new List <Tuple <InventoryEntry, PartDesignBase> >();

            foreach (var item in panel)
            {
                InventoryEntry inventory = item as InventoryEntry;
                if (inventory == null || inventory.Inventory.Part == null)
                {
                    continue;
                }

                PartDesignBase part = BotConstructor.GetPartDesign(inventory.Inventory.Part, editorOptions, isFinalModel);

                retVal.Add(Tuple.Create(inventory, part));
            }

            return(retVal.ToArray());
        }
Пример #5
0
        private PartDesignBase[] GatherParts(bool isFinalModel)
        {
            // CargoBay
            _fromCargo = _player.Ship.CargoBays == null ?
                         new Tuple <Cargo_ShipPart, PartDesignBase> [0] :
                         _player.Ship.CargoBays.GetCargoSnapshot().
                         Select(o => o as Cargo_ShipPart).
                         Where(o => o != null).
                         Select(o => Tuple.Create(o, BotConstructor.GetPartDesign(o.PartDNA, _editorOptions, isFinalModel))).
                         ToArray();

            // Nearby
            _fromNearby = GatherParts_FromPanel(_spaceDock.pnlNearbyItems.Children, _editorOptions, isFinalModel);

            // Hangar
            _fromHangar = GatherParts_FromPanel(_spaceDock.pnlHangar.Children, _editorOptions, isFinalModel);

            // Combine them
            return(_fromCargo.Select(o => o.Item2).
                   Concat(_fromNearby.Select(o => o.Item2)).
                   Concat(_fromHangar.Select(o => o.Item2)).
                   ToArray());
        }
Пример #6
0
        public Icon3D(ShipPartDNA dna, EditorOptions options)
        {
            InitializeComponent();

            // Need to set position to zero, or the image won't be centered (part's model considers position/orientation)
            dna             = UtilityCore.Clone(dna);
            dna.Position    = new Point3D();
            dna.Orientation = Quaternion.Identity;

            PartDesignBase part = BotConstructor.GetPartDesign(dna, options, false);

            this.ItemName = part.PartType;
            this.Part     = part;

            lblName.Text = this.ItemName;

            lblName.Visibility = _showName ? Visibility.Visible : Visibility.Collapsed;

            InitializeTrackball();

            RenderPart();
            InitializeLight();
        }