internal void Write(IBitWriter writer) { writer.WriteUInt16(this._Unknown1); if (this._Unknown1 >= 1) { writer.WriteUInt16((ushort)this._Unknown2.Count); foreach (var unknown2 in this._Unknown2) { writer.WriteUInt32(unknown2); } writer.WriteUInt16((ushort)this._Unknown3.Count); foreach (var unknown3 in this._Unknown3) { writer.WriteUInt32(unknown3); } } if (this._Unknown1 >= 2) { writer.WriteUInt16((ushort)this._Unknown4.Count); foreach (var unknown4 in this._Unknown4) { writer.WriteUInt32(unknown4); } } }
public override void Write(IBitWriter writer) { writer.WriteBoolean(this._Unknown4); writer.WriteUInt16((ushort)Math.Min(5, this._Mods.Count)); foreach (var kv in this._Mods) { writer.PushFrameLength(24); writer.WriteUInt32(kv.Key); if (kv.Key != 0) { writer.PushFrameLength(24); Components.InventoryComponent.WriteItemData(writer, kv.Value); writer.PopFrameLength(); } writer.PopFrameLength(); } writer.WriteUInt16((ushort)this._AugmentationItemHashes.Count); foreach (var augmentationItemHash in this._AugmentationItemHashes) { writer.PushFrameLength(24); writer.WriteUInt32(augmentationItemHash); writer.PopFrameLength(); } writer.WriteString(this._CustomName); base.Write(writer); }
internal override void Write2(IBitWriter writer) { base.Write2(writer); writer.PushFrameLength(24); this._Unknown.Write(writer); writer.PopFrameLength(); }
public override void Write(IBitWriter writer, ushort version) { base.Write(writer, version); writer.WriteUInt32(this._LayoutSignature); writer.WriteUInt32((uint)this._PackedData.Length); writer.WriteBytes(this._PackedData); }
public static void WriteNetworkObject(this IBitWriter bs, NetworkObject networkObject) { var max = NetworkObjectLookup.Instance.Entries.Length; var idx = networkObject != null ? networkObject.networkAssetId : -1; bs.WriteIntInRange(idx, -1, max); }
public void TestThatBitReaderAndBitWriterCanReadAndWriteRandomNumberOfBits() { var totalNumberOfBits = randomStringContent.Length * 8; var random = new Random(); using (bitReader = new BitReader(inputStream)) using (bitWriter = new BitWriter(outputStream)) { do { int numberOfBits = random.Next(1, 32); if (numberOfBits > totalNumberOfBits) { numberOfBits = totalNumberOfBits; } uint value = bitReader.ReadNBits(numberOfBits); bitWriter.WriteNBits(numberOfBits, value); totalNumberOfBits -= numberOfBits; } while (totalNumberOfBits > 0); } var writtenContent = File.ReadAllText(outputFilePath); Assert.AreEqual(randomStringContent, writtenContent); }
public void Write(IBitWriter writer) { writer.WriteUInt32(this._Unknown1); writer.WriteBoolean(this._Unknown2); for (int i = 0; i < this._PowerIds.Length; i++) { writer.WriteUInt32(this._PowerIds[i]); } for (int i = 0; i < this._RangedWeaponIds.Length; i++) { writer.WriteUInt32(this._RangedWeaponIds[i]); } writer.WriteUInt32(this._MeleeWeaponId); for (int i = 0; i < this._GearIds.Length; i++) { writer.WriteUInt32(this._GearIds[i]); } for (int i = 0; i < this._SpaceToolIds.Length; i++) { writer.WriteUInt32(this._SpaceToolIds[i]); } for (int i = 0; i < this._ConsumableIds.Length; i++) { writer.WriteUInt32(this._ConsumableIds[i]); } writer.WriteUInt32(this._CasualOutfitId); }
internal void Write(IBitWriter writer) { writer.WriteUInt16((ushort)this._Unknown.Count); foreach (var unknown in this._Unknown) { writer.PushFrameLength(24); writer.WriteUInt32((uint)unknown.Type); switch (unknown.Type) { case NotificationsType.Unknown0: case NotificationsType.Unknown1: { writer.WriteUInt32(unknown.Unknown1); break; } case NotificationsType.Unknown2: { writer.WriteString(unknown.Unknown2); break; } default: { throw new FormatException(); } } writer.PopFrameLength(); } }
public void WriteValues(int[] values, IBitWriter bitWriter) { bitWriter.WriteNBits(32, (uint)values.Length); foreach (var value in values) { var encodedValue = TableValueEncoding.EncodeValue(value); if (encodedValue.NumberOf1Before0 == 0) { bitWriter.WriteNBits(1, 0); } else { for (int k = 0; k < encodedValue.NumberOf1Before0; k++) { bitWriter.WriteNBits(1, 1); } bitWriter.WriteNBits(1, 0); bitWriter.WriteNBits(encodedValue.NumberOf1Before0, (uint)encodedValue.ValueAfter0); } } }
public override void Write(IBitWriter writer, ushort version) { base.Write(writer, version); writer.WriteGuid(this._Unknown); writer.WriteUInt32(this._HeadId); writer.WriteUInt32(this._HairstyleIndex); }
public void Serialize(IBitWriter bs, ReplicaBehaviour.SerializeContext ctx) { for (int i = 0; i < replicaBehaviours.Length; ++i) { var replicaBehaviour = replicaBehaviours[i]; #if UNITY_EDITOR int startSize = 0; var isDummy = bs is DummyBitWriter; if (!isDummy) { TransportDebugger.BeginScope(replicaBehavioursNames[i]); startSize = bs.BitsWritten; } #endif replicaBehaviour.Serialize(bs, ctx); #if UNITY_EDITOR || DEVELOPMENT bs.WriteByte((byte)0b10101010); #endif #if UNITY_EDITOR if (!isDummy) { TransportDebugger.EndScope(bs.BitsWritten - startSize); } #endif } }
public void Write(IBitWriter writer, bool excludeProfiles, bool excludePresets) { writer.WriteInt32(this._Level); writer.WriteFloat32(this._Unknown1); writer.WriteUInt32(this._Unknown2); writer.WriteUInt32(6); // version writer.WriteUInt32(this._Unknown3); writer.WriteUInt16((ushort)this._SkillGroups.Count); foreach (var skillGroup in this._SkillGroups) { skillGroup.Write(writer); } if (excludeProfiles == false) { writer.WriteInt32(this._CurrentProfileId); writer.WriteUInt16((ushort)this._Profiles.Count); foreach (var profile in this._Profiles) { profile.Write(writer); } } if (excludePresets == false) { writer.WriteInt32(this._CurrentPresetIndex); writer.WriteUInt16((ushort)this._Presets.Count); foreach (var preset in this._Presets) { preset.Write(writer); } } }
public void Write(IBitWriter writer, uint version) { writer.WriteUInt32(Unk0x0 ?? 0x0); writer.WriteUInt32(X); writer.WriteUInt32(Y); ItemList.Write(writer, version); }
internal void Write(IBitWriter writer) { writer.PushFrameLength(24); WriteList(writer, this._Unknown1); WriteList(writer, this._Unknown2); writer.PopFrameLength(); }
public override void Write(IBitWriter writer, ushort version) { base.Write(writer, version); writer.WriteBytes(this._Unknown1); writer.WriteUInt32(this._HeadId); writer.WriteUInt32(this._Unknown2); }
public void Write(IBitWriter writer) { writer.WriteUInt32(Magic ?? 0xAA55AA55); writer.WriteUInt32(Version); writer.WriteUInt32(Filesize); writer.WriteUInt32(Checksum); }
public void Write(IBitWriter writer) { for (int i = 0; i < _quests.Length; i++) { _quests[i].Write(writer); } }
internal void Write(IBitWriter writer) { writer.PushFrameLength(24); writer.WriteUInt32(this._Unknown1); writer.WriteBoolean(this._Unknown2); writer.PopFrameLength(); }
private static void WriteAgentData(IBitWriter writer, Dictionary <byte, Agent> agents, Dictionary <byte, uint[]> agentDataOffsets, byte index, WriteAgentDataAction action) { foreach (var kv in agents.OrderBy(kv => kv.Key)) { var agent = kv.Value; uint[] offsets; if (agentDataOffsets.TryGetValue(kv.Key, out offsets) == false) { offsets = agentDataOffsets[kv.Key] = new uint[5]; } var dataWriter = new BitWriter(0x10000, writer.Position + 24); action(dataWriter, agent); if (dataWriter.Position > 0) { var dataBytes = dataWriter.GetBytes(); //File.WriteAllBytes("agent_" + kv.Key + "_" + index + "_OUT.bin", dataBytes); offsets[index] = (uint)writer.Position; writer.PushFrameLength(24); writer.WriteBits(dataBytes, dataWriter.Position); writer.PopFrameLength(); } } }
internal override void Write4(IBitWriter writer) { base.Write4(writer); writer.PushFrameLength(24); this._Squad.Write(writer); writer.PopFrameLength(); }
public override void Serialize(IBitWriter bs, SerializeContext ctx) { bs.WriteVector3(transform.position); var euler = transform.rotation.eulerAngles; euler.x = Mathf.Repeat(euler.x, 360); euler.y = Mathf.Repeat(euler.y, 360); euler.z = Mathf.Repeat(euler.z, 360); bs.WriteLossyFloat(euler.x, 0, 360); bs.WriteLossyFloat(euler.y, 0, 360); bs.WriteLossyFloat(euler.z, 0, 360); var sleeping = rigidbody.IsSleeping(); bs.WriteBool(sleeping); if (!sleeping) { var velocity = rigidbody.velocity; bs.WriteLossyFloat(velocity.x, -maxVelocity, maxVelocity); bs.WriteLossyFloat(velocity.y, -maxVelocity, maxVelocity); bs.WriteLossyFloat(velocity.z, -maxVelocity, maxVelocity); var angularVelocity = rigidbody.angularVelocity; bs.WriteLossyFloat(angularVelocity.x, -maxAngularVelocity, maxAngularVelocity); bs.WriteLossyFloat(angularVelocity.y, -maxAngularVelocity, maxAngularVelocity); bs.WriteLossyFloat(angularVelocity.z, -maxAngularVelocity, maxAngularVelocity); } }
public void WriteValues(int[] values, IBitWriter bitWriter) { foreach (var value in values) { bitWriter.WriteNBits(numberOfBitsForValue, (uint)value); } }
public void TestThatBitWriterIsDisposedCorrectlyAndDoesNotThrowException() { using (bitWriter = new BitWriter(outputStream)) { bitWriter.WriteNBits(5, 123); } }
internal void Write(IBitWriter writer) { writer.PushFrameLength(24); writer.WriteUInt32(this._Unknown1); // probably a primitive type { writer.PushFrameLength(24); writer.WriteBytes(this._Unknown2); writer.WriteBytes(this._Unknown3); writer.WriteBytes(this._Unknown4); writer.WriteBytes(this._Unknown5); writer.WriteUInt32(this._Unknown6); writer.WriteUInt32(this._Unknown7); // probably another primitive type { writer.WriteUInt32((uint)this._Unknown8.Length); writer.WriteBytes(this._Unknown8); } writer.PopFrameLength(); } writer.PopFrameLength(); }
public void Encode(AvlData avlData, IBitWriter writer) { if (avlData == null) { throw new ArgumentNullException(nameof(avlData)); } if (writer == null) { throw new ArgumentNullException(nameof(writer)); } int num1 = Array.IndexOf(Priorities, avlData.Priority); int num2 = (int)((avlData.DateTime - GHepoch).TotalSeconds + 0.5) | (num1 & 3) << 30; writer.Write(num2); GhGlobalMask mask = avlData.GetMask(); writer.Write((byte)mask); if (mask.HasFlag(GhGlobalMask.GpsElement)) { GhGpsElementEncoding.Instance.Encode(GpsElementExt.Create(avlData, 200, 202, 201), writer); } bool flag1 = mask.HasFlag(GhGlobalMask.IoInt8); bool flag2 = mask.HasFlag(GhGlobalMask.IoInt16); bool flag3 = mask.HasFlag(GhGlobalMask.IoInt32); if (!flag1 && !flag2 && !flag3) { return; } List <IoProperty> properties1 = flag1 ? avlData.Data.Where(x => x.Size == 1).ToList() : null; List <IoProperty> properties2 = flag2 ? avlData.Data.Where(x => x.Size == 2).ToList() : null; List <IoProperty> properties3 = flag3 ? avlData.Data.Where(x => x.Size == 4).ToList() : null; if (properties1 != null) { properties1.RemoveAll(x => x.Id == 200); properties1.RemoveAll(x => x.Id == 201); properties1.RemoveAll(x => x.Id == 202); properties1.RemoveAll(x => x.Id == 204); GhIoElementEncoding.Int8.Encode(new IoElement(0, properties1), writer); } if (properties2 != null) { properties2.RemoveAll(x => x.Id == 200); properties2.RemoveAll(x => x.Id == 201); properties2.RemoveAll(x => x.Id == 202); properties2.RemoveAll(x => x.Id == 204); GhIoElementEncoding.Int16.Encode(new IoElement(0, properties2), writer); } if (properties3 != null) { properties3.RemoveAll(x => x.Id == 200); properties3.RemoveAll(x => x.Id == 201); properties3.RemoveAll(x => x.Id == 202); properties3.RemoveAll(x => x.Id == 204); GhIoElementEncoding.Int32.Encode(new IoElement(0, properties3), writer); } writer.Flush(); }
public void Write(IBitWriter writer) { writer.PushFrameLength(24); writer.WriteFloat32(this._CurrentValue); writer.WriteFloat32(this._MaximumValue); writer.WriteBoolean(this._Unknown); writer.PopFrameLength(); }
public void Write(IBitWriter writer) { writer.WriteUInt16(Header ?? 0x6669); for (int i = 0; i < SKILL_COUNT; i++) { Skills[i].Write(writer); } }
public override void Write(IBitWriter writer) { writer.WriteUInt16(this._Unknown5); writer.WriteUInt16(this._Unknown6); writer.WriteUInt16(this._Unknown7); writer.WriteUInt32(this._Unknown8); base.Write(writer); }
public void Write(IBitWriter writer) { ActI.Write(writer); ActII.Write(writer); ActIII.Write(writer); ActIV.Write(writer); ActV.Write(writer); }
internal void Write(IBitWriter writer) { writer.WriteUInt16((ushort)this._Unknown.Count); foreach (var unknown in this._Unknown) { unknown.Write(writer); } }