Exemple #1
0
#pragma warning restore 0649

        // Parsing and verification

        private static IEnumerable <IColliderSerializer> SerializeColliderRecords
        (
            IEnumerable <TextRecordParsing.Record> sourceRecords,
            List <DynamicsSetup.ParseMessage> errorRecords
        )
        {
            var serializerClasses = new Dictionary <string, System.Type>
            {
                { SphereColliderToken, typeof(SphereColliderSerializer) },
                { CapsuleColliderToken, typeof(CapsuleColliderSerializer) },
                { PanelColliderToken, typeof(PanelColliderSerializer) },
            };

            var colliderSerializers = new List <IColliderSerializer>(sourceRecords.Count());

            foreach (var sourceRecord in sourceRecords)
            {
                IColliderSerializer        newColliderInfo = null;
                DynamicsSetup.ParseMessage error           = null;
                var baseInfo = DynamicsSetup.SerializeObjectFromStrings <ColliderSerializerBaseInfo>(sourceRecord.Items, null, ref error);
                if (baseInfo != null)
                {
                    System.Type serializerType;
                    if (serializerClasses.TryGetValue(baseInfo.colliderType, out serializerType))
                    {
                        newColliderInfo = DynamicsSetup.SerializeObjectFromStrings(
                            serializerType, sourceRecord.Items, "linkedRenderer", ref error)
                                          as IColliderSerializer;
                    }
                    else
                    {
                        error = new DynamicsSetup.ParseMessage("Invalid collider type: " + baseInfo.colliderType, sourceRecord.Items);
                    }
                }

                if (newColliderInfo != null)
                {
                    colliderSerializers.Add(newColliderInfo);
                }
                else
                {
                    errorRecords.Add(error);
                }
            }
            return(colliderSerializers);
        }
Exemple #2
0
        private static IEnumerable <TransformSerializer> SerializeTransformRecords
        (
            IEnumerable <TextRecordParsing.Record> sourceRecords,
            List <DynamicsSetup.ParseMessage> errorRecords
        )
        {
            var transformRecords = new List <TransformSerializer>(sourceRecords.Count());

            foreach (var sourceRecord in sourceRecords)
            {
                DynamicsSetup.ParseMessage error = null;
                var transformRecord = DynamicsSetup.SerializeObjectFromStrings <TransformSerializer>(sourceRecord.Items, null, ref error);
                if (transformRecord != null)
                {
                    transformRecords.Add(transformRecord);
                }
                else
                {
                    errorRecords.Add(error);
                }
            }
            return(transformRecords);
        }