コード例 #1
0
        public override void Read(BinaryReader file, uint size)
        {
            CVariable parsedvar = null;
            var       varsize   = file.ReadUInt32();
            var       buffer    = file.ReadBytes((int)varsize - 4);

            using (var ms = new MemoryStream(buffer))
                using (var br = new BinaryReader(ms))
                {
                    var nameId = br.ReadUInt16();
                    var typeId = br.ReadUInt16();

                    if (nameId == 0)
                    {
                        return;
                    }

                    var typename = cr2w.Names[typeId].Str;
                    var varname  = cr2w.Names[nameId].Str;

                    parsedvar = CR2WTypeManager.Create(typename, varname, cr2w, this);
                    parsedvar.IsSerialized = true;
                    parsedvar.Read(br, size);
                    this.SetREDName(varname);
                }

            Variant = parsedvar;
        }
コード例 #2
0
ファイル: CVariant.cs プロジェクト: q4a/Wolven-kit
        public override void Read(BinaryReader file, uint size)
        {
            var typeId   = file.ReadUInt16();
            var typename = cr2w.Names[typeId].Str;

            var varsize = file.ReadUInt32() - 4;

            if (varsize > 0)
            {
                Variant = CR2WTypeManager.Create(typename, nameof(Variant), cr2w, this);
                Variant.Read(file, varsize);
                Variant.IsSerialized = true;
            }
            else
            {
                // do nothing I guess?
            }
        }
コード例 #3
0
        private void InstantiateAllRedProps()
        {
            foreach (var item in this.GetREDMembers(true))
            {
                var o = accessor[this, item.Name];
                if (o is CVariable cvar)
                {
                }
                else // is null
                {
                    var att = item.GetMemberAttribute <REDAttribute>();
                    // instantiate
                    var vartype = REDReflection.GetREDTypeString(item.Type, att.Flags);
                    var varname = REDReflection.GetREDNameString(item);

                    var newvar = CR2WTypeManager.Create(vartype, varname, this.cr2w, this);     // create new variable and parent to this
                    if (newvar != null)
                    {
                        accessor[this, item.Name] = newvar;
                    }
                }
            }
        }
コード例 #4
0
        protected void Read(BinaryReader file, uint size, int elementcount)
        {
            for (int i = 0; i < elementcount; i++)
            {
                var element = CR2WTypeManager.Create(Elementtype, i.ToString(), cr2w, this);

                // no actual way to find out the elementsize of an array element
                // bacause cdpr serialized classes have no fixed size
                // solution? not sure: pass 0 and disable checks?

                var elementsize = 0;
                if (element is IDataBufferAccessor)
                {
                    elementsize = (int)((size - 4) / elementcount);
                }

                element.Read(file, (uint)elementsize);
                if (element is T te)
                {
                    te.IsSerialized = true;
                    Elements.Add(te);
                }
            }
        }
 public gameDeviceResourceData(CR2WFile cr2w, CVariable parent, string name) : base(cr2w, parent, name)
 {
     CookedDeviceData = CR2WTypeManager.Create("array:gameCookedDeviceDataCompressed",
                                               nameof(CookedDeviceData), cr2w, this) as CArray <gameCookedDeviceDataCompressed>;
 }