コード例 #1
0
        public RootModel Disassemble(TurretAssembly assembly)
        {
            DisassemblyContext context = new DisassemblyContext();
            List <ObjectField> tiers   = new List <ObjectField>();

            foreach (Transform tier in assembly.transform)
            {
                tiers.Add(new ObjectField(tier.name, DisassembleTier(assembly, Tier.Parse(tier.gameObject.name), context)));
            }

            return(new RootModel(new ObjectModel(
                                     new ObjectField("Name", ValueModelFactory.Create(assembly.Name, context)),
                                     new ObjectField("Description", ValueModelFactory.Create(assembly.Description, context)),
                                     new ObjectField("Tiers", new ObjectModel(tiers.ToArray())),
                                     new ObjectField("UpgradeMap", _valueAssembler.Disassemble(assembly.UpgradeMap, typeof(UpgradeMap), new DisassemblyContext())
                                                     ))));
        }
コード例 #2
0
        public override ObjectModel Disassemble(LineRenderer source, DisassemblyContext context)
        {
            ValueAssembler    assembler      = new ValueAssembler();
            RendererAssembler baseSerializer = new RendererAssembler(); // Base serialization could potentially be automated using reflection.

            return(new ObjectModel(baseSerializer.Disassemble(source, context),
                                   new ObjectField("PositionCount", new PrimitiveModel(source.positionCount)),
                                   new ObjectField("Positions", new ArrayModel(GetPositions(source).Select(x => ValueModelFactory.Create(x, context)))),
                                   new ObjectField("Curve", ValueModelFactory.Create(source.widthCurve, context)),
                                   new ObjectField("Colors", ValueModelFactory.Create(source.colorGradient, context)),
                                   new ObjectField("CornerVerticies", new PrimitiveModel(source.numCornerVertices)),
                                   new ObjectField("CapVerticies", new PrimitiveModel(source.numCapVertices)),
                                   new ObjectField("Alignment", new PrimitiveModel(source.alignment)),
                                   new ObjectField("TextureMode", new PrimitiveModel(source.textureMode)),
                                   new ObjectField("ShadowBias", new PrimitiveModel(source.shadowBias)),
                                   new ObjectField("GenerateLighingData", new PrimitiveModel(source.generateLightingData)),
                                   new ObjectField("UseWorldSpace", new PrimitiveModel(source.useWorldSpace))));
        }
コード例 #3
0
        public override ObjectModel Disassemble(TrailRenderer source, DisassemblyContext context)
        {
            RendererAssembler baseAssembler = new RendererAssembler();

            return(new ObjectModel(baseAssembler.Disassemble(source, context),
                                   new ObjectField("Curve", ValueModelFactory.Create(source.widthCurve, context)),
                                   new ObjectField("Time", new PrimitiveModel(source.time)),
                                   new ObjectField("MinVertexDistance", new PrimitiveModel(source.minVertexDistance)),
                                   new ObjectField("Autodestruct", new PrimitiveModel(source.autodestruct)),
                                   new ObjectField("Emitting", new PrimitiveModel(source.emitting)),
                                   new ObjectField("Color", ValueModelFactory.Create(source.colorGradient, context)),
                                   new ObjectField("CornerVertices", new PrimitiveModel(source.numCornerVertices)),
                                   new ObjectField("CapVertices", new PrimitiveModel(source.numCapVertices)),
                                   new ObjectField("Alignment", new PrimitiveModel(source.alignment)),
                                   new ObjectField("TextureMode", new PrimitiveModel(source.textureMode)),
                                   new ObjectField("GenerateLigtingData", new PrimitiveModel(source.generateLightingData)),
                                   new ObjectField("ShadowBias", new PrimitiveModel(source.shadowBias))
                                   ));
        }
コード例 #4
0
        public ObjectModel RecursiveDisassemble(GameObject gameObject, DisassemblyContext context)
        {
            var children = new List <ObjectModel>();

            Component[] components      = gameObject.GetComponents <Component>().Where(x => !x.GetType().IsDefined(typeof(DontSerializeAttribute), false)).ToArray();
            var         componentModels = new List <ObjectModel>();

            foreach (Component component in components)
            {
                componentModels.Add(_componentAssembler.Disassemble(component, context));
            }

            return(context.MakeReferencable(gameObject, new ObjectModel(
                                                new ObjectField("Name", ValueModelFactory.Create(gameObject.name, context)),
                                                new ObjectField("Tag", ValueModelFactory.Create(gameObject.tag, context)),
                                                new ObjectField("Layer", ValueModelFactory.Create(gameObject.layer, context)),
                                                new ObjectField("Static", ValueModelFactory.Create(gameObject.isStatic, context)),
                                                new ObjectField("Components", new ArrayModel(componentModels)),
                                                new ObjectField("Children", new ArrayModel(GetChildren(gameObject).Select(x => RecursiveDisassemble(x, context))))
                                                )));
        }
コード例 #5
0
        public ObjectModel Dissassemble(TurretComponent component, DisassemblyContext context)
        {
            GameObject         obj      = component.gameObject;
            List <ObjectModel> children = new List <ObjectModel>();

            foreach (Transform child in obj.transform)
            {
                TurretComponent childComponent = child.GetComponent <TurretComponent>();
                if (childComponent != null)
                {
                    children.Add(Dissassemble(childComponent, context));
                }
            }

            return(new ObjectModel(
                       new ObjectField("UniqueIdentifier", ValueModelFactory.Create(component.Identifier, context)),
                       new ObjectField("LocalPosition", ValueModelFactory.Create((Vector2)obj.transform.localPosition, context)),
                       new ObjectField("Angle", ValueModelFactory.Create(obj.transform.localRotation.eulerAngles.z, context)),
                       new ObjectField("Flipped", ValueModelFactory.Create(component.Flipped, context)),
                       new ObjectField("Children", new ArrayModel(children))
                       ));
        }