protected override void OnUpdate() { if (!isBooted) { BootUp(); isBooted = true; } var octetStream = new OctetWriter(MAX_EVENT_OCTETS); var bitStream = new OutBitStream(octetStream); // TransferAction Entities.WithAll <Simulated>().ForEach((Entity entity, DynamicBuffer <TransferAction> buffer) => { if (buffer.Length == 0) { return; } var foundEntity = mapper.ToCoherenceEntityId(entity, out var coherenceEntityId); if (!foundEntity) { Debug.LogError($"sending event, but can't find entity {entity} in coherence mapper"); return; } for (var i = 0; i < buffer.Length; i++) { bitStream.Rewind(0); EntityIdSerializer.Serialize(coherenceEntityId, bitStream); var protocol = new Coherence.FieldStream.Serialize.Streams.OutBitStream(bitStream); var eventComponent = buffer[i]; // --------- Type Specific Part --------------- ComponentTypeIdSerializer.Serialize(TypeIds.InternalTransferAction, bitStream); messageSerializers.TransferAction(protocol, eventComponent); // -------------------------------------------- bitStream.Flush(); var payload = new BitSerializedMessage(octetStream.Octets, bitStream.Tell); messageChannels.PushEntityEvent(payload); } buffer.Clear(); }).WithoutBurst().Run(); }