コード例 #1
0
     public JObject Serialize(bool compact)
     {
         if (SubObject != null)
         {
             return(SubObject.Serialize(false, compact));
         }
         else if (Id != null)
         {
             return new JObject {
                        ["@id"] = Id
             }
         }
         ;
         else if (Primitive != null && Type != null)
         {
             return new JObject {
                        ["@value"] = JToken.FromObject(Primitive), ["@type"] = Type
             }
         }
         ;
         else
         {
             return new JObject {
                        ["@value"] = JToken.FromObject(Primitive)
             }
         };
     }
 }
コード例 #2
0
        public async Task ObjectArrayResultsWork()
        {
            var o  = new ObjectResult();
            var co = await Init <IObjectResult>(o, ChannelType.NamedPipe);

            var objects = new SubObject[]
            {
                new SubObject {
                    Name = "1"
                },
                new SubObject {
                    Name = "2"
                },
                new SubObject {
                    Name = "3"
                },
            };

            var result = co.GetObjects(objects);

            Assert.AreEqual(objects.Length, result.Length);
            for (int i = 0; i < objects.Length; i++)
            {
                Assert.AreEqual(objects[i].Name, result[i].Name);
            }
        }
コード例 #3
0
    public bool IsEqualTo(SubObject other)
    {
        var compExpr = this.CreatePropertiesEqualExpression(other);
        var compFunc = compExpr.Compile();

        return(compFunc(other));
    }
コード例 #4
0
        private GameObject CreateLODModels()
        {
            GameObject  retn     = new GameObject("Detail Root");
            BoxCollider collider = retn.AddComponent <BoxCollider>();

            collider.size = model.GetBoundingBoxSize();

            for (int i = 0; i < model.DetailLevels; i++)
            {
                SubObject  subObject = model.GetDetailLevel(i);
                GameObject go        = CreateRenderableGameObject(subObject);
                go.transform.parent = retn.transform;
            }

            if (model.DetailLevels > 1)
            {
                LODGroup lodGroup = retn.AddComponent <LODGroup>();
                LOD[]    lods     = new LOD[model.DetailLevels];

                for (int i = 0; i < model.DetailLevels; i++)
                {
                    lods[i] = new LOD(1f / (i + 1), retn.transform.GetChild(i).GetComponents <Renderer>());
                }

                lodGroup.SetLODs(lods);
                lodGroup.RecalculateBounds();
            }

            return(retn);
        }
コード例 #5
0
        private GameObject CreateRenderableGameObject(SubObject obj)
        {
            GameObject root       = new GameObject(obj.submodelName);
            MeshFilter meshFilter = root.AddComponent <MeshFilter>();

            meshFilter.mesh = AssetDatabase.LoadAssetAtPath <Mesh>(GetMeshPath(obj.submodelName));
            Renderer renderer = root.AddComponent <MeshRenderer>();

            Material[] materials = new Material[obj.textureIndices.Length];
            processedSubObjects.Add(obj);

            for (int i = 0; i < obj.textureIndices.Length; i++)
            {
                Material material;

                if (materialMap.TryGetValue(obj.textureIndices[i], out material))
                {
                    int    textureIndex = obj.textureIndices[i];
                    string materialName = model.GetTextureNameByIndex(textureIndex);
                    materials[i] = AssetDatabase.LoadAssetAtPath <Material>(GetMaterialPath(materialName));
                }
            }

            renderer.sharedMaterials = materials;
            return(root);
        }
コード例 #6
0
 public bool IsEqualTo(SubObject other)
 {
     if (this.eqFunc == null)
     {
         var compExpr = this.CreatePropertiesEqualExpression(other);
         this.eqFunc = compExpr.Compile();
     }
     return(this.eqFunc(other));
 }
        public void MonthCalendarChildAccessibleObject_LegacyIAccessiblePattern_IsSupported()
        {
            using MonthCalendar control = new MonthCalendar();

            MonthCalendarAccessibleObject      controlAccessibleObject = (MonthCalendarAccessibleObject)control.AccessibilityObject;
            MonthCalendarChildAccessibleObject accessibleObject        = new SubObject(controlAccessibleObject);

            Assert.True(accessibleObject.IsPatternSupported(UiaCore.UIA.LegacyIAccessiblePatternId));
            Assert.False(control.IsHandleCreated);
        }
        public void MonthCalendarChildAccessibleObject_FragmentRoot_IsControlAccessibleObject()
        {
            using MonthCalendar control = new MonthCalendar();

            MonthCalendarAccessibleObject      controlAccessibleObject = (MonthCalendarAccessibleObject)control.AccessibilityObject;
            MonthCalendarChildAccessibleObject accessibleObject        = new SubObject(controlAccessibleObject);

            Assert.Equal(controlAccessibleObject, accessibleObject.FragmentRoot);
            Assert.False(control.IsHandleCreated);
        }
        public void MonthCalendarChildAccessibleObject_FragmentNavigate_DoesntHaveChildrenAndSiblings(int direction)
        {
            using MonthCalendar control = new MonthCalendar();

            MonthCalendarAccessibleObject      controlAccessibleObject = (MonthCalendarAccessibleObject)control.AccessibilityObject;
            MonthCalendarChildAccessibleObject accessibleObject        = new SubObject(controlAccessibleObject);

            Assert.Null(accessibleObject.FragmentNavigate((UiaCore.NavigateDirection)direction));
            Assert.False(control.IsHandleCreated);
        }
        public void MonthCalendarChildAccessibleObject_FragmentNavigate_Parent_IsNull()
        {
            using MonthCalendar control = new MonthCalendar();

            MonthCalendarAccessibleObject      controlAccessibleObject = (MonthCalendarAccessibleObject)control.AccessibilityObject;
            MonthCalendarChildAccessibleObject accessibleObject        = new SubObject(controlAccessibleObject);

            Assert.Null(accessibleObject.FragmentNavigate(UiaCore.NavigateDirection.Parent));
            Assert.False(control.IsHandleCreated);
        }
コード例 #11
0
        public void TestMethodOutOfOrderDeserialization()
        {
            JsonObjectSerializer serializer = new JsonObjectSerializer();

            string outOfOrderJson = "{\"SubDescr\":\"Test String\",\"SubId\":2}";

            SubObject subObj = (SubObject)serializer.Deserialize(outOfOrderJson, typeof(SubObject), null);

            Assert.Equal <int>(2, subObj.SubId);
            Assert.Equal("Test String", subObj.SubDescr);
        }
        public void MonthCalendarChildAccessibleObject_GetPropertyValue_ReturnsExpected(int property, object expected)
        {
            using MonthCalendar control = new MonthCalendar();

            MonthCalendarAccessibleObject      controlAccessibleObject = (MonthCalendarAccessibleObject)control.AccessibilityObject;
            MonthCalendarChildAccessibleObject accessibleObject        = new SubObject(controlAccessibleObject);
            object actual = accessibleObject.GetPropertyValue((UiaCore.UIA)property);

            Assert.Equal(expected, actual);
            Assert.False(control.IsHandleCreated);
        }
コード例 #13
0
        public ObjectData(BinaryReader reader) : this()
        {
            MinimapType = reader.ReadByte();
            reader.ReadByte();

            SubObjects = new SubObject[8];
            for (int i = 0; i < 8; i++)
            {
                SubObjects[i] = new SubObject(reader);
            }
        }
コード例 #14
0
ファイル: ObjectData.cs プロジェクト: IllidanS4/AlbLib
        public ObjectData(BinaryReader reader)
            : this()
        {
            MinimapType = reader.ReadByte();
            reader.ReadByte();

            SubObjects = new SubObject[8];
            for(int i = 0; i < 8; i++)
            {
                SubObjects[i] = new SubObject(reader);
            }
        }
        public void MonthCalendarChildAccessibleObject_RuntimeId_HasThreeExpectedItems()
        {
            using MonthCalendar control = new MonthCalendar();

            control.CreateControl();
            MonthCalendarAccessibleObject      controlAccessibleObject = (MonthCalendarAccessibleObject)control.AccessibilityObject;
            MonthCalendarChildAccessibleObject accessibleObject        = new SubObject(controlAccessibleObject);

            Assert.Equal(3, accessibleObject.RuntimeId.Length);
            Assert.Equal(AccessibleObject.RuntimeIDFirstItem, accessibleObject.RuntimeId[0]);
            Assert.Equal(PARAM.ToInt(control.Handle), accessibleObject.RuntimeId[1]);
            Assert.Equal(accessibleObject.GetChildId(), accessibleObject.RuntimeId[2]);
            Assert.True(control.IsHandleCreated);
        }
コード例 #16
0
        private List <SubObject> GetChildSubObjects(SubObject parent)
        {
            List <SubObject> retn       = new List <SubObject>();
            List <SubObject> subObjects = model.subObjects;

            for (int i = 0; i < subObjects.Count; i++)
            {
                if (subObjects[i].submodelParent == parent.subModelNumber)
                {
                    retn.Add(subObjects[i]);
                }
            }

            return(retn);
        }
コード例 #17
0
        public void SubObject_DontThrowIfEqual()
        {
            var expected = new SubObject {
                Data1 = new IntegerData {
                    Value = 1
                }
            };
            var result = new SubObject {
                Data1 = new IntegerData {
                    Value = 1
                }
            };

            DeepAssert.Equal(expected, result);
        }
コード例 #18
0
ファイル: GraphQlController.cs プロジェクト: KhaledSMQ/aml
            public Query()
            {
                foo = new List <SubObject>();
                foo.Add(new SubObject {
                    Foo = SubObject.Blah.Blah1, TEst2 = "hallo flldldl"
                });
                foo.Add(new SubObject {
                    Foo = SubObject.Blah.Blah1, TEst2 = "hallo flldldl"
                });
                foo.Add(new SubObject {
                    Foo = SubObject.Blah.Blah1, TEst2 = "hallo flldldl"
                });

                MySubObject = new SubObject();
            }
コード例 #19
0
        /*
         *  has @type and no @value: is subobject
         *  has @id: reference to other object
         *  has @type and @value: primitive, but with special type
         *  has @value: primitive
         */

        public ASTerm Clone()
        {
            if (SubObject == null)
            {
                return new ASTerm {
                           Primitive = Primitive, Language = Language
                }
            }
            ;
            else
            {
                return new ASTerm {
                           SubObject = SubObject.Clone(), Language = Language
                }
            };
        }
コード例 #20
0
        private GameObject CreateTurretAssets()
        {
            List <TurretInfo> turrets = model.turrets;

            if (turrets.Count == 0)
            {
                return(null);
            }
            GameObject turretRoot = new GameObject("Turrets");

            for (int i = 0; i < turrets.Count; i++)
            {
                TurretInfo turret    = turrets[i];
                SubObject  obj       = model.GetSubObjectByIndex(turret.parentSubObjectIndex);
                GameObject turretObj = CreateRenderableGameObject(obj);

                if (turret.type == TurretType.Gun)
                {
                    turretObj.name = "[gun] " + turretObj.name;
                }
                else
                {
                    turretObj.name = "[missile] " + turretObj.name;
                }

                BoxCollider collider = turretObj.AddComponent <BoxCollider>();
                collider.size = obj.boundingBoxMax - obj.boundingBoxMin;
                turretObj.transform.parent        = turretRoot.transform;
                turretObj.transform.localPosition = obj.offset;
                // todo turn this back on
//                Turret turretComponent = turretObj.AddComponent<Turret>();
//                turretComponent.normal = turret.turretNormal;
//                turretComponent.firingPoints = turret.firingPoints;

                List <SubObject> children = GetChildSubObjects(obj);

                for (int j = 0; j < children.Count; j++)
                {
                    SubObject  child       = children[j];
                    GameObject turretChild = CreateRenderableGameObject(child);
                    turretChild.transform.parent        = turretObj.transform;
                    turretChild.transform.localPosition = new Vector3(); // not offset for some reason
                }
            }

            return(turretRoot);
        }
コード例 #21
0
        MapObject BuildMapObject(int tileX, int tileY, SubObject subObject, float objectYScaling)
        {
            var definition = _labyrinthData.Objects[subObject.ObjectInfoNumber];

            if (definition.SpriteId.IsNone)
            {
                return(null);
            }

            bool onFloor = (definition.Properties & LabyrinthObjectFlags.FloorObject) != 0;

            // We should probably be offsetting the main tilemap by half a tile to centre the objects
            // rather than fiddling with the object positions... will need to reevaluate when working on
            // collision detection, path-finding etc.
            var objectBias = new Vector3(-1.0f, 0, -1.0f) / 2;

            /*
             * (MapId == MapId.Jirinaar3D || MapId == MapId.AltesFormergebäude || MapId == MapId.FormergebäudeNachKampfGegenArgim)
             *  ? new Vector3(-1.0f, 0, -1.0f) / 2
             *  : new Vector3(-1.0f, 0, -1.0f); // / 2;
             */

            var tilePosition = new Vector3(tileX, 0, tileY) + objectBias;
            var offset       = new Vector3(
                subObject.X,
                subObject.Y * objectYScaling,
                subObject.Z);

            var smidgeon = onFloor
                ? new Vector3(0, subObject.ObjectInfoNumber * (offset.Y < float.Epsilon ? 0.1f : -0.1f), 0)
                : Vector3.Zero;

            Vector3 position = tilePosition * TileSize + offset + smidgeon;

            return(new MapObject(
                       definition.SpriteId,
                       position,
                       new Vector2(definition.MapWidth, definition.MapHeight),
                       (definition.Properties & LabyrinthObjectFlags.FloorObject) != 0
                       ));
        }
コード例 #22
0
        private GameObject CreateDebrisModels()
        {
            if (!model.HasDebris)
            {
                return(null);
            }

            GameObject retn = new GameObject("Debris Root");

            for (int i = 0; i < model.DebrisCount; i++)
            {
                SubObject   subObject = model.GetDebrisPiece(i);
                GameObject  go        = CreateRenderableGameObject(subObject);
                BoxCollider collider  = go.AddComponent <BoxCollider>();
                collider.size              = subObject.boundingBoxMax - subObject.boundingBoxMax;
                go.transform.parent        = retn.transform;
                go.transform.localPosition = subObject.offset;
            }

            retn.SetActive(false);
            return(retn);
        }
コード例 #23
0
        private GameObject CreateExtras()
        {
            GameObject       extras     = new GameObject("Extras");
            List <SubObject> subObjects = model.subObjects;

            for (int i = 0; i < subObjects.Count; i++)
            {
                SubObject subObject = subObjects[i];

                if (processedSubObjects.Contains(subObject))
                {
                    continue;
                }

                // ignore pilots for now
                if (subObject.submodelName.Contains("pilot"))
                {
                    processedSubObjects.Add(subObject);
                    continue;
                }

                // ignore destroyed turrets for now
                if (subObject.submodelName.Contains("-destroyed"))
                {
                    processedSubObjects.Add(subObject);
                    continue;
                }

                GameObject go = CreateRenderableGameObject(subObject);
                go.transform.parent        = extras.transform;
                go.transform.localPosition = subObject.offset;
                if (subObject.properties.Length > 0)
                {
                    Debug.Log(subObject.properties);
                }
            }

            return(extras);
        }
コード例 #24
0
        public void SubObject_ThrowIfDifferent()
        {
            var expected = new SubObject {
                Data1 = new IntegerData {
                    Value = 1
                }, Data2 = new IntegerData {
                    Value = 1
                }
            };
            var result = new SubObject {
                Data1 = new IntegerData {
                    Value = 2
                }, Data2 = new IntegerData {
                    Value = 2
                }
            };

            Assert.Throws <DeepAssertException>(() =>
            {
                DeepAssert.Equal(expected, result);
            });
        }
コード例 #25
0
        /// <summary>
        /// When null is given, the default SubObject
        /// </summary>
        /// <param name="mat"></param>
        /// <returns></returns>
        public SubObject GetOrCreateSubObject(OBJMaterial mat)
        {
            if (mat == null)
            {
                return(DefaultSubObject);
            }
            for (int i = 0; i < SubObjects.Count; i++)
            {
                if (SubObjects[i].Material == mat)
                {
                    return(SubObjects[i]);
                }
            }

            SubObject obj = new SubObject();

            SubObjects.Add(obj);

            obj.Material = mat;

            return(obj);
        }
コード例 #26
0
ファイル: ShapeFile.cs プロジェクト: perpetualKid/ORTS-MG
        private void Validate(string fileName)
        {
            if (Shape.LodControls.Count < 1)
            {
                Trace.TraceWarning("Missing at least one LOD Control element in shape {0}", fileName);
            }

            for (int distanceLevelIndex = 0; distanceLevelIndex < Shape.LodControls[0].DistanceLevels.Count; distanceLevelIndex++)
            {
                DistanceLevel distanceLevel = Shape.LodControls[0].DistanceLevels[distanceLevelIndex];

                if (distanceLevel.DistanceLevelHeader.Hierarchy.Length != Shape.Matrices.Count)
                {
                    Trace.TraceWarning("Expected {2} hierarchy elements; got {3} in distance level {1} in shape {0}", fileName, distanceLevelIndex, Shape.Matrices.Count, distanceLevel.DistanceLevelHeader.Hierarchy.Length);
                }

                for (int hierarchyIndex = 0; hierarchyIndex < distanceLevel.DistanceLevelHeader.Hierarchy.Length; hierarchyIndex++)
                {
                    int matrixIndex = distanceLevel.DistanceLevelHeader.Hierarchy[hierarchyIndex];
                    if (matrixIndex < -1 || matrixIndex >= Shape.Matrices.Count)
                    {
                        Trace.TraceWarning("Hierarchy element {2} out of range (expected {3} to {4}; got {5}) in distance level {1} in shape {0}", fileName, distanceLevelIndex, hierarchyIndex, -1, Shape.Matrices.Count - 1, matrixIndex);
                    }
                }

                for (int subObjectIndex = 0; subObjectIndex < distanceLevel.SubObjects.Count; subObjectIndex++)
                {
                    SubObject subObject = distanceLevel.SubObjects[subObjectIndex];

                    if (subObject.SubObjectHeader.GeometryInfo.GeometryNodeMap.Length != Shape.Matrices.Count)
                    {
                        Trace.TraceWarning("Expected {3} geometry node map elements; got {4} in sub-object {2} in distance level {1} in shape {0}", fileName, distanceLevelIndex, subObjectIndex, Shape.Matrices.Count, subObject.SubObjectHeader.GeometryInfo.GeometryNodeMap.Length);
                    }

                    int[] geometryNodeMap = subObject.SubObjectHeader.GeometryInfo.GeometryNodeMap;
                    for (int geometryNodeMapIndex = 0; geometryNodeMapIndex < geometryNodeMap.Length; geometryNodeMapIndex++)
                    {
                        int geometryNode = geometryNodeMap[geometryNodeMapIndex];
                        if (geometryNode < -1 || geometryNode >= subObject.SubObjectHeader.GeometryInfo.GeometryNodes.Count)
                        {
                            Trace.TraceWarning("Geometry node map element {3} out of range (expected {4} to {5}; got {6}) in sub-object {2} in distance level {1} in shape {0}", fileName, distanceLevelIndex, subObjectIndex, geometryNodeMapIndex, -1, subObject.SubObjectHeader.GeometryInfo.GeometryNodes.Count - 1, geometryNode);
                        }
                    }

                    Vertices vertices = subObject.Vertices;
                    for (int vertexIndex = 0; vertexIndex < vertices.Count; vertexIndex++)
                    {
                        Vertex vertex = vertices[vertexIndex];

                        if (vertex.PointIndex < 0 || vertex.PointIndex >= Shape.Points.Count)
                        {
                            Trace.TraceWarning("Point index out of range (expected {4} to {5}; got {6}) in vertex {3} in sub-object {2} in distance level {1} in shape {0}", fileName, distanceLevelIndex, subObjectIndex, vertexIndex, 0, Shape.Points.Count - 1, vertex.PointIndex);
                        }

                        if (vertex.NormalIndex < 0 || vertex.NormalIndex >= Shape.Normals.Count)
                        {
                            Trace.TraceWarning("Normal index out of range (expected {4} to {5}; got {6}) in vertex {3} in sub-object {2} in distance level {1} in shape {0}", fileName, distanceLevelIndex, subObjectIndex, vertexIndex, 0, Shape.Normals.Count - 1, vertex.NormalIndex);
                        }

                        if (vertex.VertexUVs.Length < 1)
                        {
                            Trace.TraceWarning("Missing UV index in vertex {3} in sub-object {2} in distance level {1} in shape {0}", fileName, distanceLevelIndex, subObjectIndex, vertexIndex);
                        }
                        else if (vertex.VertexUVs[0] < 0 || vertex.VertexUVs[0] >= Shape.UVPoints.Count)
                        {
                            Trace.TraceWarning("UV index out of range (expected {4} to {5}; got {6}) in vertex {3} in sub-object {2} in distance level {1} in shape {0}", fileName, distanceLevelIndex, subObjectIndex, vertexIndex, 0, Shape.UVPoints.Count - 1, vertex.VertexUVs[0]);
                        }
                    }

                    for (int primitiveIndex = 0; primitiveIndex < subObject.Primitives.Count; primitiveIndex++)
                    {
                        IndexedTriList triangleList = subObject.Primitives[primitiveIndex].IndexedTriList;
                        for (int triangleListIndex = 0; triangleListIndex < triangleList.VertexIndices.Count; triangleListIndex++)
                        {
                            if (triangleList.VertexIndices[triangleListIndex].A < 0 || triangleList.VertexIndices[triangleListIndex].A >= vertices.Count)
                            {
                                Trace.TraceWarning("Vertex out of range (expected {4} to {5}; got {6}) in primitive {3} in sub-object {2} in distance level {1} in shape {0}", fileName, distanceLevelIndex, subObjectIndex, primitiveIndex, 0, vertices.Count - 1, triangleList.VertexIndices[triangleListIndex].A);
                            }
                        }
                    }
                }
            }
        }