Ejemplo n.º 1
0
 public void BuildMesh(PartType partType, AdjacencyMatrix adjMatrix, MeshBuilder meshBuilder, BlockBounds clipBounds)
 {
     var slopeBuilder = new SlopedMeshBuilder(meshBuilder);
     if (partType == PartType.OuterCorner) {
         BuildMeshCorner(slopeBuilder);
     }
 }
Ejemplo n.º 2
0
 public override void DefinitionObjectDidInit()
 {
     base.DefinitionObjectDidInit();
     Images = new List<Image>();
     Type = PartType.PartTypeImage;
     Content = null;
 }
Ejemplo n.º 3
0
 private void EditPart(DataRow row, PartType partType)
 {
     dbm.GetPart((string)row["Part_num"], partType, delegate(Part part) {
         if (part != null) {
             mv.PartEditView.Part = part;
             mv.ActiveTab = MainView.Tabs.Edit;
         }
     }, null);
 }
Ejemplo n.º 4
0
 public void BuildMesh(PartType partType, AdjacencyMatrix adjMatrix,  MeshBuilder meshBuilder, BlockBounds clipBounds)
 {
     if (PartType.BlockFront == partType) {
         meshBuilder.AddTriangleStrip(
             false,
             meshBuilder.VertAutoNormal(new Vector3(1, 1, 0), new Vector2(1, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(1, 0, 0), new Vector2(1, 0), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 1, 0), new Vector2(0, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 0, 0), new Vector2(0, 0), true));;
     }
     else if (PartType.BlockBack == partType)
     {
         meshBuilder.AddTriangleStrip(
             false,
             meshBuilder.VertAutoNormal(new Vector3(0, 1, 1), new Vector2(1, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 0, 1), new Vector2(1, 0), true),
             meshBuilder.VertAutoNormal(new Vector3(1, 1, 1), new Vector2(0, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(1, 0, 1), new Vector2(0, 0), true));
     }
     else if (PartType.BlockRight == partType)
     {
         meshBuilder.AddTriangleStrip(
             false,
             meshBuilder.VertAutoNormal(new Vector3(1, 1, 1), new Vector2(1, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(1, 0, 1), new Vector2(1, 0), true),
             meshBuilder.VertAutoNormal(new Vector3(1, 1, 0), new Vector2(0, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(1, 0, 0), new Vector2(0, 0), true));
     }
     else if (PartType.BlockLeft == partType)
     {
         meshBuilder.AddTriangleStrip(
             false,
             meshBuilder.VertAutoNormal(new Vector3(0, 1, 0), new Vector2(1, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 0, 0), new Vector2(1, 0), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 1, 1), new Vector2(0, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 0, 1), new Vector2(0, 0), true));
     }
     else if (PartType.BlockTop == partType)
     {
         meshBuilder.AddTriangleStrip(
             false,
             meshBuilder.VertAutoNormal(new Vector3(1, 1, 1), new Vector2(1, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(1, 1, 0), new Vector2(1, 0), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 1, 1), new Vector2(0, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 1, 0), new Vector2(0, 0), true));
     }
     else if (PartType.BlockBottom == partType)
     {
         meshBuilder.AddTriangleStrip(
             false,
             meshBuilder.VertAutoNormal(new Vector3(1, 0, 0), new Vector2(1, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(1, 0, 1), new Vector2(1, 0), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 0, 0), new Vector2(0, 1), true),
             meshBuilder.VertAutoNormal(new Vector3(0, 0, 1), new Vector2(0, 0), true));
     }
 }
Ejemplo n.º 5
0
        public void AddPart(PartType type, RobotEntity robot)
        {
            var newPart = new Part()
            {
                Type = type,
                Robot = robot
            };

            _context.Parts.Add(newPart);
            _context.SaveChanges();
        }
Ejemplo n.º 6
0
        public void WhenInstantiatingClassWithDefaultConstructor_Succeeds()
        {
            // Arrange
            PartType userRole;

            // Act
            userRole = new PartType();

            // Assert
            Assert.NotNull(userRole);
        }
Ejemplo n.º 7
0
 public override void DefinitionObjectDidReceiveString(string str)
 {
     base.DefinitionObjectDidReceiveString(str);
     string[] array = str.Split(new[] {'\n'});
     for (int i = 0; i < array.Length; i++)
     {
         string text = array[i];
         if (text.Length > 2)
         {
             string[] array2 = text.Split(new[]
                                              {
                                                  '='
                                              });
             string a = array2[0];
             string text2 = array2[1];
             if (a == "PartID")
             {
                 UniqueID = text2;
             }
             else
             {
                 if (a == "ImageID")
                 {
                     if (Type != PartType.PartTypeLabel)
                     {
                         Images.Add(DataManager.ImageByKey(text2));
                     }
                 }
                 else
                 {
                     if (a == "ZAxis")
                     {
                         ZAxis = Convert.ToInt32(text2);
                     }
                     else
                     {
                         if (a == "Type")
                         {
                             Type = (PartType) Convert.ToInt32(text2);
                         }
                         else
                         {
                             if (a == "Content")
                             {
                                 Content = text2;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        public void Add(string name, string description, int duration, float powerRequired, byte[] image, PartType specialization)
        {
            var newQuest = new Quest
            {
                Name = name,
                Description = description,
                DurationInMinutes = duration,
                PowerRequired = powerRequired,
                Image = image,
                Specialization = specialization
            };

            this.quests.Add(newQuest);
            this.quests.SaveChanges();
        }
Ejemplo n.º 9
0
        public void BuildMesh(PartType partType, AdjacencyMatrix adjMatrix, MeshBuilder meshBuilder, BlockBounds clipBounds)
        {
            SlopedMeshBuilder slopeBuilder = new SlopedMeshBuilder(meshBuilder);
	
			if (PartType.OuterEdgeFront == partType) {

                slopeBuilder.ConstructSlopedFront(slopeBuilder.GetOuterSlopePoints());
			}else if (PartType.OuterEdgeLeft == partType) 
            {
                Matrix4x4 mat = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(-1, 1, 1));
                slopeBuilder.ConstructSlopedSide(false, mat, slopeBuilder.GetOuterSlopePoints());
			}else if (PartType.OuterEdgeRight == partType) 
            {
                Matrix4x4 mat = Matrix4x4.TRS(new Vector3(1, 0, 0), Quaternion.identity, new Vector3(1, 1, 1));
                slopeBuilder.ConstructSlopedSide(true, mat, slopeBuilder.GetOuterSlopePoints());
			}
        }
Ejemplo n.º 10
0
 public override void GetPart(string Part_num, PartType partType, PartHandler handler, ErrorHandler errorHandler)
 {
     //TODO: Move this logic into a stored procedure
     string sql = "SELECT Part_type_id, Type FROM Parts NATURAL LEFT JOIN Part_types WHERE Part_num = '" + Part_num + "'";
     Execute(sql, delegate(DataTable typeResult) {
         int typeId = (int)typeResult.Rows[0]["Part_type_id"];
         string typeName = (string)typeResult.Rows[0]["Type"];
         sql = "SELECT * FROM Parts AS P NATURAL LEFT JOIN " + typeName + "_attributes AS A WHERE P.Part_type_id = " + typeId + " AND Part_num = '" + Part_num + "'";
         Execute(sql, delegate(DataTable partResult) {
             Part part = null;
             if (partResult.Rows.Count > 0) {
                 part = new Part(Part_num, typeId, typeName, partResult);
             }
             if (handler != null) {
                 handler(part);
             }
         }, errorHandler);
     }, errorHandler);
 }
Ejemplo n.º 11
0
 public BloodPart(PartType type) : base(type)
 {
 }
Ejemplo n.º 12
0
 // Indexer
 public string this[PartType key]
 {
     get { return _parts[key]; }
     set { _parts[key] = value; }
 }
Ejemplo n.º 13
0
    public void AddPart(PartType type, Vector3Int position, PartDirection direciton, PartRotation rotation, bool recalculate)
    {
        Part part = Part.MakePart(type);

        Vector3[] addVerts = part.GetVertices(direciton, rotation, 0, 0, 0);
        Vector2[] addUVs   = part.GetUVs(direciton, rotation);
        int[]     addTrias = part.GetTriangles(direciton, rotation, 0);


        Vector3[] oldVerts = meshFilter.mesh.vertices;
        Vector2[] oldUVs   = meshFilter.mesh.uv;
        int[]     oldTrias = meshFilter.mesh.triangles;

        Vector3[] newVerts = new Vector3[oldVerts.Length + addVerts.Length];
        Vector2[] newUVs   = new Vector2[oldUVs.Length + addUVs.Length];
        int[]     newTrias = new int[oldTrias.Length + addTrias.Length];

        for (int i = 0; i < oldVerts.Length; i++)
        {
            newVerts[i] = oldVerts[i];
        }
        for (int i = 0; i < addVerts.Length; i++)
        {
            newVerts[oldVerts.Length + i] = addVerts[i] + new Vector3(position.x, position.y, position.z);
        }

        for (int i = 0; i < oldUVs.Length; i++)
        {
            newUVs[i] = oldUVs[i];
        }
        for (int i = 0; i < addUVs.Length; i++)
        {
            newUVs[oldUVs.Length + i] = addUVs[i];
        }

        for (int i = 0; i < oldTrias.Length; i++)
        {
            newTrias[i] = oldTrias[i];
        }
        for (int i = 0; i < addTrias.Length; i++)
        {
            newTrias[oldTrias.Length + i] = addTrias[i] + oldVerts.Length;
        }

        meshFilter.mesh.Clear();
        meshFilter.mesh.vertices  = newVerts;
        meshFilter.mesh.uv        = newUVs;
        meshFilter.mesh.triangles = newTrias;

        if (recalculate)
        {
            meshFilter.mesh.RecalculateNormals();
        }

        BoxCollider attachedBC = GetComponentInParent <BoxCollider>();

        //attachedBC.enabled = false;

        Vector3[] addedVerts = new Vector3[addVerts.Length];
        for (int i = 0; i < addedVerts.Length; i++)
        {
            addedVerts[i] = meshFilter.mesh.vertices[meshFilter.mesh.vertices.Length - addVerts.Length + i];
        }
        addBoxCollider(addedVerts);
    }
Ejemplo n.º 14
0
 public SimpleRangePart(String rep, bool hasLetters, bool hasNumbers)
 {
     _rep = rep;
     _type = Get(hasLetters, hasNumbers);
 }
Ejemplo n.º 15
0
 public PartTypeAttribute(PartType partType)
 {
     PartType = partType;
 }
Ejemplo n.º 16
0
 public override void NewPart(PartType partType, ErrorHandler errorHandler)
 {
     //TODO: See note in PartsDb.NewPart()
     SqlCommandBuilder bld = new SqlCommandBuilder();
     SqlCommand cmd = new SqlCommand();
     string tableNameEscaped = bld.QuoteIdentifier(partType.name);
     string partNumColumnEscaped = bld.QuoteIdentifier("Part Number");
     string partTypeColumnEscaped = bld.QuoteIdentifier("Part Type");
     cmd.CommandType = System.Data.CommandType.Text;
     cmd.CommandText = string.Format("SELECT TOP 1 {0} FROM {1} ORDER BY {0} DESC", partNumColumnEscaped, tableNameEscaped);
     Execute(cmd, delegate(DataTable partNumResult) {
         if (partNumResult.Rows.Count > 0) {
             DataRow row = partNumResult.Rows[0];
             string Part_num = Util.PartNumberString(Util.PartNumberInteger((string)row["Part Number"]) + 1);
     #if DEBUG
             Console.WriteLine("New part num: {0}", Part_num);
     #endif
             SqlCommand insertCmd = new SqlCommand();
             insertCmd.CommandType = System.Data.CommandType.Text;
             insertCmd.CommandText = string.Format("INSERT INTO {0} ({1}, {2}) VALUES (@partNum, @partType);", tableNameEscaped, partNumColumnEscaped, partTypeColumnEscaped);
             insertCmd.Parameters.AddWithValue("@partNum", Part_num);
             insertCmd.Parameters.AddWithValue("@partType", partType.name);
             Execute(insertCmd, null, errorHandler);
         }
     }, errorHandler);
 }
Ejemplo n.º 17
0
 private void NewPart(PartType partType)
 {
     dbm.NewPart(partType, null);
     ShowParts(mv.PartsView.SelectedPartType);
 }
Ejemplo n.º 18
0
 public void SpawnNeededMaterial(PartType part)
 {
     SpawnRandomItem();
 }
Ejemplo n.º 19
0
 public Part(PartType type)
 {
     Type = type;
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Initialize an instance of a part.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public Part(PartType type, string key, string value) : this()
 {
     Type   = type;
     Key    = key;
     _value = value ?? string.Empty;
 }
Ejemplo n.º 21
0
 public static YoutubeActivities RequestPart(this YoutubeActivities activities, PartType partType)
 {
     return(Activities(activities.Settings.Clone(), activities.PartTypes.Append(partType).ToArray()));
 }
Ejemplo n.º 22
0
 public Part(PartType type)
 {
     this.Type = type;
 }
Ejemplo n.º 23
0
 public DeviceTypePart(string deviceTypeId, int portNumber, string partCode, string partName, PartType partType, bool hasStatus, int statusIndex, bool enabled, string description = null, string companyId = null, string oprationId = null, string brandId = null, double warranty = 0)
     : this()
 {
     DeviceTypeId = deviceTypeId ?? throw new ArgumentNullException(nameof(deviceTypeId));
     PortNumber   = portNumber;
     PartCode     = partCode ?? throw new ArgumentNullException(nameof(partCode));
     PartName     = partName ?? throw new ArgumentNullException(nameof(partName));
     PartType     = partType;
     HasStatus    = hasStatus;
     StatusIndex  = statusIndex;
     Enabled      = enabled;
     Description  = description;
     CompanyId    = companyId;
     OprationId   = oprationId;
     BrandId      = brandId;
     Warranty     = warranty;
 }
Ejemplo n.º 24
0
Archivo: IVS.cs Proyecto: demonzhq/JLR
 public SoftPart(string Part, PartType Type, string PID, bool Isflash)
 {
     this.Part = new PartNumber(Part);
     this.Type = Type;
     this.PID = PID;
     this.IsFlash = Isflash;
 }
Ejemplo n.º 25
0
 private void ShowParts(PartType partType)
 {
     dbm.GetParts(partType, delegate(PartCollection parts) {
         mv.PartsView.Parts = parts;
     }, null);
 }
Ejemplo n.º 26
0
 public PartTypeArgument(PartType partType)
     : this(new[] { partType })
 {
 }
Ejemplo n.º 27
0
 public override void GetPart(string Part_num, PartType partType, PartHandler handler, ErrorHandler errorHandler)
 {
     SqlCommandBuilder bld = new SqlCommandBuilder();
     SqlCommand cmd = new SqlCommand();
     string tableNameEscaped = bld.QuoteIdentifier(partType.name);
     string partNumColumnEscaped = bld.QuoteIdentifier("Part Number");
     cmd.CommandType = System.Data.CommandType.Text;
     cmd.CommandText = string.Format("SELECT * FROM {0} WHERE {1} = @partNum", tableNameEscaped, partNumColumnEscaped);
     cmd.Parameters.AddWithValue("@partNum", Part_num);
     Execute(cmd, delegate(DataTable partResult) {
         Part part = null;
         if (partResult.Rows.Count > 0) {
             partResult.Columns["Part Number"].ColumnName = "Part_num";
             part = new Part(Part_num, partType.typeId, partType.name, partResult);
         }
         if (handler != null) {
             handler(part);
         }
     }, errorHandler);
 }
Ejemplo n.º 28
0
 public Part(int id, double price, int quantity, double discount, string name, PartType type, string company, bool warranty)
     : base(id, price, discount)
 {
     Name     = name;
     Type     = type;
     Company  = company;
     Quantity = quantity;
     Warranty = warranty;
 }
 public IQueryable<Quest> GetQuestsOfType(PartType type)
 {
     return this.quests.All().Where(q => q.Specialization == type);
 }
Ejemplo n.º 30
0
        static List <Part> FilterList(IEnumerable <Part> parts, PartType type)
        {
            var filters = parts.Where(p => p.type == type).ToList();

            return(filters);
        }
Ejemplo n.º 31
0
 IDrawable GetNewTexture(PartType partType)
 {
     return (IDrawable)(GetTexture(partType).Clone());
 }
Ejemplo n.º 32
0
            /// <summary>
            /// Determine element shape from its connectors.
            /// </summary>
            /// <param name="e">Checked element</param>
            /// <param name="pe">Previous element (optional), in case badly-connected MEP system</param>
            /// <param name="ne">Next element (optional), in case you want shape chenge through flow direction only
            /// (for elements with more than one output)</param>
            /// <returns>Element shape changes</returns>
            static public string GetElementShape(
                Element e,
                Element pe = null,
                Element ne = null)
            {
                if (is_element_of_category(e,
                                           BuiltInCategory.OST_DuctCurves))
                {
                    // assuming that transition is using to change shape..

                    ConnectorManager cm = (e as MEPCurve)
                                          .ConnectorManager;

                    foreach (Connector c in cm.Connectors)
                    {
                        return(c.Shape.ToString()
                               + " 2 " + c.Shape.ToString());
                    }
                }
                else if (is_element_of_category(e,
                                                BuiltInCategory.OST_DuctFitting))
                {
                    MEPSystem system
                        = ExtractMechanicalOrPipingSystem(e);

                    FamilyInstance fi = e as FamilyInstance;
                    MEPModel       mm = fi.MEPModel;

                    ConnectorSet connectors
                        = mm.ConnectorManager.Connectors;

                    if (fi != null && mm is MechanicalFitting)
                    {
                        PartType partType
                            = (mm as MechanicalFitting).PartType;

                        if (PartType.Elbow == partType)
                        {
                            // assuming that transition is using to change shape..

                            foreach (Connector c in connectors)
                            {
                                return(c.Shape.ToString()
                                       + " 2 " + c.Shape.ToString());
                            }
                        }
                        else if (PartType.Transition == partType)
                        {
                            string[] tmp = new string[2];

                            if (system != null)
                            {
                                foreach (Connector c in connectors)
                                {
                                    if (c.Direction == FlowDirectionType.In)
                                    {
                                        tmp[0] = c.Shape.ToString();
                                    }

                                    if (c.Direction == FlowDirectionType.Out)
                                    {
                                        tmp[1] = c.Shape.ToString();
                                    }
                                }
                                return(string.Join(" 2 ", tmp));
                            }
                            else
                            {
                                int i = 0;

                                foreach (Connector c in connectors)
                                {
                                    if (pe != null)
                                    {
                                        if (is_connected_to(c, pe))
                                        {
                                            tmp[0] = c.Shape.ToString();
                                        }
                                        else
                                        {
                                            tmp[1] = c.Shape.ToString();
                                        }
                                    }
                                    else
                                    {
                                        tmp[i] = c.Shape.ToString();
                                    }
                                    ++i;
                                }

                                if (pe != null)
                                {
                                    return(string.Join(" 2 ", tmp));
                                }

                                return(string.Join("-", tmp));
                            }
                        }
                        else if (PartType.Tee == partType ||
                                 PartType.Cross == partType ||
                                 PartType.Pants == partType ||
                                 PartType.Wye == partType)
                        {
                            string from, to;
                            from = to = null;
                            List <string> unk = new List <string>();

                            if (system != null)
                            {
                                foreach (Connector c in connectors)
                                {
                                    if (c.Direction == FlowDirectionType.In)
                                    {
                                        from = c.Shape.ToString();
                                    }
                                    else
                                    {
                                        unk.Add(c.Shape.ToString());
                                    }

                                    if (ne != null && is_connected_to(c, ne))
                                    {
                                        to = c.Shape.ToString();
                                    }
                                }

                                if (to != null)
                                {
                                    return(from + " 2 " + to);
                                }

                                return(from + " 2 " + string.Join("-",
                                                                  unk.ToArray()));
                            }
                            else
                            {
                                foreach (Connector c in connectors)
                                {
                                    if (ne != null && is_connected_to(
                                            c, ne))
                                    {
                                        to = c.Shape.ToString();
                                        continue;
                                    }

                                    if (pe != null && is_connected_to(
                                            c, pe))
                                    {
                                        from = c.Shape.ToString();
                                        continue;
                                    }

                                    unk.Add(c.Shape.ToString());
                                }

                                if (to != null)
                                {
                                    return(from + " 2 " + to);
                                }

                                if (from != null)
                                {
                                    return(from + " 2 "
                                           + string.Join("-", unk.ToArray()));
                                }

                                return(string.Join("-", unk.ToArray()));
                            }
                        }
                    }
                }
                return("unknown");
            }
    public override void OnInspectorGUI()
    {
        part = target as GrabbablePart;
        DrawDefaultInspector();


        if (EditorApplication.isPlaying)
        {
            GUILayout.Label("Construction editor disabled while playing");
            return;
        }

//		System.Action<Construction> deleteFunction = (construct) => DestroyImmediate(construct);

        EditorGUILayout.BeginHorizontal();
        HexMetrics.Direction oldOrietation = part.SimulationOrientation;
        HexMetrics.Direction newOrietation = (HexMetrics.Direction)EditorGUILayout.EnumPopup(part.SimulationOrientation);
        if (newOrietation != oldOrietation)
        {
            part.SetSimulationOrientation(newOrietation);
        }
        if (GUILayout.Button("<-"))
        {
            part.SetSimulationOrientation(((int)(part.SimulationOrientation) - 1) % 6);
        }
        if (GUILayout.Button("->"))
        {
            part.SetSimulationOrientation(((int)(part.SimulationOrientation) + 1) % 6);
        }
        EditorGUILayout.EndHorizontal();

        for (int i = 0; i < 6; i++)
        {
            HexMetrics.Direction iDir          = (HexMetrics.Direction)i;
            HexMetrics.Direction iDirRelative  = part.Relative(iDir);
            GrabbablePart        connectedPart = part.GetConnectedPart(iDirRelative);

            EditorGUILayout.BeginHorizontal();


            if (GUILayout.Button("GOTO", GUILayout.Width(75)))
            {
                if (connectedPart != null)
                {
                    Selection.activeObject = connectedPart;
                }
            }

            // check for other components
            Vector3     connectedPosition = part.transform.position + (Vector3)GameSettings.instance.hexCellPrefab.GetDirection(iDir);
            Collider [] colliders         = Physics.OverlapSphere(connectedPosition, 1);

            GrabbablePart contact = null;
            foreach (Collider c in colliders)
            {
                contact = c.attachedRigidbody.GetComponent <GrabbablePart>();

                if (contact != null)
                {
                    break;
                }
            }
            if (contact != null && contact.ParentConstruction != null && contact.ParentConstruction != part.ParentConstruction)
            {
                Vector3 difference = contact.transform.position - connectedPosition;
//				Debug.Log(difference);
                if (difference != Vector3.zero)
                {
                    if (GUILayout.Button("Line Up"))
                    {
                        Debug.Log(difference);
                        Transform toMove = (contact.ParentConstruction == null ? null : contact.ParentConstruction.transform) ?? contact.transform;
                        toMove.position -= difference;
                    }
                }
                else
                {
                    if (GUILayout.Button("Connect (" + (GrabbablePart.PhysicalConnectionType) 1 + ")"))
                    {
                        part.ParentConstruction.AddToConstruction(contact);
                        part.ConnectPartAndPlaceAtRelativeDirection(contact, GrabbablePart.PhysicalConnectionType.Weld, iDirRelative);
                        part.SetPhysicalConnection(iDirRelative, GrabbablePart.PhysicalConnectionType.Weld);
                    }
                }
            }
            else if (
                contact != null && contact.ParentConstruction != null && contact.ParentConstruction == part.ParentConstruction &&
                part.GetPhysicalConnectionType(iDirRelative) == GrabbablePart.PhysicalConnectionType.None)
            {
                if (GUILayout.Button((GrabbablePart.PhysicalConnectionType) 1 + " connect " + contact.partType))
                {
                    part.ConnectPartAndPlaceAtRelativeDirection(contact, GrabbablePart.PhysicalConnectionType.Weld, iDirRelative);
                }
            }
            else
            {
                PartType oldType     = connectedPart == null ? PartType.None : connectedPart.partType;
                PartType newPartType = (PartType)EditorGUILayout.EnumPopup(oldType);

                bool changingPart = newPartType != oldType;

                // if we are changing part and we have one there already, remove it
                if (connectedPart != null && changingPart)
                {
                    GameObject toDestroy = part.RemoveConnectedPart(iDirRelative).gameObject;
                    GameObject.DestroyImmediate(toDestroy);
                }
                if (changingPart && newPartType != PartType.None)
                {
                    // create part

                    GrabbablePart partPrefab       = GameSettings.instance.GetPartPrefab(newPartType);
                    GrabbablePart newConnectedPart = PrefabUtility.InstantiatePrefab(partPrefab) as GrabbablePart;
                    part.ConnectPartAndPlaceAtRelativeDirection(newConnectedPart, GrabbablePart.PhysicalConnectionType.Weld, iDirRelative);
                    part.SetSimulationOrientation(part.SimulationOrientation);
//					part.SetPhysicalConnection(iDir, GrabbablePart.PhysicalConnectionType.Weld, instantiateFunction);
                }

                GrabbablePart.PhysicalConnectionType oldConnectionType = part.GetPhysicalConnectionType(iDirRelative);
                GrabbablePart.PhysicalConnectionType newConnectionType = (GrabbablePart.PhysicalConnectionType)EditorGUILayout.EnumPopup(oldConnectionType);
                if (oldConnectionType != newConnectionType)
                {
                    part.SetPhysicalConnection(iDirRelative, newConnectionType);
                }

                int oldAuxTypes = part.GetAuxilaryConnectionTypes(iDirRelative);
                int newAuxTypes = EditorGUILayout.MaskField(oldAuxTypes, System.Enum.GetNames(typeof(GrabbablePart.AuxilaryConnectionType)));
                if (oldAuxTypes != newAuxTypes)
                {
                    part.SetAuxilaryConnections(iDirRelative, newAuxTypes);
                }
            }
            if (GUILayout.Button("<-"))
            {
                if (contact != null)
                {
                    contact.SetSimulationOrientation(((int)(contact.SimulationOrientation) - 1) % 6);
                }
            }
            if (GUILayout.Button("->"))
            {
                if (contact != null)
                {
                    contact.SetSimulationOrientation(((int)(contact.SimulationOrientation) + 1) % 6);
                }
            }

            EditorGUILayout.EndHorizontal();
        }

        EditorUtility.SetDirty(part);
    }
Ejemplo n.º 34
0
            /// <summary>
            /// Determine element shape from
            /// its MEP PartType and Size parameter.
            /// @: maciej szlek
            /// [email protected]
            /// http://maciejszlek.pl
            /// </summary>
            public static string GetElementShape(Element e)
            {
                if (is_element_of_category(e,
                                           BuiltInCategory.OST_DuctCurves))
                {
                    // simple case, no need to use regular expression

                    //string size = e.get_Parameter( "Size" ) // 2014
                    //  .AsString();

                    Debug.Assert(
                        1 == e.GetParameters("Size").Count,
                        "expected only one parameters named 'Size'");

                    string size = e.LookupParameter("Size") // 2015
                                  .AsString();

                    if (size.Split('x').Length == 2)
                    {
                        return("rectangular");
                    }
                    else if (size.Split('/').Length == 2)
                    {
                        return("oval");
                    }
                    else
                    {
                        return("round");
                    }
                }
                else if (is_element_of_category(e,
                                                BuiltInCategory.OST_DuctFitting))
                {
                    FamilyInstance fi = e as FamilyInstance;

                    if (fi != null && fi.MEPModel is MechanicalFitting)
                    {
                        string size = e.get_Parameter("Size")
                                      .AsString();

                        PartType partType = (fi.MEPModel as
                                             MechanicalFitting).PartType;

                        if (PartType.Elbow == partType ||
                            PartType.Transition == partType)
                        {
                            // more complex case

                            #region Metric only
#if METRIC_ONLY_BEFORE_REGEX_CACHE
                            if (size.Split('x').Length == 3) // could use a regex "[0-9]x[0-9]+-[0-9]+/[0-9]+" but splitting is less costly
                            {
                                return("rectangular2rectangular");
                            }
                            else if (size.Split('/').Length == 3)
                            {
                                return("oval2oval");
                            }
                            else if (
                                new Regex(@"[0-9]+x[0-9]+-[0-9]+/[0-9]+")
                                .IsMatch(size))
                            {
                                return("rectangular2oval");
                            }
                            else if (
                                new Regex(@"[0-9]+/[0-9]+-[0-9]+x[0-9]+")
                                .IsMatch(size))
                            {
                                return("oval2rectangular");
                            }
                            else if (
                                new Regex(@"[0-9]+[^0-9]-[0-9]+x[0-9]+")
                                .IsMatch(size))
                            {
                                return("round2rectangular");
                            }
                            else if (
                                new Regex(@"[0-9]+x[0-9]+-[0-9]+[^0-9]")
                                .IsMatch(size))
                            {
                                return("rectangular2round");
                            }
                            else if (
                                new Regex(@"[0-9]+[^0-9]-[0-9]+/[0-9]+")
                                .IsMatch(size))
                            {
                                return("round2oval");
                            }
                            else if (
                                new Regex(@"[0-9]+/[0-9]+-[0-9]+[^0-9]")
                                .IsMatch(size))
                            {
                                return("oval2round");
                            }
                            else if (
                                new Regex(@"[0-9]+[^0-9]-[0-9]+[^0-9]")
                                .IsMatch(size))
                            {
                                return("round2round");
                            }
                            else
                            {
                                return("other case");
                            }
#endif // METRIC_ONLY_BEFORE_REGEX_CACHE

#if METRIC_ONLY
                            if (size.Split('x').Length == 3) // could use a regex "[0-9]x[0-9]+-[0-9]+/[0-9]+" but splitting is less costly
                            {
                                return("rectangular2rectangular");
                            }
                            else if (size.Split('/').Length == 3)
                            {
                                return("oval2oval");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+x[0-9]+-[0-9]+/[0-9]+", size))
                            {
                                return("rectangular2oval");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+/[0-9]+-[0-9]+x[0-9]+", size))
                            {
                                return("oval2rectangular");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+[^0-9]-[0-9]+x[0-9]+", size))
                            {
                                return("round2rectangular");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+x[0-9]+-[0-9]+[^0-9]", size))
                            {
                                return("rectangular2round");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+[^0-9]-[0-9]+/[0-9]+", size))
                            {
                                return("round2oval");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+/[0-9]+-[0-9]+[^0-9]", size))
                            {
                                return("oval2round");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+[^0-9]-[0-9]+[^0-9]", size))
                            {
                                return("round2round");
                            }
#endif // METRIC_ONLY
                            #endregion // Metric only

                            if (size.Split('x').Length == 3) // or use Regex("[0-9]x[0-9]+-[0-9]+/[0-9]+") but splitting is less costly
                            {
                                return("rectangular2rectangular");
                            }
                            else if (size.Split('/').Length == 3) // but if in imperial units size is in fractional inches format it has to be replaced by another regular expression
                            {
                                return("oval2oval");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+\"?x[0-9]+\"?-[0-9]+\"?/[0-9]+\"?", size))
                            {
                                return("rectangular2oval");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+\"?/[0-9]+\"?-[0-9]+\"?x[0-9]+\"?", size))
                            {
                                return("oval2rectangular");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+\"?[^0-9]-[0-9]+\"?x[0-9]+\"?", size))
                            {
                                return("round2rectangular");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+\"?x[0-9]+\"?-[0-9]+\"?[^0-9]", size))
                            {
                                return("rectangular2round");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+\"?[^0-9]-[0-9]+\"?/[0-9]+\"?", size))
                            {
                                return("round2oval");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+\"?/[0-9]+\"?-[0-9]+\"?[^0-9]", size))
                            {
                                return("oval2round");
                            }
                            else if (_regexCache.Match(
                                         "[0-9]+\"?[^0-9]-[0-9]+\"?[^0-9]", size))
                            {
                                return("round2round");
                            }
                            else
                            {
                                return("other case");
                            }
                        }
                        // etc (for other part types)
                        else
                        {
                        }
                    }
                    // etc (for other categories)
                    else
                    {
                    }
                }
                return("unknown");
            }
Ejemplo n.º 35
0
 public string this[PartType key]
 {
     get { return(_verhicleParts[key]); }
     set { _verhicleParts[key] = value; }
 }
Ejemplo n.º 36
0
 protected override void OnValidate()
 {
     base.OnValidate();
     gameObject.name = PartType.ToString();
 }
Ejemplo n.º 37
0
 public CurrentGameObject(GameObject obj, PartType part)
 {
     this.currentObject = obj;
     this.partType      = part;
 }
Ejemplo n.º 38
0
 public override void GetPartTypes(PartTypesHandler partTypesHandler, ErrorHandler errorHandler)
 {
     string sql = "SELECT Part_type_id, Type FROM Part_types;";
     Execute(sql, delegate(DataTable result) {
         List<PartType> partTypes = new List<PartType>();
         foreach (DataRow row in result.Rows) {
             PartType entry = new PartType((int)row["Part_type_id"], (string)row["Type"]);
             partTypes.Add(entry);
         }
         if (partTypesHandler != null) {
             partTypesHandler(partTypes);
         }
     }, errorHandler);
 }
Ejemplo n.º 39
0
 public static extern string SHPPartTypeName(PartType partType);
Ejemplo n.º 40
0
 public override void NewPart(PartType partType, ErrorHandler errorHandler)
 {
     //TODO: See note in PartsDb.NewPart()
     string sql = "SELECT Part_num FROM Parts WHERE Part_type_id = " + partType.typeId + " ORDER BY Part_num DESC LIMIT 1";
     Execute(sql, delegate(DataTable partNumResult) {
         if (partNumResult.Rows.Count > 0) {
             DataRow row = partNumResult.Rows[0];
             string Part_num = Util.PartNumberString(Util.PartNumberInteger((string)row["Part_num"]) + 1);
     #if DEBUG
             Console.WriteLine("New part num: {0}", Part_num);
     #endif
             sql = "INSERT INTO Parts (Part_num, Part_type_id) VALUES ('" + Part_num + "', " + partType.typeId + ")";
             Execute(sql, null, errorHandler);
         }
     }, errorHandler);
 }
Ejemplo n.º 41
0
Archivo: IVS.cs Proyecto: demonzhq/JLR
 public static string PartTypeToBroadcast(PartType theType, bool NeedFlash)
 {
     if (NeedFlash)
     {
         return ("CAL");
     }
     else if (theType == PartType.Strategy)
         return "STR";
     else if (theType == PartType.Calibration)
         return "SWC";
     else if (theType == PartType.SBL)
         return "SBL";
     else if (theType == PartType.SignalConf)
         return "SWC";
     else return "XXX";
 }
Ejemplo n.º 42
0
 public override void GetParts(PartType partType, PartsHandler partsHandler, ErrorHandler errorHandler)
 {
     string sql = "SELECT * FROM Parts AS P NATURAL LEFT JOIN " + partType.name + "_attributes AS A WHERE P.Part_type_id = " + partType.typeId;
     Execute(sql, delegate(DataTable result) {
         PartCollection parts = new PartCollection(result);
         if (partsHandler != null) {
             partsHandler(parts);
         }
     }, errorHandler);
 }
Ejemplo n.º 43
0
 public Part CreatePart(PartType partType)
 {
     return(_partsFactory.Create(partType));
 }
Ejemplo n.º 44
0
 public string this[PartType key]
 {
     get { return(parts[key]); }
     set { parts[key] = value; }
 }
Ejemplo n.º 45
0
 public BHtmlPart(string content, PartType type)
 {
     Content = content;
     Type    = type;
 }
Ejemplo n.º 46
0
 public ValuePart(string text, int length)
 {
     this.type   = PartType.Text;
     this.value  = text;
     this.length = length;
 }
Ejemplo n.º 47
0
 public override void GetParts(PartType partType, PartsHandler partsHandler, ErrorHandler errorHandler)
 {
     SqlCommandBuilder bld = new SqlCommandBuilder();
     SqlCommand cmd = new SqlCommand();
     string tableNameEscaped = bld.QuoteIdentifier(partType.name);
     cmd.CommandType = System.Data.CommandType.Text;
     #if DEBUG
     cmd.CommandText = string.Format("SELECT TOP 4 * FROM {0} ORDER BY [Part Number] ASC", tableNameEscaped);
     #else
     cmd.CommandText = string.Format("SELECT * FROM {0} ORDER BY [Part Number] ASC", tableNameEscaped);
     #endif
     Execute(cmd, delegate(DataTable result) {
         result.Columns["Part Number"].ColumnName = "Part_num";
         //result.Columns.Remove("Part Type");
         PartCollection parts = new PartCollection(result);
         if (partsHandler != null) {
             partsHandler(parts);
         }
     }, errorHandler);
 }
Ejemplo n.º 48
0
 public static extern IntPtr SHPCreateObject(ShapeType shpType, int nShapeId,
     int nParts, int[] panPartStart, PartType[] paPartType,
     int nVertices, double[] adfX, double[] adfY,
     double[] adfZ, double[] adfM);
Ejemplo n.º 49
0
 private PartType PartNumToPartType(Part part)
 {
     PartType retVal = null;
     Console.WriteLine("{0}: {1}={2}", part.Part_num, part.Part_type_id, part.Part_type);
     retVal = new PartType(part.Part_type_id, partTypeNames[part.Part_type_id]);
     return retVal;
 }
Ejemplo n.º 50
0
    public void SetPart(PartType type)
    {
        destroyOldData();

        partType = type;

        Part part = Part.MakePart(type);

        if (isVisible)
        {
            //Debug.Log("IsVisible");
            meshFilter.mesh.Clear();
            meshFilter.mesh.vertices  = part.GetVertices(partDirection, partRotation, 0, 0, 0);
            meshFilter.mesh.uv        = part.GetUVs(partDirection, partRotation);
            meshFilter.mesh.triangles = part.GetTriangles(partDirection, partRotation, 0);

            meshFilter.mesh.RecalculateNormals();
        }
        else
        {
            //Debug.Log("NotVisible");
        }

        //col.sharedMesh = null;
        //col.sharedMesh = meshFilter.mesh;


        // Create box colliders

        connectionPoints = part.GetConnectionpoints(partDirection, partRotation);
        //connectionointInfos
        //createdBoxColliders = new BoxCollider[connectionointInfos.Length];
        //connectionPoints = new Connectionpoint[connectionointInfos.Length];
        //for (int i = 0; i < connectionPoints.Length; i++)
        //{
        //    for (int j = 0; j < connectionPoints[i].BoxCollidersAmount; j++)
        //    {
        //        BoxCollider boxCollider = gameObject.AddComponent<BoxCollider>();
        //        boxCollider.tag = "Connector";
        //        boxCollider.isTrigger = true;
        //        connectionPoints[i].SetBoxCollider(boxCollider, j);
        //    }
        //
        //
        //    //createdBoxColliders[i] = gameObject.AddComponent<BoxCollider>();
        //    //createdBoxColliders[i].tag = "Connector";
        //    //createdBoxColliders[i].isTrigger = true;
        //    //createdBoxColliders[i].center = connectionointInfos[i].relativePosition;
        //    //createdBoxColliders[i].size = connectionointInfos[i].size;
        //    //
        //    //connectionPoints[i] = Connectionpoint.MakeConnectionpoint(connectionointInfos[i].connectorType, connectionointInfos[i].direction, connectionointInfos[i].relativePosition);
        //    //connectionPoints[i].Boxcollider = createdBoxColliders[i];
        //}

        int conPointsNotSolid = 0;

        for (int i = 0; i < connectionPoints.Length; i++)
        {
            if (connectionPoints[i].Connectortype != ConnectorType.SOLID)
            {
                conPointsNotSolid++;
            }
        }

        connectionPointsNotSolid = new Connectionpoint[conPointsNotSolid];

        int conPointsNotSolidCounter = 0;

        for (int i = 0; i < connectionPoints.Length; i++)
        {
            if (connectionPoints[i].Connectortype != ConnectorType.SOLID)
            {
                connectionPointsNotSolid[conPointsNotSolidCounter] = connectionPoints[i];
                conPointsNotSolidCounter++;
            }
        }
    }
Ejemplo n.º 51
0
 public Hardpoint(PartSize _allowableSize, PartType _allowableType, Orientation _orientation)
 {
     allowableSize = _allowableSize;
     allowableType = _allowableType;
     orientation   = _orientation;
 }
Ejemplo n.º 52
0
            public static List <ValuePart> From(string text)
            {
                var parts = new List <ValuePart>();
                var type = PartType.Text;
                int i = 0, l = text.Length, j = 0;

                for (; i < l; i++)
                {
                    PartType _type;
                    var      c = text[i];
                    if (c == ' ')
                    {
                        _type = PartType.Space;
                    }
                    else if (char.IsDigit(c))
                    {
                        _type = PartType.Number;
                    }
                    else
                    {
                        _type = PartType.Text;
                    }

                    if (_type != type)
                    {
                        if (i != j)
                        {
                            var k = i - j;
                            var s = text.Substring(j, k);

                            switch (type)
                            {
                            case PartType.Number:
                                parts.Add(new ValuePart(int.Parse(s), k));
                                break;

                            case PartType.Space:
                                parts.Add(new ValuePart(k));
                                break;

                            case PartType.Text:
                                parts.Add(new ValuePart(s, k));
                                break;
                            }
                        }

                        j    = i;
                        type = _type;
                    }
                }

                if (i != j)
                {
                    var k = i - j;
                    var s = text.Substring(j, k);

                    switch (type)
                    {
                    case PartType.Number:
                        parts.Add(new ValuePart(int.Parse(s), k));
                        break;

                    case PartType.Space:
                        parts.Add(new ValuePart(k));
                        break;

                    case PartType.Text:
                        parts.Add(new ValuePart(s, k));
                        break;
                    }
                }

                return(parts);
            }
Ejemplo n.º 53
0
 public IDrawable GetJoinPattern(PartType pattern)
 {
     return GetNewTexture(pattern);
 }
Ejemplo n.º 54
0
        private dynamic ReadDynamicValue(PartType part, PacketReader reader)
        {
            dynamic value = null;

            switch (part)
            {
                case PartType.Int16: value = reader.ReadLEInt16(); break;
                case PartType.Int32: value = reader.ReadLEInt32(); break;
                case PartType.Int64: value = reader.ReadLEInt64(); break;
                case PartType.Single: value = reader.ReadLESingle(); break;
                case PartType.FixedString:
                    short l = reader.ReadLEInt16();
                    value = reader.ReadStringSafe(l);
                    break;
                case PartType.DynamicString: value = reader.ReadStringSafe(); break;
                case PartType.Byte: value = reader.ReadByte(); break;
                case PartType.Boolean: value = reader.ReadBoolean(); break;
                default:
                    MessageBox.Show("Undefined Segment Type Found - " + part.ToString());
                    break;
            }

            return value;
        }
Ejemplo n.º 55
0
 IDrawable GetTexture(PartType partType)
 {
     return Textures[partType];
 }
Ejemplo n.º 56
0
 public void AddPart(PartType type, Vector3Int position, PartDirection direciton, PartRotation rotation)
 {
     AddPart(type, position, direciton, rotation, true);
 }
Ejemplo n.º 57
0
 public ValuePart(int length)
 {
     this.type   = PartType.Space;
     this.length = length;
 }
Ejemplo n.º 58
0
 public void UpdatePArtType(PartType model)
 {
     _repository.UpdatePArtType(model);
 }
Ejemplo n.º 59
0
 public static extern string SHPPartTypeName(PartType partType);
Ejemplo n.º 60
0
 public ValuePart(int num, int length)
 {
     this.type   = PartType.Number;
     this.value  = num;
     this.length = length;
 }