public override void Write(BinaryWriter file)
        {
            base.Write(file);

            byte[] buffer;
            using (var ms = new MemoryStream())
                using (var bw = new BinaryWriter(ms))
                {
                    bw.WriteBit6(Data.elements.Count);
                    foreach (var cvar in Data.elements)
                    {
                        var ClassName = new CName(cr2w, null, "")
                        {
                            Value = cvar.REDType
                        };
                        ClassName.Write(bw);

                        cvar.Write(bw);
                    }
                    buffer = ms.ToArray();
                }

            file.Write(buffer.Length + 4);
            file.Write(buffer);
        }
        public override void Read(BinaryReader file, uint size)
        {
            base.Read(file, size);

            var startpos = file.BaseStream.Position;

            var bytecount = file.ReadUInt32();

            // read classes
            var count = file.ReadBit6();

            for (int i = 0; i < count; i++)
            {
                var ClassName = new CName(cr2w, null, "");
                ClassName.Read(file, 2);

                var parsedvar = CR2WTypeManager.Create(ClassName.Value, "", cr2w, Data);
                parsedvar.Read(file, size);


                Data.AddVariable(parsedvar);
            }


            //check
            var endpos    = file.BaseStream.Position;
            var bytesread = endpos - startpos;

            if (bytesread != bytecount)
            {
                throw new InvalidParsingException($"Error in parsing SAppearanceAttachment: Data Variable. {bytesread} bytes read out of {bytecount}.");
            }
        }
Esempio n. 3
0
        public override void Read(BinaryReader file, uint size)
        {
            var pos   = file.BaseStream.Position;
            var count = file.ReadBit6();

            for (var i = 0; i < count; i++)
            {
                var var = new CName(cr2w, tags, i.ToString());
                var.Read(file, 0);
                AddVariable(var);
            }
        }
Esempio n. 4
0
        public override CVariable SetValue(object val)
        {
            this.IsSerialized = true;
            Value             = val switch
            {
                string s => s,
                CName cval => cval.Value,
                       _ => Value
            };

            return(this);
        }
Esempio n. 5
0
        }                                                                            // MAX LIMIT 4

        public CurveInfo(IRed3EngineFile cr2w, CVariable parent, string name) : base(cr2w, parent, name)
        {
            someName = new CName(cr2w, this, nameof(someName))
            {
                IsSerialized = true
            };
            someByte = new CUInt8(cr2w, this, nameof(someByte))
            {
                IsSerialized = true
            };
            pieces = new CCompressedBuffer <CurvePiece>(cr2w, this, nameof(pieces))
            {
                IsSerialized = true
            };
        }
 public SEntityBufferType2(CR2WFile cr2w, CVariable parent, string name) : base(cr2w, parent, name)
 {
     componentName = new CName(cr2w, this, nameof(componentName))
     {
         IsSerialized = true
     };
     sizeofdata = new CUInt32(cr2w, this, nameof(sizeofdata))
     {
         IsSerialized = true
     };
     variables = new CBufferUInt32 <CVariantSizeTypeName>(cr2w, this, nameof(variables))
     {
         IsSerialized = true
     };
 }
Esempio n. 7
0
 public CFXTrackItem(CR2WFile cr2w, CVariable parent, string name) : base(cr2w, parent, name)
 {
     buffername = new CName(cr2w, this, nameof(buffername))
     {
         IsSerialized = true
     };
     count = new CDynamicInt(cr2w, this, nameof(count))
     {
         IsSerialized = true
     };
     unk = new CUInt8(cr2w, this, nameof(unk))
     {
         IsSerialized = true
     };
     buffer = new CCompressedBuffer <CBufferUInt16 <CFloat> >(cr2w, this, nameof(buffer))
     {
         IsSerialized = true
     };
 }
 public IdHandle(CR2WFile cr2w, CVariable parent, string name) : base(cr2w, parent, name)
 {
     handlename = new CName(cr2w, this, "handlename");
     handle     = new CHandle <CBehaviorVariable>(cr2w, this, "handle");
 }
Esempio n. 9
0
 public IdHandle(IRed3EngineFile cr2w, CVariable parent, string name) : base(cr2w, parent, name)
 {
     handlename = new CName(cr2w, this, "handlename");
     handle     = new CHandle <IEditableVariable>(cr2w, this, "handle");
 }